merge
This commit is contained in:
		@@ -1,9 +1,9 @@
 | 
			
		||||
<component name="ProjectRunConfigurationManager">
 | 
			
		||||
  <configuration default="false" name="MdgaApp" type="Application" factoryName="Application" singleton="false" nameIsGenerated="true">
 | 
			
		||||
    <option name="ALTERNATIVE_JRE_PATH" value="21" />
 | 
			
		||||
    <option name="ALTERNATIVE_JRE_PATH" value="20" />
 | 
			
		||||
    <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
 | 
			
		||||
    <option name="MAIN_CLASS_NAME" value="pp.mdga.client.MdgaApp" />
 | 
			
		||||
    <module name="Projekte.mdga.client.main" />
 | 
			
		||||
    <module name="Gruppe-01.Projekte.mdga.client.main" />
 | 
			
		||||
    <option name="VM_PARAMETERS" value="-Djava.util.logging.config.file=logging.properties -ea" />
 | 
			
		||||
    <option name="WORKING_DIRECTORY" value="$MODULE_WORKING_DIR$" />
 | 
			
		||||
    <extension name="coverage">
 | 
			
		||||
@@ -16,4 +16,4 @@
 | 
			
		||||
      <option name="Make" enabled="true" />
 | 
			
		||||
    </method>
 | 
			
		||||
  </configuration>
 | 
			
		||||
</component>
 | 
			
		||||
</component>
 | 
			
		||||
