Fix swap card issue

This commit is contained in:
Felix Koppe
2024-12-09 14:50:29 +01:00
parent db16b0d8b6
commit 6a4bdfa455
2 changed files with 15 additions and 2 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,6 +15,7 @@ public class PlayPowerCardState extends TurnStates {
private final TurnState parent;
private PlayCardMessage playCardMessage;
private int extraAnimationCounter = 0;
public PlayPowerCardState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
@@ -21,7 +24,12 @@ public PlayPowerCardState(ClientState parent, ClientGameLogic logic) {
@Override
public void enter() {
if(playCardMessage.getCard() instanceof SwapCard) {
extraAnimationCounter++;
}
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor() , playCardMessage.getCard().getCard()));
handlePowerCard(playCardMessage);
}
@@ -36,6 +44,11 @@ public void setPlayCard(PlayCardMessage playCardMessage) {
@Override
public void selectAnimationEnd(){
if(extraAnimationCounter > 0) {
extraAnimationCounter--;
return;
}
logic.send(new AnimationEndMessage());
parent.setState(parent.getRollDice());
}

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);
}