Updated 'AnimationState' class.

Updated the 'AnimationState' class by setting the data type of 'messageReceived' from 'Map' to 'Set'.
This commit is contained in:
Daniel Grigencha
2024-12-06 04:27:10 +01:00
parent dd2146d417
commit 9d1430e488

View File

@@ -1,16 +1,14 @@
package pp.mdga.server.automaton.game;
import pp.mdga.message.client.AnimationEndMessage;
import pp.mdga.message.server.DiceNowMessage;
import pp.mdga.server.ServerGameLogic;
import pp.mdga.server.automaton.GameState;
import java.util.HashMap;
import java.util.Map;
import java.util.HashSet;
import java.util.Set;
/**
* This class represents the animation state of the game state.
*
*/
public class AnimationState extends GameAutomatonState {
/**
@@ -21,7 +19,7 @@ public class AnimationState extends GameAutomatonState {
/**
* Create AnimationState attributes.
*/
private final Map<Integer, Boolean> messageReceived = new HashMap<>();
private final Set<Integer> messageReceived = new HashSet<>();
/**
* Constructs a server state of the specified game logic.
@@ -53,7 +51,7 @@ public void exit() {
*/
@Override
public void received(AnimationEndMessage msg, int from) {
this.messageReceived.put(from, true);
this.messageReceived.add(from);
if (this.messageReceived.size() == this.logic.getGame().getPlayers().size()) {
this.gameAutomaton.setCurrentState(this.gameAutomaton.getTurnState());
this.gameAutomaton.getTurnState().setCurrentState(this.gameAutomaton.getTurnState().getPowerCardState());