@@ -121,6 +121,7 @@ private void handleGame(Notification notification) {
 | 
			
		||||
            delay = STANDARD_DELAY;
 | 
			
		||||
        } else if (notification instanceof ActivePlayerNotification n) {
 | 
			
		||||
            gameView.getGuiHandler().setActivePlayer(n.getColor());
 | 
			
		||||
            boardHandler.hideDice();
 | 
			
		||||
            if(n.getColor() != ownColor) boardHandler.showDice(n.getColor());
 | 
			
		||||
            app.getAcousticHandler().playSound(MdgaSound.UI90);
 | 
			
		||||
            delay = STANDARD_DELAY;
 | 
			
		||||
@@ -166,10 +167,12 @@ private void handleGame(Notification notification) {
 | 
			
		||||
            if(n.isMoveStart()) {
 | 
			
		||||
                //StartMove
 | 
			
		||||
                boardHandler.movePieceStartAnim(n.getPiece(), n.getMoveIndex());
 | 
			
		||||
                waitForAnimation = true;
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                //InfieldMove
 | 
			
		||||
                boardHandler.movePieceAnim(n.getPiece(), n.getStartIndex(), n.getMoveIndex());
 | 
			
		||||
                waitForAnimation = true;
 | 
			
		||||
            }
 | 
			
		||||
            guiHandler.hideText();
 | 
			
		||||
        } else if (notification instanceof ThrowPieceNotification n) {
 | 
			
		||||
@@ -207,7 +210,6 @@ public void run() {
 | 
			
		||||
                waitForAnimation = true;
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                boardHandler.hideDice();
 | 
			
		||||
                if (n.isTurbo()) guiHandler.showRolledDiceMult(n.getEyes(), n.getMultiplier(), n.getColor());
 | 
			
		||||
                else guiHandler.showRolledDice(n.getEyes(), n.getColor());
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
@@ -473,6 +473,7 @@ private void movePieceStart(UUID uuid, int nodeIndex){
 | 
			
		||||
        removeItemFromMapList(waitingPiecesMap, color, pieceControl);
 | 
			
		||||
        waitingNodes.get(color).remove(uuid);
 | 
			
		||||
        app.getModelSynchronize().animationEnd();
 | 
			
		||||
        app.getModelSynchronize().animationEnd();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -486,6 +487,7 @@ private void movePiece(UUID uuid, int curIndex, int moveIndex){
 | 
			
		||||
 | 
			
		||||
        movePieceRek(uuid, curIndex, moveIndex);
 | 
			
		||||
        app.getModelSynchronize().animationEnd();
 | 
			
		||||
        app.getModelSynchronize().animationEnd();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -18,7 +18,7 @@ public class GameView extends MdgaView {
 | 
			
		||||
    private GuiHandler guiHandler;
 | 
			
		||||
 | 
			
		||||
    private ButtonLeft leaveButton;
 | 
			
		||||
    private ButtonRight confirmButton;
 | 
			
		||||
    public ButtonRight confirmButton;
 | 
			
		||||
 | 
			
		||||
    private ButtonRight noPowerButton;
 | 
			
		||||
 | 
			
		||||
@@ -28,6 +28,9 @@ public class GameView extends MdgaView {
 | 
			
		||||
 | 
			
		||||
    private FilterPostProcessor fpp;
 | 
			
		||||
 | 
			
		||||
    public boolean needConfirm = false;
 | 
			
		||||
    public boolean needNoPower = false;
 | 
			
		||||
 | 
			
		||||
    private Node guiHandlerNode = new Node();
 | 
			
		||||
 | 
			
		||||
    public GameView(MdgaApp app) {
 | 
			
		||||
@@ -116,19 +119,26 @@ public Color getOwnColor() {
 | 
			
		||||
    public void needConfirm() {
 | 
			
		||||
        noPowerButton.hide();
 | 
			
		||||
        confirmButton.show();
 | 
			
		||||
 | 
			
		||||
        needConfirm = true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void noConfirm() {
 | 
			
		||||
        confirmButton.hide();
 | 
			
		||||
 | 
			
		||||
        needConfirm = false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void showNoPower() {
 | 
			
		||||
        confirmButton.hide();
 | 
			
		||||
        noPowerButton.show();
 | 
			
		||||
 | 
			
		||||
        needNoPower = true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void hideNoPower() {
 | 
			
		||||
        noPowerButton.hide();
 | 
			
		||||
        needNoPower = false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void enterInterrupt(Color color) {
 | 
			
		||||
 
 | 
			
		||||
@@ -59,7 +59,6 @@ public void enter() {
 | 
			
		||||
    public void leave() {
 | 
			
		||||
        onLeave();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        settingsButton.hide();
 | 
			
		||||
 | 
			
		||||
        while (settingsDepth > 0) {
 | 
			
		||||
@@ -197,7 +196,13 @@ public void pressForward() {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (this instanceof GameView gameView) {
 | 
			
		||||
            app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
 | 
			
		||||
            if(gameView.needConfirm) {
 | 
			
		||||
                app.getModelSynchronize().confirm();
 | 
			
		||||
            } else if(gameView.needNoPower) {
 | 
			
		||||
                app.getModelSynchronize().confirm();
 | 
			
		||||
            } else {
 | 
			
		||||
                app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (this instanceof CeremonyView ceremonyView) {
 | 
			
		||||
 
 | 
			
		||||
@@ -159,11 +159,6 @@ public void received(ChoosePieceStateMessage msg){
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(DrawCardMessage msg){
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public ChoosePieceState getChoosePiece() {
 | 
			
		||||
        return choosePieceState;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -63,7 +63,7 @@ public void received(StartPieceMessage msg){
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(NoTurnMessage msg){
 | 
			
		||||
    public void received(EndOfTurnMessage msg){
 | 
			
		||||
        currentState.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,8 @@
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.gamestate.TurnState;
 | 
			
		||||
import pp.mdga.game.BonusCard;
 | 
			
		||||
import pp.mdga.game.card.ShieldCard;
 | 
			
		||||
import pp.mdga.game.card.SwapCard;
 | 
			
		||||
import pp.mdga.message.client.AnimationEndMessage;
 | 
			
		||||
import pp.mdga.message.server.PlayCardMessage;
 | 
			
		||||
import pp.mdga.notification.PlayCardNotification;
 | 
			
		||||
@@ -13,7 +15,7 @@ public class PlayPowerCardState extends TurnStates {
 | 
			
		||||
    private final TurnState parent;
 | 
			
		||||
 | 
			
		||||
    private PlayCardMessage playCardMessage;
 | 
			
		||||
    private int animationCounter = 0;
 | 
			
		||||
    private int extraAnimationCounter = 0;
 | 
			
		||||
 | 
			
		||||
    public PlayPowerCardState(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
@@ -22,11 +24,12 @@ public PlayPowerCardState(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
        animationCounter++;
 | 
			
		||||
        logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor() , playCardMessage.getCard().getCard()));
 | 
			
		||||
        if(!playCardMessage.getCard().getCard().equals(BonusCard.TURBO)){
 | 
			
		||||
            animationCounter++;
 | 
			
		||||
        if(playCardMessage.getCard() instanceof SwapCard) {
 | 
			
		||||
            extraAnimationCounter++;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor() , playCardMessage.getCard().getCard()));
 | 
			
		||||
 | 
			
		||||
        handlePowerCard(playCardMessage);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -41,10 +44,12 @@ public void setPlayCard(PlayCardMessage playCardMessage) {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void selectAnimationEnd(){
 | 
			
		||||
        animationCounter--;
 | 
			
		||||
        if(animationCounter == 0){
 | 
			
		||||
            logic.send(new AnimationEndMessage());
 | 
			
		||||
            parent.setState(parent.getRollDice());
 | 
			
		||||
        if(extraAnimationCounter > 0) {
 | 
			
		||||
            extraAnimationCounter--;
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        logic.send(new AnimationEndMessage());
 | 
			
		||||
        parent.setState(parent.getRollDice());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -38,7 +38,6 @@ public void exit() {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(SelectPieceMessage msg) {
 | 
			
		||||
        //TODO
 | 
			
		||||
        ArrayList<Piece> pieces = msg.getPieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece.getUuid())).collect(Collectors.toCollection(ArrayList::new));
 | 
			
		||||
        parent.getSelectPiece().setPossiblePieces(pieces);
 | 
			
		||||
        ArrayList<UUID> listPiece = pieces.stream().map(Piece::getUuid).collect(Collectors.toCollection(ArrayList::new));
 | 
			
		||||
@@ -71,7 +70,7 @@ public void received(StartPieceMessage msg){
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(NoTurnMessage msg){
 | 
			
		||||
    public void received(EndOfTurnMessage msg){
 | 
			
		||||
        logic.getGame().setTurboFlag(false);
 | 
			
		||||
        parent.getParent().getParent().setState(parent.getParent().getParent().getWaiting());
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,7 @@
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
 | 
			
		||||
import pp.mdga.game.Piece;
 | 
			
		||||
import pp.mdga.game.PieceState;
 | 
			
		||||
import pp.mdga.message.client.RequestMoveMessage;
 | 
			
		||||
import pp.mdga.message.client.SelectedPiecesMessage;
 | 
			
		||||
import pp.mdga.message.server.MoveMessage;
 | 
			
		||||
@@ -49,10 +50,46 @@ public void selectPiece(Piece piece) {
 | 
			
		||||
    public void received(MoveMessage msg) {
 | 
			
		||||
        Piece piece = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid());
 | 
			
		||||
        //logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
 | 
			
		||||
        System.out.println("Client: selectPieceState: receivedMoveMessage: msg.isHomeMoved():"+msg.isHomeMove());
 | 
			
		||||
        if (msg.isHomeMove()) {
 | 
			
		||||
            System.out.println("Client: selectPieceState: receivedMoveMessage: msg.getPiece.getState():"+piece.getState());
 | 
			
		||||
            if(piece.getState().equals(PieceState.ACTIVE)){
 | 
			
		||||
                logic.addNotification(new HomeMoveNotification(piece.getUuid(), msg.getTargetIndex()));
 | 
			
		||||
                int infieldIndex=logic.getGame().getBoard().getInfieldIndexOfPiece(piece);
 | 
			
		||||
                System.out.println("Client: SelectState: activePiece in Home: infieldIndex"+infieldIndex);
 | 
			
		||||
                if(msg.getTargetIndex()==logic.getGame().getActivePlayer().getHighestHomeIdx()){
 | 
			
		||||
                    piece.setState(PieceState.HOMEFINISHED);
 | 
			
		||||
                }
 | 
			
		||||
                else{
 | 
			
		||||
                    piece.setState(PieceState.HOME);
 | 
			
		||||
                }
 | 
			
		||||
                logic.getGame().getBoard().getInfield()[infieldIndex].clearOccupant();
 | 
			
		||||
                logic.getGame().getPlayerByColor(piece.getColor()).setPieceInHome(msg.getTargetIndex(), piece);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
            else{
 | 
			
		||||
                System.out.println("Client: SelectPieceState: receivedMoveMessage:reached else");
 | 
			
		||||
                logic.addNotification(new HomeMoveNotification(piece.getUuid(), msg.getTargetIndex()));
 | 
			
		||||
                System.out.println("Client: electPieceState: homeindex"+logic.getGame().getActivePlayer().getHomeIndexOfPiece(piece));
 | 
			
		||||
                int pieceHomeIndex = logic.getGame().getActivePlayer().getHomeIndexOfPiece(piece);
 | 
			
		||||
                if(msg.getTargetIndex()==logic.getGame().getActivePlayer().getHighestHomeIdx()){
 | 
			
		||||
                    piece.setState(PieceState.HOMEFINISHED);
 | 
			
		||||
                }
 | 
			
		||||
                else{
 | 
			
		||||
                    piece.setState(PieceState.HOME);
 | 
			
		||||
                }
 | 
			
		||||
                logic.getGame().getActivePlayer().getHomeNodes()[pieceHomeIndex].clearOccupant();
 | 
			
		||||
                logic.getGame().getPlayerByColor(piece.getColor()).setPieceInHome(msg.getTargetIndex(), piece);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
            /*
 | 
			
		||||
            logic.addNotification(new HomeMoveNotification(piece.getUuid(), msg.getTargetIndex()));
 | 
			
		||||
            logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
 | 
			
		||||
            logic.getGame().getPlayerByColor(piece.getColor()).setPieceInHome(msg.getTargetIndex(), piece);
 | 
			
		||||
 | 
			
		||||
             */
 | 
			
		||||
        } else {
 | 
			
		||||
            int oldIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(piece);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -112,7 +112,6 @@ public void received(PossiblePieceMessage msg){
 | 
			
		||||
        if (msg.getEnemyPossiblePieces().isEmpty()){
 | 
			
		||||
            parent.getShield().setPossiblePieces(msg.getOwnPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece.getUuid())).collect(Collectors.toCollection(ArrayList::new)));
 | 
			
		||||
            parent.setState(parent.getShield());
 | 
			
		||||
            logic.addNotification(new SelectableShieldNotification(msg.getOwnPossiblePieces().stream().map(Piece::getUuid).toList()));
 | 
			
		||||
        } else {
 | 
			
		||||
            System.out.println("Should enter Swap State");
 | 
			
		||||
            parent.getSwap().setPossibleOwnPieces(msg.getOwnPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece.getUuid())).collect(Collectors.toCollection(ArrayList::new)));
 | 
			
		||||
 
 | 
			
		||||
@@ -7,6 +7,7 @@
 | 
			
		||||
import pp.mdga.message.client.RequestPlayCardMessage;
 | 
			
		||||
import pp.mdga.message.client.SelectedPiecesMessage;
 | 
			
		||||
import pp.mdga.message.server.PlayCardMessage;
 | 
			
		||||
import pp.mdga.notification.SelectableShieldNotification;
 | 
			
		||||
 | 
			
		||||
import java.lang.System.Logger.Level;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
@@ -27,8 +28,7 @@ public ShieldState(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
        logic.addNotification(null);
 | 
			
		||||
        //TODO: selectable piece notification
 | 
			
		||||
        logic.addNotification(new SelectableShieldNotification(possiblePieces.stream().map(Piece::getUuid).toList()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
 
 | 
			
		||||
@@ -205,6 +205,22 @@ public boolean isHomeFinished(Piece piece) {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * this method will be used to determine the highest index in the home
 | 
			
		||||
     *
 | 
			
		||||
     * @return the index
 | 
			
		||||
     */
 | 
			
		||||
    public int getHighestHomeIdx(){
 | 
			
		||||
        for (int i =3; i>=0;i--){
 | 
			
		||||
            if(!homeNodes[i].isOccupied()) {
 | 
			
		||||
                System.out.println("Player: highestHomeIndex:"+i);
 | 
			
		||||
                return i;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        return -1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns the give name of the Player
 | 
			
		||||
     *
 | 
			
		||||
 
 | 
			
		||||
@@ -195,6 +195,7 @@ public void setCurrentState(TurnAutomatonState state) {
 | 
			
		||||
        if (this.currentState != null) {
 | 
			
		||||
            this.currentState.exit();
 | 
			
		||||
        }
 | 
			
		||||
        System.out.println("Server: the server entered:"+state);
 | 
			
		||||
        this.currentState = state;
 | 
			
		||||
        this.currentState.enter();
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -17,20 +17,21 @@ public abstract class ChoosePieceAutomatonState extends ServerState {
 | 
			
		||||
     * Constructs a server state of the specified game logic.
 | 
			
		||||
     *
 | 
			
		||||
     * @param choosePieceAutomaton as the automaton of the choose piece state as a ChoosePieceState object.
 | 
			
		||||
     * @param logic the game logic
 | 
			
		||||
     * @param logic                the game logic
 | 
			
		||||
     */
 | 
			
		||||
    public ChoosePieceAutomatonState(ChoosePieceState choosePieceAutomaton, ServerGameLogic logic) {
 | 
			
		||||
        super(logic);
 | 
			
		||||
        this.choosePieceAutomaton = choosePieceAutomaton;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected boolean canMove(Piece piece){
 | 
			
		||||
    /*
 | 
			
		||||
    protected boolean canMove(Piece piece) {
 | 
			
		||||
        int steps = logic.getGame().getDiceModifier() * logic.getGame().getDiceEyes();
 | 
			
		||||
        if (piece.getState().equals(PieceState.HOME)){
 | 
			
		||||
        if (piece.getState().equals(PieceState.HOME)) {
 | 
			
		||||
            return canHomeMove(piece, steps);
 | 
			
		||||
        } else {
 | 
			
		||||
            int homeMoves = getHomeMoves(piece, steps);
 | 
			
		||||
            if (homeMoves > 0){
 | 
			
		||||
            if (homeMoves > 0) {
 | 
			
		||||
                return canHomeMove(piece, homeMoves);
 | 
			
		||||
            } else {
 | 
			
		||||
                return canInfieldMove(piece, steps);
 | 
			
		||||
@@ -38,28 +39,34 @@ protected boolean canMove(Piece piece){
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
   protected int getHomeMoves(Piece piece, int steps){
 | 
			
		||||
     */
 | 
			
		||||
    /*
 | 
			
		||||
    protected int getHomeMoves(Piece piece, int steps) {
 | 
			
		||||
        int pieceIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(piece);
 | 
			
		||||
        Color color = piece.getColor();
 | 
			
		||||
        int startIndex = logic.getGame().getPlayerByColor(color).getStartNodeIndex();
 | 
			
		||||
        int moveIndex = pieceIndex + steps;
 | 
			
		||||
        if (moveIndex > logic.getGame().getBoard().getInfield().length){
 | 
			
		||||
            if (startIndex > pieceIndex){
 | 
			
		||||
                return steps - (startIndex - pieceIndex -1);
 | 
			
		||||
        if (moveIndex > logic.getGame().getBoard().getInfield().length) {
 | 
			
		||||
            if (startIndex > pieceIndex) {
 | 
			
		||||
                return steps - (startIndex - pieceIndex - 1);
 | 
			
		||||
            }
 | 
			
		||||
            moveIndex %= logic.getGame().getBoard().getInfield().length;
 | 
			
		||||
            if (moveIndex >= startIndex){
 | 
			
		||||
            if (moveIndex >= startIndex) {
 | 
			
		||||
                return moveIndex - startIndex + 1;
 | 
			
		||||
            }
 | 
			
		||||
            return 0;
 | 
			
		||||
        }
 | 
			
		||||
        if (pieceIndex < startIndex && startIndex <= moveIndex){
 | 
			
		||||
        if (pieceIndex < startIndex && startIndex <= moveIndex) {
 | 
			
		||||
            return moveIndex - startIndex + 1;
 | 
			
		||||
        }
 | 
			
		||||
        return 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private boolean canInfieldMove(Piece piece, int steps){
 | 
			
		||||
     */
 | 
			
		||||
    /*
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    private boolean canInfieldMove(Piece piece, int steps) {
 | 
			
		||||
        int pieceIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(piece);
 | 
			
		||||
        int moveIndex = (pieceIndex + steps) % logic.getGame().getBoard().getInfield().length;
 | 
			
		||||
        Piece occupant = logic.getGame().getBoard().getInfield()[moveIndex].getOccupant();
 | 
			
		||||
@@ -72,21 +79,23 @@ private boolean canInfieldMove(Piece piece, int steps){
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private boolean canHomeMove(Piece piece, int moveIndex){
 | 
			
		||||
     */
 | 
			
		||||
    /*
 | 
			
		||||
    private boolean canHomeMove(Piece piece, int moveIndex) {
 | 
			
		||||
        Color color = piece.getColor();
 | 
			
		||||
        Player player = logic.getGame().getPlayerByColor(color);
 | 
			
		||||
        Node[] homeNodes = player.getHomeNodes();
 | 
			
		||||
        int index;
 | 
			
		||||
        if (player.pieceInsideOfHome(piece)){
 | 
			
		||||
        if (player.pieceInsideOfHome(piece)) {
 | 
			
		||||
            index = player.getHomeIndexOfPiece(piece);
 | 
			
		||||
        } else {
 | 
			
		||||
            index = 0;
 | 
			
		||||
        }
 | 
			
		||||
        if  (index + moveIndex >= homeNodes.length){
 | 
			
		||||
        if (index + moveIndex >= homeNodes.length) {
 | 
			
		||||
            return false;
 | 
			
		||||
        } else {
 | 
			
		||||
            for (int i = index; i <= index + moveIndex; i++){
 | 
			
		||||
                if(homeNodes[i].isOccupied()){
 | 
			
		||||
            for (int i = index; i <= index + moveIndex; i++) {
 | 
			
		||||
                if (homeNodes[i].isOccupied()) {
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
@@ -94,9 +103,181 @@ private boolean canHomeMove(Piece piece, int moveIndex){
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected int calculateTargetIndex(Piece piece){
 | 
			
		||||
     */
 | 
			
		||||
    /*
 | 
			
		||||
    protected int calculateTargetIndex(Piece piece) {
 | 
			
		||||
        int steps = logic.getGame().getDiceModifier() * logic.getGame().getDiceEyes();
 | 
			
		||||
 | 
			
		||||
        return (logic.getGame().getBoard().getInfieldIndexOfPiece(piece) + steps) % logic.getGame().getBoard().getInfield().length;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
     */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * returns true, if the piece can move inside the home or infield or move from the infield to the home
 | 
			
		||||
     *
 | 
			
		||||
     * @param piece the piece that will be checked
 | 
			
		||||
     * @return true, if the piece can move
 | 
			
		||||
     */
 | 
			
		||||
    protected boolean canMove(Piece piece) {
 | 
			
		||||
        int steps = logic.getGame().getDiceModifier() * logic.getGame().getDiceEyes();
 | 
			
		||||
        int pieceIdx = logic.getGame().getBoard().getInfieldIndexOfPiece(piece);
 | 
			
		||||
        System.out.println("ChoosePieceAutomaton: pieceIndex:" + pieceIdx);
 | 
			
		||||
        int startIdx = logic.getGame().getActivePlayer().getStartNodeIndex();
 | 
			
		||||
        int normPieceIdx = (-startIdx + pieceIdx + 40) % 40;
 | 
			
		||||
        int targetIdx = normPieceIdx + steps;
 | 
			
		||||
 | 
			
		||||
        System.out.println("Server: ChoosePieceStateMachine: canMove: piece.getState()" + piece.getState());
 | 
			
		||||
        System.out.println("Server: ChoosePieceStateAutomaton: canMove:" + canPieceMoveInHome(piece, steps));
 | 
			
		||||
        //checks if the piece can move in the home
 | 
			
		||||
        if (canPieceMoveInHome(piece, steps)) {
 | 
			
		||||
            System.out.println("Server: ChoosePieceStateMachine:canMove: entered canMove/canPieceMoveInHome");
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        //checks if the piece will not go over its home-field
 | 
			
		||||
        else if(40 > targetIdx && (!piece.getState().equals(PieceState.HOME)||!piece.getState().equals(PieceState.HOMEFINISHED))) {
 | 
			
		||||
            Color activeColor = logic.getGame().getActiveColor();
 | 
			
		||||
            System.out.println("ChoosePieceAutomaton: targetindex:" + (pieceIdx + steps) % 40);
 | 
			
		||||
            Node tartgetNode = logic.getGame().getBoard().getInfield()[(pieceIdx + steps) % 40];
 | 
			
		||||
            //checks if the target-node is not occupied by an own color
 | 
			
		||||
            if (!tartgetNode.isOccupied(activeColor)) {
 | 
			
		||||
                //checks if the targetNode is not occupied or the occupant ha no shield
 | 
			
		||||
                if (!tartgetNode.isOccupied() || tartgetNode.getOccupant().getShield() != ShieldState.ACTIVE) {
 | 
			
		||||
                    return true;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        //returns false it the piece can't move
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * tests if the piece can move in the home or inside the home
 | 
			
		||||
     *
 | 
			
		||||
     * @param piece
 | 
			
		||||
     * @param steps
 | 
			
		||||
     * @return false, if the piece can't move in the home
 | 
			
		||||
     */
 | 
			
		||||
    protected boolean canPieceMoveInHome(Piece piece, int steps) {
 | 
			
		||||
        //tests if the piece can move inside the home
 | 
			
		||||
        System.out.println("Server: ChoosePieceStateMachine: canPieceMoveInHome: pieceState:" + piece.getState());
 | 
			
		||||
        steps = logic.getGame().getDiceModifier() * logic.getGame().getDiceEyes();
 | 
			
		||||
        if (piece.getState().equals(PieceState.HOME)) {
 | 
			
		||||
            System.out.println("Server: ChoosePieceStateMachine: canPieceMoveInHome: pieceState:reached if(piece.getState()==PieceState.HOME)");
 | 
			
		||||
            int homeIdx = logic.getGame().getActivePlayer().getHomeIndexOfPiece(piece);
 | 
			
		||||
            //tests if the steps are less than the possible movement
 | 
			
		||||
            System.out.println("Server: ChoosePieceAutomaton: canPieceMoveInHome: reached second if: (4 - homeIdx) > steps:" + ((4 - homeIdx) > steps) + "steps:" + steps + "homeIdx:" + homeIdx);
 | 
			
		||||
            if ((4 - homeIdx) > steps) {
 | 
			
		||||
                System.out.println("Server: canPieceMoveInHome: !jumpOver" + !jumpOver(steps, homeIdx, false));
 | 
			
		||||
                return !jumpOver(steps, homeIdx, false);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        //tests if the piece can move in the home
 | 
			
		||||
        else if (piece.getState() == PieceState.ACTIVE) {
 | 
			
		||||
            int pieceIdx = logic.getGame().getBoard().getInfieldIndexOfPiece(piece);
 | 
			
		||||
            int startIdx = logic.getGame().getActivePlayer().getStartNodeIndex();
 | 
			
		||||
            int normPieceIdx = (-startIdx + pieceIdx + 40) % 40;
 | 
			
		||||
            int targetIdx = normPieceIdx + steps;
 | 
			
		||||
            System.out.println("Server: ChoosePieceStateMachine: canPieceMoveInHome: pieceIndex:" + pieceIdx + "targetIdx:" + targetIdx);
 | 
			
		||||
            if (targetIdx >= 40) {
 | 
			
		||||
                int stepsToHome = 39 - normPieceIdx;
 | 
			
		||||
                int restMovement = steps - stepsToHome - 1;
 | 
			
		||||
                System.out.println("Server: ChoosePieceStateMachine: canPieceMoveInHome: stepsToHome:" + stepsToHome + "restMovement:" + restMovement + "jumpOver:" + jumpOver(restMovement, 0, true) + "canPieceMoveInHome: return:" + true);
 | 
			
		||||
                return !jumpOver(restMovement, 0, true);
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            System.out.println("Server: ChoosePieceStateMachine: canPieceMoveInHome: return:" + false);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * tests if the piece, when moved in or inside a home, must jump over another piece
 | 
			
		||||
     *
 | 
			
		||||
     * @param stepsInHome the steps walked inside the home
 | 
			
		||||
     * @param homeIdx     the index of the piece inside, or 0 if come from outside
 | 
			
		||||
     * @param outside     a boolean, if the piece moves inside a house or in a house
 | 
			
		||||
     * @return false, if there is no piece to jump over
 | 
			
		||||
     */
 | 
			
		||||
    private boolean jumpOver(int stepsInHome, int homeIdx, boolean outside) {
 | 
			
		||||
 | 
			
		||||
        //tests if the piece comes from the outside in the home
 | 
			
		||||
        if (outside) {
 | 
			
		||||
            if (logic.getGame().getActivePlayer().getHomeNodes()[stepsInHome].isOccupied()) return true;
 | 
			
		||||
            System.out.println("Server: ChoosePieceState: jumpOver: from outside");
 | 
			
		||||
            for (int i = 0; i < stepsInHome; i++) {
 | 
			
		||||
                if (logic.getGame().getActivePlayer().getHomeNodes()[i].isOccupied()) return true;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        //tests if the piece jumps over a piece from inside the home
 | 
			
		||||
        else {
 | 
			
		||||
            if (logic.getGame().getActivePlayer().getHomeNodes()[stepsInHome + homeIdx].isOccupied()) return true;
 | 
			
		||||
            for (int i = 1 + homeIdx; i < homeIdx + stepsInHome; i++) {
 | 
			
		||||
                if (logic.getGame().getActivePlayer().getHomeNodes()[i].isOccupied()) return true;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * returns the index in the home, where the piece will go in the home
 | 
			
		||||
     *
 | 
			
		||||
     * @param piece the give piece
 | 
			
		||||
     * @return the index in the home, where the piece will go
 | 
			
		||||
     */
 | 
			
		||||
    protected int getHomeTargetIdx(Piece piece, int steps) {
 | 
			
		||||
        //tests if the piece is active and move in the house
 | 
			
		||||
        if (piece.getState() == PieceState.ACTIVE) {
 | 
			
		||||
            //gets the id's
 | 
			
		||||
            int pieceIdx = logic.getGame().getBoard().getInfieldIndexOfPiece(piece);
 | 
			
		||||
            int startIdx = logic.getGame().getActivePlayer().getStartNodeIndex();
 | 
			
		||||
            //normalize the idx
 | 
			
		||||
            int normPieceIdx = (-startIdx + pieceIdx + 40) % 40;
 | 
			
		||||
            //calculate the steps to the home
 | 
			
		||||
            int stepsToHome = 39 - normPieceIdx;
 | 
			
		||||
            //calculates the rest-movement inside a home
 | 
			
		||||
            int restMovement = steps - stepsToHome - 1;
 | 
			
		||||
            return restMovement;
 | 
			
		||||
        }
 | 
			
		||||
        //the else handles the logic if the piece is in the home and moves inside the house
 | 
			
		||||
        else {
 | 
			
		||||
            int pieceHomeIdx = logic.getGame().getActivePlayer().getHomeIndexOfPiece(piece);
 | 
			
		||||
            return pieceHomeIdx + steps;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * returns the target index inside the infield
 | 
			
		||||
     *
 | 
			
		||||
     * @param piece the piece given
 | 
			
		||||
     * @return the index in the infield
 | 
			
		||||
     */
 | 
			
		||||
    protected int getInfieldTarget(Piece piece, int steps) {
 | 
			
		||||
        int index = logic.getGame().getBoard().getInfieldIndexOfPiece(piece);
 | 
			
		||||
        return (steps + index) % 40;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * this method is used for calculating the targetIndex
 | 
			
		||||
     *
 | 
			
		||||
     * @param piece
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    protected int calculateTargetIndex(Piece piece) {
 | 
			
		||||
        int steps = logic.getGame().getDiceModifier() * logic.getGame().getDiceEyes();
 | 
			
		||||
        if (canPieceMoveInHome(piece, steps)) {
 | 
			
		||||
            System.out.println("Server: ChoosePieceStateAutomaton: calculate index in home:" + getHomeTargetIdx(piece, steps));
 | 
			
		||||
            return getHomeTargetIdx(piece, steps);
 | 
			
		||||
        }
 | 
			
		||||
        System.out.println("Server: ChoosePieceStateAutomaton: calculate index in Infield:" + getInfieldTarget(piece, steps));
 | 
			
		||||
        return getInfieldTarget(piece, steps);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -28,16 +28,14 @@ private void initialize(){
 | 
			
		||||
        Player activePlayer = logic.getGame().getPlayerByColor(logic.getGame().getActiveColor());
 | 
			
		||||
        if(logic.getGame().getDiceModifier() == 0){
 | 
			
		||||
            if (logic.getGame().getDiceEyes() == 6) {
 | 
			
		||||
                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());
 | 
			
		||||
                if (activePlayer.hasPieceInWaitingArea()) {
 | 
			
		||||
                    if (!logic.getGame().getBoard().getInfield()[activePlayer.getStartNodeIndex()].isOccupied(activePlayer.getColor())) {
 | 
			
		||||
                        this.choosePieceAutomaton.setCurrentState(this.choosePieceAutomaton.getWaitingPieceState());
 | 
			
		||||
                        return;
 | 
			
		||||
                    }
 | 
			
		||||
                } 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())){
 | 
			
		||||
                if (logic.getGame().getDiceEyes() == 6) {
 | 
			
		||||
@@ -62,7 +60,10 @@ private void checkSelectPiece(Player activePlayer){
 | 
			
		||||
                moveablePieces.add(piece);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        System.out.println("Server: NoPieceState: movablePieces.size()"+moveablePieces.size());
 | 
			
		||||
        System.out.println("Server: NoPiece: piece.getState"+moveablePieces.get(0).getState());
 | 
			
		||||
        moveablePieces.removeIf(piece -> !canMove(piece));
 | 
			
		||||
        System.out.println("Server: NoPieceState: movablePieces.size(): after deletion:"+moveablePieces.size());
 | 
			
		||||
        if (moveablePieces.isEmpty()) {
 | 
			
		||||
            this.choosePieceAutomaton.setCurrentState(this.choosePieceAutomaton.getNoTurnState());
 | 
			
		||||
        } else {
 | 
			
		||||
 
 | 
			
		||||
@@ -29,6 +29,7 @@ private void setActivePlayer(Color color) {
 | 
			
		||||
        } else {
 | 
			
		||||
            setActivePlayer(color.next(logic.getGame()));
 | 
			
		||||
        }
 | 
			
		||||
        this.choosePieceAutomaton.getTurnAutomaton().getGameAutomaton().setCurrentState(this.choosePieceAutomaton.getTurnAutomaton().getGameAutomaton().getTurnState());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -38,6 +38,7 @@ public void setMoveablePieces(ArrayList<Piece> moveablePieces) {
 | 
			
		||||
    /**
 | 
			
		||||
     * This method will be used whenever this state will be entered.
 | 
			
		||||
     */
 | 
			
		||||
    /*
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
        LOGGER.log(System.Logger.Level.DEBUG, "Entered SelectPieceState state.");
 | 
			
		||||
@@ -54,6 +55,30 @@ public void enter() {
 | 
			
		||||
        }
 | 
			
		||||
        logic.getServerSender().send(logic.getGame().getActivePlayerId(), new SelectPieceMessage(moveablePieces, isHomeMove, targetIndex));
 | 
			
		||||
    }
 | 
			
		||||
     */
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter(){
 | 
			
		||||
        LOGGER.log(System.Logger.Level.DEBUG, "Entered SelectPieceState state in the Server.");
 | 
			
		||||
        int steps = logic.getGame().getDiceModifier() * logic.getGame().getDiceEyes();
 | 
			
		||||
        for (Piece piece : moveablePieces) {
 | 
			
		||||
 | 
			
		||||
            if(canPieceMoveInHome(piece,steps)){
 | 
			
		||||
                int target= getHomeTargetIdx(piece,steps);
 | 
			
		||||
                System.out.println("Server: SelectPieceState: enter in canPieceMoveInHome: targetIndex:"+target);
 | 
			
		||||
                targetIndex.add(target);
 | 
			
		||||
                isHomeMove.add(true);
 | 
			
		||||
            }
 | 
			
		||||
            else{
 | 
			
		||||
                int target = getInfieldTarget(piece,steps);
 | 
			
		||||
                System.out.println("Server: SelectPieceState: enter in else: targetIndex:"+target);
 | 
			
		||||
                targetIndex.add(target);
 | 
			
		||||
                isHomeMove.add(false);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        System.out.println("Server: SelectPiece: enter: send:  "+moveablePieces.get(0)+isHomeMove.get(0)+targetIndex.get(0));
 | 
			
		||||
        logic.getServerSender().send(logic.getGame().getActivePlayerId(), new SelectPieceMessage(moveablePieces, isHomeMove, targetIndex));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(RequestMoveMessage msg, int from){
 | 
			
		||||
@@ -62,10 +87,96 @@ public void received(RequestMoveMessage msg, int from){
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        int indexOfPiece = moveablePieces.indexOf(msg.getPiece());
 | 
			
		||||
        Piece movePiece = moveablePieces.get(indexOfPiece);
 | 
			
		||||
        int steps = logic.getGame().getDiceModifier() * logic.getGame().getDiceEyes();
 | 
			
		||||
        Piece piece = moveablePieces.get(indexOfPiece);
 | 
			
		||||
        if(canPieceMoveInHome(piece,steps)){
 | 
			
		||||
            System.out.println("Server: SelectPieceState: canPieceMoveInHome(piece,steps)");
 | 
			
		||||
            if(piece.getState().equals(PieceState.HOME)) {
 | 
			
		||||
                System.out.println("Server: SelectPieceState: piece.getState()==PieceState.HOME");
 | 
			
		||||
                //gets the oldNode
 | 
			
		||||
                int homeIndex = logic.getGame().getActivePlayer().getHomeIndexOfPiece(piece);
 | 
			
		||||
                Node oldNode = logic.getGame().getActivePlayer().getHomeNodes()[homeIndex];
 | 
			
		||||
                //gets the targetNode
 | 
			
		||||
                int targetHomeIdx = getHomeTargetIdx(piece,steps);
 | 
			
		||||
                Node targetNode = logic.getGame().getActivePlayer().getHomeNodes()[targetHomeIdx];
 | 
			
		||||
                if (targetHomeIdx ==logic.getGame().getActivePlayer().getHighestHomeIdx()) {
 | 
			
		||||
                    piece.setState(PieceState.HOMEFINISHED);
 | 
			
		||||
                }
 | 
			
		||||
                else{
 | 
			
		||||
                    piece.setState(PieceState.HOME);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                oldNode.clearOccupant();
 | 
			
		||||
                targetNode.setOccupant(piece);
 | 
			
		||||
                System.out.println("sets homefinsihed here:"+ (targetHomeIdx ==logic.getGame().getActivePlayer().getHighestHomeIdx())+"targetIdx:"+targetHomeIdx+"HighestHomeIdx:"+logic.getGame().getActivePlayer().getHighestHomeIdx());
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
            else{
 | 
			
		||||
                System.out.println("Server: SelectPieceState: entered else");
 | 
			
		||||
                int oldNoteIdx = logic.getGame().getBoard().getInfieldIndexOfPiece(piece);
 | 
			
		||||
                Node oldNode = logic.getGame().getBoard().getInfield()[oldNoteIdx];
 | 
			
		||||
 | 
			
		||||
                //gets the targetNode
 | 
			
		||||
                int targetHomeIdx = getHomeTargetIdx(piece,steps);
 | 
			
		||||
                Node targetNode = logic.getGame().getActivePlayer().getHomeNodes()[targetHomeIdx];
 | 
			
		||||
 | 
			
		||||
                if (targetHomeIdx ==logic.getGame().getActivePlayer().getHighestHomeIdx()) {
 | 
			
		||||
                    piece.setState(PieceState.HOMEFINISHED);
 | 
			
		||||
                }
 | 
			
		||||
                else{
 | 
			
		||||
                    piece.setState(PieceState.HOME);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                oldNode.clearOccupant();
 | 
			
		||||
                targetNode.setOccupant(piece);
 | 
			
		||||
                System.out.println("sets homefinsihed:"+ (targetHomeIdx ==logic.getGame().getActivePlayer().getHighestHomeIdx())+"targetIdx:"+targetHomeIdx+"HighestHomeIdx:"+logic.getGame().getActivePlayer().getHighestHomeIdx());
 | 
			
		||||
 | 
			
		||||
                System.out.println("Server: SelectPieceMessage: received(RequestMoveMessage): setPiece(Home)"+piece.getState());
 | 
			
		||||
            }
 | 
			
		||||
            LOGGER.log(System.Logger.Level.INFO,"Server : SelectPieceState: PieceState:"+piece.getState());
 | 
			
		||||
        }
 | 
			
		||||
        else{
 | 
			
		||||
            LOGGER.log(System.Logger.Level.INFO,"Server : SelectPieceState: PieceState:"+piece.getState());
 | 
			
		||||
            int oldNoteIdx = logic.getGame().getBoard().getInfieldIndexOfPiece(piece);
 | 
			
		||||
            Node oldNode = logic.getGame().getBoard().getInfield()[oldNoteIdx];
 | 
			
		||||
 | 
			
		||||
            int targetIndex = (oldNoteIdx+steps)%40;
 | 
			
		||||
            Node targetNode = logic.getGame().getBoard().getInfield()[targetIndex];
 | 
			
		||||
 | 
			
		||||
            Piece occ = targetNode.getOccupant();
 | 
			
		||||
            if (occ != null) {
 | 
			
		||||
                logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if(targetNode.isStart()){
 | 
			
		||||
                if(piece.getShield()== ShieldState.ACTIVE) piece.setShield(ShieldState.SUPPRESSED);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            oldNode.clearOccupant();
 | 
			
		||||
            targetNode.setOccupant(piece);
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        System.out.println("Server: SelectPieceMessage: received(RequestMoveMessage): pieceState: wichtig"+piece.getState());
 | 
			
		||||
        boolean homeMove = isHomeMove.get(indexOfPiece);
 | 
			
		||||
        int targIdx = targetIndex.get(indexOfPiece);
 | 
			
		||||
 | 
			
		||||
        Node targetNode = logic.getGame().getBoard().getInfield()[targIdx];
 | 
			
		||||
 | 
			
		||||
        LOGGER.log(System.Logger.Level.INFO,"Server : SelectPieceState: PieceState: end:"+piece.getState());
 | 
			
		||||
        logic.getServerSender().broadcast(new MoveMessage(piece, homeMove, targIdx));
 | 
			
		||||
 | 
			
		||||
        if(targetNode.isBonus()) {
 | 
			
		||||
            for (Player p : logic.getGame().getPlayersAsList()) {
 | 
			
		||||
                if(p.getColor() == logic.getGame().getActiveColor()) {
 | 
			
		||||
                    logic.getServerSender().send(logic.getGame().getPlayerIdByColor(p.getColor()), new DrawCardMessage(logic.getGame().draw()));
 | 
			
		||||
                } else {
 | 
			
		||||
                    logic.getServerSender().send(logic.getGame().getPlayerIdByColor(p.getColor()), new DrawCardMessage(new HiddenCard()));
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /*
 | 
			
		||||
        Node oldNode = logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(movePiece)];
 | 
			
		||||
        oldNode.clearOccupant();
 | 
			
		||||
        if (homeMove) {
 | 
			
		||||
@@ -81,7 +192,7 @@ public void received(RequestMoveMessage msg, int from){
 | 
			
		||||
            movePiece.setShield(ShieldState.NONE);
 | 
			
		||||
        } else {
 | 
			
		||||
            Node targetNode = logic.getGame().getBoard().getInfield()[targIdx];
 | 
			
		||||
 | 
			
		||||
            //TODO durch merge auskommentiert
 | 
			
		||||
            if(targetNode.isBonus()) {
 | 
			
		||||
                for (Player p : logic.getGame().getPlayersAsList()) {
 | 
			
		||||
                    if(p.getColor() == logic.getGame().getActiveColor()) {
 | 
			
		||||
@@ -98,7 +209,9 @@ public void received(RequestMoveMessage msg, int from){
 | 
			
		||||
            }
 | 
			
		||||
            targetNode.setOccupant(msg.getPiece());
 | 
			
		||||
        }
 | 
			
		||||
        logic.getServerSender().broadcast(new MoveMessage(movePiece, homeMove, targIdx));
 | 
			
		||||
 | 
			
		||||
         */
 | 
			
		||||
        System.out.println("Server changes from SelectPieceState to movePieceState");
 | 
			
		||||
        this.choosePieceAutomaton.getTurnAutomaton().setCurrentState(this.choosePieceAutomaton.getTurnAutomaton().getMovePieceState());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -46,16 +46,6 @@ public void received(RequestMoveMessage msg, int from){
 | 
			
		||||
            int targetIndex = calculateTargetIndex(piece);
 | 
			
		||||
            Node targetNode = logic.getGame().getBoard().getInfield()[targetIndex];
 | 
			
		||||
 | 
			
		||||
            if(targetNode.isBonus()) {
 | 
			
		||||
                for (Player p : logic.getGame().getPlayersAsList()) {
 | 
			
		||||
                    if(p.getColor() == logic.getGame().getActiveColor()) {
 | 
			
		||||
                        logic.getServerSender().send(logic.getGame().getPlayerIdByColor(p.getColor()), new DrawCardMessage(logic.getGame().draw()));
 | 
			
		||||
                    } else {
 | 
			
		||||
                        logic.getServerSender().send(logic.getGame().getPlayerIdByColor(p.getColor()), new DrawCardMessage(new HiddenCard()));
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            //send MoveMessage
 | 
			
		||||
            logic.getServerSender().broadcast(new MoveMessage(piece, false, targetIndex));
 | 
			
		||||
 | 
			
		||||
@@ -70,6 +60,16 @@ public void received(RequestMoveMessage msg, int from){
 | 
			
		||||
            //move piece to targetNode
 | 
			
		||||
            targetNode.setOccupant(piece);
 | 
			
		||||
 | 
			
		||||
            if(targetNode.isBonus()) {
 | 
			
		||||
                for (Player p : logic.getGame().getPlayersAsList()) {
 | 
			
		||||
                    if(p.getColor() == logic.getGame().getActiveColor()) {
 | 
			
		||||
                        logic.getServerSender().send(logic.getGame().getPlayerIdByColor(p.getColor()), new DrawCardMessage(logic.getGame().draw()));
 | 
			
		||||
                    } else {
 | 
			
		||||
                        logic.getServerSender().send(logic.getGame().getPlayerIdByColor(p.getColor()), new DrawCardMessage(new HiddenCard()));
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            this.choosePieceAutomaton.getTurnAutomaton().setCurrentState(this.choosePieceAutomaton.getTurnAutomaton().getMovePieceState());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -41,7 +41,7 @@ public ServerCardVisitor(ServerGameLogic logic) {
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public void visit(TurboCard card) {
 | 
			
		||||
        for (Piece piece : this.logic.getGame().getPlayerByColor(this.logic.getGame().getActiveColor()).getPieces()) {
 | 
			
		||||
        for (Piece piece : this.logic.getGame().getActivePlayer().getPieces()) {
 | 
			
		||||
            if (piece.getState() == PieceState.ACTIVE) {
 | 
			
		||||
                if (!this.cards.contains(card)) {
 | 
			
		||||
                    this.cards.add(card);
 | 
			
		||||
@@ -58,7 +58,7 @@ public void visit(TurboCard card) {
 | 
			
		||||
    @Override
 | 
			
		||||
    public void visit(SwapCard card) {
 | 
			
		||||
        List<Piece> possibleOwnPieces = new ArrayList<>();
 | 
			
		||||
        for (Piece piece : this.logic.getGame().getPlayerByColor(this.logic.getGame().getActiveColor()).getPieces()) {
 | 
			
		||||
        for (Piece piece : this.logic.getGame().getActivePlayer().getPieces()) {
 | 
			
		||||
            if (piece.getState() == PieceState.ACTIVE) {
 | 
			
		||||
                if (!possibleOwnPieces.contains(piece)) {
 | 
			
		||||
                    possibleOwnPieces.add(piece);
 | 
			
		||||
@@ -68,7 +68,7 @@ public void visit(SwapCard card) {
 | 
			
		||||
 | 
			
		||||
        List<Piece> possibleOtherPieces = new ArrayList<>();
 | 
			
		||||
        for (var player : this.logic.getGame().getPlayers().values()) {
 | 
			
		||||
            if (player != this.logic.getGame().getPlayerByColor(this.logic.getGame().getActiveColor())) {
 | 
			
		||||
            if (player != this.logic.getGame().getActivePlayer()) {
 | 
			
		||||
                for (Piece piece : player.getPieces()) {
 | 
			
		||||
                    if (piece.getState() == PieceState.ACTIVE) {
 | 
			
		||||
                        if (!possibleOtherPieces.contains(piece)) {
 | 
			
		||||
@@ -82,7 +82,9 @@ public void visit(SwapCard card) {
 | 
			
		||||
        if (!possibleOtherPieces.isEmpty() && !possibleOwnPieces.isEmpty()) {
 | 
			
		||||
            this.swapOwnPieces.addAll(possibleOwnPieces);
 | 
			
		||||
            this.swapOtherPieces.addAll(possibleOtherPieces);
 | 
			
		||||
            this.cards.add(card);
 | 
			
		||||
            if (!this.cards.contains(card)) {
 | 
			
		||||
                this.cards.add(card);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user