added a reset for the dice modifier in the server
This commit is contained in:
@@ -92,9 +92,9 @@ public Game() {
|
|||||||
* This method initializes the draw pile with the predefined number of bonus cards.
|
* This method initializes the draw pile with the predefined number of bonus cards.
|
||||||
*/
|
*/
|
||||||
private void initializeDrawPile() {
|
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 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);
|
Collections.shuffle(this.drawPile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ public class RollDiceState extends TurnAutomatonState {
|
|||||||
private final FirstRollState firstRollState;
|
private final FirstRollState firstRollState;
|
||||||
private final SecondRollState secondRollState;
|
private final SecondRollState secondRollState;
|
||||||
private final ThirdRollState thirdRollState;
|
private final ThirdRollState thirdRollState;
|
||||||
|
private boolean resetModifier = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a server state of the specified game logic.
|
* Constructs a server state of the specified game logic.
|
||||||
@@ -39,12 +40,16 @@ public RollDiceState(TurnState turnAutomaton, ServerGameLogic logic) {
|
|||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
LOGGER.log(System.Logger.Level.DEBUG, "Entered RollDiceState state.");
|
LOGGER.log(System.Logger.Level.DEBUG, "Entered RollDiceState state.");
|
||||||
|
if (resetModifier){
|
||||||
|
logic.getGame().setDiceModifier(1);
|
||||||
|
}
|
||||||
this.setCurrentState(this.firstRollState);
|
this.setCurrentState(this.firstRollState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void exit() {
|
public void exit() {
|
||||||
LOGGER.log(System.Logger.Level.DEBUG, "Exited RollDiceState state.");
|
LOGGER.log(System.Logger.Level.DEBUG, "Exited RollDiceState state.");
|
||||||
|
resetModifier = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -73,6 +78,10 @@ public RollDiceAutomatonState getCurrentState() {
|
|||||||
return this.currentState;
|
return this.currentState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setResetModifier(boolean resetModifier) {
|
||||||
|
this.resetModifier = resetModifier;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method will be used to return firstRollState attribute of RollDiceState class.
|
* This method will be used to return firstRollState attribute of RollDiceState class.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -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.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().getPlayerByColor(this.logic.getGame().getActiveColor()).removeHandCard(this.powerCardAutomaton.getSelectedCard());
|
||||||
this.logic.getGame().getDiscardPile().add(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());
|
this.powerCardAutomaton.getTurnAutomaton().setCurrentState(this.powerCardAutomaton.getTurnAutomaton().getPlayPowerCardState());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user