fixed client shield state animation

This commit is contained in:
Hanno Fleischer
2024-12-09 17:11:30 +01:00
parent 6bc769f5bb
commit 189e8a7ec3
2 changed files with 27 additions and 0 deletions

View File

@@ -4,12 +4,15 @@
import pp.mdga.client.ClientState;
import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
import pp.mdga.game.Piece;
import pp.mdga.game.ShieldState;
import pp.mdga.game.PieceState;
import pp.mdga.message.client.RequestMoveMessage;
import pp.mdga.message.client.SelectedPiecesMessage;
import pp.mdga.message.server.MoveMessage;
import pp.mdga.notification.HomeMoveNotification;
import pp.mdga.notification.MovePieceNotification;
import pp.mdga.notification.ShieldActiveNotification;
import pp.mdga.notification.ShieldSuppressedNotification;
import pp.mdga.notification.ThrowPieceNotification;
import java.util.ArrayList;
@@ -107,6 +110,15 @@ public void received(MoveMessage msg) {
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
//set new node
logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(piece);
if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].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()));
}
}
logic.getGame().setTurboFlag(false);
parent.getParent().setState(parent.getParent().getMovePiece());

View File

@@ -5,10 +5,14 @@
import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
import pp.mdga.game.Node;
import pp.mdga.game.Piece;
import pp.mdga.game.ShieldState;
import pp.mdga.message.client.RequestMoveMessage;
import pp.mdga.message.client.SelectedPiecesMessage;
import pp.mdga.message.server.MoveMessage;
import pp.mdga.notification.MovePieceNotification;
import pp.mdga.notification.RemoveShieldNotification;
import pp.mdga.notification.ShieldActiveNotification;
import pp.mdga.notification.ShieldSuppressedNotification;
import pp.mdga.notification.ThrowPieceNotification;
import java.util.ArrayList;
@@ -63,6 +67,17 @@ public void received(MoveMessage msg){
logic.addNotification(new ThrowPieceNotification(occ.getUuid(), piece.getColor()));
}
if (targetNode.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 RemoveShieldNotification(piece.getUuid()));
logic.addNotification(new ShieldActiveNotification(piece.getUuid()));
}
targetNode.setOccupant(msg.getPiece());
logic.addNotification(new MovePieceNotification(msg.getPiece().getUuid(), oldIndex, targetIndex));
logic.getGame().setTurboFlag(false);