Merge branch 'development2' of https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-01 into development2
This commit is contained in:
		@@ -152,6 +152,7 @@ private void initializeSerializables() {
 | 
			
		||||
        Serializer.registerClass(SwapCard.class);
 | 
			
		||||
        Serializer.registerClass(ShieldCard.class);
 | 
			
		||||
        Serializer.registerClass(HiddenCard.class);
 | 
			
		||||
        Serializer.registerClass(ChoosePieceStateMessage.class);
 | 
			
		||||
 | 
			
		||||
        Serializer.registerClass(Color.class, new EnumSerializer());
 | 
			
		||||
        Serializer.registerClass(PieceState.class, new EnumSerializer());
 | 
			
		||||
 
 | 
			
		||||
@@ -416,6 +416,14 @@ public void received(IncorrectRequestMessage msg) {
 | 
			
		||||
        addNotification(new InfoNotification(Resources.stringLookup("incorrect.request." + msg.getId())));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param choosePieceStateMessage
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(ChoosePieceStateMessage choosePieceStateMessage) {
 | 
			
		||||
        state.received(choosePieceStateMessage);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method calls the method received of the state
 | 
			
		||||
     *
 | 
			
		||||
 
 | 
			
		||||
@@ -95,6 +95,11 @@ public void received(LobbyPlayerLeaveMessage msg) {
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(ChoosePieceStateMessage msg) {
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(MoveMessage msg) {
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
 
 | 
			
		||||
@@ -281,6 +281,11 @@ public void received(PossiblePieceMessage msg){
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(ChoosePieceStateMessage msg){
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns the current state
 | 
			
		||||
     *
 | 
			
		||||
 
 | 
			
		||||
@@ -138,6 +138,11 @@ public void received(PossiblePieceMessage msg){
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(ChoosePieceStateMessage msg){
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public ChoosePieceState getChoosePiece() {
 | 
			
		||||
        return choosePieceState;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,7 @@
 | 
			
		||||
import pp.mdga.client.gamestate.TurnState;
 | 
			
		||||
import pp.mdga.message.client.AnimationEndMessage;
 | 
			
		||||
import pp.mdga.message.client.RequestDieMessage;
 | 
			
		||||
import pp.mdga.message.server.ChoosePieceStateMessage;
 | 
			
		||||
import pp.mdga.message.server.DieMessage;
 | 
			
		||||
import pp.mdga.message.server.NoTurnMessage;
 | 
			
		||||
import pp.mdga.notification.DiceNowNotification;
 | 
			
		||||
@@ -47,13 +48,12 @@ public void received(DieMessage msg){
 | 
			
		||||
    @Override
 | 
			
		||||
    public void selectAnimationEnd(){
 | 
			
		||||
        logic.send(new AnimationEndMessage());
 | 
			
		||||
        parent.setState(parent.getChoosePiece());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
//    @Override
 | 
			
		||||
//    public void received(ChoosePieceStateMessage msg){
 | 
			
		||||
//        parent.setState(parent.getChoosePiece());
 | 
			
		||||
//    }
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(ChoosePieceStateMessage msg){
 | 
			
		||||
        parent.setState(parent.getChoosePiece());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(NoTurnMessage msg){
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,17 @@
 | 
			
		||||
package pp.mdga.message.server;
 | 
			
		||||
 | 
			
		||||
public class ChoosePieceStateMessage extends ServerMessage {
 | 
			
		||||
 | 
			
		||||
    public ChoosePieceStateMessage() {
 | 
			
		||||
        super();
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Accepts a visitor to process this message.
 | 
			
		||||
     *
 | 
			
		||||
     * @param interpreter the visitor to process this message
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public void accept(ServerInterpreter interpreter) {
 | 
			
		||||
        interpreter.received(this);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -221,4 +221,6 @@ public interface ServerInterpreter {
 | 
			
		||||
     * @param msg the IncorrectRequest message received.
 | 
			
		||||
     */
 | 
			
		||||
    void received(IncorrectRequestMessage msg);
 | 
			
		||||
 | 
			
		||||
    void received(ChoosePieceStateMessage choosePieceStateMessage);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -31,10 +31,12 @@ private void initialize(){
 | 
			
		||||
                if (activePlayer.hasPieceInWaitingArea()){
 | 
			
		||||
                    if (!logic.getGame().getBoard().getInfield()[activePlayer.getStartNodeIndex()].isOccupied(activePlayer.getColor())){
 | 
			
		||||
                       this.choosePieceAutomaton.setCurrentState(this.choosePieceAutomaton.getWaitingPieceState());
 | 
			
		||||
                    } else {
 | 
			
		||||
                        this.choosePieceAutomaton.setCurrentState(this.choosePieceAutomaton.getNoTurnState());
 | 
			
		||||
                    }
 | 
			
		||||
                } else {
 | 
			
		||||
                    this.choosePieceAutomaton.setCurrentState(this.choosePieceAutomaton.getNoTurnState());
 | 
			
		||||
                }
 | 
			
		||||
                this.choosePieceAutomaton.setCurrentState(this.choosePieceAutomaton.getNoTurnState());
 | 
			
		||||
            }
 | 
			
		||||
        } else if (activePlayer.hasPieceInWaitingArea()) {
 | 
			
		||||
            if (!logic.getGame().getBoard().getInfield()[activePlayer.getStartNodeIndex()].isOccupied(activePlayer.getColor())){
 | 
			
		||||
@@ -45,6 +47,8 @@ private void initialize(){
 | 
			
		||||
                }
 | 
			
		||||
            } else if (canMove(logic.getGame().getBoard().getInfield()[activePlayer.getStartNodeIndex()].getOccupant())){
 | 
			
		||||
                this.choosePieceAutomaton.setCurrentState(this.choosePieceAutomaton.getStartPieceState());
 | 
			
		||||
            } else {
 | 
			
		||||
                checkSelectPiece(activePlayer);
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            checkSelectPiece(activePlayer);
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,7 @@
 | 
			
		||||
import pp.mdga.game.PieceState;
 | 
			
		||||
import pp.mdga.message.client.AnimationEndMessage;
 | 
			
		||||
import pp.mdga.message.client.RequestDieMessage;
 | 
			
		||||
import pp.mdga.message.server.ChoosePieceStateMessage;
 | 
			
		||||
import pp.mdga.message.server.DiceAgainMessage;
 | 
			
		||||
import pp.mdga.message.server.DiceNowMessage;
 | 
			
		||||
import pp.mdga.message.server.DieMessage;
 | 
			
		||||
@@ -66,9 +67,11 @@ public void received(RequestDieMessage msg, int from) {
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(AnimationEndMessage msg, int from) {
 | 
			
		||||
        if (!moveablePieces.isEmpty()) {
 | 
			
		||||
            this.logic.getServerSender().send(this.logic.getGame().getActivePlayerId(), new ChoosePieceStateMessage());
 | 
			
		||||
            this.rollDiceAutomaton.getTurnAutomaton().setCurrentState(this.rollDiceAutomaton.getTurnAutomaton().getChoosePieceState());
 | 
			
		||||
        } else {
 | 
			
		||||
            if (roll == Resources.MAX_EYES) {
 | 
			
		||||
                this.logic.getServerSender().send(this.logic.getGame().getActivePlayerId(), new ChoosePieceStateMessage());
 | 
			
		||||
                this.rollDiceAutomaton.getTurnAutomaton().setCurrentState(this.rollDiceAutomaton.getTurnAutomaton().getChoosePieceState());
 | 
			
		||||
            } else {
 | 
			
		||||
                this.rollDiceAutomaton.setCurrentState(this.rollDiceAutomaton.getSecondRollState());
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,8 @@
 | 
			
		||||
package pp.mdga.server.automaton.game.turn.rolldice;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.message.client.AnimationEndMessage;
 | 
			
		||||
import pp.mdga.message.client.RequestDieMessage;
 | 
			
		||||
import pp.mdga.message.server.ChoosePieceStateMessage;
 | 
			
		||||
import pp.mdga.message.server.DiceAgainMessage;
 | 
			
		||||
import pp.mdga.message.server.DiceNowMessage;
 | 
			
		||||
import pp.mdga.message.server.DieMessage;
 | 
			
		||||
@@ -44,8 +46,14 @@ public void exit() {
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(RequestDieMessage msg, int from) {
 | 
			
		||||
        int roll = this.logic.getGame().getDie().shuffle();
 | 
			
		||||
        this.logic.getGame().setDiceEyes(roll);
 | 
			
		||||
        this.logic.getServerSender().broadcast(new DieMessage(roll));
 | 
			
		||||
        if (roll == 6) {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(AnimationEndMessage msg, int from) {
 | 
			
		||||
        if (this.logic.getGame().getDiceEyes() == 6) {
 | 
			
		||||
            this.logic.getServerSender().send(this.logic.getGame().getActivePlayerId(), new ChoosePieceStateMessage());
 | 
			
		||||
            this.rollDiceAutomaton.getTurnAutomaton().setCurrentState(this.rollDiceAutomaton.getTurnAutomaton().getChoosePieceState());
 | 
			
		||||
        } else {
 | 
			
		||||
            this.rollDiceAutomaton.setCurrentState(this.rollDiceAutomaton.getThirdRollState());
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,6 @@
 | 
			
		||||
package pp.mdga.server.automaton.game.turn.rolldice;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.message.client.AnimationEndMessage;
 | 
			
		||||
import pp.mdga.message.client.RequestDieMessage;
 | 
			
		||||
import pp.mdga.message.server.*;
 | 
			
		||||
import pp.mdga.server.ServerGameLogic;
 | 
			
		||||
@@ -42,23 +43,20 @@ public void exit() {
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(RequestDieMessage msg, int from) {
 | 
			
		||||
        int roll = this.logic.getGame().getDie().shuffle();
 | 
			
		||||
        this.logic.getGame().setDiceEyes(roll);
 | 
			
		||||
        this.logic.getServerSender().broadcast(new DieMessage(roll));
 | 
			
		||||
        if (roll == 6) {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(AnimationEndMessage msg, int from) {
 | 
			
		||||
        if (this.logic.getGame().getDiceEyes() == 6) {
 | 
			
		||||
            this.logic.getServerSender().send(this.logic.getGame().getActivePlayerId(), new ChoosePieceStateMessage());
 | 
			
		||||
            this.rollDiceAutomaton.getTurnAutomaton().setCurrentState(this.rollDiceAutomaton.getTurnAutomaton().getChoosePieceState());
 | 
			
		||||
        } else {
 | 
			
		||||
            this.logic.getServerSender().send(this.logic.getGame().getActivePlayerId(), new NoTurnMessage());
 | 
			
		||||
 | 
			
		||||
            if (this.rollDiceAutomaton.getTurnAutomaton().getPlayer().isFinished()) {
 | 
			
		||||
                this.logic.getServerSender().send(this.logic.getGame().getActivePlayerId(), new SpectatorMessage());
 | 
			
		||||
 | 
			
		||||
                if (this.logic.getGame().getNumberOfActivePlayers() == 1) {
 | 
			
		||||
                    this.logic.getServerSender().broadcast(new CeremonyMessage());
 | 
			
		||||
                } else {
 | 
			
		||||
                    this.logic.getGame().setActiveColor(this.logic.getGame().getActiveColor().next(logic.getGame()));
 | 
			
		||||
                    this.logic.getServerSender().broadcast(new ActivePlayerMessage(this.logic.getGame().getActiveColor()));
 | 
			
		||||
                    this.rollDiceAutomaton.getTurnAutomaton().getGameAutomaton().setCurrentState(this.rollDiceAutomaton.getTurnAutomaton().getGameAutomaton().getAnimationState());
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            logic.getGame().setActiveColor(logic.getGame().getActiveColor().next(logic.getGame()));
 | 
			
		||||
            logic.getServerSender().broadcast(new ActivePlayerMessage(logic.getGame().getActiveColor()));
 | 
			
		||||
            this.rollDiceAutomaton.getTurnAutomaton().getGameAutomaton().setCurrentState(this.rollDiceAutomaton.getTurnAutomaton().getGameAutomaton().getTurnState());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user