Commit 9bb4d7ed authored by Michael Kamensky's avatar Michael Kamensky

Merge branch 'turns' into 'master'

Update advanceToNextPhase logic

See merge request core-developers/forge!4633
parents 562ef1b1 de8aaf35
......@@ -162,6 +162,8 @@ public class PhaseHandler implements java.io.Serializable {
boolean isTopsy = playerTurn.getAmountOfKeyword("The phases of your turn are reversed.") % 2 == 1;
boolean turnEnded = false;
game.getStack().clearUndoStack(); //can't undo action from previous phase
if (bRepeatCleanup) { // for when Cleanup needs to repeat itself
bRepeatCleanup = false;
}
......@@ -184,6 +186,28 @@ public class PhaseHandler implements java.io.Serializable {
setPhase(PhaseType.getNext(phase, isTopsy));
}
if (turnEnded) {
turn++;
extraPhases.clear();
game.updateTurnForView();
game.fireEvent(new GameEventTurnBegan(playerTurn, turn));
// Tokens starting game in play should suffer from Sum. Sickness
for (final Card c : playerTurn.getCardsIncludePhasingIn(ZoneType.Battlefield)) {
if (playerTurn.getTurn() > 0 || !c.isStartsGameInPlay()) {
c.setSickness(false);
}
}
playerTurn.incrementTurn();
game.getAction().resetActivationsPerTurn();
final List<Card> lands = CardLists.filter(playerTurn.getLandsInPlay(), Presets.UNTAPPED);
playerTurn.setNumPowerSurgeLands(lands.size());
}
//update tokens
game.fireEvent(new GameEventTokenStateUpdate(playerTurn.getTokensInPlay()));
// Replacement effects
final Map<AbilityKey, Object> repRunParams = AbilityKey.mapFromAffected(playerTurn);
repRunParams.put(AbilityKey.Phase, phase.nameForScripts);
......@@ -206,32 +230,7 @@ public class PhaseHandler implements java.io.Serializable {
}
}
game.getStack().clearUndoStack(); //can't undo action from previous phase
String phaseType = oldPhase == phase ? "Repeat" : phase == PhaseType.getNext(oldPhase, isTopsy) ? "" : "Additional";
if (turnEnded) {
turn++;
extraPhases.clear();
game.updateTurnForView();
game.fireEvent(new GameEventTurnBegan(playerTurn, turn));
// Tokens starting game in play should suffer from Sum. Sickness
for (final Card c : playerTurn.getCardsIncludePhasingIn(ZoneType.Battlefield)) {
if (playerTurn.getTurn() > 0 || !c.isStartsGameInPlay()) {
c.setSickness(false);
}
}
playerTurn.incrementTurn();
game.getAction().resetActivationsPerTurn();
final List<Card> lands = CardLists.filter(playerTurn.getLandsInPlay(), Presets.UNTAPPED);
playerTurn.setNumPowerSurgeLands(lands.size());
}
//update tokens
game.fireEvent(new GameEventTokenStateUpdate(playerTurn.getTokensInPlay()));
game.fireEvent(new GameEventTurnPhase(playerTurn, phase, phaseType));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment