Compare commits
10 Commits
2a7a7c81e3
...
5375db795f
| Author | SHA1 | Date |
|---|---|---|
|
|
5375db795f | |
|
|
6ecdb309a1 | |
|
|
de3bec19cc | |
|
|
65bae824a5 | |
|
|
8767b8b498 | |
|
|
193512eb63 | |
|
|
9f0b7225e4 | |
|
|
4a2a412002 | |
|
|
1f47821aea | |
|
|
11b61afade |
|
|
@ -19,20 +19,40 @@ import com.r0r5chach.competitor.r6.R6Defender;
|
|||
import com.r0r5chach.competitor.r6.R6Player;
|
||||
import com.r0r5chach.competitor.valorant.ValorantAgent;
|
||||
import com.r0r5chach.competitor.valorant.ValorantPlayer;
|
||||
/**
|
||||
* Class that defines the various attributes and methods associated with a list of Competitors
|
||||
* @author r0r5chach
|
||||
*/
|
||||
public class CompetitorList {
|
||||
/**
|
||||
* Attribute that stores an Array of Competitors
|
||||
*/
|
||||
private final ArrayList<Competitor> competitors;
|
||||
/**
|
||||
* Attribute that stores the report on the held Competitors
|
||||
*/
|
||||
private String reportContents;
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a CompetitorList Object by creating a new Array and defining the report as the stored template
|
||||
* @throws IOException if the template cannot be loaded
|
||||
*/
|
||||
public CompetitorList() throws IOException {
|
||||
competitors = new ArrayList<>();
|
||||
reportContents = reportTemplate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Array of competitors
|
||||
* @return the Array of competitors
|
||||
*/
|
||||
public ArrayList<Competitor> getCompetitors() {
|
||||
return competitors;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read the target file and add any competitors found into the Array
|
||||
* @param list the file to be read
|
||||
* @throws FileNotFoundException if the file cannot be found
|
||||
*/
|
||||
public void readCompetitors(File list) throws FileNotFoundException {
|
||||
Scanner reader = new Scanner(list);
|
||||
|
||||
|
|
@ -45,116 +65,12 @@ public class CompetitorList {
|
|||
}
|
||||
reader.close();
|
||||
}
|
||||
|
||||
private ValorantPlayer parseValorantPlayer(String[] row) {
|
||||
int playerNumber = Integer.parseInt(row[0]);
|
||||
Name playerName = new Name(row[1]);
|
||||
Rank playerLevel = Rank.valueOf(row[2]);
|
||||
ValorantAgent favoriteAgent = ValorantAgent.valueOf(row[3]);
|
||||
int[] scores = parseScores(row[4]);
|
||||
return new ValorantPlayer(playerNumber, playerName, playerLevel, favoriteAgent, scores);
|
||||
}
|
||||
|
||||
private R6Player parseR6Player(String[] row) {
|
||||
int playerNumber = Integer.parseInt(row[0]);
|
||||
Name playerName = new Name(row[1]);
|
||||
Rank playerLevel = Rank.valueOf(row[2]);
|
||||
R6Attacker favoriteAttacker = R6Attacker.valueOf(row[3]);
|
||||
R6Defender favoriteDefender = R6Defender.valueOf(row[4]);
|
||||
int[] scores = parseScores(row[5]);
|
||||
return new R6Player(playerNumber, playerName, playerLevel, favoriteAttacker, favoriteDefender, scores);
|
||||
}
|
||||
|
||||
private int[] parseScores(String row) {
|
||||
String[] scores = row.split(",");
|
||||
int[] parsedScores = new int[scores.length];
|
||||
for (int i = 0; i < scores.length; i++) {
|
||||
parsedScores[i] = Integer.parseInt(scores[i]);
|
||||
}
|
||||
return parsedScores;
|
||||
}
|
||||
|
||||
private String generateTable() {
|
||||
StringBuilder table = new StringBuilder("Competitor Level Scores Overall Favorite Character(s)");
|
||||
Competitor best = null;
|
||||
double bestScore = 0;
|
||||
Rank bestRank = Rank.BRONZE;
|
||||
List<Rank> ranks = Arrays.asList(Rank.values());
|
||||
for (Competitor player: getCompetitors()) {
|
||||
if (player.getOverallScore() > bestScore) {
|
||||
best = player;
|
||||
bestScore = player.getOverallScore();
|
||||
bestRank = player.getPlayerLevel();
|
||||
}
|
||||
else if (player.getOverallScore() == bestScore) {
|
||||
if (ranks.indexOf(player.getPlayerLevel()) > ranks.indexOf(bestRank)) {
|
||||
best = player;
|
||||
bestScore = player.getOverallScore();
|
||||
bestRank = player.getPlayerLevel();
|
||||
}
|
||||
}
|
||||
table.append("\n");
|
||||
table.append(player.getShortDetails()).append(" ");
|
||||
}
|
||||
table.append("\n\n").append(best.getFullDetails());
|
||||
return table.toString();
|
||||
}
|
||||
|
||||
private int[] generateLevelFreqs() {
|
||||
int[] freqs = {0, 0, 0, 0};
|
||||
for (Competitor player: getCompetitors()) {
|
||||
switch (player.getPlayerLevel()) {
|
||||
case BRONZE -> freqs[0] += 1;
|
||||
case SILVER -> freqs[1] += 1;
|
||||
case GOLD -> freqs[2] += 1;
|
||||
case PLATINUM -> freqs[3] += 1;
|
||||
default -> throw new IllegalArgumentException("Unexpected value: " + player.getPlayerLevel());
|
||||
}
|
||||
}
|
||||
return freqs;
|
||||
}
|
||||
|
||||
private int[] generateScoreFreqs() {
|
||||
int[] freqs = {0, 0, 0, 0, 0, 0};
|
||||
for (Competitor player: getCompetitors()) {
|
||||
for (int score: player.getScores()) {
|
||||
switch (score) {
|
||||
case 0 -> freqs[0] += 1;
|
||||
case 1 -> freqs[1] += 1;
|
||||
case 2 -> freqs[2] += 1;
|
||||
case 3 -> freqs[3] += 1;
|
||||
case 4 -> freqs[4] += 1;
|
||||
case 5 -> freqs[5] += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return freqs;
|
||||
}
|
||||
|
||||
private double generateAverageScore() {
|
||||
double avg = 0;
|
||||
int totalScores = 0;
|
||||
for (Competitor player: getCompetitors()) {
|
||||
for (int score: player.getScores()) {
|
||||
totalScores += 1;
|
||||
avg += score;
|
||||
}
|
||||
}
|
||||
avg /= totalScores;
|
||||
return avg;
|
||||
}
|
||||
|
||||
private double getHighScore() {
|
||||
double hS = 0;
|
||||
for (Competitor player: getCompetitors()) {
|
||||
if (player.getOverallScore() > hS) {
|
||||
hS = player.getOverallScore();
|
||||
}
|
||||
}
|
||||
|
||||
return hS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a text file containing a report on the currently held competitors at the specified path
|
||||
* @param pathString the absolute path of the folder the report should be made in
|
||||
* @return the text file
|
||||
* @throws IOException if the file cannot be made at that path
|
||||
*/
|
||||
public File createReportFile(String pathString) throws IOException {
|
||||
boolean exists;
|
||||
int count = 0;
|
||||
|
|
@ -180,7 +96,12 @@ public class CompetitorList {
|
|||
reportContents = reportTemplate();
|
||||
return new File(path.toUri());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a text file containing a log of the last error
|
||||
* @param e the exception that has triggered
|
||||
* @param path the absolute path of the file that the log should be made in
|
||||
* @return The contents of the log file as a string
|
||||
*/
|
||||
public static String createErrorLog(Exception e, String path) {
|
||||
try {
|
||||
FileWriter log = new FileWriter(path);
|
||||
|
|
@ -193,16 +114,162 @@ public class CompetitorList {
|
|||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Parses a line of text from a file to create a ValorantPlayer
|
||||
* @param row the line of text to be parsed
|
||||
* @return the ValorantPlayer created
|
||||
*/
|
||||
private ValorantPlayer parseValorantPlayer(String[] row) {
|
||||
int playerNumber = Integer.parseInt(row[0]);
|
||||
Name playerName = new Name(row[1]);
|
||||
Rank playerLevel = Rank.valueOf(row[2]);
|
||||
ValorantAgent favoriteAgent = ValorantAgent.valueOf(row[3]);
|
||||
int[] scores = parseScores(row[4]);
|
||||
return new ValorantPlayer(playerNumber, playerName, playerLevel, favoriteAgent, scores);
|
||||
}
|
||||
/**
|
||||
* Parses a line of text from a file to create a R6Player
|
||||
* @param row the line of text to be parsed
|
||||
* @return the R6Player created
|
||||
*/
|
||||
private R6Player parseR6Player(String[] row) {
|
||||
int playerNumber = Integer.parseInt(row[0]);
|
||||
Name playerName = new Name(row[1]);
|
||||
Rank playerLevel = Rank.valueOf(row[2]);
|
||||
R6Attacker favoriteAttacker = R6Attacker.valueOf(row[3]);
|
||||
R6Defender favoriteDefender = R6Defender.valueOf(row[4]);
|
||||
int[] scores = parseScores(row[5]);
|
||||
return new R6Player(playerNumber, playerName, playerLevel, favoriteAttacker, favoriteDefender, scores);
|
||||
}
|
||||
/**
|
||||
* Parse the scores stored in a row
|
||||
* @param list the list of scores to be parsed
|
||||
* @return an Array of the scores
|
||||
*/
|
||||
private int[] parseScores(String list) {
|
||||
String[] scores = list.split(",");
|
||||
int[] parsedScores = new int[scores.length];
|
||||
for (int i = 0; i < scores.length; i++) {
|
||||
parsedScores[i] = Integer.parseInt(scores[i]);
|
||||
}
|
||||
return parsedScores;
|
||||
}
|
||||
/**
|
||||
* Generate a string that represents a table of the competitors and their attributes
|
||||
* @return the string
|
||||
*/
|
||||
private String generateTable() {
|
||||
StringBuilder table = new StringBuilder("Competitor Level Scores Overall Favorite Character(s)");
|
||||
Competitor best = null;
|
||||
double bestScore = 0;
|
||||
Rank bestRank = Rank.BRONZE;
|
||||
List<Rank> ranks = Arrays.asList(Rank.values());
|
||||
for (Competitor player: getCompetitors()) {
|
||||
if (player.getOverallScore() > bestScore) {
|
||||
best = player;
|
||||
bestScore = player.getOverallScore();
|
||||
bestRank = player.getPlayerLevel();
|
||||
}
|
||||
else if (player.getOverallScore() == bestScore) {
|
||||
if (ranks.indexOf(player.getPlayerLevel()) > ranks.indexOf(bestRank)) {
|
||||
best = player;
|
||||
bestScore = player.getOverallScore();
|
||||
bestRank = player.getPlayerLevel();
|
||||
}
|
||||
}
|
||||
table.append("\n");
|
||||
table.append(player.getShortDetails()).append(" ");
|
||||
}
|
||||
table.append("\n\n").append(best.getFullDetails());
|
||||
return table.toString();
|
||||
}
|
||||
/**
|
||||
* Generate the frequency of each player level across all competitors
|
||||
* @return an Array of the frequencies
|
||||
*/
|
||||
private int[] generateLevelFreqs() {
|
||||
int[] freqs = {0, 0, 0, 0};
|
||||
for (Competitor player: getCompetitors()) {
|
||||
switch (player.getPlayerLevel()) {
|
||||
case BRONZE -> freqs[0] += 1;
|
||||
case SILVER -> freqs[1] += 1;
|
||||
case GOLD -> freqs[2] += 1;
|
||||
case PLATINUM -> freqs[3] += 1;
|
||||
default -> throw new IllegalArgumentException("Unexpected value: " + player.getPlayerLevel());
|
||||
}
|
||||
}
|
||||
return freqs;
|
||||
}
|
||||
/**
|
||||
* Generate the frequency of achieved scores across all competitors
|
||||
* @return an Array of the frequencies
|
||||
*/
|
||||
private int[] generateScoreFreqs() {
|
||||
int[] freqs = {0, 0, 0, 0, 0, 0};
|
||||
for (Competitor player: getCompetitors()) {
|
||||
for (int score: player.getScores()) {
|
||||
switch (score) {
|
||||
case 0 -> freqs[0] += 1;
|
||||
case 1 -> freqs[1] += 1;
|
||||
case 2 -> freqs[2] += 1;
|
||||
case 3 -> freqs[3] += 1;
|
||||
case 4 -> freqs[4] += 1;
|
||||
case 5 -> freqs[5] += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return freqs;
|
||||
}
|
||||
/**
|
||||
* Generate the average score across all competitors
|
||||
* @return the average scores
|
||||
*/
|
||||
private double generateAverageScore() {
|
||||
double avg = 0;
|
||||
int totalScores = 0;
|
||||
for (Competitor player: getCompetitors()) {
|
||||
for (int score: player.getScores()) {
|
||||
totalScores += 1;
|
||||
avg += score;
|
||||
}
|
||||
}
|
||||
avg /= totalScores;
|
||||
return avg;
|
||||
}
|
||||
/**
|
||||
* Generate the highest score achieved across all competitors
|
||||
* @return the highest score
|
||||
*/
|
||||
private double getHighScore() {
|
||||
double hS = 0;
|
||||
for (Competitor player: getCompetitors()) {
|
||||
if (player.getOverallScore() > hS) {
|
||||
hS = player.getOverallScore();
|
||||
}
|
||||
}
|
||||
|
||||
return hS;
|
||||
}
|
||||
/**
|
||||
* Replace the specified target substring in the report and replace it with the replacement string
|
||||
* @param target the target substring
|
||||
* @param replacement the replacement string
|
||||
*/
|
||||
private void replaceVar(String target, String replacement) {
|
||||
reportContents = reportContents.replace(target, replacement);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the report template
|
||||
* @return the report template
|
||||
* @throws IOException if the file is not found
|
||||
*/
|
||||
private String reportTemplate() throws IOException {
|
||||
return Files.readString(Path.of("src/main/resources/com/r0r5chach/report.template"));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the report contents
|
||||
*/
|
||||
private void generateReportContents() {
|
||||
replaceVar("%TABLE%", generateTable());
|
||||
replaceVar( "%HIGH-SCORE%", String.valueOf(getHighScore()));
|
||||
|
|
@ -219,4 +286,4 @@ public class CompetitorList {
|
|||
replaceVar( "%SCORE"+i+"%", String.valueOf(freqs[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,16 +11,47 @@ import com.r0r5chach.competitor.valorant.ValorantAgent;
|
|||
import javafx.beans.property.SimpleIntegerProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
|
||||
/**
|
||||
* Class that defines the various attributes and methods associated with a Competitor Row for Table Views
|
||||
* @author r0r5chach
|
||||
*/
|
||||
public class CompetitorRow {
|
||||
/**
|
||||
* Attribute that stores the player's number as a property
|
||||
*/
|
||||
private SimpleIntegerProperty playerNumber;
|
||||
/**
|
||||
* Attribute that stores the player's name as a property
|
||||
*/
|
||||
private SimpleStringProperty playerName;
|
||||
/**
|
||||
* Attribute that stores the player's level as a property
|
||||
*/
|
||||
private SimpleObjectProperty<Rank> playerLevel;
|
||||
/**
|
||||
* Attribute that stores the player's scores as a property
|
||||
*/
|
||||
private SimpleStringProperty scores;
|
||||
/**
|
||||
* Attribute that stores the player's favorite agent as a property
|
||||
*/
|
||||
private SimpleStringProperty favoriteAgent;
|
||||
/**
|
||||
* Attribute that stores the player's favorite attacker as a property
|
||||
*/
|
||||
private SimpleStringProperty favoriteAttacker;
|
||||
/**
|
||||
* Attribute that stores the player's favorite defender as a property
|
||||
*/
|
||||
private SimpleStringProperty favoriteDefender;
|
||||
|
||||
/**
|
||||
* Constructs a CompetitorRow Object with the specified attributes
|
||||
* Sets favorite characters to "N/A" as none are specified
|
||||
* @param playerNumber the player's number
|
||||
* @param playerName the player's name
|
||||
* @param playerLevel the player's level
|
||||
* @param scores the player's scores
|
||||
*/
|
||||
public CompetitorRow(int playerNumber, Name playerName, Rank playerLevel, int[] scores) {
|
||||
this.playerNumber = new SimpleIntegerProperty(playerNumber);
|
||||
this.playerName = new SimpleStringProperty(playerName.getFullName());
|
||||
|
|
@ -30,7 +61,15 @@ public class CompetitorRow {
|
|||
favoriteAttacker = new SimpleStringProperty("N/A");
|
||||
favoriteDefender = new SimpleStringProperty("N/A");
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a CompetitorRow Object with the specified attributes
|
||||
* Sets favorite attacker and defender to "N/A" as none are specified
|
||||
* @param playerNumber the player's number
|
||||
* @param playerName the player's name
|
||||
* @param playerLevel the player's level
|
||||
* @param scores the player's scores
|
||||
* @param favoriteAgent the player's favorite agent
|
||||
*/
|
||||
public CompetitorRow(int playerNumber, Name playerName, Rank playerLevel, int[] scores, ValorantAgent favoriteAgent) {
|
||||
this.playerNumber = new SimpleIntegerProperty(playerNumber);
|
||||
this.playerName = new SimpleStringProperty(playerName.getFullName());
|
||||
|
|
@ -40,7 +79,16 @@ public class CompetitorRow {
|
|||
favoriteAttacker = new SimpleStringProperty("N/A");
|
||||
favoriteDefender = new SimpleStringProperty("N/A");
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a CompetitorRow Object with the specified attributes
|
||||
* Sets favorite agent to "N/A" as none are specified
|
||||
* @param playerNumber the player's number
|
||||
* @param playerName the player's name
|
||||
* @param playerLevel the player's level
|
||||
* @param scores the player's scores
|
||||
* @param favoriteAttacker the player's favorite attacker
|
||||
* @param favoriteDefender the player's favorite defender
|
||||
*/
|
||||
public CompetitorRow(int playerNumber, Name playerName, Rank playerLevel, int[] scores, R6Attacker favoriteAttacker, R6Defender favoriteDefender) {
|
||||
this.playerName = new SimpleStringProperty(playerName.getFullName());
|
||||
this.playerNumber = new SimpleIntegerProperty(playerNumber);
|
||||
|
|
@ -50,26 +98,53 @@ public class CompetitorRow {
|
|||
this.favoriteAttacker = new SimpleStringProperty(favoriteAttacker.getAttacker());
|
||||
this.favoriteDefender = new SimpleStringProperty(favoriteDefender.getDefender());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the player's number
|
||||
* @return the player's number
|
||||
*/
|
||||
public int getPlayerNumber() {
|
||||
return playerNumber.get();
|
||||
}
|
||||
/**
|
||||
* Get the player's name
|
||||
* @return the player's name
|
||||
*/
|
||||
public String getPlayerName() {
|
||||
return playerName.get();
|
||||
}
|
||||
/**
|
||||
* Get the player's level
|
||||
* @return the player's level
|
||||
*/
|
||||
public Rank getPlayerLevel() {
|
||||
return playerLevel.get();
|
||||
}
|
||||
/**
|
||||
* Get the player's scores
|
||||
* @return the player's scores
|
||||
*/
|
||||
public String getScores() {
|
||||
return scores.get();
|
||||
}
|
||||
/**
|
||||
* Get the player's favorite agent
|
||||
* @return the player's favorite agent
|
||||
*/
|
||||
public String getFavoriteAgent() {
|
||||
return favoriteAgent.get();
|
||||
}
|
||||
/**
|
||||
* Get the player's favorite attacker
|
||||
* @return the player's favorite attacker
|
||||
*/
|
||||
public String getFavoriteAttacker() {
|
||||
return favoriteAttacker.get();
|
||||
}
|
||||
/**
|
||||
* Get the player's favorite defender
|
||||
* @return the player's favorite defender
|
||||
*/
|
||||
public String getFavoriteDefender() {
|
||||
return favoriteDefender.get();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -15,15 +15,32 @@ import javafx.fxml.FXMLLoader;
|
|||
import javafx.scene.Parent;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.scene.Scene;
|
||||
|
||||
/**
|
||||
* Class that contains the main method and starts the GUI
|
||||
* @author r0r5chach
|
||||
*/
|
||||
public class Manager extends Application {
|
||||
|
||||
/**
|
||||
* Attribute that stores the GUI's scene
|
||||
*/
|
||||
private static Scene scene;
|
||||
/**
|
||||
* Attribute that stores the GUI's stage
|
||||
*/
|
||||
public static Stage stage;
|
||||
/**
|
||||
* Attribute that stores the program's competitors
|
||||
*/
|
||||
private static CompetitorList competitors;
|
||||
|
||||
/**
|
||||
* Attribute that stores the currently active controller
|
||||
*/
|
||||
private static Controller controller;
|
||||
|
||||
/**
|
||||
* Creates the GUI and competitor list, then sets the main View
|
||||
* @param stage the stage to use for the GUI
|
||||
* @throws IOException if the scene's FXML file cannot be found
|
||||
*/
|
||||
@Override
|
||||
public void start(Stage stage) throws IOException {
|
||||
competitors = createList();
|
||||
|
|
@ -33,7 +50,9 @@ public class Manager extends Application {
|
|||
Manager.stage.setScene(scene);
|
||||
Manager.stage.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the GUI and outputs a report file
|
||||
*/
|
||||
@Override
|
||||
public void stop() {
|
||||
try {
|
||||
|
|
@ -43,11 +62,20 @@ public class Manager extends Application {
|
|||
createErrorLog(e, "src/main/resources/com/r0r5chach/log.txt");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the root for the scene
|
||||
* @param fxml the view to be loaded
|
||||
* @throws IOException if the view file cannot be found
|
||||
*/
|
||||
public static void setRoot(String fxml) throws IOException {
|
||||
scene.setRoot(loadFXML(fxml));
|
||||
}
|
||||
|
||||
/**
|
||||
* Load an FXML file
|
||||
* @param fxml the file to be loaded
|
||||
* @return the root to change the scene to
|
||||
* @throws IOException if the file cannot be found
|
||||
*/
|
||||
public static Parent loadFXML(String fxml) throws IOException {
|
||||
FXMLLoader fxmlLoader = new FXMLLoader(Manager.class.getResource(fxml + ".fxml"));
|
||||
Parent root = fxmlLoader.load();
|
||||
|
|
@ -74,15 +102,20 @@ public class Manager extends Application {
|
|||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
/**
|
||||
* Launch the GUI
|
||||
* @param args the arguments passed to the program
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
launch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the competitor list
|
||||
* @return the competitor list
|
||||
*/
|
||||
private CompetitorList createList() {
|
||||
CompetitorList competitors = null;
|
||||
File valorantPlayers = new File("src/main/resources/com/r0r5chach/valorantPlayers.txt");
|
||||
|
|
|
|||
|
|
@ -117,7 +117,6 @@ public class Name {
|
|||
/**
|
||||
* Get the initials of the stored name
|
||||
* @return a string containing the initials
|
||||
* @author r0r5chach
|
||||
*/
|
||||
public String getInitials() {
|
||||
String result = firstName.substring(0,1);
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import javafx.scene.control.TabPane;
|
|||
/**
|
||||
* Class that defines a generic controller for the GUI
|
||||
* Inherits from javafx.fxml.Initializable
|
||||
* @author r0r5chach
|
||||
*/
|
||||
public class Controller implements Initializable {
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ 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
|
||||
* @author r0r5chach
|
||||
*/
|
||||
public class EditController extends Controller {
|
||||
/**
|
||||
|
|
@ -121,7 +122,7 @@ public class EditController extends Controller {
|
|||
* @param rb The resources used to localize the root object
|
||||
*/
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
public void initialize(URL url, ResourceBundle rb) {
|
||||
Platform.runLater(() -> {
|
||||
textFields = new TextField[]{playerNumber, playerName, overallScore};
|
||||
scoreFields = new TextField[]{scores0, scores1, scores2, scores3, scores4, scores5};
|
||||
|
|
|
|||
|
|
@ -13,41 +13,60 @@ import javafx.collections.FXCollections;
|
|||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.ChoiceBox;
|
||||
import javafx.scene.control.TextArea;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.control.ToggleGroup;
|
||||
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
|
||||
* @author r0r5chach
|
||||
*/
|
||||
public class FiltersController implements Initializable {
|
||||
/**
|
||||
* Attribute that stores the filter for player number for the filter View
|
||||
*/
|
||||
@FXML
|
||||
private TextField numberFilter;
|
||||
|
||||
/**
|
||||
* Attribute that stores the filter for player name for the filter View
|
||||
*/
|
||||
@FXML
|
||||
private TextField nameFilter;
|
||||
|
||||
/**
|
||||
* Attribute that stores the filter for player level for the filter View
|
||||
*/
|
||||
@FXML
|
||||
private ChoiceBox<Rank> levelFilter;
|
||||
|
||||
/**
|
||||
* Attribute that stores the filter for player type for the filter View
|
||||
*/
|
||||
@FXML
|
||||
private ToggleGroup typeFilter;
|
||||
|
||||
/**
|
||||
* Attribute that stores the filter for player's favorite agent for the filter View
|
||||
*/
|
||||
@FXML
|
||||
private ChoiceBox<ValorantAgent> agentFilter;
|
||||
|
||||
/**
|
||||
* Attribute that stores the filter for player's favorite attacker for the filter View
|
||||
*/
|
||||
@FXML
|
||||
private ChoiceBox<R6Attacker> attackerFilter;
|
||||
|
||||
/**
|
||||
* Attribute that stores the filter for player's favorite defender for the filter View
|
||||
*/
|
||||
@FXML
|
||||
private ChoiceBox<R6Defender> defenderFilter;
|
||||
|
||||
@FXML
|
||||
private TextArea filterBox;
|
||||
|
||||
/**
|
||||
* Attribute that stores the Array of currently selected filters for the filter View
|
||||
*/
|
||||
private static String[] filters;
|
||||
|
||||
/**
|
||||
* Method that runs when the program initializes the edit 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
|
||||
public void initialize(URL url, ResourceBundle rb) {
|
||||
attackerFilter.setItems(FXCollections.observableList(Arrays.asList(R6Attacker.values())));
|
||||
|
|
@ -59,8 +78,17 @@ public class FiltersController implements Initializable {
|
|||
levelFilter.setItems(FXCollections.observableList(Arrays.asList(Rank.values())));
|
||||
levelFilter.setValue(Rank.NONE);
|
||||
}
|
||||
|
||||
@FXML
|
||||
/**
|
||||
* Gets the Array of currently selected filters
|
||||
* @return the Array of currently selected filters
|
||||
*/
|
||||
public static String[] getFilters() {
|
||||
return filters;
|
||||
}
|
||||
/**
|
||||
* Sets the currently selected filters based off of the selections on the filters View
|
||||
*/
|
||||
@FXML //Triggers when mouse leaves the area of any of the selection boxes
|
||||
private void setFilters() {
|
||||
String[] output = new String[7];
|
||||
for(int i= 0;i < output.length;i++ ) {
|
||||
|
|
@ -86,11 +114,11 @@ public class FiltersController implements Initializable {
|
|||
|
||||
filters = output;
|
||||
}
|
||||
|
||||
public static String[] getFilters() {
|
||||
return filters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if a string is null
|
||||
* @param string The string to be checked
|
||||
* @return true if null; false otherwise
|
||||
*/
|
||||
private boolean isNull(String string) {
|
||||
if (string == null) {
|
||||
return true;
|
||||
|
|
@ -99,4 +127,4 @@ public class FiltersController implements Initializable {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@ package com.r0r5chach.controllers;
|
|||
/**
|
||||
* Class that defines the controller for the main View (main.fxml) of the GUI
|
||||
* Inherits from com.r0r5chach.controllers.Controller
|
||||
* @author r0r5chach
|
||||
*/
|
||||
public class MainController extends Controller {
|
||||
|
||||
}
|
||||
|
|
@ -11,14 +11,25 @@ import javafx.scene.control.TextArea;
|
|||
/**
|
||||
* Class that defines the controller for the report View of the GUI
|
||||
* Inherits from com.r0r5chach.controllers.Controller
|
||||
* @author r0r5chach
|
||||
*/
|
||||
public class ReportController extends Controller {
|
||||
/**
|
||||
* Attribute that stores the competitor list for the report View
|
||||
*/
|
||||
@FXML
|
||||
private ListView<Integer> competitorList;
|
||||
|
||||
/**
|
||||
* Attribute that stores the output area for the report View
|
||||
*/
|
||||
@FXML
|
||||
private TextArea outputArea;
|
||||
|
||||
/**
|
||||
* Method that runs when the program initializes the edit 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
|
||||
public void initialize(URL url, ResourceBundle rb) {
|
||||
Platform.runLater(() -> {
|
||||
|
|
@ -26,8 +37,10 @@ public class ReportController extends Controller {
|
|||
competitorList.setItems(FXCollections.observableList(competitorIds));
|
||||
});
|
||||
}
|
||||
|
||||
@FXML
|
||||
/**
|
||||
* Outputs the short details of the selected player to the output area
|
||||
*/
|
||||
@FXML //Triggers when the short details button is pressed
|
||||
private void shortDetailsPress() {
|
||||
Integer item = competitorList.getSelectionModel().getSelectedItem();
|
||||
outputArea.clear();
|
||||
|
|
@ -38,8 +51,10 @@ public class ReportController extends Controller {
|
|||
outputArea.setText("Select A Competitor");
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
/**
|
||||
* Outputs the full details of the selected player to the output area
|
||||
*/
|
||||
@FXML //Triggers when the full details button is pressed
|
||||
private void fullDetailsPress() {
|
||||
Integer item = competitorList.getSelectionModel().getSelectedItem();
|
||||
if (item != null) {
|
||||
|
|
@ -50,4 +65,4 @@ public class ReportController extends Controller {
|
|||
outputArea.setText("Select A Competitor");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,8 @@ import java.util.ResourceBundle;
|
|||
import java.util.function.Predicate;
|
||||
|
||||
import static com.r0r5chach.controllers.FiltersController.getFilters;
|
||||
|
||||
import com.r0r5chach.CompetitorList;
|
||||
import com.r0r5chach.CompetitorRow;
|
||||
import com.r0r5chach.Manager;
|
||||
import com.r0r5chach.competitor.Competitor;
|
||||
|
|
@ -24,36 +26,75 @@ import javafx.scene.Parent;
|
|||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.TextArea;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.stage.Popup;
|
||||
/**
|
||||
* Class that defines the Controller for the view View (view.fxml) of the GUI
|
||||
* Inherits from com.r0r5chach.controllers.Controller
|
||||
* @author r0r5chach
|
||||
*/
|
||||
public class ViewController extends Controller {
|
||||
/**
|
||||
* Attribute that stores the table view for the view View
|
||||
*/
|
||||
@FXML
|
||||
private TableView<CompetitorRow> competitorTable;
|
||||
|
||||
/**
|
||||
* Attribute that stores the players' number column
|
||||
*/
|
||||
private TableColumn<CompetitorRow,Integer> playerNumCol;
|
||||
/**
|
||||
* Attribute that stores the players' name column
|
||||
*/
|
||||
private TableColumn<CompetitorRow,String> playerNameCol;
|
||||
/**
|
||||
* Attribute that stores the players' level column
|
||||
*/
|
||||
private TableColumn<CompetitorRow,Rank> playerLevelCol;
|
||||
/**
|
||||
* Attribute that stores the players' scores column
|
||||
*/
|
||||
private TableColumn<CompetitorRow,String> scoresCol;
|
||||
/**
|
||||
* Attribute that stores the players' favorite characters column
|
||||
*/
|
||||
private TableColumn<CompetitorRow,String> favoriteCharsCol;
|
||||
/**
|
||||
* Attribute that stores the players' favorite agent column
|
||||
* This is a sub column of the players' favorite characters column
|
||||
*/
|
||||
private TableColumn<CompetitorRow,String> favoriteAgentCol;
|
||||
/**
|
||||
* Attribute that stores the players' favorite attacker column
|
||||
* This is a sub column of the players' favorite characters column
|
||||
*/
|
||||
private TableColumn<CompetitorRow,String> favoriteAttackerCol;
|
||||
/**
|
||||
* Attribute that stores the players' favorite defender column
|
||||
* This is a sub column of the players' favorite characters column
|
||||
*/
|
||||
private TableColumn<CompetitorRow,String> favoriteDefenderCol;
|
||||
|
||||
/**
|
||||
* Attribute that stores the filter button for the view View
|
||||
*/
|
||||
@FXML
|
||||
private Button filterButton;
|
||||
/**
|
||||
* Attribute that stores the filter popup
|
||||
*/
|
||||
private Popup filterPopup;
|
||||
/**
|
||||
* Attribute that stores the Array that contains active filters
|
||||
*/
|
||||
private String[] filters;
|
||||
|
||||
@FXML
|
||||
private TextArea filterBox;
|
||||
|
||||
/**
|
||||
* Method that runs when the program initializes the edit 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
|
||||
public void initialize(URL ul, ResourceBundle rb) {
|
||||
public void initialize(URL url, ResourceBundle rb) {
|
||||
Platform.runLater(() -> {
|
||||
filters = new String[]{"", "", "", "", "", "", ""};
|
||||
filterPopup = new Popup();
|
||||
|
|
@ -62,13 +103,29 @@ public class ViewController extends Controller {
|
|||
loadView();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Either opens the filters popup or saves the filter selection dependant on what state the button is in
|
||||
*/
|
||||
@FXML //Triggers when filter/save button is pressed
|
||||
private void filterPress() {
|
||||
switch(filterButton.getText().toLowerCase()) {
|
||||
case "filters" -> filterDialog();
|
||||
case "save" -> saveFilters();
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Generates the table
|
||||
*/
|
||||
private void generateTable() {
|
||||
initColumns();
|
||||
setColumnCellValues();
|
||||
addColumns();
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the predicate that controls filtering for the table
|
||||
* @return The predicate
|
||||
*/
|
||||
private Predicate<CompetitorRow> filter() {
|
||||
Predicate<CompetitorRow> test = competitor -> {
|
||||
boolean flag = true;
|
||||
|
|
@ -111,7 +168,11 @@ public class ViewController extends Controller {
|
|||
};
|
||||
return test;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the rows of data into usable data for the table
|
||||
* @param list The list of competitors to be loaded into the table
|
||||
* @return The list of rows as usable data
|
||||
*/
|
||||
private ObservableList<CompetitorRow> loadTable(ArrayList<Competitor> list) {
|
||||
ArrayList<CompetitorRow> outputList = new ArrayList<>();
|
||||
for(Competitor player: list) {
|
||||
|
|
@ -124,7 +185,9 @@ public class ViewController extends Controller {
|
|||
}
|
||||
return FXCollections.observableArrayList(outputList);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the view View elements with their appropriate data
|
||||
*/
|
||||
private void loadView() {
|
||||
ObservableList<CompetitorRow> table = loadTable(competitors.getCompetitors());
|
||||
generateTable();
|
||||
|
|
@ -138,7 +201,9 @@ public class ViewController extends Controller {
|
|||
competitorTable.setItems(table);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the table columns
|
||||
*/
|
||||
private void initColumns() {
|
||||
playerNumCol = new TableColumn<CompetitorRow,Integer>("Player Number");
|
||||
playerNameCol = new TableColumn<CompetitorRow,String>("Player Name");
|
||||
|
|
@ -149,7 +214,9 @@ public class ViewController extends Controller {
|
|||
favoriteAttackerCol = new TableColumn<CompetitorRow,String>("Attacker");
|
||||
favoriteDefenderCol = new TableColumn<CompetitorRow,String>("Defender");
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the appropriate attribute to the corresponding column
|
||||
*/
|
||||
private void setColumnCellValues() {
|
||||
playerNumCol.setCellValueFactory(new PropertyValueFactory<CompetitorRow,Integer>("playerNumber"));
|
||||
playerNameCol.setCellValueFactory(new PropertyValueFactory<CompetitorRow,String>("playerName"));
|
||||
|
|
@ -159,7 +226,9 @@ public class ViewController extends Controller {
|
|||
favoriteAttackerCol.setCellValueFactory(new PropertyValueFactory<CompetitorRow,String>("favoriteAttacker"));
|
||||
favoriteDefenderCol.setCellValueFactory(new PropertyValueFactory<CompetitorRow,String>("favoriteDefender"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the table columns to the table
|
||||
*/
|
||||
private void addColumns() {
|
||||
competitorTable.getColumns().add(playerNumCol);
|
||||
competitorTable.getColumns().add(playerNameCol);
|
||||
|
|
@ -170,31 +239,35 @@ public class ViewController extends Controller {
|
|||
favoriteCharsCol.getColumns().add(favoriteDefenderCol);
|
||||
competitorTable.getColumns().add(favoriteCharsCol);
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void filterPress() throws IOException {
|
||||
switch(filterButton.getText().toLowerCase()) {
|
||||
case "filters" -> filterDialog();
|
||||
case "save" -> saveFilters();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void filterDialog() throws IOException {
|
||||
/**
|
||||
* Open the filters popup and change the state of the button
|
||||
*/
|
||||
private void filterDialog() {
|
||||
filterPopup = new Popup();
|
||||
Parent root = Manager.loadFXML("pages/filters");
|
||||
Parent root = null;
|
||||
try {
|
||||
root = Manager.loadFXML("pages/filters");
|
||||
}
|
||||
catch (IOException e) {
|
||||
CompetitorList.createErrorLog(e, "src/main/resources/com/r0r5chach");
|
||||
}
|
||||
filterPopup.getContent().add(root);
|
||||
filterPopup.show(Manager.stage);
|
||||
filterButton.setText("Save");
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the filter selection from the filters popup
|
||||
*/
|
||||
private void saveFilters() {
|
||||
filterPopup.hide();
|
||||
filterButton.setText("Filters");
|
||||
filters = getFilters();
|
||||
loadView();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a filter is selected
|
||||
* @return true if a filter is selected; false otherwise
|
||||
*/
|
||||
private boolean filterCheck() {
|
||||
for(String filter: filters) {
|
||||
if (!filter.equals("")) {
|
||||
|
|
|
|||
|
|
@ -6,9 +6,18 @@ import org.junit.jupiter.api.Test;
|
|||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Class that defines the test for com.r0r5chach.CompetitorList
|
||||
* @author r0r5chach
|
||||
*/
|
||||
public class CompetitorListTest {
|
||||
/**
|
||||
* Attribute that stores the path to the test resources directory
|
||||
*/
|
||||
private String testPath = "src/test/resources";
|
||||
/**
|
||||
* Tests CompetitorList.createReportFile(String)
|
||||
*/
|
||||
@Test
|
||||
public void competitorListCreateReportFileTest() {
|
||||
char[] output = new char[10];
|
||||
|
|
@ -23,23 +32,31 @@ public class CompetitorListTest {
|
|||
}
|
||||
assertEquals("Competitor", String.valueOf(output));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests CompetitorList.createErrorLog(Exception, String)
|
||||
*/
|
||||
@Test
|
||||
public void CompetitorListCreateErrorLogTest() {
|
||||
String output = CompetitorList.createErrorLog(new IOException(), testPath+"/log.txt");
|
||||
assertEquals("java.io.IOException", output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests CompetitorList.readCompetitors()
|
||||
*/
|
||||
@Test
|
||||
public void competitorListReadCompetitorsTest() {
|
||||
//Already tested in competitorListCreateReportFileTest()
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests CompetitorList.getCompetitors()
|
||||
*/
|
||||
@Test
|
||||
public void competitorListGetCompetitorsTest() {
|
||||
//Already tested in competitorListCreateReportFileTest()
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests CompetitorList.CompetitorList()
|
||||
*/
|
||||
@Test
|
||||
public void competitorListTest() {
|
||||
//Already tested in competitorListCreateReportFileTest()
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.r0r5chach;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.r0r5chach.competitor.Name;
|
||||
|
|
@ -9,9 +8,14 @@ import com.r0r5chach.competitor.Rank;
|
|||
import com.r0r5chach.competitor.valorant.ValorantAgent;
|
||||
import com.r0r5chach.competitor.r6.R6Attacker;
|
||||
import com.r0r5chach.competitor.r6.R6Defender;
|
||||
|
||||
/**
|
||||
* Class that defines the test for com.r0r5chach.CompetitorRow
|
||||
* @author r0r5chach
|
||||
*/
|
||||
public class CompetitorRowTest {
|
||||
|
||||
/**
|
||||
* Tests CompetitorRow.CompetitorRow(int, Name, Rank, int[])
|
||||
*/
|
||||
@Test
|
||||
public void competitorRowCompetitorTest() {
|
||||
CompetitorRow cR = new CompetitorRow(101, new Name("Joshua Perry"), Rank.GOLD, new int[]{5,5,5,5,5,5});
|
||||
|
|
@ -20,46 +24,70 @@ public class CompetitorRowTest {
|
|||
assertEquals(Rank.GOLD, cR.getPlayerLevel());
|
||||
assertEquals("5, 5, 5, 5, 5, 5", cR.getScores());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests CompetitorRow.CompetitorRow(int, Name, Rank, int[], ValorantAgent)
|
||||
*/
|
||||
@Test
|
||||
public void competitorRowValorantPlayerTest() {
|
||||
CompetitorRow cR = new CompetitorRow(101, new Name("Joshua Perry"), Rank.GOLD, new int[]{5,5,5,5,5,5}, ValorantAgent.ASTRA);
|
||||
assertEquals(ValorantAgent.ASTRA.getAgent(), cR.getFavoriteAgent());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests CompetitorRow.CompetitorRow(int, Name, Rank, int[], R6Attacker, R6Defender)
|
||||
*/
|
||||
@Test
|
||||
public void competitorRowR6PlayerTest() {
|
||||
CompetitorRow cR = new CompetitorRow(101, new Name("Joshua Perry"), Rank.GOLD, new int[]{5,5,5,5,5,5}, R6Attacker.GLAZ, R6Defender.CASTLE);
|
||||
assertEquals(R6Attacker.GLAZ.getAttacker(), cR.getFavoriteAttacker());
|
||||
assertEquals(R6Defender.CASTLE.getDefender(), cR.getFavoriteDefender());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests CompetitorRow.getPlayerNumber()
|
||||
*/
|
||||
@Test
|
||||
public void competitorRowGetPlayerNumberTest() {
|
||||
//Already tested in competitorRowCompetitorTest()
|
||||
}
|
||||
/**
|
||||
* Tests CompetitorRow.getPlayerName()
|
||||
*/
|
||||
@Test
|
||||
public void competitorRowGetPlayerNameTest() {
|
||||
//Already tested in competitorRowCompetitorTest()
|
||||
}
|
||||
/**
|
||||
* Tests CompetitorRow.getPlayerLevel()
|
||||
*/
|
||||
@Test
|
||||
public void competitorRowGetPlayerLevelTest() {
|
||||
//Already tested in competitorRowCompetitorTest()
|
||||
}
|
||||
/**
|
||||
* Tests CompetitorRow.getScores()
|
||||
*/
|
||||
@Test
|
||||
public void competitorRowGetScoresTest() {
|
||||
//Already tested in competitorRowCompetitorTest()
|
||||
}
|
||||
/**
|
||||
* Tests CompetitorRow.getFavoriteAgent()
|
||||
*/
|
||||
@Test
|
||||
public void competitorRowGetFavoriteAgentTest() {
|
||||
//Already tested in competitorRowValorantPlayerTest()
|
||||
}
|
||||
/**
|
||||
* Tests CompetitorRow.getFavoriteAttacker()
|
||||
*/
|
||||
@Test
|
||||
public void competitorRowGetFavoriteAttackerTest() {
|
||||
//Already tested in competitorRowR6PlayerTest()
|
||||
}
|
||||
/**
|
||||
* Tests CompetitorRow.getFavoriteDefender()
|
||||
*/
|
||||
@Test
|
||||
public void competitorRowGetFavoriteDefenderTest() {
|
||||
//Already tested in competitorRowR6PlayerTest()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,8 @@
|
|||
package com.r0r5chach;
|
||||
|
||||
/**
|
||||
* Class that defines the test for com.r0r5chach.competitor.Competitor
|
||||
* @author r0r5chach
|
||||
*/
|
||||
public class CompetitorTest {
|
||||
//Already Tested in com.r0r5chach.ValorantPlayerTest.java
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,19 @@
|
|||
package com.r0r5chach;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.r0r5chach.controllers.Controller;
|
||||
|
||||
/**
|
||||
* Class that defines the test for com.r0r5chach.controllers.Controller
|
||||
* @author r0r5chach
|
||||
*/
|
||||
public class ControllerTest {
|
||||
|
||||
/**
|
||||
* Tests Controller.setCompetitors(CompetitorList)
|
||||
*/
|
||||
@Test
|
||||
public void controllerSetCompetitorsTest() {
|
||||
Controller c = new Controller();
|
||||
|
|
@ -24,7 +28,9 @@ public class ControllerTest {
|
|||
c.setCompetitors(cL);
|
||||
assertEquals(101, c.getCompetitors().getCompetitors().get(0).getPlayerNumber());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests Controller.getCompetitors()
|
||||
*/
|
||||
@Test
|
||||
public void controllerGetCompetitorsTest() {
|
||||
//Already tested in controllerSetCompetitorsTest()
|
||||
|
|
|
|||
|
|
@ -1,13 +1,17 @@
|
|||
package com.r0r5chach;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.r0r5chach.controllers.FiltersController;
|
||||
|
||||
/**
|
||||
* Class that defines the test for com.r0r5chach.controllers.FiltersController
|
||||
* @author r0r5chach
|
||||
*/
|
||||
public class FiltersControllerTest {
|
||||
|
||||
/**
|
||||
* Tests FiltersController.getFilters()
|
||||
*/
|
||||
@Test
|
||||
public void filtersControllerGetFiltersTest() {
|
||||
assertEquals(null, FiltersController.getFilters());
|
||||
|
|
|
|||
|
|
@ -1,28 +1,37 @@
|
|||
package com.r0r5chach;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.r0r5chach.competitor.Name;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* Class that defines the test for com.r0r5chach.competitor.Name
|
||||
* @author r0r5chach
|
||||
*/
|
||||
public class NameTest {
|
||||
|
||||
/**
|
||||
* Tests Name.Name(String, String)
|
||||
*/
|
||||
@Test
|
||||
public void nameTestFNameLName() {
|
||||
public void nameFNameLNameTest() {
|
||||
Name n = new Name("Joshua", "Perry");
|
||||
assertEquals("Joshua", n.getFirstName());
|
||||
assertEquals("", n.getMiddleName());
|
||||
assertEquals("Perry", n.getLastName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests Name.Name(String, String, String)
|
||||
*/
|
||||
@Test
|
||||
public void nameTestFNameMNameLName() {
|
||||
public void nameFNameMNameLNameTest() {
|
||||
Name n = new Name("Joshua", "Luke", "Perry");
|
||||
assertEquals("Joshua", n.getFirstName());
|
||||
assertEquals("Luke", n.getMiddleName());
|
||||
assertEquals("Perry", n.getLastName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests Name.Name(String)
|
||||
*/
|
||||
@Test
|
||||
public void nameFullNameTest() {
|
||||
Name n = new Name("Joshua Luke Perry");
|
||||
|
|
@ -35,7 +44,9 @@ public class NameTest {
|
|||
assertEquals("", n.getMiddleName());
|
||||
assertEquals("Perry", n.getLastName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests Name.setFirstName(String)
|
||||
*/
|
||||
@Test
|
||||
public void nameSetFirstNameTest() {
|
||||
Name n = new Name("Joshua Luke Perry");
|
||||
|
|
@ -43,7 +54,9 @@ public class NameTest {
|
|||
n.setFirstName("Bradley");
|
||||
assertEquals("Bradley", n.getFirstName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests Name.setLastName(String)
|
||||
*/
|
||||
@Test
|
||||
public void nameSetLastNameTest() {
|
||||
Name n = new Name("Joshua Luke Perry");
|
||||
|
|
@ -51,19 +64,25 @@ public class NameTest {
|
|||
n.setLastName("Gordon-Taylor");
|
||||
assertEquals("Gordon-Taylor", n.getLastName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests Name.getFistAndLastName()
|
||||
*/
|
||||
@Test
|
||||
public void nameGetFirstAndLastNameTest() {
|
||||
Name n = new Name("Joshua Luke Perry");
|
||||
assertEquals("Joshua Perry", n.getFirstAndLastName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests Name.getLastCommaFirst()
|
||||
*/
|
||||
@Test
|
||||
public void nameGetLastCommaFirstTest() {
|
||||
Name n = new Name("Joshua Luke Perry");
|
||||
assertEquals("Perry, Joshua", n.getLastCommaFirst());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests Name.getFullName()
|
||||
*/
|
||||
@Test
|
||||
public void nameGetFullNameTest() {
|
||||
Name n = new Name("Joshua Luke Perry");
|
||||
|
|
@ -71,7 +90,9 @@ public class NameTest {
|
|||
n.setMiddleName("");
|
||||
assertEquals("Joshua Perry", n.getFullName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests Name.getInitials()
|
||||
*/
|
||||
@Test
|
||||
public void nameGetInitialsTest() {
|
||||
Name n = new Name("Joshua Luke Perry");
|
||||
|
|
@ -79,25 +100,32 @@ public class NameTest {
|
|||
n.setMiddleName("");
|
||||
assertEquals("JP", n.getInitials());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests Name.getFirstName()
|
||||
*/
|
||||
@Test
|
||||
public void nameGetFirstNameTest() {
|
||||
//Already tested in nameFNameLNameTest()
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests Name.getMiddleName()
|
||||
*/
|
||||
@Test
|
||||
public void nameGetMiddleNameTest() {
|
||||
//Already tested in nameFNameMNameLNameTest()
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests Name.getLastName()
|
||||
*/
|
||||
@Test
|
||||
public void nameGetLastNameTest() {
|
||||
//Already tested in nameFullNameTest()
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests Name.setMiddleName(String)
|
||||
*/
|
||||
@Test
|
||||
public void nameSetMiddleNameTest() {
|
||||
//Already tested in nameGetFullNameTest()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,12 +4,17 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.r0r5chach.competitor.r6.R6Attacker;
|
||||
|
||||
|
||||
/**
|
||||
* Class that defines the test for com.r0r5chach.competitor.r6.R6Attacker
|
||||
* @author r0r5chach
|
||||
*/
|
||||
public class R6AttackerTest {
|
||||
/**
|
||||
* Tests R6Attacker.getAttacker()
|
||||
*/
|
||||
@Test
|
||||
public void r6AttackerGetAttackerTest() {
|
||||
R6Attacker a = R6Attacker.GLAZ;
|
||||
assertEquals("Glaz", a.getAttacker());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +1,20 @@
|
|||
package com.r0r5chach;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.r0r5chach.competitor.r6.R6Defender;
|
||||
|
||||
/**
|
||||
* Class that defines the test for com.r0r5chach.competitor.r6.R6Defender
|
||||
* @author r0r5chach
|
||||
*/
|
||||
public class R6DefenderTest {
|
||||
|
||||
/**
|
||||
* Tests R6Defender.getDefender()
|
||||
*/
|
||||
@Test
|
||||
public void r6AttackerGetAttackerTest() {
|
||||
public void r6AttackerGetDefenderTest() {
|
||||
R6Defender d = R6Defender.CASTLE;
|
||||
assertEquals("Castle", d.getDefender());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
package com.r0r5chach;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.r0r5chach.competitor.Name;
|
||||
|
|
@ -9,9 +8,14 @@ import com.r0r5chach.competitor.Rank;
|
|||
import com.r0r5chach.competitor.r6.R6Attacker;
|
||||
import com.r0r5chach.competitor.r6.R6Defender;
|
||||
import com.r0r5chach.competitor.r6.R6Player;
|
||||
|
||||
/**
|
||||
* Class that defines the test for com.r0r5chach.competitor.r6.R6Player
|
||||
* @author r0r5chach
|
||||
*/
|
||||
public class R6PlayerTest {
|
||||
|
||||
/**
|
||||
* Tests R6Player.getFullDetails()
|
||||
*/
|
||||
@Test
|
||||
public void r6PlayerGetFullDetailsTest() {
|
||||
R6Player r6P = new R6Player(1, new Name("Joshua Perry"), Rank.BRONZE, R6Attacker.ACE, R6Defender.ALIBI, new int[]{5,5,5,5,5,5});
|
||||
|
|
@ -28,30 +32,39 @@ public class R6PlayerTest {
|
|||
Favorite Attacker: Amaru
|
||||
Favorite Defender: Aruni""", r6P.getFullDetails());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests R6Player.setFavoriteAttacker(R6Attacker)
|
||||
*/
|
||||
@Test
|
||||
public void r6PlayerSetFavoriteAttacker() {
|
||||
//Already tested in r6PlayerGetFullDetailsTest()
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests R6Player.setFavoriteDefender(R6Defender)
|
||||
*/
|
||||
@Test
|
||||
public void r6PlayerSetFavoriteDefender() {
|
||||
//Already tested in r6PlayerGetFullDetailsTest()
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests R6Player.getFavoriteAttacker()
|
||||
*/
|
||||
@Test
|
||||
public void r6PlayerGetFavoriteAttacker() {
|
||||
//Already tested in r6PlayerGetFullDetailsTest()
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests R6Player.getFavoriteAttacker()
|
||||
*/
|
||||
@Test
|
||||
public void r6PlayerGetFavoriteDefender() {
|
||||
//Already tested in r6PlayerGetFullDetailsTest()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests R6Player.R6Player(int, Name, Rank, R6Attacker, R6Defender, int[])
|
||||
*/
|
||||
@Test
|
||||
public void r6PlayerTest() {
|
||||
//Already tested in r6PlayerGetFullDetailsTest()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,12 +4,17 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.r0r5chach.competitor.Rank;
|
||||
|
||||
|
||||
/**
|
||||
* Class that defines the test for com.r0r5chach.competitor.Rank
|
||||
* @author r0r5chach
|
||||
*/
|
||||
public class RankTest {
|
||||
/**
|
||||
* Tests Rank.getRank()
|
||||
*/
|
||||
@Test
|
||||
public void valorantRankGetRankTest() {
|
||||
Rank vR = Rank.BRONZE;
|
||||
assertEquals("Bronze", vR.getRank());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,13 +1,20 @@
|
|||
package com.r0r5chach;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.r0r5chach.competitor.valorant.ValorantAgent;
|
||||
|
||||
/**
|
||||
* Class that defines the test for com.r0r5chach.competitor.valorant.ValorantAgent
|
||||
* @author r0r5chach
|
||||
*/
|
||||
public class ValorantAgentTest {
|
||||
/**
|
||||
* Tests ValorantAgent.getAgent()
|
||||
*/
|
||||
@Test
|
||||
public void valorantAgentGetAgentTest() {
|
||||
ValorantAgent vA = ValorantAgent.HARBOR;
|
||||
assertEquals("Harbor", vA.getAgent());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
package com.r0r5chach;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
|
@ -6,7 +7,14 @@ import com.r0r5chach.competitor.Name;
|
|||
import com.r0r5chach.competitor.Rank;
|
||||
import com.r0r5chach.competitor.valorant.ValorantAgent;
|
||||
import com.r0r5chach.competitor.valorant.ValorantPlayer;
|
||||
/**
|
||||
* Class that defines the test for com.r0r5chach.competitor.valorant.ValorantPlayer
|
||||
* @author r0r5chach
|
||||
*/
|
||||
public class ValorantPlayerTest {
|
||||
/**
|
||||
* Tests ValorantPlayer.ValorantPlayer(int, Name, Rank, ValorantAgent, int[])
|
||||
*/
|
||||
@Test
|
||||
public void valorantPlayerTest() {
|
||||
int[] scores = {5,5,5,5,5,5};
|
||||
|
|
@ -17,7 +25,9 @@ public class ValorantPlayerTest {
|
|||
assertEquals("Fade", vP.getFavoriteAgent().getAgent());
|
||||
assertEquals(5, vP.getOverallScore());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ValorantPlayer.setPlayerNumber(int)
|
||||
*/
|
||||
@Test
|
||||
public void valorantPlayerTestSetPlayerNumber() {
|
||||
int[] scores = {5,5,5,5,5,5};
|
||||
|
|
@ -26,7 +36,9 @@ public class ValorantPlayerTest {
|
|||
vP.setPlayerNumber(5);
|
||||
assertEquals(5, vP.getPlayerNumber());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ValorantPlayer.setPlayerName(Name)
|
||||
*/
|
||||
@Test
|
||||
public void valorantPlayerTestSetPlayerName() {
|
||||
int[] scores = {5,5,5,5,5,5};
|
||||
|
|
@ -35,7 +47,9 @@ public class ValorantPlayerTest {
|
|||
vP.setPlayerName(new Name("Bradley Gordon-Taylor"));
|
||||
assertEquals("Bradley Gordon-Taylor", vP.getPlayerName().getFullName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ValorantPlayer.setPlayerLevel(Rank)
|
||||
*/
|
||||
@Test
|
||||
public void valorantPlayerTestSetPlayerLevel() {
|
||||
int[] scores = {5,5,5,5,5,5};
|
||||
|
|
@ -44,7 +58,9 @@ public class ValorantPlayerTest {
|
|||
vP.setPlayerLevel(Rank.BRONZE);
|
||||
assertEquals("Bronze", vP.getPlayerLevel().getRank());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ValorantPlayer.setFavoriteAgent(ValorantAgent)
|
||||
*/
|
||||
@Test
|
||||
public void valorantPlayerTestSetFavoriteAgent() {
|
||||
int[] scores = {5,5,5,5,5,5};
|
||||
|
|
@ -53,7 +69,9 @@ public class ValorantPlayerTest {
|
|||
vP.setFavoriteAgent(ValorantAgent.VIPER);
|
||||
assertEquals("Viper", vP.getFavoriteAgent().getAgent());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ValorantPlayer.setScores(int[])
|
||||
*/
|
||||
@Test
|
||||
public void valorantPlayerTestSetScores() {
|
||||
int[] scores = {5,5,5,5,5,5};
|
||||
|
|
@ -62,14 +80,18 @@ public class ValorantPlayerTest {
|
|||
vP.setScores(new int[]{0, 0, 0, 0, 0, 0});
|
||||
assertEquals(0, vP.getOverallScore());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ValorantPlayer.getOverallScore()
|
||||
*/
|
||||
@Test
|
||||
public void valorantPlayerTestGetOverallScore() {
|
||||
int[] scores = {5,5,5,5,5,5};
|
||||
ValorantPlayer vP = new ValorantPlayer(2,new Name("Joshua Luke Perry"), Rank.GOLD, ValorantAgent.FADE, scores);
|
||||
assertEquals(5, vP.getOverallScore());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ValorantPlayer.getFullDetails()
|
||||
*/
|
||||
@Test
|
||||
public void valorantPlayerTestGetFullDetails() {
|
||||
int[] scores = {5,5,5,5,5,5};
|
||||
|
|
@ -83,7 +105,9 @@ public class ValorantPlayerTest {
|
|||
Overall Score: 5.0
|
||||
Favorite Agent: Fade""", vP.getFullDetails());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ValorantPlayer.getShortDetails()
|
||||
*/
|
||||
@Test
|
||||
public void valorantPlayerTestGetShortDetails() {
|
||||
int[] scores = {5,5,5,5,5,5};
|
||||
|
|
@ -91,25 +115,32 @@ public class ValorantPlayerTest {
|
|||
|
||||
assertEquals("CN 2 (JLP) has overall score 5.0", vP.getShortDetails());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests ValorantPlayer.getPlayerNumber()
|
||||
*/
|
||||
@Test
|
||||
public void valorantPlayerTestGetPlayerNumber() {
|
||||
//Already tested in valorantPlayerTest()
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ValorantPlayer.getPlayerName()
|
||||
*/
|
||||
@Test
|
||||
public void valorantPlayerTestGetPlayerName() {
|
||||
//Already tested in valorantPlayerTest()
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ValorantPlayer.getPlayerLevel()
|
||||
*/
|
||||
@Test
|
||||
public void valorantPlayerTestGetPlayerLevel() {
|
||||
//Already tested in valorantPlayerTest()
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ValorantPlayer.getFavoriteAgent()
|
||||
*/
|
||||
@Test
|
||||
public void valorantPlayerTestGetFavoriteAgent() {
|
||||
//Already tested in valorantPlayerTest()
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue