This commit is contained in:
Benjamin Feyer
2024-12-09 16:11:32 +01:00
7 changed files with 36 additions and 18 deletions

View File

@@ -4,6 +4,8 @@
import pp.mdga.client.ClientState;
import pp.mdga.client.gamestate.TurnState;
import pp.mdga.game.BonusCard;
import pp.mdga.game.card.ShieldCard;
import pp.mdga.game.card.SwapCard;
import pp.mdga.message.client.AnimationEndMessage;
import pp.mdga.message.server.PlayCardMessage;
import pp.mdga.notification.PlayCardNotification;
@@ -13,7 +15,7 @@ public class PlayPowerCardState extends TurnStates {
private final TurnState parent;
private PlayCardMessage playCardMessage;
private int animationCounter = 0;
private int extraAnimationCounter = 0;
public PlayPowerCardState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
@@ -22,11 +24,12 @@ public PlayPowerCardState(ClientState parent, ClientGameLogic logic) {
@Override
public void enter() {
animationCounter++;
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor() , playCardMessage.getCard().getCard()));
if(!playCardMessage.getCard().getCard().equals(BonusCard.TURBO)){
animationCounter++;
if(playCardMessage.getCard() instanceof SwapCard) {
extraAnimationCounter++;
}
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor() , playCardMessage.getCard().getCard()));
handlePowerCard(playCardMessage);
}
@@ -41,10 +44,12 @@ public void setPlayCard(PlayCardMessage playCardMessage) {
@Override
public void selectAnimationEnd(){
animationCounter--;
if(animationCounter == 0){
logic.send(new AnimationEndMessage());
parent.setState(parent.getRollDice());
if(extraAnimationCounter > 0) {
extraAnimationCounter--;
return;
}
logic.send(new AnimationEndMessage());
parent.setState(parent.getRollDice());
}
}

View File

@@ -38,7 +38,6 @@ public void exit() {
@Override
public void received(SelectPieceMessage msg) {
//TODO
ArrayList<Piece> pieces = msg.getPieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece.getUuid())).collect(Collectors.toCollection(ArrayList::new));
parent.getSelectPiece().setPossiblePieces(pieces);
ArrayList<UUID> listPiece = pieces.stream().map(Piece::getUuid).collect(Collectors.toCollection(ArrayList::new));

View File

@@ -112,7 +112,6 @@ public void received(PossiblePieceMessage msg){
if (msg.getEnemyPossiblePieces().isEmpty()){
parent.getShield().setPossiblePieces(msg.getOwnPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece.getUuid())).collect(Collectors.toCollection(ArrayList::new)));
parent.setState(parent.getShield());
logic.addNotification(new SelectableShieldNotification(msg.getOwnPossiblePieces().stream().map(Piece::getUuid).toList()));
} else {
System.out.println("Should enter Swap State");
parent.getSwap().setPossibleOwnPieces(msg.getOwnPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece.getUuid())).collect(Collectors.toCollection(ArrayList::new)));

View File

@@ -7,6 +7,7 @@
import pp.mdga.message.client.RequestPlayCardMessage;
import pp.mdga.message.client.SelectedPiecesMessage;
import pp.mdga.message.server.PlayCardMessage;
import pp.mdga.notification.SelectableShieldNotification;
import java.lang.System.Logger.Level;
import java.util.ArrayList;
@@ -27,8 +28,7 @@ public ShieldState(ClientState parent, ClientGameLogic logic) {
@Override
public void enter() {
logic.addNotification(null);
//TODO: selectable piece notification
logic.addNotification(new SelectableShieldNotification(possiblePieces.stream().map(Piece::getUuid).toList()));
}
@Override

View File

@@ -94,8 +94,8 @@ public Game() {
* This method initializes the draw pile with the predefined number of bonus cards.
*/
private void initializeDrawPile() {
// this.addBonusCards(new TurboCard(), AMOUNT_OF_TURBO_CARDS);
// this.addBonusCards(new SwapCard(), AMOUNT_OF_SWAP_CARDS);
this.addBonusCards(new TurboCard(), AMOUNT_OF_TURBO_CARDS);
this.addBonusCards(new SwapCard(), AMOUNT_OF_SWAP_CARDS);
this.addBonusCards(new ShieldCard(), AMOUNT_OF_SHIELD_CARDS);
Collections.shuffle(this.drawPile);
}