Updated 'AnimationState' class.

Updated the 'AnimationState' class by updating the content inside the 'received(AnimationEndMessage msg, int from) method in it.
This commit is contained in:
Daniel Grigencha
2024-12-03 03:41:58 +01:00
parent 79bf1c16e8
commit 2248d044c1

View File

@@ -11,10 +11,15 @@
*/ */
public class AnimationState extends GameAutomatonState { public class AnimationState extends GameAutomatonState {
/** /**
* Create FirstRollState constants. * Create AnimationState constants.
*/ */
private static final System.Logger LOGGER = System.getLogger(AnimationState.class.getName()); private static final System.Logger LOGGER = System.getLogger(AnimationState.class.getName());
/**
* Create AnimationState attributes.
*/
private int messageReceived = 0;
/** /**
* Constructs a server state of the specified game logic. * Constructs a server state of the specified game logic.
* *
@@ -33,6 +38,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;
} }
/** /**
@@ -44,7 +50,11 @@ public void exit() {
*/ */
@Override @Override
public void received(AnimationEndMessage msg, int from) { public void received(AnimationEndMessage msg, int from) {
this.logic.getServerSender().send(from, new DiceNowMessage()); if (this.messageReceived == this.logic.getGame().getPlayers().size()) {
this.gameAutomaton.setCurrentState(this.gameAutomaton.getTurnState()); this.logic.getServerSender().send(this.logic.getGame().getActivePlayerId(), new DiceNowMessage());
this.gameAutomaton.setCurrentState(this.gameAutomaton.getTurnState());
} else {
this.messageReceived++;
}
} }
} }