Updated 'DetermineStartPlayerState' class.
Updated the 'DetermineStartPlayerState' class by adding the 'received(AnimationEndMessage msg, int from)' method to it.
This commit is contained in:
		@@ -1,6 +1,7 @@
 | 
			
		||||
package pp.mdga.server.automaton.game;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.game.Player;
 | 
			
		||||
import pp.mdga.message.client.AnimationEndMessage;
 | 
			
		||||
import pp.mdga.message.client.RequestDieMessage;
 | 
			
		||||
import pp.mdga.message.server.ActivePlayerMessage;
 | 
			
		||||
import pp.mdga.message.server.DiceNowMessage;
 | 
			
		||||
@@ -28,6 +29,7 @@ public class DetermineStartPlayerState extends GameAutomatonState {
 | 
			
		||||
     */
 | 
			
		||||
    private Map<Integer, Integer> diceResults = new HashMap<>();
 | 
			
		||||
    private Map<Integer, Integer> rankedResults = new HashMap<>();
 | 
			
		||||
    private Map<Integer, Boolean> messageReceived = new HashMap<>();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructs a server state of the specified game logic.
 | 
			
		||||
@@ -93,4 +95,22 @@ else if (maximumRoll < entry.getKey()) {
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 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) {
 | 
			
		||||
        if (this.messageReceived.size() == this.logic.getGame().getPlayers().size()) {
 | 
			
		||||
            this.logic.getServerSender().send(this.logic.getGame().getActivePlayerId(), new DiceNowMessage());
 | 
			
		||||
            this.gameAutomaton.setCurrentState(this.gameAutomaton.getTurnState());
 | 
			
		||||
            this.gameAutomaton.getTurnState().setCurrentState(this.gameAutomaton.getTurnState().getPowerCardState());
 | 
			
		||||
        } else {
 | 
			
		||||
            this.messageReceived.put(from, true);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user