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
*/
public class EditController extends Controller {
/**
* Attribute that stores the competitor list for the edit View
*/
@FXML
private ListView<Integer> competitorsList;
/**
* Attribute that stores the selected player's number for the edit View
*/
@FXML
private TextField playerNumber;
/**
* Attribute that stores the selected player's name for the edit View
*/
@FXML
private TextField playerName;
/**
* Attribute that stores the selected player's level for the edit View
*/
@FXML
private ChoiceBox<Rank> playerLevel;
/**
* Attribute that stores the selected player's favorite character identifier for the edit View
*/
@FXML
private Text favoriteCharacters;
/**
* Attribute that stores the selected player's favorite attacker for the edit View
*/
@FXML
private ChoiceBox<R6Attacker> favoriteAttacker;
/**
* Attribute that stores the selected player's favorite agent for the edit View
*/
@FXML
private ChoiceBox<ValorantAgent> favoriteAgent;
/**
* Attribute that stores the selected player's favorite defender for the edit View
*/
@FXML
private ChoiceBox<R6Defender> favoriteDefender;
/**
* Attribute that stores the selected player's first score for the edit View
*/
@FXML
private TextField scores0;
/**
* Attribute that stores the selected player's second score for the edit View
*/
@FXML
private TextField scores1;
/**
* Attribute that stores the selected player's third score for the edit View
*/
@FXML
private TextField scores2;
/**
* Attribute that stores the selected player's fourth score for the edit View
*/
@FXML
private TextField scores3;
/**
* Attribute that stores the selected player's fifth score for the edit View
*/
@FXML
private TextField scores4;
/**
* Attribute that stores the selected player's sixth score for the edit View
*/
@FXML
private TextField scores5;
/**
* Attribute that stores the selected player's overall score for the edit View
*/
@FXML
private TextField overallScore;
/**
* Attribute that stores the button that updates selected player for the edit View
*/
@FXML
private Button updateButton;
/**
* Attribute that stores an Array of the text fields for the edit View
*/
private TextField[] textFields;
/**
* Attribute that stores an Array of the score fields for the edit View
*/
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
public void initialize(URL location, ResourceBundle resources) {
Platform.runLater(() -> {
@ -88,8 +129,10 @@ public class EditController extends Controller {
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) {
textFields[0].setText(String.valueOf(player.getPlayerNumber()));
textFields[1].setText(player.getPlayerName().getFullName());
@ -98,7 +141,10 @@ public class EditController extends Controller {
loadFavoriteCharacters(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) {
if (player instanceof R6Player) {
favoriteAttacker.getSelectionModel().select(((R6Player) player).getFavoriteAttacker());
@ -116,14 +162,20 @@ public class EditController extends Controller {
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) {
int[] playerScores = player.getScores();
for (int i = 0; i < playerScores.length; 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) {
player.setPlayerNumber(Integer.parseInt(textFields[0].getText()));
player.setPlayerName(new Name(textFields[1].getText()));
@ -131,7 +183,10 @@ public class EditController extends Controller {
updateFavoriteCharacters(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) {
if (player instanceof R6Player) {
((R6Player) player).setFavoriteAttacker(favoriteAttacker.getValue());
@ -141,7 +196,10 @@ public class EditController extends Controller {
((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) {
int[] newScores = new int[6];
for (int i = 0; i < newScores.length; i++) {
@ -149,14 +207,18 @@ public class EditController extends Controller {
}
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() {
Competitor player = competitors.getCompetitors().get(competitorIds.indexOf(competitorsList.getSelectionModel().getSelectedItem()));
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() {
int playerIndex = competitorIds.indexOf(competitorsList.getSelectionModel().getSelectedItem());
Competitor player = competitors.getCompetitors().get(playerIndex);
@ -165,7 +227,9 @@ public class EditController extends Controller {
loadEdit();
loadPlayer(player);
}
/**
* Loads the edit View elements with their appropriate data
*/
public void loadEdit() {
competitorsList.setItems(FXCollections.observableList(competitorIds));
playerLevel.setItems(FXCollections.observableList(Arrays.asList(Rank.values())));