Updated 'PlayPowerCardState' class.
Updated the 'PlayPowerCardState' class by adding the 'AnimationEndMessage' handling to it.
This commit is contained in:
@@ -1,15 +1,25 @@
|
|||||||
package pp.mdga.server.automaton.game.turn;
|
package pp.mdga.server.automaton.game.turn;
|
||||||
|
|
||||||
|
import pp.mdga.message.client.AnimationEndMessage;
|
||||||
|
import pp.mdga.message.server.DiceNowMessage;
|
||||||
import pp.mdga.server.ServerGameLogic;
|
import pp.mdga.server.ServerGameLogic;
|
||||||
import pp.mdga.server.automaton.game.AnimationState;
|
import pp.mdga.server.automaton.game.AnimationState;
|
||||||
import pp.mdga.server.automaton.game.TurnState;
|
import pp.mdga.server.automaton.game.TurnState;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class PlayPowerCardState extends TurnAutomatonState {
|
public class PlayPowerCardState extends TurnAutomatonState {
|
||||||
/**
|
/**
|
||||||
* Create FirstRollState constants.
|
* Create FirstRollState constants.
|
||||||
*/
|
*/
|
||||||
private static final System.Logger LOGGER = System.getLogger(PlayPowerCardState.class.getName());
|
private static final System.Logger LOGGER = System.getLogger(PlayPowerCardState.class.getName());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create PlayPowerCardState attributes.
|
||||||
|
*/
|
||||||
|
private Set<Integer> messageReceived = new HashSet<Integer>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a server state of the specified game logic.
|
* Constructs a server state of the specified game logic.
|
||||||
*
|
*
|
||||||
@@ -29,4 +39,20 @@ public void enter() {
|
|||||||
public void exit() {
|
public void exit() {
|
||||||
LOGGER.log(System.Logger.Level.DEBUG, "Exited PlayPowerCardState state.");
|
LOGGER.log(System.Logger.Level.DEBUG, "Exited PlayPowerCardState state.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will be called whenever the server received an AnimationEndMessage message.
|
||||||
|
* It will also get the client id of the player who send this message.
|
||||||
|
*
|
||||||
|
* @param msg as the message which was sent by the player as a AnimationEndMessage object.
|
||||||
|
* @param from as the client id of the player as an Integer.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void received(AnimationEndMessage msg, int from) {
|
||||||
|
this.messageReceived.add(from);
|
||||||
|
if (this.messageReceived.size() == this.logic.getGame().getPlayers().size()) {
|
||||||
|
this.logic.getServerSender().send(this.logic.getGame().getActivePlayerId(), new DiceNowMessage());
|
||||||
|
this.turnAutomaton.setCurrentState(this.turnAutomaton.getRollDiceState());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user