made the determinstartplayer machine fully functional
This commit is contained in:
		@@ -3,6 +3,7 @@
 | 
			
		||||
import pp.mdga.client.ceremonyState.CeremonyStates;
 | 
			
		||||
import pp.mdga.client.ceremonyState.PodiumState;
 | 
			
		||||
import pp.mdga.client.ceremonyState.StatisticsState;
 | 
			
		||||
import pp.mdga.notification.CeremonyNotification;
 | 
			
		||||
 | 
			
		||||
public class CeremonyState extends ClientState {
 | 
			
		||||
 | 
			
		||||
@@ -15,9 +16,19 @@ public CeremonyState(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    private CeremonyNotification prepareNotification(){
 | 
			
		||||
        CeremonyNotification notification = new CeremonyNotification();
 | 
			
		||||
 | 
			
		||||
        //TODO: creation of the notification
 | 
			
		||||
 | 
			
		||||
        return notification;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
        currentState = podiumState;
 | 
			
		||||
        logic.addNotification(prepareNotification());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,10 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.gameState.*;
 | 
			
		||||
import pp.mdga.message.server.DieMessage;
 | 
			
		||||
import pp.mdga.message.server.PauseGameMessage;
 | 
			
		||||
import pp.mdga.message.server.RankingResponseMessage;
 | 
			
		||||
import pp.mdga.message.server.RankingRollAgainMessage;
 | 
			
		||||
import pp.mdga.notification.InterruptNotification;
 | 
			
		||||
 | 
			
		||||
public class GameState extends ClientState {
 | 
			
		||||
@@ -40,12 +43,32 @@ public void selectAnimationEnd(){
 | 
			
		||||
        state.selectAnimationEnd();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void selectDice(){
 | 
			
		||||
        state.selectDice();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(PauseGameMessage msg){
 | 
			
		||||
        logic.enterInterrupt();
 | 
			
		||||
        logic.addNotification(new InterruptNotification(logic.getGame().getPlayers().get(msg.getPlayerId()).getColor()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(DieMessage msg){
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(RankingRollAgainMessage msg){
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(RankingResponseMessage msg){
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public GameStates getState(){
 | 
			
		||||
        return state;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -6,6 +6,9 @@
 | 
			
		||||
import pp.mdga.client.gameState.determineStartPlayerState.DetermineStartPlayerStates;
 | 
			
		||||
import pp.mdga.client.gameState.determineStartPlayerState.RollRankingDiceState;
 | 
			
		||||
import pp.mdga.client.gameState.determineStartPlayerState.WaitRankingState;
 | 
			
		||||
import pp.mdga.message.server.DieMessage;
 | 
			
		||||
import pp.mdga.message.server.RankingResponseMessage;
 | 
			
		||||
import pp.mdga.message.server.RankingRollAgainMessage;
 | 
			
		||||
 | 
			
		||||
public class DetermineStartPlayerState extends GameStates {
 | 
			
		||||
 | 
			
		||||
@@ -36,6 +39,26 @@ public void setState(DetermineStartPlayerStates state) {
 | 
			
		||||
        this.state = state;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void selectDice() {
 | 
			
		||||
        state.selectDice();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(DieMessage msg){
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(RankingRollAgainMessage msg){
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(RankingResponseMessage msg){
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public RollRankingDiceState getRollRankingDice() {
 | 
			
		||||
        return rollRankingDiceState;
 | 
			
		||||
    }
 | 
			
		||||
@@ -47,4 +70,8 @@ public WaitRankingState getWaitRanking() {
 | 
			
		||||
    public DetermineStartPlayerStates getState(){
 | 
			
		||||
        return state;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public GameState getParent() {
 | 
			
		||||
        return parent;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,7 @@
 | 
			
		||||
import pp.mdga.client.gameState.DetermineStartPlayerState;
 | 
			
		||||
import pp.mdga.message.client.RequestDieMessage;
 | 
			
		||||
import pp.mdga.message.server.DieMessage;
 | 
			
		||||
import pp.mdga.notification.DiceNowNotification;
 | 
			
		||||
 | 
			
		||||
public class RollRankingDiceState extends DetermineStartPlayerStates {
 | 
			
		||||
 | 
			
		||||
@@ -17,7 +18,7 @@ public RollRankingDiceState(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
 | 
			
		||||
        logic.addNotification(new DiceNowNotification());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,7 @@
 | 
			
		||||
import pp.mdga.client.gameState.DetermineStartPlayerState;
 | 
			
		||||
import pp.mdga.message.server.RankingResponseMessage;
 | 
			
		||||
import pp.mdga.message.server.RankingRollAgainMessage;
 | 
			
		||||
import pp.mdga.notification.ActivePlayerNotification;
 | 
			
		||||
 | 
			
		||||
public class WaitRankingState extends DetermineStartPlayerStates {
 | 
			
		||||
 | 
			
		||||
@@ -32,6 +33,8 @@ public void received(RankingRollAgainMessage msg){
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(RankingResponseMessage msg){
 | 
			
		||||
        //TODO: implement
 | 
			
		||||
        logic.addNotification(new ActivePlayerNotification(logic.getGame().getPlayers().get(msg.getStartingPlayerId()).getColor()));
 | 
			
		||||
        logic.getGame().setActiveColor(logic.getGame().getPlayers().get(msg.getStartingPlayerId()).getColor());
 | 
			
		||||
        parent.getParent().setState(parent.getParent().getWaiting());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -7,11 +7,32 @@
 | 
			
		||||
 */
 | 
			
		||||
@Serializable
 | 
			
		||||
public class RankingResponseMessage extends ServerMessage {
 | 
			
		||||
 | 
			
		||||
    private final int startingPlayerId;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructs a new RankingResponse instance.
 | 
			
		||||
     */
 | 
			
		||||
    public RankingResponseMessage(int startingPlayerId) {
 | 
			
		||||
        super();
 | 
			
		||||
        this.startingPlayerId = startingPlayerId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructs a new RankingResponse instance.
 | 
			
		||||
     */
 | 
			
		||||
    public RankingResponseMessage() {
 | 
			
		||||
        super();
 | 
			
		||||
        this.startingPlayerId = 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * The id of the starting Player.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the id of the starting player as an int
 | 
			
		||||
     */
 | 
			
		||||
    public int getStartingPlayerId() {
 | 
			
		||||
        return startingPlayerId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user