fixed missing check on shield state after swap

This commit is contained in:
Fleischer Hanno
2024-12-09 19:55:03 +01:00
parent ece249cf66
commit 6ab8f2d90d

View File

@@ -37,15 +37,6 @@ protected void handlePowerCard(PlayCardMessage msg) {
logic.getGame().getDiscardPile().add(msg.getCard());
}
protected void throwPiece(Piece piece) {
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
logic.getGame().getPlayerByColor(piece.getColor()).addWaitingPiece(piece);
logic.addNotification(new ThrowPieceNotification(piece.getUuid(), piece.getColor()));
logic.getGame().getPlayerByColor(piece.getColor()).getPlayerStatistic().increasePiecesBeingThrown();
logic.getGame().getGameStatistics().increasePiecesBeingThrown();
piece.setState(PieceState.WAITING);
}
private void handleShield(UUID uuid) {
Board board = logic.getGame().getBoard();
Piece piece = logic.getGame().getPieceThroughUUID(uuid);
@@ -70,6 +61,22 @@ private void swapPieces(Piece messageOwn, Piece messageEnemy) {
ownNode.setOccupant(modelEnemy);
enemyNode.setOccupant(modelOwn);
logic.addNotification(new SwapPieceNotification(modelOwn.getUuid(), modelEnemy.getUuid()));
checkShieldAfterSwap(enemyNode, modelOwn);
checkShieldAfterSwap(ownNode, modelEnemy);
}
private void checkShieldAfterSwap(Node node, Piece piece){
if (node.isStart()){
if (piece.isShielded()){
piece.setShield(ShieldState.SUPPRESSED);
logic.addNotification(new ShieldSuppressedNotification(piece.getUuid()));
}
} else if (piece.isSuppressed()){
piece.setShield(ShieldState.ACTIVE);
logic.addNotification(new ShieldActiveNotification(piece.getUuid()));
}
}
}