Remove moveOccupant
This commit is contained in:
		@@ -1,6 +1,6 @@
 | 
			
		||||
<component name="ProjectRunConfigurationManager">
 | 
			
		||||
  <configuration default="false" name="MdgaApp" type="Application" factoryName="Application" singleton="false" nameIsGenerated="true">
 | 
			
		||||
    <option name="ALTERNATIVE_JRE_PATH" value="temurin-20" />
 | 
			
		||||
    <option name="ALTERNATIVE_JRE_PATH" value="21" />
 | 
			
		||||
    <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
 | 
			
		||||
    <option name="MAIN_CLASS_NAME" value="pp.mdga.client.MdgaApp" />
 | 
			
		||||
    <module name="Projekte.mdga.client.main" />
 | 
			
		||||
 
 | 
			
		||||
@@ -51,12 +51,16 @@ public void received(MoveMessage msg){
 | 
			
		||||
        Piece piece = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid());
 | 
			
		||||
        int i = logic.getGame().getBoard().getInfieldIndexOfPiece(piece);
 | 
			
		||||
        LOGGER.log(System.Logger.Level.INFO, "Received MoveMessage with start index: " + i);
 | 
			
		||||
        logic.addNotification(new MovePieceNotification(msg.getPiece().getUuid(), i, msg.getTargetIndex()));
 | 
			
		||||
        Piece occ = logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].moveOccupant(piece);
 | 
			
		||||
 | 
			
		||||
        Piece occ = logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant();
 | 
			
		||||
        if (occ != null){
 | 
			
		||||
            logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ);
 | 
			
		||||
            logic.addNotification(new ThrowPieceNotification(occ.getUuid(), piece.getColor()));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        logic.addNotification(new MovePieceNotification(msg.getPiece().getUuid(), i, msg.getTargetIndex()));
 | 
			
		||||
        logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(msg.getPiece());
 | 
			
		||||
 | 
			
		||||
        parent.getParent().setState(parent.getParent().getMovePiece());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -43,12 +43,15 @@ public void selectPiece(Piece piece){
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(MoveMessage msg){
 | 
			
		||||
        Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid());
 | 
			
		||||
        Piece occ = logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].moveOccupant(pieceToMove);
 | 
			
		||||
        logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getStartNodeIndex(), true));
 | 
			
		||||
        Piece occ = logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant();
 | 
			
		||||
        if (occ != null){
 | 
			
		||||
            logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ);
 | 
			
		||||
            logic.addNotification(new ThrowPieceNotification(occ.getUuid(), pieceToMove.getColor()));
 | 
			
		||||
            logic.addNotification(new ThrowPieceNotification(occ.getUuid(), msg.getPiece().getColor()));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getStartNodeIndex(), true));
 | 
			
		||||
        logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(msg.getPiece());
 | 
			
		||||
 | 
			
		||||
        pieceToMove.setState(PieceState.ACTIVE);
 | 
			
		||||
        parent.getParent().setState(parent.getParent().getMovePiece());
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -85,6 +85,7 @@ public int getInfieldIndexOfPiece(Piece piece) {
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return -1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -32,7 +32,7 @@ public WaitingPieceState(ChoosePieceState choosePieceAutomaton, ServerGameLogic
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
        LOGGER.log(System.Logger.Level.DEBUG, "Entered WaitingPieceState state.");
 | 
			
		||||
        LOGGER.log(System.Logger.Level.INFO, "Entered WaitingPieceState state.");
 | 
			
		||||
        this.piece = logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getWaitingPiece();
 | 
			
		||||
        logic.getServerSender().send(logic.getGame().getActivePlayerId(), new WaitPieceMessage(this.piece.getUuid()));
 | 
			
		||||
    }
 | 
			
		||||
@@ -41,10 +41,12 @@ public void enter() {
 | 
			
		||||
    public void received(RequestMoveMessage msg, int from){
 | 
			
		||||
        if (msg.getPiece().equals(this.piece)) {
 | 
			
		||||
            piece.setState(PieceState.ACTIVE);
 | 
			
		||||
            Piece thrownOcc = logic.getGame().getBoard().getInfield()[logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getStartNodeIndex()].moveOccupant(this.piece);
 | 
			
		||||
            Piece thrownOcc = logic.getGame().getBoard().getInfield()[logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getStartNodeIndex()].getOccupant();
 | 
			
		||||
            if (thrownOcc != null) {
 | 
			
		||||
                logic.getServerSender().broadcast(new MoveMessage());
 | 
			
		||||
                logic.getGame().getPlayerByColor(thrownOcc.getColor()).addWaitingPiece(thrownOcc);
 | 
			
		||||
            }
 | 
			
		||||
            logic.getGame().getBoard().getInfield()[logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getStartNodeIndex()].setOccupant(this.piece);
 | 
			
		||||
            logic.getServerSender().broadcast(new MoveMessage(this.piece, false, logic.getGame().getPlayerById(logic.getGame().getActivePlayerId()).getStartNodeIndex()));
 | 
			
		||||
            this.choosePieceAutomaton.getTurnAutomaton().setCurrentState(this.choosePieceAutomaton.getTurnAutomaton().getMovePieceState());
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user