Updated 'AnimationState' class.
Updated the 'AnimationState' class by updating the 'messageReceived' attribute in it. In Addition, the 'AnimationEndMessage' handling was updated.
This commit is contained in:
@@ -5,6 +5,9 @@
|
|||||||
import pp.mdga.server.ServerGameLogic;
|
import pp.mdga.server.ServerGameLogic;
|
||||||
import pp.mdga.server.automaton.GameState;
|
import pp.mdga.server.automaton.GameState;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents the animation state of the game state.
|
* This class represents the animation state of the game state.
|
||||||
*
|
*
|
||||||
@@ -18,7 +21,7 @@ public class AnimationState extends GameAutomatonState {
|
|||||||
/**
|
/**
|
||||||
* Create AnimationState attributes.
|
* Create AnimationState attributes.
|
||||||
*/
|
*/
|
||||||
private int messageReceived = 0;
|
private final Map<Integer, Boolean> messageReceived = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a server state of the specified game logic.
|
* Constructs a server state of the specified game logic.
|
||||||
@@ -38,7 +41,7 @@ public void enter() {
|
|||||||
@Override
|
@Override
|
||||||
public void exit() {
|
public void exit() {
|
||||||
LOGGER.log(System.Logger.Level.DEBUG, "Exited AnimationState state.");
|
LOGGER.log(System.Logger.Level.DEBUG, "Exited AnimationState state.");
|
||||||
this.messageReceived = 0;
|
this.messageReceived.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -50,12 +53,11 @@ public void exit() {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(AnimationEndMessage msg, int from) {
|
public void received(AnimationEndMessage msg, int from) {
|
||||||
if (this.messageReceived == this.logic.getGame().getPlayers().size()) {
|
this.messageReceived.put(from, true)
|
||||||
|
if (this.messageReceived.size() == this.logic.getGame().getPlayers().size()) {
|
||||||
this.logic.getServerSender().send(this.logic.getGame().getActivePlayerId(), new DiceNowMessage());
|
this.logic.getServerSender().send(this.logic.getGame().getActivePlayerId(), new DiceNowMessage());
|
||||||
this.gameAutomaton.setCurrentState(this.gameAutomaton.getTurnState());
|
this.gameAutomaton.setCurrentState(this.gameAutomaton.getTurnState());
|
||||||
this.gameAutomaton.getTurnState().setCurrentState(this.gameAutomaton.getTurnState().getPowerCardState());
|
this.gameAutomaton.getTurnState().setCurrentState(this.gameAutomaton.getTurnState().getPowerCardState());
|
||||||
} else {
|
|
||||||
this.messageReceived++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user