From 3134fd2c89e974479cbd07877e0cbea6262a4823 Mon Sep 17 00:00:00 2001 From: Joshua Perry <45966243+jpez-development@users.noreply.github.com> Date: Wed, 1 Feb 2023 19:40:30 +0000 Subject: [PATCH] added characters to table --- .../java/com/r0r5chach/CompetitorRow.java | 36 +++++++++---------- .../java/com/r0r5chach/MainController.java | 17 ++++++--- 2 files changed, 30 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/r0r5chach/CompetitorRow.java b/src/main/java/com/r0r5chach/CompetitorRow.java index ef8d38a..8db4306 100644 --- a/src/main/java/com/r0r5chach/CompetitorRow.java +++ b/src/main/java/com/r0r5chach/CompetitorRow.java @@ -15,18 +15,18 @@ public class CompetitorRow { private SimpleStringProperty playerName; private SimpleObjectProperty playerLevel; private SimpleStringProperty scores; - private SimpleObjectProperty favoriteAgent; - private SimpleObjectProperty favoriteAttacker; - private SimpleObjectProperty favoriteDefender; + private SimpleStringProperty favoriteAgent; + private SimpleStringProperty favoriteAttacker; + private SimpleStringProperty favoriteDefender; public CompetitorRow(int playerNumber, Name playerName, Rank playerLevel, int[] scores) { this.playerNumber = new SimpleIntegerProperty(playerNumber); this.playerName = new SimpleStringProperty(playerName.getFullName()); this.playerLevel = new SimpleObjectProperty(playerLevel); this.scores = new SimpleStringProperty(Arrays.toString(scores).replace("[", "").replace("]", "")); - this.favoriteAgent = null; - this.favoriteAttacker = null; - this.favoriteDefender = null; + this.favoriteAgent = new SimpleStringProperty("N/A"); + this.favoriteAttacker = new SimpleStringProperty("N/A"); + this.favoriteDefender = new SimpleStringProperty("N/A"); } public CompetitorRow(int playerNumber, Name playerName, Rank playerLevel, int[] scores, ValorantAgent favoriteAgent) { @@ -34,9 +34,9 @@ public class CompetitorRow { this.playerName = new SimpleStringProperty(playerName.getFullName()); this.scores = new SimpleStringProperty(Arrays.toString(scores).replace("[", "").replace("]", "")); this.playerLevel = new SimpleObjectProperty(playerLevel); - this.favoriteAgent = new SimpleObjectProperty(favoriteAgent); - this.favoriteAttacker = null; - this.favoriteDefender = null; + this.favoriteAgent = new SimpleStringProperty(favoriteAgent.getAgent()); + this.favoriteAttacker = new SimpleStringProperty("N/A"); + this.favoriteDefender = new SimpleStringProperty("N/A"); } public CompetitorRow(int playerNumber, Name playerName, Rank playerLevel, int[] scores, R6Attacker favoriteAttacker, R6Defender favoriteDefender) { @@ -44,9 +44,9 @@ public class CompetitorRow { this.playerNumber = new SimpleIntegerProperty(playerNumber); this.scores = new SimpleStringProperty(Arrays.toString(scores).replace("[", "").replace("]", "")); this.playerLevel = new SimpleObjectProperty(playerLevel); - this.favoriteAgent = null; - this.favoriteAttacker = new SimpleObjectProperty(favoriteAttacker); - this.favoriteDefender = new SimpleObjectProperty(favoriteDefender); + this.favoriteAgent = new SimpleStringProperty("N/A"); + this.favoriteAttacker = new SimpleStringProperty(favoriteAttacker.getAttacker()); + this.favoriteDefender = new SimpleStringProperty(favoriteDefender.getDefender()); } public void setPlayerNumber(int newValue) { @@ -61,13 +61,13 @@ public class CompetitorRow { public void setScores(String newValue) { this.scores.set(newValue); } - public void setFavoriteAgent(ValorantAgent newValue) { + public void setFavoriteAgent(String newValue) { this.favoriteAgent.set(newValue); } - public void setFavoriteAttacker(R6Attacker newValue) { + public void setFavoriteAttacker(String newValue) { this.favoriteAttacker.set(newValue); } - public void setFavoriteDefender(R6Defender newValue) { + public void setFavoriteDefender(String newValue) { this.favoriteDefender.set(newValue); } @@ -83,13 +83,13 @@ public class CompetitorRow { public String getScores() { return this.scores.get(); } - public ValorantAgent getFavoriteAgent() { + public String getFavoriteAgent() { return this.favoriteAgent.get(); } - public R6Attacker getFavoriteAttacker() { + public String getFavoriteAttacker() { return this.favoriteAttacker.get(); } - public R6Defender getFavoriteDefender() { + public String getFavoriteDefender() { return this.favoriteDefender.get(); } } diff --git a/src/main/java/com/r0r5chach/MainController.java b/src/main/java/com/r0r5chach/MainController.java index 367b5e8..f4d6d86 100644 --- a/src/main/java/com/r0r5chach/MainController.java +++ b/src/main/java/com/r0r5chach/MainController.java @@ -134,20 +134,30 @@ public class MainController implements Initializable { TableColumn playerNameCol = new TableColumn("Player Name"); TableColumn playerLevelCol = new TableColumn("Player Level"); TableColumn scoresCol = new TableColumn("Player Scores"); + TableColumn favoriteCharsCol = new TableColumn("Favorite Characters"); + TableColumn favoriteAgentCol = new TableColumn("Agent"); + TableColumn favoriteAttackerCol = new TableColumn("Attacker"); + TableColumn favoriteDefenderCol = new TableColumn("Defender"); playerNumCol.setCellValueFactory(new PropertyValueFactory("playerNumber")); playerNameCol.setCellValueFactory(new PropertyValueFactory("playerName")); playerLevelCol.setCellValueFactory(new PropertyValueFactory("playerLevel")); scoresCol.setCellValueFactory(new PropertyValueFactory("scores")); + favoriteAgentCol.setCellValueFactory(new PropertyValueFactory("favoriteAgent")); + favoriteAttackerCol.setCellValueFactory(new PropertyValueFactory("favoriteAttacker")); + favoriteDefenderCol.setCellValueFactory(new PropertyValueFactory("favoriteDefender")); competitorTable.getColumns().add(playerNumCol); competitorTable.getColumns().add(playerNameCol); competitorTable.getColumns().add(playerLevelCol); competitorTable.getColumns().add(scoresCol); + favoriteCharsCol.getColumns().add(favoriteAgentCol); + favoriteCharsCol.getColumns().add(favoriteAttackerCol); + favoriteCharsCol.getColumns().add(favoriteDefenderCol); + competitorTable.getColumns().add(favoriteCharsCol); } @FXML private void loadView() { competitorTable.setItems(generateTable()); - //TODO: Add favorite characters } private void loadPlayer(Competitor player) { @@ -216,12 +226,9 @@ public class MainController implements Initializable { if (player instanceof ValorantPlayer) { list.add(new CompetitorRow(player.getPlayerNumber(), player.getPlayerName(), player.getPlayerLevel(), player.getScores(), ((ValorantPlayer) player).getFavoriteAgent())); } - else if (player instanceof R6Player) { + if (player instanceof R6Player) { list.add(new CompetitorRow(player.getPlayerNumber(), player.getPlayerName(), player.getPlayerLevel(), player.getScores(), ((R6Player) player).getFavoriteAttacker(), ((R6Player) player).getFavoriteDefender())); } - else { - list.add(new CompetitorRow(player.getPlayerNumber(), player.getPlayerName(), player.getPlayerLevel(), player.getScores())); - } } return FXCollections.observableArrayList(list); }