Fix selectPieceState and startPieceState logic
This commit is contained in:
		@@ -48,21 +48,30 @@ public void selectPiece(Piece piece) {
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(MoveMessage msg) {
 | 
			
		||||
        Piece piece = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid());
 | 
			
		||||
        logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
 | 
			
		||||
        //logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
 | 
			
		||||
        if (msg.isHomeMove()) {
 | 
			
		||||
            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 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(), logic.getGame().getBoard().getInfieldIndexOfPiece(piece), msg.getTargetIndex()));
 | 
			
		||||
            Piece occ = logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].moveOccupant(piece);
 | 
			
		||||
            if (occ != null){
 | 
			
		||||
                logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ);
 | 
			
		||||
            int oldIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(piece);
 | 
			
		||||
 | 
			
		||||
            Piece occ = logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant();
 | 
			
		||||
            //logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].moveOccupant(piece);
 | 
			
		||||
            if (occ != null) {
 | 
			
		||||
                //TODO: MoveThrowNotification
 | 
			
		||||
                logic.addNotification(new ThrowPieceNotification(occ.getUuid(), piece.getColor()));
 | 
			
		||||
                //set occ to waiting
 | 
			
		||||
                logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ);
 | 
			
		||||
            }
 | 
			
		||||
            parent.getParent().setState(parent.getParent().getMovePiece());
 | 
			
		||||
            logic.addNotification(new MovePieceNotification(msg.getPiece().getUuid(), oldIndex, msg.getTargetIndex()));
 | 
			
		||||
 | 
			
		||||
            //clear old node
 | 
			
		||||
            logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
 | 
			
		||||
            //set new node
 | 
			
		||||
            logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(piece);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        parent.getParent().setState(parent.getParent().getMovePiece());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -51,7 +51,7 @@ 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(), logic.getGame().getBoard().getInfieldIndexOfPiece(piece), msg.getTargetIndex()));
 | 
			
		||||
        logic.addNotification(new MovePieceNotification(msg.getPiece().getUuid(), i, msg.getTargetIndex()));
 | 
			
		||||
        Piece occ = logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].moveOccupant(piece);
 | 
			
		||||
        if (occ != null){
 | 
			
		||||
            logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user