Skip to content

Commit

Permalink
enhance player names update in skill points input controller
Browse files Browse the repository at this point in the history
  • Loading branch information
akmsw committed Jan 6, 2024
1 parent faf2c0b commit eab473e
Showing 1 changed file with 8 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package armameeldoparti.controllers;

import armameeldoparti.models.Player;
import java.util.Arrays;
import armameeldoparti.models.Position;
import armameeldoparti.models.ProgramView;
import armameeldoparti.utils.common.CommonFields;
import armameeldoparti.utils.common.CommonFunctions;
import armameeldoparti.utils.common.Constants;
import armameeldoparti.views.SkillPointsInputView;
import java.util.Map;
import javax.swing.JLabel;
import javax.swing.JSpinner;

/**
* Skill points input view controller class.
Expand Down Expand Up @@ -73,16 +70,13 @@ public void backButtonEvent() {
* Updates the players name labels.
*/
public void updateNameLabels() {
Map<JSpinner, JLabel> labelsMap = view.getLabelsMap();
Map<Player, JSpinner> spinnersMap = view.getSpinnersMap();

for (Position position : Position.values()) {
for (Player player : CommonFields.getPlayersSets()
.get(position)) {
labelsMap.get(spinnersMap.get(player))
.setText(player.getName());
}
}
Arrays.asList(Position.values())
.forEach(position -> CommonFields.getPlayersSets()
.get(position)
.forEach(player -> view.getLabelsMap()
.get(view.getSpinnersMap()
.get(player))
.setText(player.getName())));

view.pack();
}
Expand All @@ -103,10 +97,8 @@ protected void setUpInitialState() {
protected void setUpListeners() {
view.getBackButton()
.addActionListener(e -> backButtonEvent());

view.getFinishButton()
.addActionListener(e -> finishButtonEvent());

view.getResetSkillPointsButton()
.addActionListener(e -> resetSkillPointsButtonEvent());
}
Expand Down

0 comments on commit eab473e

Please sign in to comment.