diff --git a/Mage/src/mage/Mana.java b/Mage/src/mage/Mana.java index 337b619421..0d7e66948f 100644 --- a/Mage/src/mage/Mana.java +++ b/Mage/src/mage/Mana.java @@ -210,7 +210,9 @@ public class Mana implements Comparable, Serializable, Copyable { @Override public String toString() { StringBuilder sbMana = new StringBuilder(); - + if (colorless > 0) { + sbMana.append("{").append(Integer.toString(colorless)).append("}"); + } for (int i = 0; i < red; i++) { sbMana.append("{R}"); } @@ -220,18 +222,15 @@ public class Mana implements Comparable, Serializable, Copyable { for (int i = 0; i < blue; i++) { sbMana.append("{U}"); } - for (int i = 0; i < black; i++) { - sbMana.append("{B}"); - } for (int i = 0; i < white; i++) { sbMana.append("{W}"); } + for (int i = 0; i < black; i++) { + sbMana.append("{B}"); + } for (int i = 0; i < any; i++) { sbMana.append("{Any}"); } - if (colorless > 0) { - sbMana.append("{").append(Integer.toString(colorless)).append("}"); - } return sbMana.toString(); } diff --git a/Mage/src/mage/constants/PlayerAction.java b/Mage/src/mage/constants/PlayerAction.java index 6763936ad9..cf0fc62ea3 100644 --- a/Mage/src/mage/constants/PlayerAction.java +++ b/Mage/src/mage/constants/PlayerAction.java @@ -37,6 +37,7 @@ public enum PlayerAction { PASS_PRIORITY_UNTIL_TURN_END_STEP, PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, PASS_PRIORITY_UNTIL_NEXT_TURN, + PASS_PRIORITY_UNTIL_STACK_RESOLVED, PASS_PRIORITY_CANCEL_ALL_ACTIONS, UNDO, CONCEDE, diff --git a/Mage/src/mage/game/stack/SpellStack.java b/Mage/src/mage/game/stack/SpellStack.java index 950254b930..305c062535 100644 --- a/Mage/src/mage/game/stack/SpellStack.java +++ b/Mage/src/mage/game/stack/SpellStack.java @@ -29,6 +29,7 @@ package mage.game.stack; import java.util.ArrayDeque; +import java.util.Date; import java.util.UUID; import mage.MageObject; import mage.constants.Zone; @@ -41,6 +42,8 @@ import mage.game.events.GameEvent; */ public class SpellStack extends ArrayDeque { + protected Date dateLastAdded; + public SpellStack () {} public SpellStack(final SpellStack stack) { @@ -123,4 +126,15 @@ public class SpellStack extends ArrayDeque { public SpellStack copy() { return new SpellStack(this); } + + @Override + public void push(StackObject e) { + super.push(e); + this.dateLastAdded = new Date(); + } + + public Date getDateLastAdded() { + return dateLastAdded; + } + } diff --git a/Mage/src/mage/players/Player.java b/Mage/src/mage/players/Player.java index b52be777e2..f035786493 100644 --- a/Mage/src/mage/players/Player.java +++ b/Mage/src/mage/players/Player.java @@ -127,6 +127,7 @@ public interface Player extends MageItem, Copyable { boolean getPassedTurn(); boolean getPassedUntilEndOfTurn(); boolean getPassedUntilNextMain(); + boolean getPassedUntilStackResolved(); boolean getPassedAllTurns(); boolean hasLost(); diff --git a/Mage/src/mage/players/PlayerImpl.java b/Mage/src/mage/players/PlayerImpl.java index 7bc077b121..485a277843 100644 --- a/Mage/src/mage/players/PlayerImpl.java +++ b/Mage/src/mage/players/PlayerImpl.java @@ -30,6 +30,7 @@ package mage.players; import java.io.Serializable; import java.util.ArrayList; +import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -159,6 +160,8 @@ public abstract class PlayerImpl implements Player, Serializable { protected boolean passedTurn; // F4 protected boolean passedUntilEndOfTurn; // F5 protected boolean passedUntilNextMain; // F6 + protected boolean passedUntilStackResolved; // F8 + protected Date dateLastAddedToStack; // F8 protected boolean skippedAtLeastOnce; // used to track if passed started in specific phase /** * This indicates that player passed all turns until his own turn starts (F9). @@ -293,6 +296,8 @@ public abstract class PlayerImpl implements Player, Serializable { this.passedUntilEndOfTurn = player.passedUntilEndOfTurn; this.passedUntilNextMain = player.passedUntilNextMain; this.skippedAtLeastOnce = player.skippedAtLeastOnce; + this.passedUntilStackResolved = player.passedUntilStackResolved; + this.dateLastAddedToStack = player.dateLastAddedToStack; this.passedAllTurns = player.passedAllTurns; this.priorityTimeLeft = player.getPriorityTimeLeft(); @@ -404,6 +409,7 @@ public abstract class PlayerImpl implements Player, Serializable { this.passedUntilEndOfTurn = false; this.passedUntilNextMain = false; this.skippedAtLeastOnce = false; + this.passedUntilStackResolved = false; this.passedAllTurns = false; this.canGainLife = true; this.canLoseLife = true; @@ -1708,6 +1714,7 @@ public abstract class PlayerImpl implements Player, Serializable { passedUntilEndOfTurn = false; passedTurn = false; passedAllTurns = true; + passedUntilStackResolved = false; this.skip(); break; case PASS_PRIORITY_UNTIL_TURN_END_STEP: // F5 @@ -1715,6 +1722,7 @@ public abstract class PlayerImpl implements Player, Serializable { passedTurn = false; passedAllTurns = false; passedUntilEndOfTurn = true; + passedUntilStackResolved = false; skippedAtLeastOnce = !game.getTurn().getStepType().equals(PhaseStep.END_TURN); this.skip(); break; @@ -1722,6 +1730,7 @@ public abstract class PlayerImpl implements Player, Serializable { passedUntilNextMain = false; passedAllTurns = false; passedUntilEndOfTurn = false; + passedUntilStackResolved = false; passedTurn = true; this.skip(); break; @@ -1730,14 +1739,25 @@ public abstract class PlayerImpl implements Player, Serializable { passedTurn = false; passedUntilEndOfTurn = false; passedUntilNextMain = true; + passedUntilStackResolved = false; skippedAtLeastOnce = !(game.getTurn().getStepType().equals(PhaseStep.POSTCOMBAT_MAIN) || game.getTurn().getStepType().equals(PhaseStep.PRECOMBAT_MAIN)); this.skip(); break; + case PASS_PRIORITY_UNTIL_STACK_RESOLVED: //F8 + passedAllTurns = false; + passedTurn = false; + passedUntilEndOfTurn = false; + passedUntilNextMain = false; + passedUntilStackResolved = true; + dateLastAddedToStack = game.getStack().getDateLastAdded(); + this.skip(); + break; case PASS_PRIORITY_CANCEL_ALL_ACTIONS: passedAllTurns = false; passedTurn = false; passedUntilEndOfTurn = false; passedUntilNextMain = false; + passedUntilStackResolved = false; } logger.trace("PASS Priority: " + playerAction.toString()); } @@ -2683,5 +2703,10 @@ public abstract class PlayerImpl implements Player, Serializable { public boolean getPassedTurn() { return passedTurn; } + + @Override + public boolean getPassedUntilStackResolved() { + return passedUntilStackResolved; + } }