added a reset for the dice modifier in the server

This commit is contained in:
Fleischer Hanno
2024-12-09 02:03:57 +01:00
parent b86aeb63e6
commit e457fe23d4
3 changed files with 12 additions and 2 deletions

View File

@@ -92,9 +92,9 @@ 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 TurboCard(), AMOUNT_OF_TURBO_CARDS);
// this.addBonusCards(new SwapCard(), AMOUNT_OF_SWAP_CARDS);
this.addBonusCards(new ShieldCard(), AMOUNT_OF_SHIELD_CARDS);
// this.addBonusCards(new ShieldCard(), AMOUNT_OF_SHIELD_CARDS);
Collections.shuffle(this.drawPile);
}

View File

@@ -22,6 +22,7 @@ public class RollDiceState extends TurnAutomatonState {
private final FirstRollState firstRollState;
private final SecondRollState secondRollState;
private final ThirdRollState thirdRollState;
private boolean resetModifier = true;
/**
* Constructs a server state of the specified game logic.
@@ -39,12 +40,16 @@ public RollDiceState(TurnState turnAutomaton, ServerGameLogic logic) {
@Override
public void enter() {
LOGGER.log(System.Logger.Level.DEBUG, "Entered RollDiceState state.");
if (resetModifier){
logic.getGame().setDiceModifier(1);
}
this.setCurrentState(this.firstRollState);
}
@Override
public void exit() {
LOGGER.log(System.Logger.Level.DEBUG, "Exited RollDiceState state.");
resetModifier = true;
}
/**
@@ -73,6 +78,10 @@ public RollDiceAutomatonState getCurrentState() {
return this.currentState;
}
public void setResetModifier(boolean resetModifier) {
this.resetModifier = resetModifier;
}
/**
* This method will be used to return firstRollState attribute of RollDiceState class.
*

View File

@@ -28,6 +28,7 @@ public void enter() {
this.logic.getServerSender().send(this.logic.getGame().getActivePlayerId(), new PlayCardMessage(this.powerCardAutomaton.getSelectedCard(), new ArrayList<>(), this.logic.getGame().getDiceModifier()));
this.logic.getGame().getPlayerByColor(this.logic.getGame().getActiveColor()).removeHandCard(this.powerCardAutomaton.getSelectedCard());
this.logic.getGame().getDiscardPile().add(this.powerCardAutomaton.getSelectedCard());
this.powerCardAutomaton.getTurnAutomaton().getRollDiceState().setResetModifier(false);
this.powerCardAutomaton.getTurnAutomaton().setCurrentState(this.powerCardAutomaton.getTurnAutomaton().getPlayPowerCardState());
}