This commit is contained in:
Joshua Perry 2023-02-03 19:41:30 +00:00
parent 10319aac16
commit 841ff873d3
16 changed files with 151 additions and 60 deletions

View File

@ -19,8 +19,6 @@ import com.r0r5chach.competitor.r6.R6Defender;
import com.r0r5chach.competitor.r6.R6Player; import com.r0r5chach.competitor.r6.R6Player;
import com.r0r5chach.competitor.valorant.ValorantAgent; import com.r0r5chach.competitor.valorant.ValorantAgent;
import com.r0r5chach.competitor.valorant.ValorantPlayer; import com.r0r5chach.competitor.valorant.ValorantPlayer;
public class CompetitorList { public class CompetitorList {
private final ArrayList<Competitor> competitors; private final ArrayList<Competitor> competitors;
private String reportContents; private String reportContents;

View File

@ -93,7 +93,7 @@ public class Manager extends Application {
competitors.readCompetitors(r6Players); competitors.readCompetitors(r6Players);
} }
catch (Exception e) { catch (Exception e) {
createErrorLog(e, "src/main/resources/log.txt"); createErrorLog(e, "src/main/resources/com/r0r5chach/log.txt");
} }
return competitors; return competitors;
} }

View File

@ -2,7 +2,7 @@ package com.r0r5chach.competitor;
import java.text.DecimalFormat; import java.text.DecimalFormat;
/** /**
* Class that defines the various attributes and methods associated with a Valorant Player * Class that defines the various attributes and methods associated with a Competitor
* @author r0r5chach * @author r0r5chach
*/ */
public abstract class Competitor { public abstract class Competitor {
@ -32,6 +32,7 @@ public abstract class Competitor {
* @param playerNumber the number of the player * @param playerNumber the number of the player
* @param playerName the name of the player * @param playerName the name of the player
* @param playerLevel the level of the player * @param playerLevel the level of the player
* @param scores an array containing the 6 scores the player has achieved
*/ */
public Competitor(int playerNumber, Name playerName, Rank playerLevel, int[] scores) { public Competitor(int playerNumber, Name playerName, Rank playerLevel, int[] scores) {
this.playerNumber = playerNumber; this.playerNumber = playerNumber;

View File

@ -2,7 +2,7 @@ package com.r0r5chach.competitor;
/** /**
* Class that defines a name and it's parts * Class that defines a name and it's parts
* @author John.Kanyaru@northampton.ac.uk * @author r0r5chach
*/ */
public class Name { public class Name {
/** /**
@ -128,4 +128,3 @@ public class Name {
return result; return result;
} }
} }

View File

@ -1,17 +1,18 @@
package com.r0r5chach.competitor; package com.r0r5chach.competitor;
import java.util.Locale; import java.util.Locale;
/** /**
* All levels a ValorantPlayer can be * All levels a ValorantPlayer can be
* @author r0r5chach * @author r0r5chach
*/ */
public enum Rank { public enum Rank {
/** /**
* First Level * For ChoiceBoxes so selection is not null
*/ */
NONE, NONE,
/**
* First Level
*/
BRONZE, BRONZE,
/** /**
* Second Level * Second Level

View File

@ -1,8 +1,13 @@
package com.r0r5chach.competitor.r6; package com.r0r5chach.competitor.r6;
import java.util.Locale; import java.util.Locale;
/** All Attackers an R6Player can play
* @author r0r5chach
*/
public enum R6Attacker { public enum R6Attacker {
/**
* For ChoiceBoxes so selection is not null
*/
NONE, NONE,
GRIM, GRIM,
SENS, SENS,
@ -37,7 +42,10 @@ public enum R6Attacker {
IQ, IQ,
FUZE, FUZE,
GLAZ; GLAZ;
/**
* Get the name of the attacker
* @return the name of the attacker as a formatted string
*/
public String getAttacker() { public String getAttacker() {
return this.name().charAt(0) + this.name().substring(1).toLowerCase(Locale.ROOT); //Capitalizes the first letter and makes sure the other letters are lowercase return this.name().charAt(0) + this.name().substring(1).toLowerCase(Locale.ROOT); //Capitalizes the first letter and makes sure the other letters are lowercase
} }

View File

@ -1,8 +1,13 @@
package com.r0r5chach.competitor.r6; package com.r0r5chach.competitor.r6;
import java.util.Locale; import java.util.Locale;
/** All Defenders an R6Player can play
* @author r0r5chach
*/
public enum R6Defender { public enum R6Defender {
/**
* For ChoiceBoxes so selection is not null
*/
NONE, NONE,
SOLIS, SOLIS,
AZAMI, AZAMI,
@ -37,7 +42,10 @@ public enum R6Defender {
BANDIT, BANDIT,
TACHANKA, TACHANKA,
KAPKAN; KAPKAN;
/**
* Get the name of the defender
* @return the name of the defender as a formatted string
*/
public String getDefender() { public String getDefender() {
return this.name().charAt(0) + this.name().substring(1).toLowerCase(Locale.ROOT); //Capitalizes the first letter and makes sure the other letters are lowercase return this.name().charAt(0) + this.name().substring(1).toLowerCase(Locale.ROOT); //Capitalizes the first letter and makes sure the other letters are lowercase
} }

View File

@ -5,33 +5,66 @@ import java.util.Arrays;
import com.r0r5chach.competitor.Competitor; import com.r0r5chach.competitor.Competitor;
import com.r0r5chach.competitor.Name; import com.r0r5chach.competitor.Name;
import com.r0r5chach.competitor.Rank; import com.r0r5chach.competitor.Rank;
/**
* Class that defines the various attributes and methods associated with a R6 Player
* Inherits from the com.r0r5chach.competitor.Competitor Class
* @author r0r5chach
*/
public class R6Player extends Competitor{ public class R6Player extends Competitor{
/**
* Attribute that stores the player's favorite Attacker
*/
private R6Attacker favoriteAttacker; private R6Attacker favoriteAttacker;
/**
* Attribute that stores the player's favorite Defender
*/
private R6Defender favoriteDefender; private R6Defender favoriteDefender;
/**
* Constructs an R6Player object with attributes matching the parameters passed
* @param playerNumber the number of the player
* @param playerName the name of the player
* @param playerLevel the level of the player
* @param favoriteAttacker the attacker the player plays most
* @param favoriteDefender the defender the player plays most
* @param scores an array containing the 6 scores the player has achieved
*/
public R6Player(int playerNumber, Name playerName, Rank playerLevel, R6Attacker favoriteAttacker, R6Defender favoriteDefender, int[] scores) { public R6Player(int playerNumber, Name playerName, Rank playerLevel, R6Attacker favoriteAttacker, R6Defender favoriteDefender, int[] scores) {
super(playerNumber, playerName, playerLevel, scores); super(playerNumber, playerName, playerLevel, scores);
this.favoriteAttacker = favoriteAttacker; this.favoriteAttacker = favoriteAttacker;
this.favoriteDefender = favoriteDefender; this.favoriteDefender = favoriteDefender;
} }
/**
* Set the player's most played attacker to that of the parameter
* @param favoriteAttacker the new most played attacker of the player
*/
public void setFavoriteAttacker(R6Attacker favoriteAttacker) { public void setFavoriteAttacker(R6Attacker favoriteAttacker) {
this.favoriteAttacker = favoriteAttacker; this.favoriteAttacker = favoriteAttacker;
} }
/**
* Set the player's most played defender to that of the parameter
* @param favoriteDefender the new most played defender of the player
*/
public void setFavoriteDefender(R6Defender favoriteDefender) { public void setFavoriteDefender(R6Defender favoriteDefender) {
this.favoriteDefender = favoriteDefender; this.favoriteDefender = favoriteDefender;
} }
/**
* Get the player's most played attacker
* @return the player's most played attack
*/
public R6Attacker getFavoriteAttacker() { public R6Attacker getFavoriteAttacker() {
return this.favoriteAttacker; return this.favoriteAttacker;
} }
/**
* Get the player's most played defender
* @return the player's most played defender
*/
public R6Defender getFavoriteDefender() { public R6Defender getFavoriteDefender() {
return this.favoriteDefender; return this.favoriteDefender;
} }
/**
* Get all the attributes of the player
* @return all attributes of the player in a formatted string
*/
public String getFullDetails() { public String getFullDetails() {
return "Player Number: " + getPlayerNumber() + return "Player Number: " + getPlayerNumber() +
"\nName: " + getPlayerName().getFullName() + "\nName: " + getPlayerName().getFullName() +

View File

@ -1,12 +1,14 @@
package com.r0r5chach.competitor.valorant; package com.r0r5chach.competitor.valorant;
import java.util.Locale; import java.util.Locale;
/** /**
* All Characters a ValorantPlayer can play * All Characters a ValorantPlayer can play
* @author r0r5chach * @author r0r5chach
*/ */
public enum ValorantAgent { public enum ValorantAgent {
/**
* For ChoiceBoxes so selection is not null
*/
NONE, NONE,
BRIMSTONE, BRIMSTONE,
VIPER, VIPER,
@ -30,7 +32,7 @@ public enum ValorantAgent {
HARBOR; HARBOR;
/** /**
* Get the name of the character * Get the name of the character
* @return a formatted string containing the character name * @return the name of the character as a formatted string
*/ */
public String getAgent() { public String getAgent() {
return this.name().charAt(0) + this.name().substring(1).toLowerCase(Locale.ROOT); //Capitalizes the first letter and makes sure the other letters are lowercase return this.name().charAt(0) + this.name().substring(1).toLowerCase(Locale.ROOT); //Capitalizes the first letter and makes sure the other letters are lowercase

View File

@ -7,9 +7,13 @@ import com.r0r5chach.competitor.Name;
import com.r0r5chach.competitor.Rank; import com.r0r5chach.competitor.Rank;
/** /**
* Class that defines the various attributes and methods associated with a Valorant Player * Class that defines the various attributes and methods associated with a Valorant Player
* Inherits from the com.r0r5chach.competitor.Competitor Class
* @author r0r5chach * @author r0r5chach
*/ */
public class ValorantPlayer extends Competitor { public class ValorantPlayer extends Competitor {
/**
* Attribute that stores the player's favorite character to play
*/
private ValorantAgent favoriteAgent; private ValorantAgent favoriteAgent;
/** /**
* Constructs an object with attributes matching the parameters passed * Constructs an object with attributes matching the parameters passed
@ -17,6 +21,7 @@ public class ValorantPlayer extends Competitor {
* @param playerName the name of the player * @param playerName the name of the player
* @param playerLevel the level of the player * @param playerLevel the level of the player
* @param favoriteAgent the character the player plays most * @param favoriteAgent the character the player plays most
* @param scores an array containing the 6 scores the player has achieved
*/ */
public ValorantPlayer(int playerNumber, Name playerName, Rank playerLevel, ValorantAgent favoriteAgent, int[] scores) { public ValorantPlayer(int playerNumber, Name playerName, Rank playerLevel, ValorantAgent favoriteAgent, int[] scores) {
super(playerNumber, playerName, playerLevel, scores); super(playerNumber, playerName, playerLevel, scores);

View File

@ -5,6 +5,7 @@ import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.ResourceBundle; import java.util.ResourceBundle;
import static com.r0r5chach.CompetitorList.createErrorLog;
import com.r0r5chach.CompetitorList; import com.r0r5chach.CompetitorList;
import com.r0r5chach.Manager; import com.r0r5chach.Manager;
import com.r0r5chach.competitor.Competitor; import com.r0r5chach.competitor.Competitor;
@ -15,51 +16,72 @@ import javafx.fxml.Initializable;
import javafx.scene.Parent; import javafx.scene.Parent;
import javafx.scene.control.Tab; import javafx.scene.control.Tab;
import javafx.scene.control.TabPane; import javafx.scene.control.TabPane;
import javafx.scene.layout.AnchorPane; /**
* Class that defines a generic controller for the GUI
* Inherits from javafx.fxml.Initializable
*/
public class Controller implements Initializable { public class Controller implements Initializable {
@FXML /**
protected AnchorPane editTab; * Attribute that stores the Main Pane for the GUI view
*/
@FXML
protected AnchorPane viewTab;
@FXML
protected AnchorPane reportTab;
@FXML @FXML
protected TabPane tabs; protected TabPane tabs;
/**
* Attribute that stores the competitor list used by the program
*/
protected CompetitorList competitors; protected CompetitorList competitors;
/**
* Attribute that stores the playerNumber of each competitor in the same order as the competitors list to allow easy indexing of competitors list
*/
protected ArrayList<Integer> competitorIds; protected ArrayList<Integer> competitorIds;
/**
* Method that runs when the program initializes the GUI view
* (param details copied from super implementation)
* @param url The location used to resolve relative paths for the root object
* @param rb The resources used to localize the root object
*/
@Override @Override
public void initialize(URL location, ResourceBundle resources) { public void initialize(URL url, ResourceBundle rb) {
Platform.runLater(() -> { Platform.runLater(() -> {
loadCompetitors(); loadCompetitors();
}); });
} }
/**
* Sets the controller's competitor list to that of the new parameter
* @param competitors the new competitor list
*/
public void setCompetitors(CompetitorList competitors) { public void setCompetitors(CompetitorList competitors) {
this.competitors = competitors; this.competitors = competitors;
} }
/**
* Gets the controller's competitor list
* @return the controller's competitor list
*/
public CompetitorList getCompetitors() { public CompetitorList getCompetitors() {
return competitors; return competitors;
} }
/**
* Gets the tab selected on the GUI
*/
@FXML @FXML
protected void getTab() throws IOException { protected void getTab() {
Parent root = null; Parent root = null;
Tab tab = tabs.getSelectionModel().getSelectedItem(); Tab tab = tabs.getSelectionModel().getSelectedItem();
switch(tab.getText().toLowerCase()) { try {
case "view" -> root = Manager.loadFXML("pages/view"); switch(tab.getText().toLowerCase()) {
case "edit" -> root = Manager.loadFXML("pages/edit"); case "view" -> root = Manager.loadFXML("pages/view");
case "report" -> root = Manager.loadFXML("pages/report"); case "edit" -> root = Manager.loadFXML("pages/edit");
case "report" -> root = Manager.loadFXML("pages/report");
}
}
catch (IOException e) {
createErrorLog(e, "src/main/resources/com/r0r5chach/log.txt");
} }
tab.setContent(root); tab.setContent(root);
} }
/**
* Initializes the competitorIds array for the controller
*/
protected void loadCompetitors(){ protected void loadCompetitors(){
competitorIds = new ArrayList<Integer>(); competitorIds = new ArrayList<Integer>();
for (Competitor player : competitors.getCompetitors()) { for (Competitor player : competitors.getCompetitors()) {

View File

@ -21,8 +21,10 @@ import javafx.scene.control.ChoiceBox;
import javafx.scene.control.ListView; import javafx.scene.control.ListView;
import javafx.scene.control.TextField; import javafx.scene.control.TextField;
import javafx.scene.text.Text; import javafx.scene.text.Text;
/**
* Class that defines the controller for the edit View (edit.fxml) of the GUI
* Inherits from com.r0r5chach.controllers.Controller
*/
public class EditController extends Controller { public class EditController extends Controller {
@FXML @FXML

View File

@ -17,7 +17,10 @@ import javafx.scene.control.TextArea;
import javafx.scene.control.TextField; import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup; import javafx.scene.control.ToggleGroup;
import javafx.scene.control.RadioButton; import javafx.scene.control.RadioButton;
/**
* Class that defines the controller for the filters View (filters.fxml) of the GUI
* Inherits from com.r0r5chach.controllers.Controller
*/
public class FiltersController implements Initializable { public class FiltersController implements Initializable {
@FXML @FXML
private TextField numberFilter; private TextField numberFilter;

View File

@ -1,5 +1,8 @@
package com.r0r5chach.controllers; package com.r0r5chach.controllers;
/**
* Class that defines the controller for the main View (main.fxml) of the GUI
* Inherits from com.r0r5chach.controllers.Controller
*/
public class MainController extends Controller { public class MainController extends Controller {
} }

View File

@ -8,7 +8,10 @@ import javafx.collections.FXCollections;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.ListView; import javafx.scene.control.ListView;
import javafx.scene.control.TextArea; import javafx.scene.control.TextArea;
/**
* Class that defines the controller for the report View of the GUI
* Inherits from com.r0r5chach.controllers.Controller
*/
public class ReportController extends Controller { public class ReportController extends Controller {
@FXML @FXML
private ListView<Integer> competitorList; private ListView<Integer> competitorList;

View File

@ -27,7 +27,10 @@ import javafx.scene.control.TableView;
import javafx.scene.control.TextArea; import javafx.scene.control.TextArea;
import javafx.scene.control.cell.PropertyValueFactory; import javafx.scene.control.cell.PropertyValueFactory;
import javafx.stage.Popup; import javafx.stage.Popup;
/**
* Class that defines the Controller for the view View (view.fxml) of the GUI
* Inherits from com.r0r5chach.controllers.Controller
*/
public class ViewController extends Controller { public class ViewController extends Controller {
@FXML @FXML
private TableView<CompetitorRow> competitorTable; private TableView<CompetitorRow> competitorTable;