added javadoc

This commit is contained in:
Joshua Perry 2023-02-05 20:45:09 +00:00
parent d36a9b3e0b
commit b79048e60d
1 changed files with 95 additions and 31 deletions

View File

@ -26,59 +26,100 @@ import javafx.scene.text.Text;
* Inherits from com.r0r5chach.controllers.Controller * Inherits from com.r0r5chach.controllers.Controller
*/ */
public class EditController extends Controller { public class EditController extends Controller {
/**
* Attribute that stores the competitor list for the edit View
*/
@FXML @FXML
private ListView<Integer> competitorsList; private ListView<Integer> competitorsList;
/**
* Attribute that stores the selected player's number for the edit View
*/
@FXML @FXML
private TextField playerNumber; private TextField playerNumber;
/**
* Attribute that stores the selected player's name for the edit View
*/
@FXML @FXML
private TextField playerName; private TextField playerName;
/**
* Attribute that stores the selected player's level for the edit View
*/
@FXML @FXML
private ChoiceBox<Rank> playerLevel; private ChoiceBox<Rank> playerLevel;
/**
* Attribute that stores the selected player's favorite character identifier for the edit View
*/
@FXML @FXML
private Text favoriteCharacters; private Text favoriteCharacters;
/**
* Attribute that stores the selected player's favorite attacker for the edit View
*/
@FXML @FXML
private ChoiceBox<R6Attacker> favoriteAttacker; private ChoiceBox<R6Attacker> favoriteAttacker;
/**
* Attribute that stores the selected player's favorite agent for the edit View
*/
@FXML @FXML
private ChoiceBox<ValorantAgent> favoriteAgent; private ChoiceBox<ValorantAgent> favoriteAgent;
/**
* Attribute that stores the selected player's favorite defender for the edit View
*/
@FXML @FXML
private ChoiceBox<R6Defender> favoriteDefender; private ChoiceBox<R6Defender> favoriteDefender;
/**
* Attribute that stores the selected player's first score for the edit View
*/
@FXML @FXML
private TextField scores0; private TextField scores0;
/**
* Attribute that stores the selected player's second score for the edit View
*/
@FXML @FXML
private TextField scores1; private TextField scores1;
/**
* Attribute that stores the selected player's third score for the edit View
*/
@FXML @FXML
private TextField scores2; private TextField scores2;
/**
* Attribute that stores the selected player's fourth score for the edit View
*/
@FXML @FXML
private TextField scores3; private TextField scores3;
/**
* Attribute that stores the selected player's fifth score for the edit View
*/
@FXML @FXML
private TextField scores4; private TextField scores4;
/**
* Attribute that stores the selected player's sixth score for the edit View
*/
@FXML @FXML
private TextField scores5; private TextField scores5;
/**
* Attribute that stores the selected player's overall score for the edit View
*/
@FXML @FXML
private TextField overallScore; private TextField overallScore;
/**
* Attribute that stores the button that updates selected player for the edit View
*/
@FXML @FXML
private Button updateButton; private Button updateButton;
/**
* Attribute that stores an Array of the text fields for the edit View
*/
private TextField[] textFields; private TextField[] textFields;
/**
* Attribute that stores an Array of the score fields for the edit View
*/
private TextField[] scoreFields; private TextField[] scoreFields;
/**
* 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 @Override
public void initialize(URL location, ResourceBundle resources) { public void initialize(URL location, ResourceBundle resources) {
Platform.runLater(() -> { Platform.runLater(() -> {
@ -88,8 +129,10 @@ public class EditController extends Controller {
loadEdit(); loadEdit();
}); });
} }
/**
* Loads the selected player into the editing area of the edit View
* @param player The player to load into the editing area
*/
private void loadPlayer(Competitor player) { private void loadPlayer(Competitor player) {
textFields[0].setText(String.valueOf(player.getPlayerNumber())); textFields[0].setText(String.valueOf(player.getPlayerNumber()));
textFields[1].setText(player.getPlayerName().getFullName()); textFields[1].setText(player.getPlayerName().getFullName());
@ -98,7 +141,10 @@ public class EditController extends Controller {
loadFavoriteCharacters(player); loadFavoriteCharacters(player);
loadScores(player); loadScores(player);
} }
/**
* Loads the selected player's favorite character(s) into the editing area of the edit View
* @param player The player that needs their character(s) loading
*/
private void loadFavoriteCharacters(Competitor player) { private void loadFavoriteCharacters(Competitor player) {
if (player instanceof R6Player) { if (player instanceof R6Player) {
favoriteAttacker.getSelectionModel().select(((R6Player) player).getFavoriteAttacker()); favoriteAttacker.getSelectionModel().select(((R6Player) player).getFavoriteAttacker());
@ -116,14 +162,20 @@ public class EditController extends Controller {
favoriteCharacters.setText("Favorite Agent"); favoriteCharacters.setText("Favorite Agent");
} }
} }
/**
* Loads the selected player's scores into the editing area of the edit View
* @param player The player that needs their scores loading
*/
private void loadScores(Competitor player) { private void loadScores(Competitor player) {
int[] playerScores = player.getScores(); int[] playerScores = player.getScores();
for (int i = 0; i < playerScores.length; i++) { for (int i = 0; i < playerScores.length; i++) {
scoreFields[i].setText(String.valueOf(playerScores[i])); scoreFields[i].setText(String.valueOf(playerScores[i]));
} }
} }
/**
* Updates the selected player's attributes
* @param player The player that needs to be updated
*/
private void updatePlayer(Competitor player) { private void updatePlayer(Competitor player) {
player.setPlayerNumber(Integer.parseInt(textFields[0].getText())); player.setPlayerNumber(Integer.parseInt(textFields[0].getText()));
player.setPlayerName(new Name(textFields[1].getText())); player.setPlayerName(new Name(textFields[1].getText()));
@ -131,7 +183,10 @@ public class EditController extends Controller {
updateFavoriteCharacters(player); updateFavoriteCharacters(player);
updateScores(player); updateScores(player);
} }
/**
* Updates the selected player's favorite character(s)
* @param player The player that needs their character(s) updated
*/
private void updateFavoriteCharacters(Competitor player) { private void updateFavoriteCharacters(Competitor player) {
if (player instanceof R6Player) { if (player instanceof R6Player) {
((R6Player) player).setFavoriteAttacker(favoriteAttacker.getValue()); ((R6Player) player).setFavoriteAttacker(favoriteAttacker.getValue());
@ -141,7 +196,10 @@ public class EditController extends Controller {
((ValorantPlayer) player).setFavoriteAgent(favoriteAgent.getValue()); ((ValorantPlayer) player).setFavoriteAgent(favoriteAgent.getValue());
} }
} }
/**
* Updates the selected player's scores
* @param player The player that needs their scores updated
*/
private void updateScores(Competitor player) { private void updateScores(Competitor player) {
int[] newScores = new int[6]; int[] newScores = new int[6];
for (int i = 0; i < newScores.length; i++) { for (int i = 0; i < newScores.length; i++) {
@ -149,14 +207,18 @@ public class EditController extends Controller {
} }
player.setScores(newScores); player.setScores(newScores);
} }
/**
@FXML * Gets the player selected in the competitors list and loads the player in the editing area of the edit View
*/
@FXML //Triggered when new list item is selected
private void getCompetitor() { private void getCompetitor() {
Competitor player = competitors.getCompetitors().get(competitorIds.indexOf(competitorsList.getSelectionModel().getSelectedItem())); Competitor player = competitors.getCompetitors().get(competitorIds.indexOf(competitorsList.getSelectionModel().getSelectedItem()));
loadPlayer(player); loadPlayer(player);
} }
/**
@FXML * Updates the player that is loaded in the editing area of the edit View
*/
@FXML //Triggered when the update button is pressed
private void updateCompetitor() { private void updateCompetitor() {
int playerIndex = competitorIds.indexOf(competitorsList.getSelectionModel().getSelectedItem()); int playerIndex = competitorIds.indexOf(competitorsList.getSelectionModel().getSelectedItem());
Competitor player = competitors.getCompetitors().get(playerIndex); Competitor player = competitors.getCompetitors().get(playerIndex);
@ -165,7 +227,9 @@ public class EditController extends Controller {
loadEdit(); loadEdit();
loadPlayer(player); loadPlayer(player);
} }
/**
* Loads the edit View elements with their appropriate data
*/
public void loadEdit() { public void loadEdit() {
competitorsList.setItems(FXCollections.observableList(competitorIds)); competitorsList.setItems(FXCollections.observableList(competitorIds));
playerLevel.setItems(FXCollections.observableList(Arrays.asList(Rank.values()))); playerLevel.setItems(FXCollections.observableList(Arrays.asList(Rank.values())));