fixed calcTargetIndex

This commit is contained in:
Cedric Beck
2024-12-08 17:24:36 +01:00
parent 34cde15a0d
commit f489357bbb

View File

@@ -39,13 +39,14 @@ public void enter() {
public void received(RequestMoveMessage msg, int from){
LOGGER.log(System.Logger.Level.INFO, "Received RequestMoveMessage message. is piece equals: " + piece.equals(msg.getPiece()));
if (piece.equals(msg.getPiece())) {
logic.getServerSender().broadcast(new MoveMessage(piece, false, calculateTargetIndex(piece)));
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
Piece occ = logic.getGame().getBoard().getInfield()[logic.getGame().getPlayerByColor(piece.getColor()).getStartNodeIndex()].getOccupant();
Piece occ = logic.getGame().getBoard().getInfield()[calculateTargetIndex(piece)].getOccupant();
if (occ != null){
logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ);
}
logic.getGame().getBoard().getInfield()[logic.getGame().getPlayerByColor(piece.getColor()).getStartNodeIndex()].setOccupant(msg.getPiece());
logic.getGame().getBoard().getInfield()[calculateTargetIndex(piece)].setOccupant(piece);
this.choosePieceAutomaton.getTurnAutomaton().setCurrentState(this.choosePieceAutomaton.getTurnAutomaton().getMovePieceState());
}