From 05dfac125034e3aeab488f50c8a4660be4dae42c Mon Sep 17 00:00:00 2001
From: slapshot5
Date: Tue, 17 Jan 2012 02:55:29 +0000
Subject: [PATCH] rename Phase.java to PhaseHandler.java (matches other
TriggerHandler, etc.) and updated all calling classes. Remade the Phase
class as a superclass for Untap, Upkeep, EndOfTurn, EndOfCombat to
consolidate some code.
---
.gitattributes | 3 +-
src/main/java/forge/AllZone.java | 8 +-
src/main/java/forge/Card.java | 10 +-
src/main/java/forge/Combat.java | 10 +-
src/main/java/forge/CombatUtil.java | 8 +-
src/main/java/forge/ComputerAIGeneral.java | 22 +-
src/main/java/forge/ComputerAIInput.java | 4 +-
src/main/java/forge/ComputerUtilAttack.java | 4 +-
src/main/java/forge/DefaultPlayerZone.java | 4 +-
src/main/java/forge/EndOfCombat.java | 63 +-
src/main/java/forge/EndOfTurn.java | 69 +-
src/main/java/forge/GameAction.java | 24 +-
src/main/java/forge/GameActionUtil.java | 4 +-
src/main/java/forge/GuiDisplayUtil.java | 8 +-
src/main/java/forge/GuiInput.java | 2 +-
src/main/java/forge/MagicStack.java | 16 +-
src/main/java/forge/MyObservable.java | 8 +-
src/main/java/forge/Phase.java | 983 +---------------
src/main/java/forge/PhaseHandler.java | 1023 +++++++++++++++++
src/main/java/forge/PhaseUtil.java | 374 +-----
src/main/java/forge/Player.java | 4 +-
src/main/java/forge/Untap.java | 382 +++++-
src/main/java/forge/Upkeep.java | 124 +-
.../card/abilityfactory/AbilityFactory.java | 9 +-
.../AbilityFactoryAlterLife.java | 8 +-
.../abilityfactory/AbilityFactoryAnimate.java | 12 +-
.../abilityfactory/AbilityFactoryAttach.java | 2 +-
.../AbilityFactoryChangeZone.java | 14 +-
.../abilityfactory/AbilityFactoryCombat.java | 22 +-
.../abilityfactory/AbilityFactoryCopy.java | 2 +-
.../AbilityFactoryCounters.java | 6 +-
.../AbilityFactoryDealDamage.java | 14 +-
.../abilityfactory/AbilityFactoryDebuff.java | 6 +-
.../abilityfactory/AbilityFactoryEffect.java | 10 +-
.../AbilityFactoryGainControl.java | 2 +-
.../AbilityFactoryPermanentState.java | 6 +-
.../AbilityFactoryPreventDamage.java | 8 +-
.../AbilityFactoryProtection.java | 18 +-
.../abilityfactory/AbilityFactoryPump.java | 40 +-
.../AbilityFactoryRegenerate.java | 8 +-
.../abilityfactory/AbilityFactoryReveal.java | 2 +-
.../abilityfactory/AbilityFactoryToken.java | 10 +-
.../abilityfactory/AbilityFactoryTurns.java | 2 +-
.../AbilityFactoryZoneAffecting.java | 16 +-
.../cardfactory/CardFactoryEquipment.java | 4 +-
.../card/cardfactory/CardFactoryInstants.java | 4 +-
.../card/cardfactory/CardFactoryLands.java | 4 +-
.../cardfactory/CardFactoryPlaneswalkers.java | 18 +-
.../cardfactory/CardFactorySorceries.java | 6 +-
.../card/cardfactory/CardFactoryUtil.java | 22 +-
src/main/java/forge/card/cost/CostMana.java | 4 +-
.../java/forge/card/spellability/Spell.java | 4 +-
.../spellability/SpellAbilityCondition.java | 12 +-
.../spellability/SpellAbilityRestriction.java | 14 +-
.../card/spellability/SpellPermanent.java | 2 +-
.../card/staticability/StaticAbility.java | 8 +-
.../StaticAbilityCantBeCast.java | 4 +-
src/main/java/forge/card/trigger/Trigger.java | 8 +-
.../forge/card/trigger/TriggerHandler.java | 4 +-
.../java/forge/control/ControlMatchUI.java | 2 +-
.../forge/control/match/ControlInput.java | 6 +-
src/main/java/forge/gui/input/Input.java | 6 +-
.../java/forge/gui/input/InputAttack.java | 6 +-
src/main/java/forge/gui/input/InputBlock.java | 2 +-
.../java/forge/gui/input/InputCleanup.java | 8 +-
.../java/forge/gui/input/InputControl.java | 22 +-
.../java/forge/gui/input/InputMulligan.java | 8 +-
.../forge/gui/input/InputPassPriority.java | 10 +-
.../forge/gui/input/InputPayManaCost.java | 6 +-
src/main/java/forge/model/FGameState.java | 22 +-
.../forge/quest/data/pet/QuestPetPlant.java | 2 +-
.../java/forge/view/match/ViewWinLose.java | 4 +-
.../{PhaseTest.java => PhaseHandlerTest.java} | 6 +-
73 files changed, 1762 insertions(+), 1840 deletions(-)
create mode 100644 src/main/java/forge/PhaseHandler.java
rename src/test/java/forge/{PhaseTest.java => PhaseHandlerTest.java} (81%)
diff --git a/.gitattributes b/.gitattributes
index ae935c28ac3..0d81ea52412 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -10711,6 +10711,7 @@ src/main/java/forge/MyObservable.java svneol=native#text/plain
src/main/java/forge/MyRandom.java svneol=native#text/plain
src/main/java/forge/NameChanger.java svneol=native#text/plain
src/main/java/forge/Phase.java svneol=native#text/plain
+src/main/java/forge/PhaseHandler.java -text
src/main/java/forge/PhaseUtil.java svneol=native#text/plain
src/main/java/forge/Player.java svneol=native#text/plain
src/main/java/forge/PlayerType.java svneol=native#text/plain
@@ -11150,7 +11151,7 @@ src/test/java/forge/GuiMultipleBlockers4Test.java svneol=native#text/plain
src/test/java/forge/GuiProgressBarWindowTest.java svneol=native#text/plain
src/test/java/forge/GuiQuestOptionsTest.java svneol=native#text/plain
src/test/java/forge/PanelTest.java svneol=native#text/plain
-src/test/java/forge/PhaseTest.java svneol=native#text/plain
+src/test/java/forge/PhaseHandlerTest.java -text
src/test/java/forge/RunTest.java svneol=native#text/plain
src/test/java/forge/TinyTest.java svneol=native#text/plain
src/test/java/forge/card/cardFactory/CardFactoryTest.java svneol=native#text/plain
diff --git a/src/main/java/forge/AllZone.java b/src/main/java/forge/AllZone.java
index 186ebb41bd0..b76d2004595 100644
--- a/src/main/java/forge/AllZone.java
+++ b/src/main/java/forge/AllZone.java
@@ -289,19 +289,19 @@ public final class AllZone {
/**
*
- * getPhase.
+ * getPhaseHandler.
*
*
* Will eventually be marked deprecated.
*
- * @return a {@link forge.Phase} object; may be null.
+ * @return a {@link forge.PhaseHandler} object; may be null.
* @since 1.0.15
*/
- public static Phase getPhase() {
+ public static PhaseHandler getPhaseHandler() {
final FGameState gameState = Singletons.getModel().getGameState();
if (gameState != null) {
- return gameState.getPhase();
+ return gameState.getPhaseHandler();
}
return null;
diff --git a/src/main/java/forge/Card.java b/src/main/java/forge/Card.java
index f7684709bfd..5b3a1043b18 100644
--- a/src/main/java/forge/Card.java
+++ b/src/main/java/forge/Card.java
@@ -306,9 +306,9 @@ public class Card extends GameEntity implements Comparable {
}
/**
- * Sets wether or not this card is transformable, but non-flip and not doublefaced.
+ * Sets whether or not this card is transformable, but non-flip and not double-faced.
*
- * @param isTransformable0
+ * @param otherTransformable0 a String
*/
public final void setTransformable(final String otherTransformable0) {
this.otherTransformable = otherTransformable0;
@@ -1598,7 +1598,7 @@ public class Card extends GameEntity implements Comparable {
// set activating player for base spell ability
c.getSpellAbility()[0].setActivatingPlayer(c.getOwner());
// Any trigger should cause the phase not to skip
- AllZone.getPhase().setSkipPhase(false);
+ AllZone.getPhaseHandler().setSkipPhase(false);
AllZone.getGameAction().playCardNoCost(c);
}
}
@@ -6927,11 +6927,11 @@ public class Card extends GameEntity implements Comparable {
return false;
}
} else if (property.startsWith("enteredBattlefieldThisTurn")) {
- if (!(this.getTurnInZone() == AllZone.getPhase().getTurn())) {
+ if (!(this.getTurnInZone() == AllZone.getPhaseHandler().getTurn())) {
return false;
}
} else if (property.startsWith("notEnteredBattlefieldThisTurn")) {
- if (this.getTurnInZone() == AllZone.getPhase().getTurn()) {
+ if (this.getTurnInZone() == AllZone.getPhaseHandler().getTurn()) {
return false;
}
} else if (property.startsWith("dealtDamageToYouThisTurn")) {
diff --git a/src/main/java/forge/Combat.java b/src/main/java/forge/Combat.java
index b32326770c0..f70764be530 100644
--- a/src/main/java/forge/Combat.java
+++ b/src/main/java/forge/Combat.java
@@ -90,7 +90,7 @@ public class Combat {
this.currentDefender = 0;
this.nextDefender = 0;
- this.initiatePossibleDefenders(AllZone.getPhase().getPlayerTurn().getOpponent());
+ this.initiatePossibleDefenders(AllZone.getPhaseHandler().getPlayerTurn().getOpponent());
}
/**
@@ -242,7 +242,7 @@ public class Combat {
if (this.attackingPlayer != null) {
return this.attackingPlayer;
} else {
- return AllZone.getPhase().getPlayerTurn();
+ return AllZone.getPhaseHandler().getPlayerTurn();
}
}
@@ -257,7 +257,7 @@ public class Combat {
if (this.attackingPlayer != null) {
return this.defendingPlayer;
} else {
- return AllZone.getPhase().getPlayerTurn().getOpponent();
+ return AllZone.getPhaseHandler().getPlayerTurn().getOpponent();
}
}
@@ -622,7 +622,7 @@ public class Combat {
// TODO if Declare Blockers and Declare Blockers (Abilities)
// merge this logic needs to be tweaked
if ((this.getBlockers(a).size() == 0)
- && AllZone.getPhase().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS)) {
+ && AllZone.getPhaseHandler().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS)) {
this.blocked.remove(a);
}
}
@@ -859,7 +859,7 @@ public class Combat {
// This function handles both Regular and First Strike combat assignment
final Player player = AllZone.getCombat().getDefendingPlayer();
- final boolean bFirstStrike = AllZone.getPhase().is(Constant.Phase.COMBAT_FIRST_STRIKE_DAMAGE);
+ final boolean bFirstStrike = AllZone.getPhaseHandler().is(Constant.Phase.COMBAT_FIRST_STRIKE_DAMAGE);
final HashMap defMap = AllZone.getCombat().getDefendingDamageMap();
diff --git a/src/main/java/forge/CombatUtil.java b/src/main/java/forge/CombatUtil.java
index 1ba7017a783..5f8e8a483ca 100644
--- a/src/main/java/forge/CombatUtil.java
+++ b/src/main/java/forge/CombatUtil.java
@@ -863,7 +863,7 @@ public class CombatUtil {
}
// The creature won't untap next turn
- if (c.isTapped() && !PhaseUtil.canUntap(c)) {
+ if (c.isTapped() && !Untap.canUntap(c)) {
return false;
}
@@ -2234,7 +2234,7 @@ public class CombatUtil {
final Card crd = c;
- final String phase = AllZone.getPhase().getPhase();
+ final String phase = AllZone.getPhaseHandler().getPhase();
if (phase.equals(Constant.Phase.COMBAT_DECLARE_ATTACKERS)
|| phase.equals(Constant.Phase.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)) {
@@ -2684,7 +2684,7 @@ public class CombatUtil {
final Player phasingPlayer = c.getController();
// Finest Hour untaps the creature on the first combat phase
if ((phasingPlayer.getCardsIn(Zone.Battlefield, "Finest Hour").size() > 0)
- && AllZone.getPhase().isFirstCombat()) {
+ && AllZone.getPhaseHandler().isFirstCombat()) {
// Untap the attacking creature
final Ability fhUntap = new Ability(c, "0") {
@Override
@@ -2704,7 +2704,7 @@ public class CombatUtil {
final Ability fhAddCombat = new Ability(c, "0") {
@Override
public void resolve() {
- AllZone.getPhase().addExtraCombat();
+ AllZone.getPhaseHandler().addExtraCombat();
}
};
diff --git a/src/main/java/forge/ComputerAIGeneral.java b/src/main/java/forge/ComputerAIGeneral.java
index 027b853d727..e65f395d861 100644
--- a/src/main/java/forge/ComputerAIGeneral.java
+++ b/src/main/java/forge/ComputerAIGeneral.java
@@ -93,7 +93,7 @@ public class ComputerAIGeneral implements Computer {
final boolean nextPhase = ComputerUtil.playSpellAbilities(sp);
if (nextPhase) {
- AllZone.getPhase().passPriority();
+ AllZone.getPhaseHandler().passPriority();
}
} // playCards()
@@ -248,7 +248,7 @@ public class ComputerAIGeneral implements Computer {
public boolean addCard(final Card c) {
if (c.isPermanent()
&& c.hasKeyword("Flash")
- && (AllZone.getPhase().isPlayerTurn(AllZone.getComputerPlayer()) || AllZone.getPhase()
+ && (AllZone.getPhaseHandler().isPlayerTurn(AllZone.getComputerPlayer()) || AllZone.getPhaseHandler()
.isBefore(Constant.Phase.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY))) {
return false;
}
@@ -299,7 +299,7 @@ public class ComputerAIGeneral implements Computer {
public boolean addCard(final Card c) {
if (c.isPermanent()
&& c.hasKeyword("Flash")
- && (AllZone.getPhase().isPlayerTurn(AllZone.getComputerPlayer()) || AllZone.getPhase()
+ && (AllZone.getPhaseHandler().isPlayerTurn(AllZone.getComputerPlayer()) || AllZone.getPhaseHandler()
.isBefore(Constant.Phase.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY))) {
return false;
}
@@ -442,7 +442,7 @@ public class ComputerAIGeneral implements Computer {
final Card[] att = AllZone.getCombat().getAttackers();
if (att.length > 0) {
- AllZone.getPhase().setCombat(true);
+ AllZone.getPhaseHandler().setCombat(true);
}
for (final Card element : att) {
@@ -457,7 +457,7 @@ public class ComputerAIGeneral implements Computer {
AllZone.getComputerPlayer().getZone(Zone.Battlefield).updateObservers();
CombatUtil.showCombat();
- AllZone.getPhase().setNeedToNextPhase(true);
+ AllZone.getPhaseHandler().setNeedToNextPhase(true);
}
/**
@@ -483,7 +483,7 @@ public class ComputerAIGeneral implements Computer {
CombatUtil.showCombat();
- AllZone.getPhase().setNeedToNextPhase(true);
+ AllZone.getPhaseHandler().setNeedToNextPhase(true);
}
/**
@@ -538,13 +538,13 @@ public class ComputerAIGeneral implements Computer {
if (AllZone.getStack().size() == 0) {
boolean pass = (sas.length == 0)
- || AllZone.getPhase().is(Constant.Phase.END_OF_TURN, AllZone.getComputerPlayer());
+ || AllZone.getPhaseHandler().is(Constant.Phase.END_OF_TURN, AllZone.getComputerPlayer());
if (!pass) { // Each AF should check the phase individually
pass = ComputerUtil.playSpellAbilities(sas);
}
if (pass) {
- AllZone.getPhase().passPriority();
+ AllZone.getPhaseHandler().passPriority();
}
return;
}
@@ -553,7 +553,7 @@ public class ComputerAIGeneral implements Computer {
if (AllZone.getStack().peekInstance().getActivatingPlayer().isComputer()) {
// probably should let my stuff resolve to force Human to respond to
// it
- AllZone.getPhase().passPriority();
+ AllZone.getPhaseHandler().passPriority();
return;
}
@@ -571,7 +571,7 @@ public class ComputerAIGeneral implements Computer {
possibleCounters = this.getPossibleETBCounters();
if ((possibleCounters.size() > 0) && !ComputerUtil.playAbilities(possibleCounters)) {
// Responding Permanent w/ ETB Counter is on the Stack
- // AllZone.getPhase().passPriority();
+ // AllZone.getPhaseHandler().passPriority();
return;
}
@@ -582,6 +582,6 @@ public class ComputerAIGeneral implements Computer {
}
}
// if this hasn't been covered above, just PassPriority()
- AllZone.getPhase().passPriority();
+ AllZone.getPhaseHandler().passPriority();
}
}
diff --git a/src/main/java/forge/ComputerAIInput.java b/src/main/java/forge/ComputerAIInput.java
index 2ff706a3d89..e47b37d3ce0 100644
--- a/src/main/java/forge/ComputerAIInput.java
+++ b/src/main/java/forge/ComputerAIInput.java
@@ -64,7 +64,7 @@ public class ComputerAIInput extends Input {
/*
* //put this back in ButtonUtil.disableAll();
* AllZone.getDisplay().showMessage("Phase: " +
- * AllZone.getPhase().getPhase() + "\nAn error may have occurred. Please
+ * AllZone.getPhaseHandler().getPhase() + "\nAn error may have occurred. Please
* send the \"Stack Report\" and the
* \"Detailed Error Trace\" to the Forge forum.");
*/
@@ -89,7 +89,7 @@ public class ComputerAIInput extends Input {
*/
private void think() {
// TODO instead of setNextPhase, pass priority
- final String phase = AllZone.getPhase().getPhase();
+ final String phase = AllZone.getPhaseHandler().getPhase();
if (AllZone.getStack().size() > 0) {
this.computer.stackNotEmpty();
diff --git a/src/main/java/forge/ComputerUtilAttack.java b/src/main/java/forge/ComputerUtilAttack.java
index 611483356ff..53834b78860 100644
--- a/src/main/java/forge/ComputerUtilAttack.java
+++ b/src/main/java/forge/ComputerUtilAttack.java
@@ -426,7 +426,7 @@ public class ComputerUtilAttack {
// randomInt is used so that the computer doesn't always
// do the same thing on turn 3 if he had the same creatures in play
// I know this is a little confusing
- this.random.setSeed(AllZone.getPhase().getTurn() + this.randomInt);
+ this.random.setSeed(AllZone.getPhaseHandler().getTurn() + this.randomInt);
final Combat combat = new Combat();
combat.setAttackingPlayer(AllZone.getCombat().getAttackingPlayer());
@@ -653,7 +653,7 @@ public class ComputerUtilAttack {
|| AllZoneUtil.isCardInPlay("Rafiq of the Many", AllZone.getComputerPlayer())
|| (AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield, "Battlegrace Angel").size() >= 2) || ((AllZone
.getComputerPlayer().getCardsIn(Zone.Battlefield, "Finest Hour").size() >= 1) && AllZone
- .getPhase().isFirstCombat())) && !bAssault) {
+ .getPhaseHandler().isFirstCombat())) && !bAssault) {
int biggest = 0;
Card att = null;
for (int i = 0; i < attackersLeft.size(); i++) {
diff --git a/src/main/java/forge/DefaultPlayerZone.java b/src/main/java/forge/DefaultPlayerZone.java
index 5f39a73a84d..6798f28ff24 100644
--- a/src/main/java/forge/DefaultPlayerZone.java
+++ b/src/main/java/forge/DefaultPlayerZone.java
@@ -102,7 +102,7 @@ public class DefaultPlayerZone extends PlayerZone implements java.io.Serializabl
c.addObserver(this);
- c.setTurnInZone(AllZone.getPhase().getTurn());
+ c.setTurnInZone(AllZone.getPhaseHandler().getTurn());
if (!this.is(Zone.Battlefield) && c.isTapped()) {
AllZone.getTriggerHandler().suppressMode("Untaps");
@@ -156,7 +156,7 @@ public class DefaultPlayerZone extends PlayerZone implements java.io.Serializabl
}
this.getCardList().add(index, c);
- c.setTurnInZone(AllZone.getPhase().getTurn());
+ c.setTurnInZone(AllZone.getPhaseHandler().getTurn());
this.update();
}
diff --git a/src/main/java/forge/EndOfCombat.java b/src/main/java/forge/EndOfCombat.java
index 82dfb494030..c5fe664782e 100644
--- a/src/main/java/forge/EndOfCombat.java
+++ b/src/main/java/forge/EndOfCombat.java
@@ -25,70 +25,9 @@ package forge;
* @author Forge
* @version $Id$
*/
-public class EndOfCombat implements java.io.Serializable {
+public class EndOfCombat extends Phase implements java.io.Serializable {
/** Constant serialVersionUID=3035250030566186842L. */
private static final long serialVersionUID = 3035250030566186842L;
- private final CommandList at = new CommandList();
- private final CommandList until = new CommandList();
-
- /**
- *
- * Add a hardcoded trigger that will execute "at end of combat".
- *
- *
- * @param c
- * a {@link forge.Command} object.
- */
- public final void addAt(final Command c) {
- this.at.add(c);
- }
-
- /**
- *
- * Add a Command that will terminate an effect with "until end of combat".
- *
- *
- * @param c
- * a {@link forge.Command} object.
- */
- public final void addUntil(final Command c) {
- this.until.add(c);
- }
-
- /**
- *
- * Executes any hardcoded triggers that happen "at end of combat".
- *
- */
- public final void executeAt() {
- this.execute(this.at);
- }
-
- /**
- *
- * Executes the termination of effects that apply "until end of combat".
- *
- */
- public final void executeUntil() {
- this.execute(this.until);
- }
-
- /**
- *
- * execute.
- *
- *
- * @param c
- * a {@link forge.CommandList} object.
- */
- private void execute(final CommandList c) {
- final int length = c.size();
-
- for (int i = 0; i < length; i++) {
- c.remove(0).execute();
- }
- }
-
} // end class EndOfCombat
diff --git a/src/main/java/forge/EndOfTurn.java b/src/main/java/forge/EndOfTurn.java
index c1cc994a05c..0a1447488bf 100644
--- a/src/main/java/forge/EndOfTurn.java
+++ b/src/main/java/forge/EndOfTurn.java
@@ -30,42 +30,16 @@ import forge.gui.GuiUtils;
* @author Forge
* @version $Id$
*/
-public class EndOfTurn implements java.io.Serializable {
+public class EndOfTurn extends Phase implements java.io.Serializable {
/** Constant serialVersionUID=-3656715295379727275L. */
private static final long serialVersionUID = -3656715295379727275L;
- private final CommandList at = new CommandList();
- private final CommandList until = new CommandList();
-
- /**
- *
- * Add a Command that will act as a trigger for "at end of turn".
- *
- *
- * @param c
- * a {@link forge.Command} object.
- */
- public final void addAt(final Command c) {
- this.at.add(c);
- }
-
- /**
- *
- * Add a Command that will terminate an effect with "until end of turn".
- *
- *
- * @param c
- * a {@link forge.Command} object.
- */
- public final void addUntil(final Command c) {
- this.until.add(c);
- }
-
/**
*
* Handles all the hardcoded events that happen "at end of turn".
*
*/
+ @Override
public final void executeAt() {
// TODO - should this freeze the Stack?
@@ -77,7 +51,7 @@ public class EndOfTurn implements java.io.Serializable {
EndOfTurn.endOfTurnLighthouseChronologist();
// reset mustAttackEntity for me
- AllZone.getPhase().getPlayerTurn().setMustAttackEntity(null);
+ AllZone.getPhaseHandler().getPlayerTurn().setMustAttackEntity(null);
EndOfTurn.removeAttackedBlockedThisTurn();
@@ -182,7 +156,7 @@ public class EndOfTurn implements java.io.Serializable {
}
if (c.getName().equals("Erg Raiders") && !c.getCreatureAttackedThisTurn() && !c.hasSickness()
- && AllZone.getPhase().isPlayerTurn(c.getController())) {
+ && AllZone.getPhaseHandler().isPlayerTurn(c.getController())) {
final Card raider = c;
final SpellAbility change = new Ability(raider, "0") {
@Override
@@ -200,7 +174,7 @@ public class EndOfTurn implements java.io.Serializable {
}
if (c.hasKeyword("At the beginning of your end step, return CARDNAME to its owner's hand.")
- && AllZone.getPhase().isPlayerTurn(c.getController())) {
+ && AllZone.getPhaseHandler().isPlayerTurn(c.getController())) {
final Card source = c;
final SpellAbility change = new Ability(source, "0") {
@Override
@@ -224,33 +198,8 @@ public class EndOfTurn implements java.io.Serializable {
} // executeAt()
- /**
- *
- * Executes the termination of effects that apply "until end of turn".
- *
- */
- public final void executeUntil() {
- this.execute(this.until);
- }
-
- /**
- *
- * Executes each Command in a CommandList.
- *
- *
- * @param c
- * a {@link forge.CommandList} object.
- */
- private void execute(final CommandList c) {
- final int length = c.size();
-
- for (int i = 0; i < length; i++) {
- c.remove(0).execute();
- }
- }
-
private static void endOfTurnWallOfReverence() {
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
final CardList list = player.getCardsIn(Zone.Battlefield, "Wall of Reverence");
Ability ability;
@@ -294,7 +243,7 @@ public class EndOfTurn implements java.io.Serializable {
} // endOfTurnWallOfReverence()
private static void endOfTurnLighthouseChronologist() {
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
final Player opponent = player.getOpponent();
CardList list = opponent.getCardsIn(Zone.Battlefield);
@@ -311,7 +260,7 @@ public class EndOfTurn implements java.io.Serializable {
ability = new Ability(list.get(i), "0") {
@Override
public void resolve() {
- AllZone.getPhase().addExtraTurn(card.getController());
+ AllZone.getPhaseHandler().addExtraTurn(card.getController());
}
};
@@ -326,7 +275,7 @@ public class EndOfTurn implements java.io.Serializable {
private static void removeAttackedBlockedThisTurn() {
// resets the status of attacked/blocked this turn
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
final CardList list = AllZoneUtil.getCreaturesInPlay(player);
for (int i = 0; i < list.size(); i++) {
diff --git a/src/main/java/forge/GameAction.java b/src/main/java/forge/GameAction.java
index d3e75a77a17..a4be05edc06 100644
--- a/src/main/java/forge/GameAction.java
+++ b/src/main/java/forge/GameAction.java
@@ -1567,10 +1567,10 @@ public class GameAction {
((GuiTopLevel) (AllZone.getDisplay())).getController().getMatchView().getInputController().updateGameCount();
AllZone.getInputControl().setInput(new InputMulligan());
- Phase.setGameBegins(1);
+ PhaseHandler.setGameBegins(1);
- AllZone.getGameLog().add("Turn", "Turn " + AllZone.getPhase().getTurn()
- + " (" + AllZone.getPhase().getPlayerTurn() + ")", 0);
+ AllZone.getGameLog().add("Turn", "Turn " + AllZone.getPhaseHandler().getTurn()
+ + " (" + AllZone.getPhaseHandler().getPlayerTurn() + ")", 0);
} // newGame()
// this is where the computer cheats
@@ -1849,7 +1849,7 @@ public class GameAction {
*/
public final void computerStartsGame() {
final Player computer = AllZone.getComputerPlayer();
- AllZone.getPhase().setPlayerTurn(computer);
+ AllZone.getPhaseHandler().setPlayerTurn(computer);
// AllZone.getGameInfo().setPlayerWhoGotFirstTurn(computer.getName());
}
@@ -2090,13 +2090,13 @@ public class GameAction {
originalCard.setXManaCostPaid(0);
}
- if (Phase.getGameBegins() != 1) {
+ if (PhaseHandler.getGameBegins() != 1) {
return manaCost;
}
if (spell.isSpell()) {
if (originalCard.getName().equals("Avatar of Woe")) {
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
final Player opponent = player.getOpponent();
CardList playerCreatureList = player.getCardsIn(Zone.Graveyard);
playerCreatureList = playerCreatureList.getType("Creature");
@@ -2106,19 +2106,19 @@ public class GameAction {
manaCost = new ManaCost("B B");
} // Avatar of Woe
} else if (originalCard.getName().equals("Avatar of Will")) {
- final Player opponent = AllZone.getPhase().getPlayerTurn().getOpponent();
+ final Player opponent = AllZone.getPhaseHandler().getPlayerTurn().getOpponent();
final CardList opponentHandList = opponent.getCardsIn(Zone.Hand);
if (opponentHandList.size() == 0) {
manaCost = new ManaCost("U U");
} // Avatar of Will
} else if (originalCard.getName().equals("Avatar of Fury")) {
- final Player opponent = AllZone.getPhase().getPlayerTurn().getOpponent();
+ final Player opponent = AllZone.getPhaseHandler().getPlayerTurn().getOpponent();
final CardList opponentLand = AllZoneUtil.getPlayerLandsInPlay(opponent);
if (opponentLand.size() >= 7) {
manaCost = new ManaCost("R R");
} // Avatar of Fury
} else if (originalCard.getName().equals("Avatar of Might")) {
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
final Player opponent = player.getOpponent();
final CardList playerCreature = AllZoneUtil.getCreaturesInPlay(player);
final CardList opponentCreature = AllZoneUtil.getCreaturesInPlay(opponent);
@@ -2418,7 +2418,7 @@ public class GameAction {
}
}
if (k[7].contains("OpponentTurn")) {
- if (AllZone.getPhase().isPlayerTurn(controller)) {
+ if (AllZone.getPhaseHandler().isPlayerTurn(controller)) {
k[3] = "0";
}
}
@@ -2605,7 +2605,7 @@ public class GameAction {
}
}
if (k[7].contains("OpponentTurn")) {
- if (AllZone.getPhase().isPlayerTurn(controller)) {
+ if (AllZone.getPhaseHandler().isPlayerTurn(controller)) {
k[3] = "0";
}
}
@@ -2708,7 +2708,7 @@ public class GameAction {
}
if (originalCard.getName().equals("Khalni Hydra") && spell.isSpell()) {
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
CardList playerCreature = AllZoneUtil.getCreaturesInPlay(player);
playerCreature = playerCreature.filter(CardListFilter.GREEN);
String manaC = manaCost + " ";
diff --git a/src/main/java/forge/GameActionUtil.java b/src/main/java/forge/GameActionUtil.java
index 66ffac84763..52a5e4097bb 100644
--- a/src/main/java/forge/GameActionUtil.java
+++ b/src/main/java/forge/GameActionUtil.java
@@ -1260,12 +1260,12 @@ public final class GameActionUtil {
}
}
if (specialConditions.contains("isYourTurn")) {
- if (!AllZone.getPhase().isPlayerTurn(sourceCard.getController())) {
+ if (!AllZone.getPhaseHandler().isPlayerTurn(sourceCard.getController())) {
return false;
}
}
if (specialConditions.contains("notYourTurn")) {
- if (!AllZone.getPhase().isPlayerTurn(sourceCard.getController().getOpponent())) {
+ if (!AllZone.getPhaseHandler().isPlayerTurn(sourceCard.getController().getOpponent())) {
return false;
}
}
diff --git a/src/main/java/forge/GuiDisplayUtil.java b/src/main/java/forge/GuiDisplayUtil.java
index b2b91e41f29..4a332e7ff75 100644
--- a/src/main/java/forge/GuiDisplayUtil.java
+++ b/src/main/java/forge/GuiDisplayUtil.java
@@ -1293,15 +1293,15 @@ public final class GuiDisplayUtil {
if (!tChangePlayer.trim().toLowerCase().equals("none")) {
if (tChangePlayer.trim().toLowerCase().equals("human")) {
- AllZone.getPhase().setPlayerTurn(AllZone.getHumanPlayer());
+ AllZone.getPhaseHandler().setPlayerTurn(AllZone.getHumanPlayer());
}
if (tChangePlayer.trim().toLowerCase().equals("ai")) {
- AllZone.getPhase().setPlayerTurn(AllZone.getComputerPlayer());
+ AllZone.getPhaseHandler().setPlayerTurn(AllZone.getComputerPlayer());
}
}
if (!tChangePhase.trim().toLowerCase().equals("none")) {
- AllZone.getPhase().setDevPhaseState(tChangePhase);
+ AllZone.getPhaseHandler().setDevPhaseState(tChangePhase);
}
if (!tHumanSetupCardsInPlay.trim().toLowerCase().equals("none")) {
@@ -1402,7 +1402,7 @@ public final class GuiDisplayUtil {
}
AllZone.getGameAction().checkStateEffects();
- AllZone.getPhase().updateObservers();
+ AllZone.getPhaseHandler().updateObservers();
AllZone.getHumanPlayer().getZone(Zone.Exile).updateObservers();
AllZone.getComputerPlayer().getZone(Zone.Exile).updateObservers();
AllZone.getHumanPlayer().getZone(Zone.Hand).updateObservers();
diff --git a/src/main/java/forge/GuiInput.java b/src/main/java/forge/GuiInput.java
index 6875de181ee..d3469a67a55 100644
--- a/src/main/java/forge/GuiInput.java
+++ b/src/main/java/forge/GuiInput.java
@@ -43,7 +43,7 @@ public class GuiInput extends MyObservable implements Observer {
public GuiInput() {
AllZone.getInputControl().addObserver(this);
AllZone.getStack().addObserver(this);
- AllZone.getPhase().addObserver(this);
+ AllZone.getPhaseHandler().addObserver(this);
}
/** {@inheritDoc} */
diff --git a/src/main/java/forge/MagicStack.java b/src/main/java/forge/MagicStack.java
index 1c9d35652da..46384b64fb5 100644
--- a/src/main/java/forge/MagicStack.java
+++ b/src/main/java/forge/MagicStack.java
@@ -418,17 +418,17 @@ public class MagicStack extends MyObservable {
System.out.println(sp.getSourceCard().getName() + " - activatingPlayer not set before adding to stack.");
}
- if (AllZone.getPhase().is(Constant.Phase.CLEANUP)) { // If something
+ if (AllZone.getPhaseHandler().is(Constant.Phase.CLEANUP)) { // If something
// triggers during
// Cleanup, need to
// repeat
- AllZone.getPhase().repeatPhase();
+ AllZone.getPhaseHandler().repeatPhase();
}
// TODO: triggered abilities need to be fixed
if (!((sp instanceof AbilityTriggered) || (sp instanceof AbilityStatic))) {
// when something is added we need to setPriority
- AllZone.getPhase().setPriority(sp.getActivatingPlayer());
+ AllZone.getPhaseHandler().setPriority(sp.getActivatingPlayer());
}
if ((sp instanceof AbilityTriggered) || (sp instanceof AbilityStatic)) {
@@ -831,7 +831,7 @@ public class MagicStack extends MyObservable {
*/
if (this.getSimultaneousStackEntryList().size() > 0) {
- AllZone.getPhase().passPriority();
+ AllZone.getPhaseHandler().passPriority();
}
}
@@ -892,7 +892,7 @@ public class MagicStack extends MyObservable {
final SpellAbility sa = AllZone.getStack().pop();
- AllZone.getPhase().resetPriority(); // ActivePlayer gains priority first
+ AllZone.getPhaseHandler().resetPriority(); // ActivePlayer gains priority first
// after Resolve
final Card source = sa.getSourceCard();
@@ -1072,9 +1072,9 @@ public class MagicStack extends MyObservable {
AllZone.getGameAction().checkStateEffects();
- AllZone.getPhase().setNeedToNextPhase(false);
+ AllZone.getPhaseHandler().setNeedToNextPhase(false);
- if (AllZone.getPhase().inCombat()) {
+ if (AllZone.getPhaseHandler().inCombat()) {
CombatUtil.showCombat();
}
@@ -1314,7 +1314,7 @@ public class MagicStack extends MyObservable {
*
*/
public final void chooseOrderOfSimultaneousStackEntryAll() {
- final Player playerTurn = AllZone.getPhase().getPlayerTurn();
+ final Player playerTurn = AllZone.getPhaseHandler().getPlayerTurn();
this.chooseOrderOfSimultaneousStackEntry(playerTurn);
diff --git a/src/main/java/forge/MyObservable.java b/src/main/java/forge/MyObservable.java
index 49585cb7070..6043e36aeab 100644
--- a/src/main/java/forge/MyObservable.java
+++ b/src/main/java/forge/MyObservable.java
@@ -37,11 +37,11 @@ public class MyObservable extends Observable {
this.setChanged();
this.notifyObservers();
- if ((AllZone.getPhase() != null) && AllZone.getPhase().isNeedToNextPhase()) {
- if (AllZone.getPhase().isNeedToNextPhaseInit()) {
+ if ((AllZone.getPhaseHandler() != null) && AllZone.getPhaseHandler().isNeedToNextPhase()) {
+ if (AllZone.getPhaseHandler().isNeedToNextPhaseInit()) {
// this is used.
- AllZone.getPhase().setNeedToNextPhase(false);
- AllZone.getPhase().nextPhase();
+ AllZone.getPhaseHandler().setNeedToNextPhase(false);
+ AllZone.getPhaseHandler().nextPhase();
}
}
}
diff --git a/src/main/java/forge/Phase.java b/src/main/java/forge/Phase.java
index 57d4f625992..d0ce26e2810 100644
--- a/src/main/java/forge/Phase.java
+++ b/src/main/java/forge/Phase.java
@@ -18,12 +18,7 @@
package forge;
import java.util.HashMap;
-import java.util.Observer;
-import java.util.Stack;
-import com.esotericsoftware.minlog.Log;
-
-import forge.Constant.Zone;
/**
*
@@ -33,991 +28,107 @@ import forge.Constant.Zone;
* @author Forge
* @version $Id$
*/
-public class Phase extends MyObservable implements java.io.Serializable {
+public abstract class Phase implements java.io.Serializable {
- /** Constant serialVersionUID=5207222278370963197L. */
- private static final long serialVersionUID = 5207222278370963197L;
+ private static final long serialVersionUID = 4665309652476851977L;
- private int phaseIndex;
- private int turn;
+ protected final CommandList at = new CommandList();
+ protected final CommandList until = new CommandList();
- // Please use getX, setX, and incrementX methods instead of directly
- // accessing the following:
- /** Constant GameBegins=0. */
- private static int gameBegins = 0;
-
- private final Stack extraTurns = new Stack();
-
- private int extraCombats;
-
- private int nCombatsThisTurn;
- private boolean bPreventCombatDamageThisTurn;
-
- private Player playerTurn = AllZone.getHumanPlayer();
+ protected final HashMap untilMap = new HashMap();
/**
*
- * isPlayerTurn.
- *
- *
- * @param player
- * a {@link forge.Player} object.
- * @return a boolean.
- */
- public final boolean isPlayerTurn(final Player player) {
- return this.playerTurn.isPlayer(player);
- }
-
- /**
- *
- * Setter for the field playerTurn.
- *
- *
- * @param s
- * a {@link forge.Player} object.
- */
- public final void setPlayerTurn(final Player s) {
- this.playerTurn = s;
- }
-
- /**
- *
- * Getter for the field playerTurn.
- *
- *
- * @return a {@link forge.Player} object.
- */
- public final Player getPlayerTurn() {
- return this.playerTurn;
- }
-
- // priority player
-
- private Player pPlayerPriority = AllZone.getHumanPlayer();
-
- /**
- *
- * getPriorityPlayer.
- *
- *
- * @return a {@link forge.Player} object.
- */
- public final Player getPriorityPlayer() {
- return this.pPlayerPriority;
- }
-
- /**
- *
- * setPriorityPlayer.
+ * Add a Command that will terminate an effect with "until next ".
*
*
* @param p
- * a {@link forge.Player} object.
+ * a {@link forge.Player} object
+ * @param c
+ * a {@link forge.Command} object.
*/
- public final void setPriorityPlayer(final Player p) {
- this.pPlayerPriority = p;
- }
+ public final void addUntil(Player p, final Command c) {
+ if (null == p) {
+ p = AllZone.getPhaseHandler().getPlayerTurn();
+ }
- private Player pFirstPriority = AllZone.getHumanPlayer();
-
- /**
- *
- * getFirstPriority.
- *
- *
- * @return a {@link forge.Player} object.
- */
- public final Player getFirstPriority() {
- return this.pFirstPriority;
+ if (this.untilMap.containsKey(p)) {
+ this.untilMap.get(p).add(c);
+ } else {
+ this.untilMap.put(p, new CommandList(c));
+ }
}
/**
*
- * setFirstPriority.
+ * Executes the termination of effects that apply "until next ".
*
*
* @param p
- * a {@link forge.Player} object.
+ * the player the execute until for
*/
- public final void setFirstPriority(final Player p) {
- this.pFirstPriority = p;
- }
-
- /**
- *
- * setPriority.
- *
- *
- * @param p
- * a {@link forge.Player} object.
- */
- public final void setPriority(final Player p) {
- if (AllZone.getStack() != null) {
- AllZone.getStack().chooseOrderOfSimultaneousStackEntryAll();
- }
-
- this.pFirstPriority = p;
- this.pPlayerPriority = p;
- }
-
- /**
- *
- * resetPriority.
- *
- */
- public final void resetPriority() {
- this.setPriority(this.playerTurn);
- }
-
- private boolean bPhaseEffects = true;
-
- /**
- *
- * doPhaseEffects.
- *
- *
- * @return a boolean.
- */
- public final boolean doPhaseEffects() {
- return this.bPhaseEffects;
- }
-
- /**
- *
- * setPhaseEffects.
- *
- *
- * @param b
- * a boolean.
- */
- public final void setPhaseEffects(final boolean b) {
- this.bPhaseEffects = b;
- }
-
- private boolean bSkipPhase = true;
-
- /**
- *
- * doSkipPhase.
- *
- *
- * @return a boolean.
- */
- public final boolean doSkipPhase() {
- return this.bSkipPhase;
- }
-
- /**
- *
- * setSkipPhase.
- *
- *
- * @param b
- * a boolean.
- */
- public final void setSkipPhase(final boolean b) {
- this.bSkipPhase = b;
- }
-
- private boolean bCombat = false;
-
- /**
- *
- * inCombat.
- *
- *
- * @return a boolean.
- */
- public final boolean inCombat() {
- return this.bCombat;
- }
-
- /**
- *
- * setCombat.
- *
- *
- * @param b
- * a boolean.
- */
- public final void setCombat(final boolean b) {
- this.bCombat = b;
- }
-
- private boolean bRepeat = false;
-
- /**
- *
- * repeatPhase.
- *
- */
- public final void repeatPhase() {
- this.bRepeat = true;
- }
-
- /** The phase order. */
- private String[] phaseOrder = { Constant.Phase.UNTAP, Constant.Phase.UPKEEP, Constant.Phase.DRAW,
- Constant.Phase.MAIN1, Constant.Phase.COMBAT_BEGIN, Constant.Phase.COMBAT_DECLARE_ATTACKERS,
- Constant.Phase.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY, Constant.Phase.COMBAT_DECLARE_BLOCKERS,
- Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY, Constant.Phase.COMBAT_FIRST_STRIKE_DAMAGE,
- Constant.Phase.COMBAT_DAMAGE, Constant.Phase.COMBAT_END, Constant.Phase.MAIN2, Constant.Phase.END_OF_TURN,
- Constant.Phase.CLEANUP };
-
- /**
- *
- * Constructor for Phase.
- *
- */
- public Phase() {
- this.reset();
- }
-
- /**
- *
- * reset.
- *
- */
- public final void reset() {
- this.turn = 1;
- this.playerTurn = AllZone.getHumanPlayer();
- this.resetPriority();
- this.bPhaseEffects = true;
- this.needToNextPhase = false;
- Phase.setGameBegins(0);
- this.phaseIndex = 0;
- this.extraTurns.clear();
- this.nCombatsThisTurn = 0;
- this.extraCombats = 0;
- this.bPreventCombatDamageThisTurn = false;
- this.bCombat = false;
- this.bRepeat = false;
- this.updateObservers();
- }
-
- /**
- *
- * turnReset.
- *
- */
- public final void turnReset() {
- this.playerTurn.setNumLandsPlayed(0);
- }
-
- /**
- *
- * handleBeginPhase.
- *
- */
- public final void handleBeginPhase() {
- AllZone.getPhase().setPhaseEffects(false);
- // Handle effects that happen at the beginning of phases
- final String phase = AllZone.getPhase().getPhase();
- final Player turn = AllZone.getPhase().getPlayerTurn();
- AllZone.getPhase().setSkipPhase(true);
- AllZone.getGameAction().checkStateEffects();
-
- if (phase.equals(Constant.Phase.UNTAP)) {
- PhaseUtil.handleUntap();
- } else if (phase.equals(Constant.Phase.UPKEEP)) {
- PhaseUtil.handleUpkeep();
- } else if (phase.equals(Constant.Phase.DRAW)) {
- PhaseUtil.handleDraw();
- } else if (phase.equals(Constant.Phase.COMBAT_BEGIN)) {
- PhaseUtil.verifyCombat();
- } else if (phase.equals(Constant.Phase.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)) {
- if (this.inCombat()) {
- PhaseUtil.handleDeclareAttackers();
- } else {
- AllZone.getPhase().setNeedToNextPhase(true);
- }
- }
-
- // we can skip AfterBlockers and AfterAttackers if necessary
- else if (phase.equals(Constant.Phase.COMBAT_DECLARE_BLOCKERS)) {
- if (this.inCombat()) {
- PhaseUtil.verifyCombat();
- } else {
- AllZone.getPhase().setNeedToNextPhase(true);
- }
- } else if (phase.equals(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
- // After declare blockers are finished being declared mark them
- // blocked and trigger blocking things
- if (!this.inCombat()) {
- AllZone.getPhase().setNeedToNextPhase(true);
- } else {
- PhaseUtil.handleDeclareBlockers();
- }
- } else if (phase.equals(Constant.Phase.COMBAT_FIRST_STRIKE_DAMAGE)) {
- if (!this.inCombat()) {
- AllZone.getPhase().setNeedToNextPhase(true);
- } else {
- AllZone.getCombat().verifyCreaturesInPlay();
-
- // no first strikers, skip this step
- if (!AllZone.getCombat().setAssignedFirstStrikeDamage()) {
- AllZone.getPhase().setNeedToNextPhase(true);
- } else {
- if (!this.isPreventCombatDamageThisTurn()) {
- Combat.dealAssignedDamage();
- }
-
- AllZone.getGameAction().checkStateEffects();
- CombatUtil.showCombat();
- }
- }
- } else if (phase.equals(Constant.Phase.COMBAT_DAMAGE)) {
- if (!this.inCombat()) {
- AllZone.getPhase().setNeedToNextPhase(true);
- } else {
- AllZone.getCombat().verifyCreaturesInPlay();
-
- AllZone.getCombat().setAssignedDamage();
-
- if (!this.isPreventCombatDamageThisTurn()) {
- Combat.dealAssignedDamage();
- }
-
- AllZone.getGameAction().checkStateEffects();
- CombatUtil.showCombat();
- }
- } else if (phase.equals(Constant.Phase.COMBAT_END)) {
- // End Combat always happens
- AllZone.getEndOfCombat().executeUntil();
- AllZone.getEndOfCombat().executeAt();
- } else if (phase.equals(Constant.Phase.END_OF_TURN)) {
- AllZone.getEndOfTurn().executeAt();
- } else if (phase.equals(Constant.Phase.CLEANUP)) {
- AllZone.getPhase().getPlayerTurn().setAssignedDamage(0);
-
- // Reset Damage received map
- final CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield);
- for (final Card c : list) {
- c.resetPreventNextDamage();
- c.resetReceivedDamageFromThisTurn();
- c.resetDealtDamageToThisTurn();
- c.setDealtDmgToHumanThisTurn(false);
- c.setDealtDmgToComputerThisTurn(false);
- c.setDealtCombatDmgToHumanThisTurn(false);
- c.setDealtCombatDmgToComputerThisTurn(false);
- c.setRegeneratedThisTurn(0);
- c.clearMustBlockCards();
- if (AllZone.getPhase().isPlayerTurn(AllZone.getComputerPlayer())) {
- c.setCreatureAttackedLastComputerTurn(c.getCreatureAttackedThisTurn());
- }
- if (AllZone.getPhase().isPlayerTurn(AllZone.getHumanPlayer())) {
- c.setCreatureAttackedLastHumanTurn(c.getCreatureAttackedThisTurn());
- }
- c.setCreatureAttackedThisTurn(false);
- c.setCreatureBlockedThisTurn(false);
- c.setCreatureGotBlockedThisTurn(false);
- }
- AllZone.getHumanPlayer().resetPreventNextDamage();
- AllZone.getComputerPlayer().resetPreventNextDamage();
-
- AllZone.getEndOfTurn().executeUntil();
- final CardList cHand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand);
- final CardList hHand = AllZone.getHumanPlayer().getCardsIn(Zone.Hand);
- for (final Card c : cHand) {
- c.setDrawnThisTurn(false);
- }
- for (final Card c : hHand) {
- c.setDrawnThisTurn(false);
- }
- AllZone.getHumanPlayer().resetNumDrawnThisTurn();
- AllZone.getComputerPlayer().resetNumDrawnThisTurn();
- }
-
- if (!AllZone.getPhase().isNeedToNextPhase()) {
- // Run triggers if phase isn't being skipped
- final HashMap runParams = new HashMap();
- runParams.put("Phase", phase);
- runParams.put("Player", turn);
- AllZone.getTriggerHandler().runTrigger("Phase", runParams);
-
- }
-
- // This line fixes Combat Damage triggers not going off when they should
- AllZone.getStack().unfreezeStack();
-
- if (!phase.equals(Constant.Phase.UNTAP)) {
- // during untap
- this.resetPriority();
- }
- }
-
- /**
- * Checks if is prevent combat damage this turn.
- *
- * @return true, if is prevent combat damage this turn
- */
- public final boolean isPreventCombatDamageThisTurn() {
- return this.bPreventCombatDamageThisTurn;
- }
-
- /**
- *
- * nextPhase.
- *
- */
- public final void nextPhase() {
- // experimental, add executeCardStateEffects() here:
- for (final String effect : AllZone.getStaticEffects().getStateBasedMap().keySet()) {
- final Command com = GameActionUtil.getCommands().get(effect);
- com.execute();
- }
-
- this.needToNextPhase = false;
-
- // If the Stack isn't empty why is nextPhase being called?
- if (AllZone.getStack().size() != 0) {
- Log.debug("Phase.nextPhase() is called, but Stack isn't empty.");
- return;
- }
- this.bPhaseEffects = true;
- if (!AllZoneUtil.isCardInPlay("Upwelling")) {
- AllZone.getHumanPlayer().getManaPool().clearPool();
- AllZone.getComputerPlayer().getManaPool().clearPool();
- }
-
- if (this.getPhase().equals(Constant.Phase.COMBAT_DECLARE_ATTACKERS)) {
- AllZone.getStack().unfreezeStack();
- this.nCombatsThisTurn++;
- } else if (this.getPhase().equals(Constant.Phase.UNTAP)) {
- this.nCombatsThisTurn = 0;
- }
-
- if (this.getPhase().equals(Constant.Phase.COMBAT_END)) {
- AllZone.getCombat().reset();
- AllZone.getDisplay().showCombat("");
- this.resetAttackedThisCombat(this.getPlayerTurn());
- this.bCombat = false;
- }
-
- if (this.getPhaseOrder()[this.phaseIndex].equals(Constant.Phase.CLEANUP)) {
- this.bPreventCombatDamageThisTurn = false;
- if (!this.bRepeat) {
- AllZone.getPhase().setPlayerTurn(this.handleNextTurn());
- }
- }
-
- if (this.is(Constant.Phase.COMBAT_DECLARE_BLOCKERS)) {
- AllZone.getStack().unfreezeStack();
- }
-
- if (this.is(Constant.Phase.COMBAT_END) && (this.extraCombats > 0)) {
- // TODO: ExtraCombat needs to be changed for other spell/abilities
- // that give extra combat
- // can do it like ExtraTurn stack ExtraPhases
-
- final Player player = this.getPlayerTurn();
- final Player opp = player.getOpponent();
-
- this.bCombat = true;
- this.extraCombats--;
- AllZone.getCombat().reset();
- AllZone.getCombat().setAttackingPlayer(player);
- AllZone.getCombat().setDefendingPlayer(opp);
- this.phaseIndex = this.findIndex(Constant.Phase.COMBAT_DECLARE_ATTACKERS);
- } else {
- if (!this.bRepeat) { // for when Cleanup needs to repeat itself
- this.phaseIndex++;
- this.phaseIndex %= this.getPhaseOrder().length;
- } else {
- this.bRepeat = false;
- }
- }
-
- AllZone.getGameLog().add("Phase", getPlayerTurn() + " " + getPhase(), 6);
-
- // **** Anything BELOW Here is actually in the next phase. Maybe move
- // this to handleBeginPhase
- if (this.getPhase().equals(Constant.Phase.UNTAP)) {
- this.turn++;
- AllZone.getGameLog().add("Turn", "Turn " + turn + " (" + getPlayerTurn() + ")", 0);
- }
-
- PhaseUtil.visuallyActivatePhase(this.getPhase());
-
- // When consecutively skipping phases (like in combat) this section
- // pushes through that block
- this.updateObservers();
- if ((AllZone.getPhase() != null) && AllZone.getPhase().isNeedToNextPhase()) {
- AllZone.getPhase().setNeedToNextPhase(false);
- AllZone.getPhase().nextPhase();
+ public final void executeUntil(final Player p) {
+ if (this.untilMap.containsKey(p)) {
+ this.execute(this.untilMap.get(p));
}
}
/**
*
- * handleNextTurn.
+ * Add a hardcoded trigger that will execute "at ".
*
*
- * @return a {@link forge.Player} object.
+ * @param c
+ * a {@link forge.Command} object.
*/
- private Player handleNextTurn() {
- final Player nextTurn = this.extraTurns.isEmpty() ? this.getPlayerTurn().getOpponent() : this.extraTurns.pop();
-
- AllZone.getStack().setCardsCastLastTurn();
- AllZone.getStack().clearCardsCastThisTurn();
- AllZone.resetZoneMoveTracking();
- AllZone.getComputerPlayer().resetProwl();
- AllZone.getHumanPlayer().resetProwl();
- AllZone.getComputerPlayer().setLifeLostThisTurn(0);
- AllZone.getHumanPlayer().setLifeLostThisTurn(0);
-
- return this.skipTurnTimeVault(nextTurn);
+ public final void addAt(final Command c) {
+ this.at.add(c);
}
/**
*
- * skipTurnTimeVault.
+ * Add a Command that will terminate an effect with "until ".
*
*
- * @param turn
- * a {@link forge.Player} object.
- * @return a {@link forge.Player} object.
+ * @param c
+ * a {@link forge.Command} object.
*/
- private Player skipTurnTimeVault(Player turn) {
- // time vault:
- CardList vaults = turn.getCardsIn(Zone.Battlefield, "Time Vault");
- vaults = vaults.filter(new CardListFilter() {
- @Override
- public boolean addCard(final Card c) {
- return c.isTapped();
- }
- });
-
- if (vaults.size() > 0) {
- final Card crd = vaults.get(0);
-
- if (turn.isHuman()) {
- if (GameActionUtil.showYesNoDialog(crd, "Untap " + crd + "?")) {
- crd.untap();
- turn = this.extraTurns.isEmpty() ? turn.getOpponent() : this.extraTurns.pop();
- }
- } else {
- // TODO Should AI skip his turn for time vault?
- }
- }
- return turn;
+ public final void addUntil(final Command c) {
+ this.until.add(c);
}
/**
*
- * is.
+ * Executes any hardcoded triggers that happen "at ".
*
- *
- * @param phase
- * a {@link java.lang.String} object.
- * @param player
- * a {@link forge.Player} object.
- * @return a boolean.
*/
- public final synchronized boolean is(final String phase, final Player player) {
- return this.getPhase().equals(phase) && this.getPlayerTurn().isPlayer(player);
+ public void executeAt() {
+ this.execute(this.at);
}
/**
*
- * is.
+ * Executes the termination of effects that apply "until ".
*
- *
- * @param phase
- * a {@link java.lang.String} object.
- * @return a boolean.
*/
- public final synchronized boolean is(final String phase) {
- return (this.getPhase().equals(phase));
+ public final void executeUntil() {
+ this.execute(this.until);
}
/**
*
- * isAfter.
+ * execute.
*
*
- * @param phase
- * a {@link java.lang.String} object.
- * @return a boolean.
+ * @param c
+ * a {@link forge.CommandList} object.
*/
- public final boolean isAfter(final String phase) {
- return this.phaseIndex > this.findIndex(phase);
- }
+ protected void execute(final CommandList c) {
+ final int length = c.size();
- /**
- *
- * isBefore.
- *
- *
- * @param phase
- * a {@link java.lang.String} object.
- * @return a boolean.
- */
- public final boolean isBefore(final String phase) {
- return this.phaseIndex < this.findIndex(phase);
- }
-
- /**
- *
- * findIndex.
- *
- *
- * @param phase
- * a {@link java.lang.String} object.
- * @return a int.
- */
- private int findIndex(final String phase) {
- for (int i = 0; i < this.getPhaseOrder().length; i++) {
- if (phase.equals(this.getPhaseOrder()[i])) {
- return i;
- }
- }
- throw new RuntimeException("Phase : findIndex() invalid argument, phase = " + phase);
- }
-
- /**
- *
- * getPhase.
- *
- *
- * @return a {@link java.lang.String} object.
- */
- public final String getPhase() {
- return this.getPhaseOrder()[this.phaseIndex];
- }
-
- /**
- *
- * Getter for the field turn.
- *
- *
- * @return a int.
- */
- public final int getTurn() {
- return this.turn;
- }
-
- /**
- *
- * getNextTurn.
- *
- *
- * @return a {@link forge.Player} object.
- */
- public final Player getNextTurn() {
- if (this.extraTurns.isEmpty()) {
- return this.getPlayerTurn().getOpponent();
- }
-
- return this.extraTurns.peek();
- }
-
- /**
- *
- * isNextTurn.
- *
- *
- * @param pl
- * a {@link forge.Player} object.
- * @return a boolean.
- */
- public final boolean isNextTurn(final Player pl) {
- final Player next = this.getNextTurn();
- return (pl.equals(next));
- }
-
- /**
- *
- * addExtraTurn.
- *
- *
- * @param player
- * a {@link forge.Player} object.
- */
- public final void addExtraTurn(final Player player) {
- // use a stack to handle extra turns, make sure the bottom of the stack
- // restores original turn order
- if (this.extraTurns.isEmpty()) {
- this.extraTurns.push(this.getPlayerTurn().getOpponent());
- }
-
- this.extraTurns.push(player);
- }
-
- /**
- *
- * skipTurn.
- *
- *
- * @param player
- * a {@link forge.Player} object.
- */
- public final void skipTurn(final Player player) {
- // skipping turn without having extras is equivalent to giving your
- // opponent an extra turn
- if (this.extraTurns.isEmpty()) {
- this.addExtraTurn(player.getOpponent());
- } else {
- final int pos = this.extraTurns.lastIndexOf(player);
- if (pos == -1) {
- this.addExtraTurn(player.getOpponent());
- } else {
- this.extraTurns.remove(pos);
- }
+ for (int i = 0; i < length; i++) {
+ c.remove(0).execute();
}
}
- /**
- *
- * addExtraCombat.
- *
- */
- public final void addExtraCombat() {
- // Extra combats can only happen
- this.extraCombats++;
- }
-
- /**
- *
- * isFirstCombat.
- *
- *
- * @return a boolean.
- */
- public final boolean isFirstCombat() {
- return (this.nCombatsThisTurn == 1);
- }
-
- /**
- *
- * resetAttackedThisCombat.
- *
- *
- * @param player
- * a {@link forge.Player} object.
- */
- public final void resetAttackedThisCombat(final Player player) {
- // resets the status of attacked/blocked this phase
- CardList list = player.getCardsIn(Zone.Battlefield);
-
- list = list.getType("Creature");
-
- for (int i = 0; i < list.size(); i++) {
- final Card c = list.get(i);
- if (c.getCreatureAttackedThisCombat()) {
- c.setCreatureAttackedThisCombat(false);
- }
- if (c.getCreatureBlockedThisCombat()) {
- c.setCreatureBlockedThisCombat(false);
- }
-
- if (c.getCreatureGotBlockedThisCombat()) {
- c.setCreatureGotBlockedThisCombat(false);
- }
- }
- }
-
- /**
- *
- * passPriority.
- *
- */
- public final void passPriority() {
- final Player actingPlayer = this.getPriorityPlayer();
- final Player lastToAct = this.getFirstPriority();
-
- // actingPlayer is the player who may act
- // the lastToAct is the player who gained Priority First in this segment
- // of Priority
-
- if (lastToAct.equals(actingPlayer)) {
- // pass the priority to other player
- this.setPriorityPlayer(actingPlayer.getOpponent());
- AllZone.getInputControl().resetInput();
- AllZone.getStack().chooseOrderOfSimultaneousStackEntryAll();
- } else {
- if (AllZone.getStack().size() == 0) {
- // end phase
- this.needToNextPhase = true;
- this.pPlayerPriority = this.getPlayerTurn(); // this needs to be
- // set early
- // as we exit the phase
- } else {
- if (!AllZone.getStack().hasSimultaneousStackEntries()) {
- AllZone.getStack().resolveStack();
- }
- }
- AllZone.getStack().chooseOrderOfSimultaneousStackEntryAll();
- }
- }
-
- /** {@inheritDoc} */
- @Override
- public final void addObserver(final Observer o) {
- super.addObserver(o);
- }
-
- /** The need to next phase. */
- private boolean needToNextPhase = false;
-
- /**
- *
- * Setter for the field needToNextPhase.
- *
- *
- * @param needToNextPhase
- * a boolean.
- */
- public final void setNeedToNextPhase(final boolean needToNextPhase) {
- this.needToNextPhase = needToNextPhase;
- }
-
- /**
- *
- * isNeedToNextPhase.
- *
- *
- * @return a boolean.
- */
- public final boolean isNeedToNextPhase() {
- return this.needToNextPhase;
- }
-
- // This should only be true four times! that is for the initial nextPhases
- // in MyObservable
- /** The need to next phase init. */
- private int needToNextPhaseInit = 0;
-
- /**
- *
- * isNeedToNextPhaseInit.
- *
- *
- * @return a boolean.
- */
- public final boolean isNeedToNextPhaseInit() {
- this.needToNextPhaseInit++;
- if (this.needToNextPhaseInit <= 4) {
- return true;
- }
- return false;
- }
-
- /**
- *
- * canCastSorcery.
- *
- *
- * @param player
- * a {@link forge.Player} object.
- * @return a boolean.
- */
- public static boolean canCastSorcery(final Player player) {
- return AllZone.getPhase().isPlayerTurn(player)
- && (AllZone.getPhase().getPhase().equals(Constant.Phase.MAIN2) || AllZone.getPhase().getPhase()
- .equals(Constant.Phase.MAIN1)) && (AllZone.getStack().size() == 0);
- }
-
- /**
- *
- * buildActivateString.
- *
- *
- * @param startPhase
- * a {@link java.lang.String} object.
- * @param endPhase
- * a {@link java.lang.String} object.
- * @return a {@link java.lang.String} object.
- */
- public final String buildActivateString(final String startPhase, final String endPhase) {
- final StringBuilder sb = new StringBuilder();
-
- boolean add = false;
- for (int i = 0; i < this.getPhaseOrder().length; i++) {
- if (this.getPhaseOrder()[i].equals(startPhase)) {
- add = true;
- }
-
- if (add) {
- if (sb.length() != 0) {
- sb.append(",");
- }
- sb.append(this.getPhaseOrder()[i]);
- }
-
- if (this.getPhaseOrder()[i].equals(endPhase)) {
- add = false;
- }
- }
-
- return sb.toString();
- }
-
- /**
- *
- * setGameBegins.
- *
- *
- * @param gameBegins
- * a int.
- */
- public static void setGameBegins(final int gameBegins) {
- Phase.gameBegins = gameBegins;
- }
-
- /**
- *
- * getGameBegins.
- *
- *
- * @return a int.
- */
- public static int getGameBegins() {
- return Phase.gameBegins;
- }
-
- // this is a hack for the setup game state mode, do not use outside of
- // devSetupGameState code
- // as it avoids calling any of the phase effects that may be necessary in a
- // less enforced context
- /**
- *
- * setDevPhaseState.
- *
- *
- * @param phaseID
- * a {@link java.lang.String} object.
- */
- public final void setDevPhaseState(final String phaseID) {
- this.phaseIndex = this.findIndex(phaseID);
- }
-
- /**
- *
- * TODO Write javadoc for this method.
- *
- * @param b
- * a boolean
- */
- public final void setPreventCombatDamageThisTurn(final boolean b) {
- this.bPreventCombatDamageThisTurn = true;
- }
-
- /**
- * Gets the phase order.
- *
- * @return the phaseOrder
- */
- public String[] getPhaseOrder() {
- return this.phaseOrder;
- }
-
- /**
- * Sets the phase order.
- *
- * @param phaseOrder0
- * the phaseOrder to set
- */
- public void setPhaseOrder(final String[] phaseOrder0) {
- this.phaseOrder = phaseOrder0;
- }
-}
+} //end class Phase
diff --git a/src/main/java/forge/PhaseHandler.java b/src/main/java/forge/PhaseHandler.java
new file mode 100644
index 00000000000..8a1206fc82a
--- /dev/null
+++ b/src/main/java/forge/PhaseHandler.java
@@ -0,0 +1,1023 @@
+/*
+ * Forge: Play Magic: the Gathering.
+ * Copyright (C) 2011 Forge Team
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package forge;
+
+import java.util.HashMap;
+import java.util.Observer;
+import java.util.Stack;
+
+import com.esotericsoftware.minlog.Log;
+
+import forge.Constant.Zone;
+
+/**
+ *
+ * Phase class.
+ *
+ *
+ * @author Forge
+ * @version $Id: PhaseHandler.java 13001 2012-01-08 12:25:25Z Sloth $
+ */
+public class PhaseHandler extends MyObservable implements java.io.Serializable {
+
+ /** Constant serialVersionUID=5207222278370963197L. */
+ private static final long serialVersionUID = 5207222278370963197L;
+
+ private int phaseIndex;
+ private int turn;
+
+ // Please use getX, setX, and incrementX methods instead of directly
+ // accessing the following:
+ /** Constant GameBegins=0. */
+ private static int gameBegins = 0;
+
+ private final Stack extraTurns = new Stack();
+
+ private int extraCombats;
+
+ private int nCombatsThisTurn;
+ private boolean bPreventCombatDamageThisTurn;
+
+ private Player playerTurn = AllZone.getHumanPlayer();
+
+ /**
+ *
+ * isPlayerTurn.
+ *
+ *
+ * @param player
+ * a {@link forge.Player} object.
+ * @return a boolean.
+ */
+ public final boolean isPlayerTurn(final Player player) {
+ return this.playerTurn.isPlayer(player);
+ }
+
+ /**
+ *
+ * Setter for the field playerTurn.
+ *
+ *
+ * @param s
+ * a {@link forge.Player} object.
+ */
+ public final void setPlayerTurn(final Player s) {
+ this.playerTurn = s;
+ }
+
+ /**
+ *
+ * Getter for the field playerTurn.
+ *
+ *
+ * @return a {@link forge.Player} object.
+ */
+ public final Player getPlayerTurn() {
+ return this.playerTurn;
+ }
+
+ // priority player
+
+ private Player pPlayerPriority = AllZone.getHumanPlayer();
+
+ /**
+ *
+ * getPriorityPlayer.
+ *
+ *
+ * @return a {@link forge.Player} object.
+ */
+ public final Player getPriorityPlayer() {
+ return this.pPlayerPriority;
+ }
+
+ /**
+ *
+ * setPriorityPlayer.
+ *
+ *
+ * @param p
+ * a {@link forge.Player} object.
+ */
+ public final void setPriorityPlayer(final Player p) {
+ this.pPlayerPriority = p;
+ }
+
+ private Player pFirstPriority = AllZone.getHumanPlayer();
+
+ /**
+ *
+ * getFirstPriority.
+ *
+ *
+ * @return a {@link forge.Player} object.
+ */
+ public final Player getFirstPriority() {
+ return this.pFirstPriority;
+ }
+
+ /**
+ *
+ * setFirstPriority.
+ *
+ *
+ * @param p
+ * a {@link forge.Player} object.
+ */
+ public final void setFirstPriority(final Player p) {
+ this.pFirstPriority = p;
+ }
+
+ /**
+ *
+ * setPriority.
+ *
+ *
+ * @param p
+ * a {@link forge.Player} object.
+ */
+ public final void setPriority(final Player p) {
+ if (AllZone.getStack() != null) {
+ AllZone.getStack().chooseOrderOfSimultaneousStackEntryAll();
+ }
+
+ this.pFirstPriority = p;
+ this.pPlayerPriority = p;
+ }
+
+ /**
+ *
+ * resetPriority.
+ *
+ */
+ public final void resetPriority() {
+ this.setPriority(this.playerTurn);
+ }
+
+ private boolean bPhaseEffects = true;
+
+ /**
+ *
+ * doPhaseEffects.
+ *
+ *
+ * @return a boolean.
+ */
+ public final boolean doPhaseEffects() {
+ return this.bPhaseEffects;
+ }
+
+ /**
+ *
+ * setPhaseEffects.
+ *
+ *
+ * @param b
+ * a boolean.
+ */
+ public final void setPhaseEffects(final boolean b) {
+ this.bPhaseEffects = b;
+ }
+
+ private boolean bSkipPhase = true;
+
+ /**
+ *
+ * doSkipPhase.
+ *
+ *
+ * @return a boolean.
+ */
+ public final boolean doSkipPhase() {
+ return this.bSkipPhase;
+ }
+
+ /**
+ *
+ * setSkipPhase.
+ *
+ *
+ * @param b
+ * a boolean.
+ */
+ public final void setSkipPhase(final boolean b) {
+ this.bSkipPhase = b;
+ }
+
+ private boolean bCombat = false;
+
+ /**
+ *
+ * inCombat.
+ *
+ *
+ * @return a boolean.
+ */
+ public final boolean inCombat() {
+ return this.bCombat;
+ }
+
+ /**
+ *
+ * setCombat.
+ *
+ *
+ * @param b
+ * a boolean.
+ */
+ public final void setCombat(final boolean b) {
+ this.bCombat = b;
+ }
+
+ private boolean bRepeat = false;
+
+ /**
+ *
+ * repeatPhase.
+ *
+ */
+ public final void repeatPhase() {
+ this.bRepeat = true;
+ }
+
+ /** The phase order. */
+ private String[] phaseOrder = { Constant.Phase.UNTAP, Constant.Phase.UPKEEP, Constant.Phase.DRAW,
+ Constant.Phase.MAIN1, Constant.Phase.COMBAT_BEGIN, Constant.Phase.COMBAT_DECLARE_ATTACKERS,
+ Constant.Phase.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY, Constant.Phase.COMBAT_DECLARE_BLOCKERS,
+ Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY, Constant.Phase.COMBAT_FIRST_STRIKE_DAMAGE,
+ Constant.Phase.COMBAT_DAMAGE, Constant.Phase.COMBAT_END, Constant.Phase.MAIN2, Constant.Phase.END_OF_TURN,
+ Constant.Phase.CLEANUP };
+
+ /**
+ *
+ * Constructor for PhaseHandler.
+ *
+ */
+ public PhaseHandler() {
+ this.reset();
+ }
+
+ /**
+ *
+ * reset.
+ *
+ */
+ public final void reset() {
+ this.turn = 1;
+ this.playerTurn = AllZone.getHumanPlayer();
+ this.resetPriority();
+ this.bPhaseEffects = true;
+ this.needToNextPhase = false;
+ PhaseHandler.setGameBegins(0);
+ this.phaseIndex = 0;
+ this.extraTurns.clear();
+ this.nCombatsThisTurn = 0;
+ this.extraCombats = 0;
+ this.bPreventCombatDamageThisTurn = false;
+ this.bCombat = false;
+ this.bRepeat = false;
+ this.updateObservers();
+ }
+
+ /**
+ *
+ * turnReset.
+ *
+ */
+ public final void turnReset() {
+ this.playerTurn.setNumLandsPlayed(0);
+ }
+
+ /**
+ *
+ * handleBeginPhase.
+ *
+ */
+ public final void handleBeginPhase() {
+ AllZone.getPhaseHandler().setPhaseEffects(false);
+ // Handle effects that happen at the beginning of phases
+ final String phase = AllZone.getPhaseHandler().getPhase();
+ final Player turn = AllZone.getPhaseHandler().getPlayerTurn();
+ AllZone.getPhaseHandler().setSkipPhase(true);
+ AllZone.getGameAction().checkStateEffects();
+
+ if (phase.equals(Constant.Phase.UNTAP)) {
+ PhaseUtil.handleUntap();
+ } else if (phase.equals(Constant.Phase.UPKEEP)) {
+ PhaseUtil.handleUpkeep();
+ } else if (phase.equals(Constant.Phase.DRAW)) {
+ PhaseUtil.handleDraw();
+ } else if (phase.equals(Constant.Phase.COMBAT_BEGIN)) {
+ PhaseUtil.verifyCombat();
+ } else if (phase.equals(Constant.Phase.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)) {
+ if (this.inCombat()) {
+ PhaseUtil.handleDeclareAttackers();
+ } else {
+ AllZone.getPhaseHandler().setNeedToNextPhase(true);
+ }
+ }
+
+ // we can skip AfterBlockers and AfterAttackers if necessary
+ else if (phase.equals(Constant.Phase.COMBAT_DECLARE_BLOCKERS)) {
+ if (this.inCombat()) {
+ PhaseUtil.verifyCombat();
+ } else {
+ AllZone.getPhaseHandler().setNeedToNextPhase(true);
+ }
+ } else if (phase.equals(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
+ // After declare blockers are finished being declared mark them
+ // blocked and trigger blocking things
+ if (!this.inCombat()) {
+ AllZone.getPhaseHandler().setNeedToNextPhase(true);
+ } else {
+ PhaseUtil.handleDeclareBlockers();
+ }
+ } else if (phase.equals(Constant.Phase.COMBAT_FIRST_STRIKE_DAMAGE)) {
+ if (!this.inCombat()) {
+ AllZone.getPhaseHandler().setNeedToNextPhase(true);
+ } else {
+ AllZone.getCombat().verifyCreaturesInPlay();
+
+ // no first strikers, skip this step
+ if (!AllZone.getCombat().setAssignedFirstStrikeDamage()) {
+ AllZone.getPhaseHandler().setNeedToNextPhase(true);
+ } else {
+ if (!this.isPreventCombatDamageThisTurn()) {
+ Combat.dealAssignedDamage();
+ }
+
+ AllZone.getGameAction().checkStateEffects();
+ CombatUtil.showCombat();
+ }
+ }
+ } else if (phase.equals(Constant.Phase.COMBAT_DAMAGE)) {
+ if (!this.inCombat()) {
+ AllZone.getPhaseHandler().setNeedToNextPhase(true);
+ } else {
+ AllZone.getCombat().verifyCreaturesInPlay();
+
+ AllZone.getCombat().setAssignedDamage();
+
+ if (!this.isPreventCombatDamageThisTurn()) {
+ Combat.dealAssignedDamage();
+ }
+
+ AllZone.getGameAction().checkStateEffects();
+ CombatUtil.showCombat();
+ }
+ } else if (phase.equals(Constant.Phase.COMBAT_END)) {
+ // End Combat always happens
+ AllZone.getEndOfCombat().executeUntil();
+ AllZone.getEndOfCombat().executeAt();
+ } else if (phase.equals(Constant.Phase.END_OF_TURN)) {
+ AllZone.getEndOfTurn().executeAt();
+ } else if (phase.equals(Constant.Phase.CLEANUP)) {
+ AllZone.getPhaseHandler().getPlayerTurn().setAssignedDamage(0);
+
+ // Reset Damage received map
+ final CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield);
+ for (final Card c : list) {
+ c.resetPreventNextDamage();
+ c.resetReceivedDamageFromThisTurn();
+ c.resetDealtDamageToThisTurn();
+ c.setDealtDmgToHumanThisTurn(false);
+ c.setDealtDmgToComputerThisTurn(false);
+ c.setDealtCombatDmgToHumanThisTurn(false);
+ c.setDealtCombatDmgToComputerThisTurn(false);
+ c.setRegeneratedThisTurn(0);
+ c.clearMustBlockCards();
+ if (AllZone.getPhaseHandler().isPlayerTurn(AllZone.getComputerPlayer())) {
+ c.setCreatureAttackedLastComputerTurn(c.getCreatureAttackedThisTurn());
+ }
+ if (AllZone.getPhaseHandler().isPlayerTurn(AllZone.getHumanPlayer())) {
+ c.setCreatureAttackedLastHumanTurn(c.getCreatureAttackedThisTurn());
+ }
+ c.setCreatureAttackedThisTurn(false);
+ c.setCreatureBlockedThisTurn(false);
+ c.setCreatureGotBlockedThisTurn(false);
+ }
+ AllZone.getHumanPlayer().resetPreventNextDamage();
+ AllZone.getComputerPlayer().resetPreventNextDamage();
+
+ AllZone.getEndOfTurn().executeUntil();
+ final CardList cHand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand);
+ final CardList hHand = AllZone.getHumanPlayer().getCardsIn(Zone.Hand);
+ for (final Card c : cHand) {
+ c.setDrawnThisTurn(false);
+ }
+ for (final Card c : hHand) {
+ c.setDrawnThisTurn(false);
+ }
+ AllZone.getHumanPlayer().resetNumDrawnThisTurn();
+ AllZone.getComputerPlayer().resetNumDrawnThisTurn();
+ }
+
+ if (!AllZone.getPhaseHandler().isNeedToNextPhase()) {
+ // Run triggers if phase isn't being skipped
+ final HashMap runParams = new HashMap();
+ runParams.put("Phase", phase);
+ runParams.put("Player", turn);
+ AllZone.getTriggerHandler().runTrigger("Phase", runParams);
+
+ }
+
+ // This line fixes Combat Damage triggers not going off when they should
+ AllZone.getStack().unfreezeStack();
+
+ if (!phase.equals(Constant.Phase.UNTAP)) {
+ // during untap
+ this.resetPriority();
+ }
+ }
+
+ /**
+ * Checks if is prevent combat damage this turn.
+ *
+ * @return true, if is prevent combat damage this turn
+ */
+ public final boolean isPreventCombatDamageThisTurn() {
+ return this.bPreventCombatDamageThisTurn;
+ }
+
+ /**
+ *
+ * nextPhase.
+ *
+ */
+ public final void nextPhase() {
+ // experimental, add executeCardStateEffects() here:
+ for (final String effect : AllZone.getStaticEffects().getStateBasedMap().keySet()) {
+ final Command com = GameActionUtil.getCommands().get(effect);
+ com.execute();
+ }
+
+ this.needToNextPhase = false;
+
+ // If the Stack isn't empty why is nextPhase being called?
+ if (AllZone.getStack().size() != 0) {
+ Log.debug("Phase.nextPhase() is called, but Stack isn't empty.");
+ return;
+ }
+ this.bPhaseEffects = true;
+ if (!AllZoneUtil.isCardInPlay("Upwelling")) {
+ AllZone.getHumanPlayer().getManaPool().clearPool();
+ AllZone.getComputerPlayer().getManaPool().clearPool();
+ }
+
+ if (this.getPhase().equals(Constant.Phase.COMBAT_DECLARE_ATTACKERS)) {
+ AllZone.getStack().unfreezeStack();
+ this.nCombatsThisTurn++;
+ } else if (this.getPhase().equals(Constant.Phase.UNTAP)) {
+ this.nCombatsThisTurn = 0;
+ }
+
+ if (this.getPhase().equals(Constant.Phase.COMBAT_END)) {
+ AllZone.getCombat().reset();
+ AllZone.getDisplay().showCombat("");
+ this.resetAttackedThisCombat(this.getPlayerTurn());
+ this.bCombat = false;
+ }
+
+ if (this.getPhaseOrder()[this.phaseIndex].equals(Constant.Phase.CLEANUP)) {
+ this.bPreventCombatDamageThisTurn = false;
+ if (!this.bRepeat) {
+ AllZone.getPhaseHandler().setPlayerTurn(this.handleNextTurn());
+ }
+ }
+
+ if (this.is(Constant.Phase.COMBAT_DECLARE_BLOCKERS)) {
+ AllZone.getStack().unfreezeStack();
+ }
+
+ if (this.is(Constant.Phase.COMBAT_END) && (this.extraCombats > 0)) {
+ // TODO: ExtraCombat needs to be changed for other spell/abilities
+ // that give extra combat
+ // can do it like ExtraTurn stack ExtraPhases
+
+ final Player player = this.getPlayerTurn();
+ final Player opp = player.getOpponent();
+
+ this.bCombat = true;
+ this.extraCombats--;
+ AllZone.getCombat().reset();
+ AllZone.getCombat().setAttackingPlayer(player);
+ AllZone.getCombat().setDefendingPlayer(opp);
+ this.phaseIndex = this.findIndex(Constant.Phase.COMBAT_DECLARE_ATTACKERS);
+ } else {
+ if (!this.bRepeat) { // for when Cleanup needs to repeat itself
+ this.phaseIndex++;
+ this.phaseIndex %= this.getPhaseOrder().length;
+ } else {
+ this.bRepeat = false;
+ }
+ }
+
+ AllZone.getGameLog().add("Phase", getPlayerTurn() + " " + getPhase(), 6);
+
+ // **** Anything BELOW Here is actually in the next phase. Maybe move
+ // this to handleBeginPhase
+ if (this.getPhase().equals(Constant.Phase.UNTAP)) {
+ this.turn++;
+ AllZone.getGameLog().add("Turn", "Turn " + turn + " (" + getPlayerTurn() + ")", 0);
+ }
+
+ PhaseUtil.visuallyActivatePhase(this.getPhase());
+
+ // When consecutively skipping phases (like in combat) this section
+ // pushes through that block
+ this.updateObservers();
+ if ((AllZone.getPhaseHandler() != null) && AllZone.getPhaseHandler().isNeedToNextPhase()) {
+ AllZone.getPhaseHandler().setNeedToNextPhase(false);
+ AllZone.getPhaseHandler().nextPhase();
+ }
+ }
+
+ /**
+ *
+ * handleNextTurn.
+ *
+ *
+ * @return a {@link forge.Player} object.
+ */
+ private Player handleNextTurn() {
+ final Player nextTurn = this.extraTurns.isEmpty() ? this.getPlayerTurn().getOpponent() : this.extraTurns.pop();
+
+ AllZone.getStack().setCardsCastLastTurn();
+ AllZone.getStack().clearCardsCastThisTurn();
+ AllZone.resetZoneMoveTracking();
+ AllZone.getComputerPlayer().resetProwl();
+ AllZone.getHumanPlayer().resetProwl();
+ AllZone.getComputerPlayer().setLifeLostThisTurn(0);
+ AllZone.getHumanPlayer().setLifeLostThisTurn(0);
+
+ return this.skipTurnTimeVault(nextTurn);
+ }
+
+ /**
+ *
+ * skipTurnTimeVault.
+ *
+ *
+ * @param turn
+ * a {@link forge.Player} object.
+ * @return a {@link forge.Player} object.
+ */
+ private Player skipTurnTimeVault(Player turn) {
+ // time vault:
+ CardList vaults = turn.getCardsIn(Zone.Battlefield, "Time Vault");
+ vaults = vaults.filter(new CardListFilter() {
+ @Override
+ public boolean addCard(final Card c) {
+ return c.isTapped();
+ }
+ });
+
+ if (vaults.size() > 0) {
+ final Card crd = vaults.get(0);
+
+ if (turn.isHuman()) {
+ if (GameActionUtil.showYesNoDialog(crd, "Untap " + crd + "?")) {
+ crd.untap();
+ turn = this.extraTurns.isEmpty() ? turn.getOpponent() : this.extraTurns.pop();
+ }
+ } else {
+ // TODO Should AI skip his turn for time vault?
+ }
+ }
+ return turn;
+ }
+
+ /**
+ *
+ * is.
+ *
+ *
+ * @param phase
+ * a {@link java.lang.String} object.
+ * @param player
+ * a {@link forge.Player} object.
+ * @return a boolean.
+ */
+ public final synchronized boolean is(final String phase, final Player player) {
+ return this.getPhase().equals(phase) && this.getPlayerTurn().isPlayer(player);
+ }
+
+ /**
+ *
+ * is.
+ *
+ *
+ * @param phase
+ * a {@link java.lang.String} object.
+ * @return a boolean.
+ */
+ public final synchronized boolean is(final String phase) {
+ return (this.getPhase().equals(phase));
+ }
+
+ /**
+ *
+ * isAfter.
+ *
+ *
+ * @param phase
+ * a {@link java.lang.String} object.
+ * @return a boolean.
+ */
+ public final boolean isAfter(final String phase) {
+ return this.phaseIndex > this.findIndex(phase);
+ }
+
+ /**
+ *
+ * isBefore.
+ *
+ *
+ * @param phase
+ * a {@link java.lang.String} object.
+ * @return a boolean.
+ */
+ public final boolean isBefore(final String phase) {
+ return this.phaseIndex < this.findIndex(phase);
+ }
+
+ /**
+ *
+ * findIndex.
+ *
+ *
+ * @param phase
+ * a {@link java.lang.String} object.
+ * @return a int.
+ */
+ private int findIndex(final String phase) {
+ for (int i = 0; i < this.getPhaseOrder().length; i++) {
+ if (phase.equals(this.getPhaseOrder()[i])) {
+ return i;
+ }
+ }
+ throw new RuntimeException("Phase : findIndex() invalid argument, phase = " + phase);
+ }
+
+ /**
+ *
+ * getPhase.
+ *
+ *
+ * @return a {@link java.lang.String} object.
+ */
+ public final String getPhase() {
+ return this.getPhaseOrder()[this.phaseIndex];
+ }
+
+ /**
+ *
+ * Getter for the field turn.
+ *
+ *
+ * @return a int.
+ */
+ public final int getTurn() {
+ return this.turn;
+ }
+
+ /**
+ *
+ * getNextTurn.
+ *
+ *
+ * @return a {@link forge.Player} object.
+ */
+ public final Player getNextTurn() {
+ if (this.extraTurns.isEmpty()) {
+ return this.getPlayerTurn().getOpponent();
+ }
+
+ return this.extraTurns.peek();
+ }
+
+ /**
+ *
+ * isNextTurn.
+ *
+ *
+ * @param pl
+ * a {@link forge.Player} object.
+ * @return a boolean.
+ */
+ public final boolean isNextTurn(final Player pl) {
+ final Player next = this.getNextTurn();
+ return (pl.equals(next));
+ }
+
+ /**
+ *
+ * addExtraTurn.
+ *
+ *
+ * @param player
+ * a {@link forge.Player} object.
+ */
+ public final void addExtraTurn(final Player player) {
+ // use a stack to handle extra turns, make sure the bottom of the stack
+ // restores original turn order
+ if (this.extraTurns.isEmpty()) {
+ this.extraTurns.push(this.getPlayerTurn().getOpponent());
+ }
+
+ this.extraTurns.push(player);
+ }
+
+ /**
+ *
+ * skipTurn.
+ *
+ *
+ * @param player
+ * a {@link forge.Player} object.
+ */
+ public final void skipTurn(final Player player) {
+ // skipping turn without having extras is equivalent to giving your
+ // opponent an extra turn
+ if (this.extraTurns.isEmpty()) {
+ this.addExtraTurn(player.getOpponent());
+ } else {
+ final int pos = this.extraTurns.lastIndexOf(player);
+ if (pos == -1) {
+ this.addExtraTurn(player.getOpponent());
+ } else {
+ this.extraTurns.remove(pos);
+ }
+ }
+ }
+
+ /**
+ *
+ * addExtraCombat.
+ *
+ */
+ public final void addExtraCombat() {
+ // Extra combats can only happen
+ this.extraCombats++;
+ }
+
+ /**
+ *
+ * isFirstCombat.
+ *
+ *
+ * @return a boolean.
+ */
+ public final boolean isFirstCombat() {
+ return (this.nCombatsThisTurn == 1);
+ }
+
+ /**
+ *
+ * resetAttackedThisCombat.
+ *
+ *
+ * @param player
+ * a {@link forge.Player} object.
+ */
+ public final void resetAttackedThisCombat(final Player player) {
+ // resets the status of attacked/blocked this phase
+ CardList list = player.getCardsIn(Zone.Battlefield);
+
+ list = list.getType("Creature");
+
+ for (int i = 0; i < list.size(); i++) {
+ final Card c = list.get(i);
+ if (c.getCreatureAttackedThisCombat()) {
+ c.setCreatureAttackedThisCombat(false);
+ }
+ if (c.getCreatureBlockedThisCombat()) {
+ c.setCreatureBlockedThisCombat(false);
+ }
+
+ if (c.getCreatureGotBlockedThisCombat()) {
+ c.setCreatureGotBlockedThisCombat(false);
+ }
+ }
+ }
+
+ /**
+ *
+ * passPriority.
+ *
+ */
+ public final void passPriority() {
+ final Player actingPlayer = this.getPriorityPlayer();
+ final Player lastToAct = this.getFirstPriority();
+
+ // actingPlayer is the player who may act
+ // the lastToAct is the player who gained Priority First in this segment
+ // of Priority
+
+ if (lastToAct.equals(actingPlayer)) {
+ // pass the priority to other player
+ this.setPriorityPlayer(actingPlayer.getOpponent());
+ AllZone.getInputControl().resetInput();
+ AllZone.getStack().chooseOrderOfSimultaneousStackEntryAll();
+ } else {
+ if (AllZone.getStack().size() == 0) {
+ // end phase
+ this.needToNextPhase = true;
+ this.pPlayerPriority = this.getPlayerTurn(); // this needs to be
+ // set early
+ // as we exit the phase
+ } else {
+ if (!AllZone.getStack().hasSimultaneousStackEntries()) {
+ AllZone.getStack().resolveStack();
+ }
+ }
+ AllZone.getStack().chooseOrderOfSimultaneousStackEntryAll();
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public final void addObserver(final Observer o) {
+ super.addObserver(o);
+ }
+
+ /** The need to next phase. */
+ private boolean needToNextPhase = false;
+
+ /**
+ *
+ * Setter for the field needToNextPhase.
+ *
+ *
+ * @param needToNextPhase
+ * a boolean.
+ */
+ public final void setNeedToNextPhase(final boolean needToNextPhase) {
+ this.needToNextPhase = needToNextPhase;
+ }
+
+ /**
+ *
+ * isNeedToNextPhase.
+ *
+ *
+ * @return a boolean.
+ */
+ public final boolean isNeedToNextPhase() {
+ return this.needToNextPhase;
+ }
+
+ // This should only be true four times! that is for the initial nextPhases
+ // in MyObservable
+ /** The need to next phase init. */
+ private int needToNextPhaseInit = 0;
+
+ /**
+ *
+ * isNeedToNextPhaseInit.
+ *
+ *
+ * @return a boolean.
+ */
+ public final boolean isNeedToNextPhaseInit() {
+ this.needToNextPhaseInit++;
+ if (this.needToNextPhaseInit <= 4) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ *
+ * canCastSorcery.
+ *
+ *
+ * @param player
+ * a {@link forge.Player} object.
+ * @return a boolean.
+ */
+ public static boolean canCastSorcery(final Player player) {
+ return AllZone.getPhaseHandler().isPlayerTurn(player)
+ && (AllZone.getPhaseHandler().getPhase().equals(Constant.Phase.MAIN2) || AllZone.getPhaseHandler().getPhase()
+ .equals(Constant.Phase.MAIN1)) && (AllZone.getStack().size() == 0);
+ }
+
+ /**
+ *
+ * buildActivateString.
+ *
+ *
+ * @param startPhase
+ * a {@link java.lang.String} object.
+ * @param endPhase
+ * a {@link java.lang.String} object.
+ * @return a {@link java.lang.String} object.
+ */
+ public final String buildActivateString(final String startPhase, final String endPhase) {
+ final StringBuilder sb = new StringBuilder();
+
+ boolean add = false;
+ for (int i = 0; i < this.getPhaseOrder().length; i++) {
+ if (this.getPhaseOrder()[i].equals(startPhase)) {
+ add = true;
+ }
+
+ if (add) {
+ if (sb.length() != 0) {
+ sb.append(",");
+ }
+ sb.append(this.getPhaseOrder()[i]);
+ }
+
+ if (this.getPhaseOrder()[i].equals(endPhase)) {
+ add = false;
+ }
+ }
+
+ return sb.toString();
+ }
+
+ /**
+ *
+ * setGameBegins.
+ *
+ *
+ * @param gameBegins
+ * a int.
+ */
+ public static void setGameBegins(final int gameBegins) {
+ PhaseHandler.gameBegins = gameBegins;
+ }
+
+ /**
+ *
+ * getGameBegins.
+ *
+ *
+ * @return a int.
+ */
+ public static int getGameBegins() {
+ return PhaseHandler.gameBegins;
+ }
+
+ // this is a hack for the setup game state mode, do not use outside of
+ // devSetupGameState code
+ // as it avoids calling any of the phase effects that may be necessary in a
+ // less enforced context
+ /**
+ *
+ * setDevPhaseState.
+ *
+ *
+ * @param phaseID
+ * a {@link java.lang.String} object.
+ */
+ public final void setDevPhaseState(final String phaseID) {
+ this.phaseIndex = this.findIndex(phaseID);
+ }
+
+ /**
+ *
+ * TODO Write javadoc for this method.
+ *
+ * @param b
+ * a boolean
+ */
+ public final void setPreventCombatDamageThisTurn(final boolean b) {
+ this.bPreventCombatDamageThisTurn = true;
+ }
+
+ /**
+ * Gets the phase order.
+ *
+ * @return the phaseOrder
+ */
+ public String[] getPhaseOrder() {
+ return this.phaseOrder;
+ }
+
+ /**
+ * Sets the phase order.
+ *
+ * @param phaseOrder0
+ * the phaseOrder to set
+ */
+ public void setPhaseOrder(final String[] phaseOrder0) {
+ this.phaseOrder = phaseOrder0;
+ }
+}
diff --git a/src/main/java/forge/PhaseUtil.java b/src/main/java/forge/PhaseUtil.java
index 41648d9ab4c..08293f5af42 100644
--- a/src/main/java/forge/PhaseUtil.java
+++ b/src/main/java/forge/PhaseUtil.java
@@ -17,12 +17,9 @@
*/
package forge;
-import java.util.ArrayList;
import java.util.HashMap;
import forge.Constant.Zone;
-import forge.card.cardfactory.CardFactoryUtil;
-import forge.gui.input.Input;
import forge.view.GuiTopLevel;
import forge.view.match.ViewField.PhaseLabel;
import forge.view.match.ViewTopLevel;
@@ -65,9 +62,9 @@ public class PhaseUtil {
*
*/
public static void handleUntap() {
- final Player turn = AllZone.getPhase().getPlayerTurn();
+ final Player turn = AllZone.getPhaseHandler().getPlayerTurn();
- AllZone.getPhase().turnReset();
+ AllZone.getPhaseHandler().turnReset();
AllZone.getGameInfo().notifyNextTurn();
AllZone.getCombat().reset();
@@ -93,364 +90,17 @@ public class PhaseUtil {
// phase is skipped
if (PhaseUtil.skipUntap(turn)) {
- AllZone.getPhase().setNeedToNextPhase(true);
+ AllZone.getPhaseHandler().setNeedToNextPhase(true);
return;
}
AllZone.getUntap().executeUntil(turn);
AllZone.getUntap().executeAt();
- // Phasing would happen here
- PhaseUtil.doPhasing(turn);
-
- PhaseUtil.doUntap();
-
// otherwise land seems to stay tapped when it is really untapped
AllZone.getHumanPlayer().getZone(Zone.Battlefield).updateObservers();
- AllZone.getPhase().setNeedToNextPhase(true);
- }
-
- private static void doPhasing(final Player turn) {
- // Needs to include phased out cards
- final CardList list = turn.getCardsIncludePhasingIn(Constant.Zone.Battlefield).filter(new CardListFilter() {
-
- @Override
- public boolean addCard(final Card c) {
- return ((c.isPhasedOut() && c.isDirectlyPhasedOut()) || c.hasKeyword("Phasing"));
- }
- });
-
- // If c has things attached to it, they phase out simultaneously, and
- // will phase back in with it
- // If c is attached to something, it will phase out on its own, and try
- // to attach back to that thing when it comes back
- for (final Card c : list) {
- if (c.isPhasedOut()) {
- c.phase();
- } else if (c.hasKeyword("Phasing")) {
- // 702.23g If an object would simultaneously phase out directly
- // and indirectly, it just phases out indirectly.
- if (c.isAura()) {
- final GameEntity ent = c.getEnchanting();
-
- if ((ent instanceof Card) && list.contains((Card) ent)) {
- continue;
- }
- } else if (c.isEquipment() && c.isEquipping()) {
- if (list.contains(c.getEquippingCard())) {
- continue;
- }
- }
- // TODO: Fortification
- c.phase();
- }
- }
- }
-
- /**
- *
- * doUntap.
- *
- */
- private static void doUntap() {
- final Player player = AllZone.getPhase().getPlayerTurn();
- CardList list = player.getCardsIn(Zone.Battlefield);
-
- for (final Card c : list) {
- if (c.getBounceAtUntap() && c.getName().contains("Undiscovered Paradise")) {
- AllZone.getGameAction().moveToHand(c);
- }
- }
-
- list = list.filter(new CardListFilter() {
- @Override
- public boolean addCard(final Card c) {
- if (!PhaseUtil.canUntap(c)) {
- return false;
- }
- if (PhaseUtil.canOnlyUntapOneLand() && c.isLand()) {
- return false;
- }
- if ((AllZoneUtil.isCardInPlay("Damping Field") || AllZoneUtil.isCardInPlay("Imi Statue"))
- && c.isArtifact()) {
- return false;
- }
- if ((AllZoneUtil.isCardInPlay("Smoke") || AllZoneUtil.isCardInPlay("Stoic Angel") || AllZoneUtil
- .isCardInPlay("Intruder Alarm")) && c.isCreature()) {
- return false;
- }
- return true;
- }
- });
-
- for (final Card c : list) {
- if (c.hasKeyword("You may choose not to untap CARDNAME during your untap step.")) {
- if (c.isTapped()) {
- if (c.getController().isHuman()) {
- String prompt = "Untap " + c.getName() + "?";
- boolean defaultNo = false;
- if (c.getGainControlTargets().size() > 0) {
- final ArrayList targets = c.getGainControlTargets();
- prompt += "\r\n" + c + " is controlling: ";
- for (final Card target : targets) {
- prompt += target;
- if (AllZoneUtil.isCardInPlay(target)) {
- defaultNo |= true;
- }
- }
- }
- if (GameActionUtil.showYesNoDialog(c, prompt, defaultNo)) {
- c.untap();
- }
- } else { // computer
- // if it is controlling something by staying tapped,
- // leave it tapped
- // if not, untap it
- if (c.getGainControlTargets().size() > 0) {
- final ArrayList targets = c.getGainControlTargets();
- boolean untap = true;
- for (final Card target : targets) {
- if (AllZoneUtil.isCardInPlay(target)) {
- untap |= true;
- }
- }
- if (untap) {
- c.untap();
- }
- }
- }
- }
- } else if ((c.getCounters(Counters.WIND) > 0) && AllZoneUtil.isCardInPlay("Freyalise's Winds")) {
- // remove a WIND counter instead of untapping
- c.subtractCounter(Counters.WIND, 1);
- } else {
- c.untap();
- }
- }
-
- // opponent untapping during your untap phase
- final CardList opp = player.getOpponent().getCardsIn(Zone.Battlefield);
- for (final Card oppCard : opp) {
- if (oppCard.hasKeyword("CARDNAME untaps during each other player's untap step.")) {
- oppCard.untap();
- // end opponent untapping during your untap phase
- }
- }
-
- if (PhaseUtil.canOnlyUntapOneLand()) {
- if (AllZone.getPhase().getPlayerTurn().isComputer()) {
- // search for lands the computer has and only untap 1
- CardList landList = AllZoneUtil.getPlayerLandsInPlay(AllZone.getComputerPlayer());
- landList = landList.filter(CardListFilter.TAPPED).filter(new CardListFilter() {
- @Override
- public boolean addCard(final Card c) {
- return PhaseUtil.canUntap(c);
- }
- });
- if (landList.size() > 0) {
- landList.get(0).untap();
- }
- } else {
- final Input target = new Input() {
- private static final long serialVersionUID = 6653677835629939465L;
-
- @Override
- public void showMessage() {
- AllZone.getDisplay().showMessage("Select one tapped land to untap");
- ButtonUtil.enableOnlyCancel();
- }
-
- @Override
- public void selectButtonCancel() {
- this.stop();
- }
-
- @Override
- public void selectCard(final Card c, final PlayerZone zone) {
- if (c.isLand() && zone.is(Constant.Zone.Battlefield) && c.isTapped() && PhaseUtil.canUntap(c)) {
- c.untap();
- this.stop();
- }
- } // selectCard()
- }; // Input
- CardList landList = AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer());
- landList = landList.filter(CardListFilter.TAPPED).filter(new CardListFilter() {
- @Override
- public boolean addCard(final Card c) {
- return PhaseUtil.canUntap(c);
- }
- });
- if (landList.size() > 0) {
- AllZone.getInputControl().setInput(target);
- }
- }
- }
- if (AllZoneUtil.isCardInPlay("Damping Field") || AllZoneUtil.isCardInPlay("Imi Statue")) {
- if (AllZone.getPhase().getPlayerTurn().isComputer()) {
- CardList artList = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield);
- artList = artList.filter(CardListFilter.ARTIFACTS);
- artList = artList.filter(CardListFilter.TAPPED).filter(new CardListFilter() {
- @Override
- public boolean addCard(final Card c) {
- return PhaseUtil.canUntap(c);
- }
- });
- if (artList.size() > 0) {
- CardFactoryUtil.getBestArtifactAI(artList).untap();
- }
- } else {
- final Input target = new Input() {
- private static final long serialVersionUID = 5555427219659889707L;
-
- @Override
- public void showMessage() {
- AllZone.getDisplay().showMessage("Select one tapped artifact to untap");
- ButtonUtil.enableOnlyCancel();
- }
-
- @Override
- public void selectButtonCancel() {
- this.stop();
- }
-
- @Override
- public void selectCard(final Card c, final PlayerZone zone) {
- if (c.isArtifact() && zone.is(Constant.Zone.Battlefield) && c.getController().isHuman()
- && PhaseUtil.canUntap(c)) {
- c.untap();
- this.stop();
- }
- } // selectCard()
- }; // Input
- CardList artList = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield);
- artList = artList.filter(CardListFilter.ARTIFACTS);
- artList = artList.filter(CardListFilter.TAPPED).filter(new CardListFilter() {
- @Override
- public boolean addCard(final Card c) {
- return PhaseUtil.canUntap(c);
- }
- });
- if (artList.size() > 0) {
- AllZone.getInputControl().setInput(target);
- }
- }
- }
- if ((AllZoneUtil.isCardInPlay("Smoke") || AllZoneUtil.isCardInPlay("Stoic Angel"))) {
- if (AllZone.getPhase().getPlayerTurn().isComputer()) {
- CardList creatures = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer());
- creatures = creatures.filter(CardListFilter.TAPPED).filter(new CardListFilter() {
- @Override
- public boolean addCard(final Card c) {
- return PhaseUtil.canUntap(c);
- }
- });
- if (creatures.size() > 0) {
- creatures.get(0).untap();
- }
- } else {
- final Input target = new Input() {
- private static final long serialVersionUID = 5555427219659889707L;
-
- @Override
- public void showMessage() {
- AllZone.getDisplay().showMessage("Select one creature to untap");
- ButtonUtil.enableOnlyCancel();
- }
-
- @Override
- public void selectButtonCancel() {
- this.stop();
- }
-
- @Override
- public void selectCard(final Card c, final PlayerZone zone) {
- if (c.isCreature() && zone.is(Constant.Zone.Battlefield) && c.getController().isHuman()
- && PhaseUtil.canUntap(c)) {
- c.untap();
- this.stop();
- }
- } // selectCard()
- }; // Input
- CardList creatures = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer());
- creatures = creatures.filter(CardListFilter.TAPPED).filter(new CardListFilter() {
- @Override
- public boolean addCard(final Card c) {
- return PhaseUtil.canUntap(c);
- }
- });
- if (creatures.size() > 0) {
- AllZone.getInputControl().setInput(target);
- }
- }
- }
-
- // Remove temporary keywords
- list = player.getCardsIn(Zone.Battlefield);
- for (final Card c : list) {
- c.removeAllExtrinsicKeyword("This card doesn't untap during your next untap step.");
- c.removeAllExtrinsicKeyword("HIDDEN This card doesn't untap during your next untap step.");
- if (c.hasKeyword("This card doesn't untap during your next two untap steps.")) {
- c.removeAllExtrinsicKeyword("HIDDEN This card doesn't untap during your next two untap steps.");
- c.addHiddenExtrinsicKeyword("This card doesn't untap during your next untap step.");
- }
- }
- } // end doUntap
-
- /**
- *
- * canUntap.
- *
- *
- * @param c
- * a {@link forge.Card} object.
- * @return a boolean.
- */
- public static boolean canUntap(final Card c) {
-
- if (c.hasKeyword("CARDNAME doesn't untap during your untap step.")
- || c.hasKeyword("This card doesn't untap during your next untap step.")
- || c.hasKeyword("This card doesn't untap during your next two untap steps.")) {
- return false;
- }
-
- final CardList allp = AllZoneUtil.getCardsIn(Zone.Battlefield);
- for (final Card ca : allp) {
- if (ca.hasStartOfKeyword("Permanents don't untap during their controllers' untap steps")) {
- final int keywordPosition = ca
- .getKeywordPosition("Permanents don't untap during their controllers' untap steps");
- final String parse = ca.getKeyword().get(keywordPosition).toString();
- final String[] k = parse.split(":");
- final String[] restrictions = k[1].split(",");
- final Card card = ca;
- if (c.isValid(restrictions, card.getController(), card)) {
- return false;
- }
- }
- } // end of Permanents don't untap during their controllers' untap steps
-
- return true;
- }
-
- /**
- *
- * canOnlyUntapOneLand.
- *
- *
- * @return a boolean.
- */
- private static boolean canOnlyUntapOneLand() {
- // Winter Orb was given errata so it no longer matters if it's tapped or
- // not
- if (AllZoneUtil.getCardsIn(Zone.Battlefield, "Winter Orb").size() > 0) {
- return true;
- }
-
- if (AllZone.getPhase().getPlayerTurn().getCardsIn(Zone.Battlefield, "Mungha Wurm").size() > 0) {
- return true;
- }
-
- return false;
+ AllZone.getPhaseHandler().setNeedToNextPhase(true);
}
// ******* UPKEEP PHASE *****
@@ -460,14 +110,14 @@ public class PhaseUtil {
*
*/
public static void handleUpkeep() {
- final Player turn = AllZone.getPhase().getPlayerTurn();
+ final Player turn = AllZone.getPhaseHandler().getPlayerTurn();
if (PhaseUtil.skipUpkeep()) {
// Slowtrips all say "on the next turn's upkeep" if there is no
// upkeep next turn, the trigger will never occur.
turn.clearSlowtripList();
turn.getOpponent().clearSlowtripList();
- AllZone.getPhase().setNeedToNextPhase(true);
+ AllZone.getPhaseHandler().setNeedToNextPhase(true);
return;
}
@@ -487,7 +137,7 @@ public class PhaseUtil {
return true;
}
- final Player turn = AllZone.getPhase().getPlayerTurn();
+ final Player turn = AllZone.getPhaseHandler().getPlayerTurn();
if ((turn.getCardsIn(Zone.Hand).size() == 0) && AllZoneUtil.isCardInPlay("Gibbering Descent", turn)) {
return true;
@@ -503,10 +153,10 @@ public class PhaseUtil {
*
*/
public static void handleDraw() {
- final Player playerTurn = AllZone.getPhase().getPlayerTurn();
+ final Player playerTurn = AllZone.getPhaseHandler().getPlayerTurn();
if (PhaseUtil.skipDraw(playerTurn)) {
- AllZone.getPhase().setNeedToNextPhase(true);
+ AllZone.getPhaseHandler().setNeedToNextPhase(true);
return;
}
@@ -524,7 +174,7 @@ public class PhaseUtil {
*/
private static boolean skipDraw(final Player player) {
// starting player skips his draw
- if (AllZone.getPhase().getTurn() == 1) {
+ if (AllZone.getPhaseHandler().getTurn() == 1) {
return true;
}
@@ -656,7 +306,7 @@ public class PhaseUtil {
* @return a boolean.
*/
public static boolean isBeforeAttackersAreDeclared() {
- final String phase = AllZone.getPhase().getPhase();
+ final String phase = AllZone.getPhaseHandler().getPhase();
return phase.equals(Constant.Phase.UNTAP) || phase.equals(Constant.Phase.UPKEEP)
|| phase.equals(Constant.Phase.DRAW) || phase.equals(Constant.Phase.MAIN1)
|| phase.equals(Constant.Phase.COMBAT_BEGIN);
@@ -671,7 +321,7 @@ public class PhaseUtil {
*/
public static void visuallyActivatePhase(final String s) {
PhaseLabel lbl = null;
- final Player p = AllZone.getPhase().getPlayerTurn();
+ final Player p = AllZone.getPhaseHandler().getPlayerTurn();
final ViewTopLevel t = ((GuiTopLevel) AllZone.getDisplay()).getController().getMatchController().getView();
int i; // Index of field; computer is 0, human is 1
diff --git a/src/main/java/forge/Player.java b/src/main/java/forge/Player.java
index 77d2d6e6bee..ec7d9f60ae2 100644
--- a/src/main/java/forge/Player.java
+++ b/src/main/java/forge/Player.java
@@ -1779,7 +1779,7 @@ public abstract class Player extends GameEntity {
final ViewTopLevel t = ((GuiTopLevel) AllZone.getDisplay()).getController().getMatchController().getView();
if (t.getTabberController().getView().getLblUnlimitedLands().getEnabled() && this.isHuman() && Constant.Runtime.DEV_MODE[0]) {
- return Phase.canCastSorcery(this);
+ return PhaseHandler.canCastSorcery(this);
}
// CantBeCast static abilities
@@ -1793,7 +1793,7 @@ public abstract class Player extends GameEntity {
}
}
- return Phase.canCastSorcery(this)
+ return PhaseHandler.canCastSorcery(this)
&& ((this.numLandsPlayed < this.maxLandsToPlay) || (this.getCardsIn(Zone.Battlefield, "Fastbond")
.size() > 0));
}
diff --git a/src/main/java/forge/Untap.java b/src/main/java/forge/Untap.java
index 60033766b61..b4ef5ad427b 100644
--- a/src/main/java/forge/Untap.java
+++ b/src/main/java/forge/Untap.java
@@ -17,7 +17,11 @@
*/
package forge;
-import java.util.HashMap;
+import java.util.ArrayList;
+
+import forge.Constant.Zone;
+import forge.card.cardfactory.CardFactoryUtil;
+import forge.gui.input.Input;
/**
*
@@ -29,66 +33,358 @@ import java.util.HashMap;
* @author Forge
* @version $Id: Untap 12482 2011-12-06 11:14:11Z Sloth $
*/
-public class Untap implements java.io.Serializable {
+public class Untap extends Phase implements java.io.Serializable {
private static final long serialVersionUID = 4515266331266259123L;
- private final HashMap until = new HashMap();
/**
*
- * Add a Command that will terminate an effect with "until next untap".
+ * Executes any hardcoded triggers that happen "at end of combat".
+ *
+ */
+ @Override
+ public void executeAt() {
+ this.execute(this.at);
+
+ final Player turn = AllZone.getPhaseHandler().getPlayerTurn();
+ Untap.doPhasing(turn);
+
+ Untap.doUntap();
+ }
+
+ /**
+ *
+ * canUntap.
*
*
- * @param p
- * a {@link forge.Player} object
* @param c
- * a {@link forge.Command} object.
+ * a {@link forge.Card} object.
+ * @return a boolean.
*/
- public final void addUntil(Player p, final Command c) {
- if (null == p) {
- p = AllZone.getPhase().getPlayerTurn();
+ public static boolean canUntap(final Card c) {
+
+ if (c.hasKeyword("CARDNAME doesn't untap during your untap step.")
+ || c.hasKeyword("This card doesn't untap during your next untap step.")
+ || c.hasKeyword("This card doesn't untap during your next two untap steps.")) {
+ return false;
}
- if (this.until.containsKey(p)) {
- this.until.get(p).add(c);
- } else {
- this.until.put(p, new CommandList(c));
- }
+ final CardList allp = AllZoneUtil.getCardsIn(Zone.Battlefield);
+ for (final Card ca : allp) {
+ if (ca.hasStartOfKeyword("Permanents don't untap during their controllers' untap steps")) {
+ final int keywordPosition = ca
+ .getKeywordPosition("Permanents don't untap during their controllers' untap steps");
+ final String parse = ca.getKeyword().get(keywordPosition).toString();
+ final String[] k = parse.split(":");
+ final String[] restrictions = k[1].split(",");
+ final Card card = ca;
+ if (c.isValid(restrictions, card.getController(), card)) {
+ return false;
+ }
+ }
+ } // end of Permanents don't untap during their controllers' untap steps
+
+ return true;
}
/**
*
- * Executes the termination of effects that apply "until next untap".
- *
- *
- * @param p
- * the player the execute until for
- */
- public final void executeUntil(final Player p) {
- if (this.until.containsKey(p)) {
- this.execute(this.until.get(p));
- }
- }
-
- private void execute(final CommandList c) {
- final int length = c.size();
-
- for (int i = 0; i < length; i++) {
- c.remove(0).execute();
- }
- }
-
- /**
- *
- * Handles all the hardcoded events that happen at the beginning of each Untap Phase.
- *
- * This will freeze the Stack at the start, and unfreeze the Stack at the end.
+ * doUntap.
*
*/
- public final void executeAt() {
- AllZone.getStack().freezeStack();
+ private static void doUntap() {
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
+ CardList list = player.getCardsIn(Zone.Battlefield);
- AllZone.getStack().unfreezeStack();
+ for (final Card c : list) {
+ if (c.getBounceAtUntap() && c.getName().contains("Undiscovered Paradise")) {
+ AllZone.getGameAction().moveToHand(c);
+ }
+ }
+
+ list = list.filter(new CardListFilter() {
+ @Override
+ public boolean addCard(final Card c) {
+ if (!Untap.canUntap(c)) {
+ return false;
+ }
+ if (Untap.canOnlyUntapOneLand() && c.isLand()) {
+ return false;
+ }
+ if ((AllZoneUtil.isCardInPlay("Damping Field") || AllZoneUtil.isCardInPlay("Imi Statue"))
+ && c.isArtifact()) {
+ return false;
+ }
+ if ((AllZoneUtil.isCardInPlay("Smoke") || AllZoneUtil.isCardInPlay("Stoic Angel") || AllZoneUtil
+ .isCardInPlay("Intruder Alarm")) && c.isCreature()) {
+ return false;
+ }
+ return true;
+ }
+ });
+
+ for (final Card c : list) {
+ if (c.hasKeyword("You may choose not to untap CARDNAME during your untap step.")) {
+ if (c.isTapped()) {
+ if (c.getController().isHuman()) {
+ String prompt = "Untap " + c.getName() + "?";
+ boolean defaultNo = false;
+ if (c.getGainControlTargets().size() > 0) {
+ final ArrayList targets = c.getGainControlTargets();
+ prompt += "\r\n" + c + " is controlling: ";
+ for (final Card target : targets) {
+ prompt += target;
+ if (AllZoneUtil.isCardInPlay(target)) {
+ defaultNo |= true;
+ }
+ }
+ }
+ if (GameActionUtil.showYesNoDialog(c, prompt, defaultNo)) {
+ c.untap();
+ }
+ } else { // computer
+ // if it is controlling something by staying tapped,
+ // leave it tapped
+ // if not, untap it
+ if (c.getGainControlTargets().size() > 0) {
+ final ArrayList targets = c.getGainControlTargets();
+ boolean untap = true;
+ for (final Card target : targets) {
+ if (AllZoneUtil.isCardInPlay(target)) {
+ untap |= true;
+ }
+ }
+ if (untap) {
+ c.untap();
+ }
+ }
+ }
+ }
+ } else if ((c.getCounters(Counters.WIND) > 0) && AllZoneUtil.isCardInPlay("Freyalise's Winds")) {
+ // remove a WIND counter instead of untapping
+ c.subtractCounter(Counters.WIND, 1);
+ } else {
+ c.untap();
+ }
+ }
+
+ // opponent untapping during your untap phase
+ final CardList opp = player.getOpponent().getCardsIn(Zone.Battlefield);
+ for (final Card oppCard : opp) {
+ if (oppCard.hasKeyword("CARDNAME untaps during each other player's untap step.")) {
+ oppCard.untap();
+ // end opponent untapping during your untap phase
+ }
+ }
+
+ if (Untap.canOnlyUntapOneLand()) {
+ if (AllZone.getPhaseHandler().getPlayerTurn().isComputer()) {
+ // search for lands the computer has and only untap 1
+ CardList landList = AllZoneUtil.getPlayerLandsInPlay(AllZone.getComputerPlayer());
+ landList = landList.filter(CardListFilter.TAPPED).filter(new CardListFilter() {
+ @Override
+ public boolean addCard(final Card c) {
+ return Untap.canUntap(c);
+ }
+ });
+ if (landList.size() > 0) {
+ landList.get(0).untap();
+ }
+ } else {
+ final Input target = new Input() {
+ private static final long serialVersionUID = 6653677835629939465L;
+
+ @Override
+ public void showMessage() {
+ AllZone.getDisplay().showMessage("Select one tapped land to untap");
+ ButtonUtil.enableOnlyCancel();
+ }
+
+ @Override
+ public void selectButtonCancel() {
+ this.stop();
+ }
+
+ @Override
+ public void selectCard(final Card c, final PlayerZone zone) {
+ if (c.isLand() && zone.is(Constant.Zone.Battlefield) && c.isTapped() && Untap.canUntap(c)) {
+ c.untap();
+ this.stop();
+ }
+ } // selectCard()
+ }; // Input
+ CardList landList = AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer());
+ landList = landList.filter(CardListFilter.TAPPED).filter(new CardListFilter() {
+ @Override
+ public boolean addCard(final Card c) {
+ return Untap.canUntap(c);
+ }
+ });
+ if (landList.size() > 0) {
+ AllZone.getInputControl().setInput(target);
+ }
+ }
+ }
+ if (AllZoneUtil.isCardInPlay("Damping Field") || AllZoneUtil.isCardInPlay("Imi Statue")) {
+ if (AllZone.getPhaseHandler().getPlayerTurn().isComputer()) {
+ CardList artList = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield);
+ artList = artList.filter(CardListFilter.ARTIFACTS);
+ artList = artList.filter(CardListFilter.TAPPED).filter(new CardListFilter() {
+ @Override
+ public boolean addCard(final Card c) {
+ return Untap.canUntap(c);
+ }
+ });
+ if (artList.size() > 0) {
+ CardFactoryUtil.getBestArtifactAI(artList).untap();
+ }
+ } else {
+ final Input target = new Input() {
+ private static final long serialVersionUID = 5555427219659889707L;
+
+ @Override
+ public void showMessage() {
+ AllZone.getDisplay().showMessage("Select one tapped artifact to untap");
+ ButtonUtil.enableOnlyCancel();
+ }
+
+ @Override
+ public void selectButtonCancel() {
+ this.stop();
+ }
+
+ @Override
+ public void selectCard(final Card c, final PlayerZone zone) {
+ if (c.isArtifact() && zone.is(Constant.Zone.Battlefield) && c.getController().isHuman()
+ && Untap.canUntap(c)) {
+ c.untap();
+ this.stop();
+ }
+ } // selectCard()
+ }; // Input
+ CardList artList = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield);
+ artList = artList.filter(CardListFilter.ARTIFACTS);
+ artList = artList.filter(CardListFilter.TAPPED).filter(new CardListFilter() {
+ @Override
+ public boolean addCard(final Card c) {
+ return Untap.canUntap(c);
+ }
+ });
+ if (artList.size() > 0) {
+ AllZone.getInputControl().setInput(target);
+ }
+ }
+ }
+ if ((AllZoneUtil.isCardInPlay("Smoke") || AllZoneUtil.isCardInPlay("Stoic Angel"))) {
+ if (AllZone.getPhaseHandler().getPlayerTurn().isComputer()) {
+ CardList creatures = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer());
+ creatures = creatures.filter(CardListFilter.TAPPED).filter(new CardListFilter() {
+ @Override
+ public boolean addCard(final Card c) {
+ return Untap.canUntap(c);
+ }
+ });
+ if (creatures.size() > 0) {
+ creatures.get(0).untap();
+ }
+ } else {
+ final Input target = new Input() {
+ private static final long serialVersionUID = 5555427219659889707L;
+
+ @Override
+ public void showMessage() {
+ AllZone.getDisplay().showMessage("Select one creature to untap");
+ ButtonUtil.enableOnlyCancel();
+ }
+
+ @Override
+ public void selectButtonCancel() {
+ this.stop();
+ }
+
+ @Override
+ public void selectCard(final Card c, final PlayerZone zone) {
+ if (c.isCreature() && zone.is(Constant.Zone.Battlefield) && c.getController().isHuman()
+ && Untap.canUntap(c)) {
+ c.untap();
+ this.stop();
+ }
+ } // selectCard()
+ }; // Input
+ CardList creatures = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer());
+ creatures = creatures.filter(CardListFilter.TAPPED).filter(new CardListFilter() {
+ @Override
+ public boolean addCard(final Card c) {
+ return Untap.canUntap(c);
+ }
+ });
+ if (creatures.size() > 0) {
+ AllZone.getInputControl().setInput(target);
+ }
+ }
+ }
+
+ // Remove temporary keywords
+ list = player.getCardsIn(Zone.Battlefield);
+ for (final Card c : list) {
+ c.removeAllExtrinsicKeyword("This card doesn't untap during your next untap step.");
+ c.removeAllExtrinsicKeyword("HIDDEN This card doesn't untap during your next untap step.");
+ if (c.hasKeyword("This card doesn't untap during your next two untap steps.")) {
+ c.removeAllExtrinsicKeyword("HIDDEN This card doesn't untap during your next two untap steps.");
+ c.addHiddenExtrinsicKeyword("This card doesn't untap during your next untap step.");
+ }
+ }
+ } // end doUntap
+
+ private static boolean canOnlyUntapOneLand() {
+ // Winter Orb was given errata so it no longer matters if it's tapped or
+ // not
+ if (AllZoneUtil.getCardsIn(Zone.Battlefield, "Winter Orb").size() > 0) {
+ return true;
+ }
+
+ if (AllZone.getPhaseHandler().getPlayerTurn().getCardsIn(Zone.Battlefield, "Mungha Wurm").size() > 0) {
+ return true;
+ }
+
+ return false;
+ }
+
+ private static void doPhasing(final Player turn) {
+ // Needs to include phased out cards
+ final CardList list = turn.getCardsIncludePhasingIn(Constant.Zone.Battlefield).filter(new CardListFilter() {
+
+ @Override
+ public boolean addCard(final Card c) {
+ return ((c.isPhasedOut() && c.isDirectlyPhasedOut()) || c.hasKeyword("Phasing"));
+ }
+ });
+
+ // If c has things attached to it, they phase out simultaneously, and
+ // will phase back in with it
+ // If c is attached to something, it will phase out on its own, and try
+ // to attach back to that thing when it comes back
+ for (final Card c : list) {
+ if (c.isPhasedOut()) {
+ c.phase();
+ } else if (c.hasKeyword("Phasing")) {
+ // 702.23g If an object would simultaneously phase out directly
+ // and indirectly, it just phases out indirectly.
+ if (c.isAura()) {
+ final GameEntity ent = c.getEnchanting();
+
+ if ((ent instanceof Card) && list.contains((Card) ent)) {
+ continue;
+ }
+ } else if (c.isEquipment() && c.isEquipping()) {
+ if (list.contains(c.getEquippingCard())) {
+ continue;
+ }
+ }
+ // TODO: Fortification
+ c.phase();
+ }
+ }
}
} //end class Untap
diff --git a/src/main/java/forge/Upkeep.java b/src/main/java/forge/Upkeep.java
index 6084b64aa1f..e01f593b709 100644
--- a/src/main/java/forge/Upkeep.java
+++ b/src/main/java/forge/Upkeep.java
@@ -18,7 +18,6 @@
package forge;
import java.util.ArrayList;
-import java.util.HashMap;
import forge.Constant.Zone;
import forge.card.cardfactory.CardFactoryUtil;
@@ -39,55 +38,9 @@ import forge.gui.input.Input;
* @author Forge
* @version $Id$
*/
-public class Upkeep implements java.io.Serializable {
+public class Upkeep extends Phase implements java.io.Serializable {
private static final long serialVersionUID = 6906459482978819354L;
- private final HashMap until = new HashMap();
-
- /**
- *
- * Add a Command that will terminate an effect with "until next upkeep".
- *
- *
- * @param p
- * a {@link forge.Player} object
- * @param c
- * a {@link forge.Command} object.
- */
- public final void addUntil(Player p, final Command c) {
- if (null == p) {
- p = AllZone.getPhase().getPlayerTurn();
- }
-
- if (this.until.containsKey(p)) {
- this.until.get(p).add(c);
- } else {
- this.until.put(p, new CommandList(c));
- }
- }
-
- /**
- *
- * Executes the termination of effects that apply "until next upkeep".
- *
- *
- * @param p
- * the player the execute until for
- */
- public final void executeUntil(final Player p) {
- if (this.until.containsKey(p)) {
- this.execute(this.until.get(p));
- }
- }
-
- private void execute(final CommandList c) {
- final int length = c.size();
-
- for (int i = 0; i < length; i++) {
- c.remove(0).execute();
- }
- }
-
/**
*
* Handles all the hardcoded events that happen at the beginning of each Upkeep Phase.
@@ -95,6 +48,7 @@ public class Upkeep implements java.io.Serializable {
* This will freeze the Stack at the start, and unfreeze the Stack at the end.
*
*/
+ @Override
public final void executeAt() {
AllZone.getStack().freezeStack();
Upkeep.upkeepBraidOfFire();
@@ -157,7 +111,7 @@ public class Upkeep implements java.io.Serializable {
*
*/
private static void upkeepBraidOfFire() {
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
final CardList braids = player.getCardsIn(Zone.Battlefield, "Braid of Fire");
@@ -197,7 +151,7 @@ public class Upkeep implements java.io.Serializable {
*
*/
private static void upkeepEcho() {
- CardList list = AllZone.getPhase().getPlayerTurn().getCardsIn(Zone.Battlefield);
+ CardList list = AllZone.getPhaseHandler().getPlayerTurn().getCardsIn(Zone.Battlefield);
list = list.filter(new CardListFilter() {
@Override
public boolean addCard(final Card c) {
@@ -255,7 +209,7 @@ public class Upkeep implements java.io.Serializable {
*
*/
private static void upkeepSlowtrips() {
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
CardList list = player.getSlowtripList();
@@ -309,7 +263,7 @@ public class Upkeep implements java.io.Serializable {
*
*/
private static void upkeepUpkeepCost() {
- final CardList list = AllZone.getPhase().getPlayerTurn().getCardsIn(Zone.Battlefield);
+ final CardList list = AllZone.getPhaseHandler().getPlayerTurn().getCardsIn(Zone.Battlefield);
for (int i = 0; i < list.size(); i++) {
final Card c = list.get(i);
@@ -499,7 +453,7 @@ public class Upkeep implements java.io.Serializable {
* creature that player controls of his or her choice. It can't be
* regenerated.
*/
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
final CardList the = AllZoneUtil.getCardsIn(Zone.Battlefield, "The Abyss");
final CardList magus = AllZoneUtil.getCardsIn(Zone.Battlefield, "Magus of the Abyss");
@@ -575,7 +529,7 @@ public class Upkeep implements java.io.Serializable {
* At the beginning of your upkeep, you may sacrifice an artifact. If
* you don't, tap Yawgmoth Demon and it deals 2 damage to you.
*/
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
final CardList cards = player.getCardsIn(Zone.Battlefield, "Yawgmoth Demon");
for (int i = 0; i < cards.size(); i++) {
@@ -649,7 +603,7 @@ public class Upkeep implements java.io.Serializable {
* At the beginning of your upkeep, sacrifice a creature other than Lord
* of the Pit. If you can't, Lord of the Pit deals 7 damage to you.
*/
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
final CardList lords = player.getCardsIn(Zone.Battlefield, "Lord of the Pit");
lords.addAll(player.getCardsIn(Zone.Battlefield, "Liege of the Pit"));
final CardList cards = lords;
@@ -720,7 +674,7 @@ public class Upkeep implements java.io.Serializable {
* power. It can't be regenerated. If two or more creatures are tied for
* least power, you choose one of them.
*/
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
final CardList drops = player.getCardsIn(Zone.Battlefield, "Drop of Honey");
drops.addAll(player.getCardsIn(Zone.Battlefield, "Porphyry Nodes"));
final CardList cards = drops;
@@ -796,7 +750,7 @@ public class Upkeep implements java.io.Serializable {
* Hordes and sacrifice a land of an opponent's choice.
*/
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
final CardList cards = player.getCardsIn(Zone.Battlefield, "Demonic Hordes");
for (int i = 0; i < cards.size(); i++) {
@@ -883,7 +837,7 @@ public class Upkeep implements java.io.Serializable {
*
*/
private static void upkeepInkDissolver() {
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
final Player opponent = player.getOpponent();
final CardList kinship = player.getCardsIn(Zone.Battlefield, "Ink Dissolver");
@@ -970,7 +924,7 @@ public class Upkeep implements java.io.Serializable {
*
*/
private static void upkeepKithkinZephyrnaut() {
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
final CardList kinship = player.getCardsIn(Zone.Battlefield, "Kithkin Zephyrnaut");
final PlayerZone library = player.getZone(Constant.Zone.Library);
@@ -1072,7 +1026,7 @@ public class Upkeep implements java.io.Serializable {
*
*/
private static void upkeepLeafCrownedElder() {
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
final CardList kinship = player.getCardsIn(Zone.Battlefield, "Leaf-Crowned Elder");
final PlayerZone library = player.getZone(Constant.Zone.Library);
@@ -1172,7 +1126,7 @@ public class Upkeep implements java.io.Serializable {
*
*/
private static void upkeepMudbuttonClanger() {
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
final CardList kinship = player.getCardsIn(Zone.Battlefield, "Mudbutton Clanger");
final PlayerZone library = player.getZone(Constant.Zone.Library);
@@ -1269,7 +1223,7 @@ public class Upkeep implements java.io.Serializable {
*
*/
private static void upkeepNightshadeSchemers() {
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
final CardList kinship = player.getCardsIn(Zone.Battlefield, "Nightshade Schemers");
final Player opponent = player.getOpponent();
@@ -1354,7 +1308,7 @@ public class Upkeep implements java.io.Serializable {
*
*/
private static void upkeepPyroclastConsul() {
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
final CardList kinship = player.getCardsIn(Zone.Battlefield, "Pyroclast Consul");
final PlayerZone library = player.getZone(Constant.Zone.Library);
@@ -1453,7 +1407,7 @@ public class Upkeep implements java.io.Serializable {
*
*/
private static void upkeepSensationGorger() {
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
final CardList kinship = player.getCardsIn(Zone.Battlefield, "Sensation Gorger");
final Player opponent = player.getOpponent();
@@ -1545,7 +1499,7 @@ public class Upkeep implements java.io.Serializable {
*
*/
private static void upkeepSqueakingPieGrubfellows() {
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
final CardList kinship = player.getCardsIn(Zone.Battlefield, "Squeaking Pie Grubfellows");
final Player opponent = player.getOpponent();
@@ -1631,7 +1585,7 @@ public class Upkeep implements java.io.Serializable {
*
*/
private static void upkeepWanderingGraybeard() {
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
final CardList kinship = player.getCardsIn(Zone.Battlefield, "Wandering Graybeard");
final PlayerZone library = player.getZone(Constant.Zone.Library);
@@ -1715,7 +1669,7 @@ public class Upkeep implements java.io.Serializable {
*
*/
private static void upkeepWaterspoutWeavers() {
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
final CardList kinship = player.getCardsIn(Zone.Battlefield, "Waterspout Weavers");
final PlayerZone library = player.getZone(Constant.Zone.Library);
@@ -1820,7 +1774,7 @@ public class Upkeep implements java.io.Serializable {
*
*/
private static void upkeepWinnowerPatrol() {
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
final CardList kinship = player.getCardsIn(Zone.Battlefield, "Winnower Patrol");
final PlayerZone library = player.getZone(Constant.Zone.Library);
@@ -1904,7 +1858,7 @@ public class Upkeep implements java.io.Serializable {
*
*/
private static void upkeepWolfSkullShaman() {
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
final CardList kinship = player.getCardsIn(Zone.Battlefield, "Wolf-Skull Shaman");
final PlayerZone library = player.getZone(Constant.Zone.Library);
@@ -1995,7 +1949,7 @@ public class Upkeep implements java.io.Serializable {
*
*/
private static void upkeepSuspend() {
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
CardList list = player.getCardsIn(Zone.Exile);
@@ -2025,7 +1979,7 @@ public class Upkeep implements java.io.Serializable {
*/
private static void upkeepVanishing() {
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
CardList list = player.getCardsIn(Zone.Battlefield);
list = list.filter(new CardListFilter() {
@Override
@@ -2061,7 +2015,7 @@ public class Upkeep implements java.io.Serializable {
*/
private static void upkeepFading() {
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
CardList list = player.getCardsIn(Zone.Battlefield);
list = list.filter(new CardListFilter() {
@Override
@@ -2106,7 +2060,7 @@ public class Upkeep implements java.io.Serializable {
return;
}
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
if (AllZoneUtil.compareTypeAmountInPlay(player, "Creature") < 0) {
for (int i = 0; i < oathList.size(); i++) {
@@ -2187,7 +2141,7 @@ public class Upkeep implements java.io.Serializable {
return;
}
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
if (AllZoneUtil.compareTypeAmountInGraveyard(player, "Creature") > 0) {
for (int i = 0; i < oathList.size(); i++) {
@@ -2231,7 +2185,7 @@ public class Upkeep implements java.io.Serializable {
*
*/
private static void upkeepKarma() {
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
final CardList karmas = AllZoneUtil.getCardsIn(Zone.Battlefield, "Karma");
final CardList swamps = player.getCardsIn(Zone.Battlefield).getType("Swamp");
@@ -2270,7 +2224,7 @@ public class Upkeep implements java.io.Serializable {
*
*/
private static void upkeepDegaSanctuary() {
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
final CardList list = player.getCardsIn(Zone.Battlefield, "Dega Sanctuary");
@@ -2309,7 +2263,7 @@ public class Upkeep implements java.io.Serializable {
*
*/
private static void upkeepCetaSanctuary() {
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
final CardList list = player.getCardsIn(Zone.Battlefield, "Ceta Sanctuary");
@@ -2359,7 +2313,7 @@ public class Upkeep implements java.io.Serializable {
* to that player, where X is the number of untapped lands he or she
* controlled at the beginning of this turn.
*/
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
final CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield, "Power Surge");
final int damage = player.getNumPowerSurgeLands();
@@ -2390,7 +2344,7 @@ public class Upkeep implements java.io.Serializable {
private static void upkeepVesuvanDoppelgangerKeyword() {
// TODO - what about enchantments? i dont know how great this solution
// is
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
final String keyword = "At the beginning of your upkeep, you may have this "
+ "creature become a copy of target creature except it doesn't copy that "
+ "creature's color. If you do, this creature gains this ability.";
@@ -2480,7 +2434,7 @@ public class Upkeep implements java.io.Serializable {
*
*/
private static void upkeepTangleWire() {
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
final CardList wires = AllZoneUtil.getCardsIn(Zone.Battlefield, "Tangle Wire");
for (final Card source : wires) {
@@ -2546,7 +2500,7 @@ public class Upkeep implements java.io.Serializable {
*
*/
private static void upkeepMasticore() {
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
final CardList list = player.getCardsIn(Zone.Battlefield, "Masticore");
list.addAll(player.getCardsIn(Zone.Battlefield, "Molten-Tail Masticore"));
@@ -2617,7 +2571,7 @@ public class Upkeep implements java.io.Serializable {
*
*/
private static void upkeepEldraziMonument() {
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
final CardList list = player.getCardsIn(Zone.Battlefield, "Eldrazi Monument");
@@ -2665,7 +2619,7 @@ public class Upkeep implements java.io.Serializable {
*
*/
private static void upkeepBlazeCounters() {
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
CardList blaze = player.getCardsIn(Zone.Battlefield);
blaze = blaze.filter(new CardListFilter() {
@@ -2700,7 +2654,7 @@ public class Upkeep implements java.io.Serializable {
*
*/
private static void upkeepCarnophage() {
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
final CardList list = player.getCardsIn(Zone.Battlefield, "Carnophage");
if (player.isHuman()) {
@@ -2732,7 +2686,7 @@ public class Upkeep implements java.io.Serializable {
*
*/
private static void upkeepSangrophage() {
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
final CardList list = player.getCardsIn(Zone.Battlefield, "Sangrophage");
if (player.isHuman()) {
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactory.java b/src/main/java/forge/card/abilityfactory/AbilityFactory.java
index a1bec12d3e6..40ce769b526 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactory.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactory.java
@@ -1356,11 +1356,11 @@ public class AbilityFactory {
return false;
}
- if (sa.getRestrictions().getPlaneswalker() && AllZone.getPhase().is(Constant.Phase.MAIN2)) {
+ if (sa.getRestrictions().getPlaneswalker() && AllZone.getPhaseHandler().is(Constant.Phase.MAIN2)) {
return true;
}
- return (AllZone.getPhase().is(Constant.Phase.END_OF_TURN) && AllZone.getPhase().isNextTurn(
+ return (AllZone.getPhaseHandler().is(Constant.Phase.END_OF_TURN) && AllZone.getPhaseHandler().isNextTurn(
AllZone.getComputerPlayer()));
}
@@ -1376,8 +1376,8 @@ public class AbilityFactory {
*/
public static boolean waitForBlocking(final SpellAbility sa) {
- return (sa.getSourceCard().isCreature() && sa.getPayCosts().getTap() && (AllZone.getPhase().isBefore(
- Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY) || AllZone.getPhase().isNextTurn(
+ return (sa.getSourceCard().isCreature() && sa.getPayCosts().getTap() && (AllZone.getPhaseHandler().isBefore(
+ Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY) || AllZone.getPhaseHandler().isNextTurn(
AllZone.getHumanPlayer())));
}
@@ -1867,7 +1867,6 @@ public class AbilityFactory {
}
}
} else if (defined.startsWith("Replaced")) {
- String bleh = defined.substring(8);
final SpellAbility root = sa.getRootSpellAbility();
Object o = null;
if (defined.endsWith("Controller")) {
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryAlterLife.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryAlterLife.java
index ec71abf491b..869c44b2427 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryAlterLife.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryAlterLife.java
@@ -295,7 +295,7 @@ public class AbilityFactoryAlterLife {
}
// Don't use lifegain before main 2 if possible
- if (AllZone.getPhase().isBefore(Constant.Phase.MAIN2) && !params.containsKey("ActivationPhases")) {
+ if (AllZone.getPhaseHandler().isBefore(Constant.Phase.MAIN2) && !params.containsKey("ActivationPhases")) {
return false;
}
@@ -663,7 +663,7 @@ public class AbilityFactoryAlterLife {
}
// Don't use loselife before main 2 if possible
- if (AllZone.getPhase().isBefore(Constant.Phase.MAIN2) && !params.containsKey("ActivationPhases") && !priority) {
+ if (AllZone.getPhaseHandler().isBefore(Constant.Phase.MAIN2) && !params.containsKey("ActivationPhases") && !priority) {
return false;
}
@@ -1092,7 +1092,7 @@ public class AbilityFactoryAlterLife {
}
// Don't use poison before main 2 if possible
- if (AllZone.getPhase().isBefore(Constant.Phase.MAIN2) && !params.containsKey("ActivationPhases")) {
+ if (AllZone.getPhaseHandler().isBefore(Constant.Phase.MAIN2) && !params.containsKey("ActivationPhases")) {
return false;
}
@@ -1311,7 +1311,7 @@ public class AbilityFactoryAlterLife {
}
// Don't use setLife before main 2 if possible
- if (AllZone.getPhase().isBefore(Constant.Phase.MAIN2) && !params.containsKey("ActivationPhases")) {
+ if (AllZone.getPhaseHandler().isBefore(Constant.Phase.MAIN2) && !params.containsKey("ActivationPhases")) {
return false;
}
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryAnimate.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryAnimate.java
index d327edd7660..24202baf71e 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryAnimate.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryAnimate.java
@@ -320,21 +320,21 @@ public final class AbilityFactoryAnimate {
// don't use instant speed animate abilities outside computers
// Combat_Begin step
- if (!AllZone.getPhase().is(Constant.Phase.COMBAT_BEGIN)
- && AllZone.getPhase().isPlayerTurn(AllZone.getComputerPlayer()) && !AbilityFactory.isSorcerySpeed(sa)
+ if (!AllZone.getPhaseHandler().is(Constant.Phase.COMBAT_BEGIN)
+ && AllZone.getPhaseHandler().isPlayerTurn(AllZone.getComputerPlayer()) && !AbilityFactory.isSorcerySpeed(sa)
&& !params.containsKey("ActivationPhases") && !params.containsKey("Permanent")) {
return false;
}
// don't use instant speed animate abilities outside humans
// Combat_Declare_Attackers_InstantAbility step
- if ((!AllZone.getPhase().is(Constant.Phase.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY) || (AllZone.getCombat()
- .getAttackers().length == 0)) && AllZone.getPhase().isPlayerTurn(AllZone.getHumanPlayer())) {
+ if ((!AllZone.getPhaseHandler().is(Constant.Phase.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY) || (AllZone.getCombat()
+ .getAttackers().length == 0)) && AllZone.getPhaseHandler().isPlayerTurn(AllZone.getHumanPlayer())) {
return false;
}
// don't activate during main2 unless this effect is permanent
- if (AllZone.getPhase().is(Constant.Phase.MAIN2) && !params.containsKey("Permanent")) {
+ if (AllZone.getPhaseHandler().is(Constant.Phase.MAIN2) && !params.containsKey("Permanent")) {
return false;
}
@@ -343,7 +343,7 @@ public final class AbilityFactoryAnimate {
boolean bFlag = false;
for (final Card c : defined) {
- bFlag |= (!c.isCreature() && !c.isTapped() && !(c.getTurnInZone() == AllZone.getPhase().getTurn()));
+ bFlag |= (!c.isCreature() && !c.isTapped() && !(c.getTurnInZone() == AllZone.getPhaseHandler().getTurn()));
// for creatures that could be improved (like Figure of Destiny)
if (c.isCreature() && (params.containsKey("Permanent") || (!c.isTapped() && !c.isSick()))) {
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryAttach.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryAttach.java
index 2e47ff4f468..b8d051e1f7c 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryAttach.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryAttach.java
@@ -898,7 +898,7 @@ public class AbilityFactoryAttach {
source.setSVar("PayX", Integer.toString(xPay));
}
- if (AllZone.getPhase().isAfter(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)
+ if (AllZone.getPhaseHandler().isAfter(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)
&& !"Curse".equals(af.getMapParams().get("AILogic"))) {
return false;
}
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryChangeZone.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryChangeZone.java
index 2b3a86f7de0..dcd1d7d4c35 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryChangeZone.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryChangeZone.java
@@ -441,7 +441,7 @@ public final class AbilityFactoryChangeZone {
}
// don't use fetching to top of library/graveyard before main2
- if (AllZone.getPhase().isBefore(Constant.Phase.MAIN2) && !params.containsKey("ActivationPhases")
+ if (AllZone.getPhaseHandler().isBefore(Constant.Phase.MAIN2) && !params.containsKey("ActivationPhases")
&& !destination.equals("Battlefield") && !destination.equals("Hand")) {
return false;
}
@@ -1354,7 +1354,7 @@ public final class AbilityFactoryChangeZone {
}
}
// Save combatants
- else if (AllZone.getPhase().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
+ else if (AllZone.getPhaseHandler().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
final CardList combatants = aiPermanents.getType("Creature");
CardListUtil.sortByEvaluateCreature(combatants);
@@ -1406,7 +1406,7 @@ public final class AbilityFactoryChangeZone {
if (origin.equals(Zone.Battlefield)
&& destination.equals(Zone.Exile)
&& (subAPI.equals("DelayedTrigger") || (subAPI.equals("ChangeZone") && subAffected.equals("Remembered")))
- && !(AllZone.getPhase().is(Constant.Phase.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY) || sa.isAbility())) {
+ && !(AllZone.getPhaseHandler().is(Constant.Phase.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY) || sa.isAbility())) {
return false;
}
@@ -1414,8 +1414,8 @@ public final class AbilityFactoryChangeZone {
if (destination.equals(Zone.Exile) || origin.equals(Zone.Battlefield)) {
// don't rush bouncing stuff when not going to attack
- if (AllZone.getPhase().isBefore(Constant.Phase.MAIN2)
- && AllZone.getPhase().isPlayerTurn(AllZone.getComputerPlayer())
+ if (AllZone.getPhaseHandler().isBefore(Constant.Phase.MAIN2)
+ && AllZone.getPhaseHandler().isPlayerTurn(AllZone.getComputerPlayer())
&& AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()).isEmpty()) {
return false;
}
@@ -1423,7 +1423,7 @@ public final class AbilityFactoryChangeZone {
}
// Only care about combatants during combat
- if (AllZone.getPhase().inCombat()) {
+ if (AllZone.getPhaseHandler().inCombat()) {
list.getValidCards("Card.attacking,Card.blocking", null, null);
}
@@ -2059,7 +2059,7 @@ public final class AbilityFactoryChangeZone {
}
// Don't cast during main1?
- if (AllZone.getPhase().is(Constant.Phase.MAIN1, AllZone.getComputerPlayer())) {
+ if (AllZone.getPhaseHandler().is(Constant.Phase.MAIN1, AllZone.getComputerPlayer())) {
return false;
}
} else if (origin.equals(Zone.Graveyard)) {
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryCombat.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryCombat.java
index e3994bb6b07..0765d1846fb 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryCombat.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryCombat.java
@@ -203,10 +203,10 @@ public final class AbilityFactoryCombat {
*/
public static boolean fogCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
// AI should only activate this during Human's Declare Blockers phase
- if (AllZone.getPhase().isPlayerTurn(sa.getActivatingPlayer())) {
+ if (AllZone.getPhaseHandler().isPlayerTurn(sa.getActivatingPlayer())) {
return false;
}
- if (!AllZone.getPhase().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
+ if (!AllZone.getPhaseHandler().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
return false;
}
@@ -216,7 +216,7 @@ public final class AbilityFactoryCombat {
}
// Don't cast it, if the effect is already in place
- if (AllZone.getPhase().isPreventCombatDamageThisTurn()) {
+ if (AllZone.getPhaseHandler().isPreventCombatDamageThisTurn()) {
return false;
}
@@ -245,10 +245,10 @@ public final class AbilityFactoryCombat {
public static boolean fogPlayDrawbackAI(final AbilityFactory af, final SpellAbility sa) {
// AI should only activate this during Human's turn
boolean chance;
- if (AllZone.getPhase().isPlayerTurn(sa.getActivatingPlayer().getOpponent())) {
- chance = AllZone.getPhase().isBefore(Constant.Phase.COMBAT_FIRST_STRIKE_DAMAGE);
+ if (AllZone.getPhaseHandler().isPlayerTurn(sa.getActivatingPlayer().getOpponent())) {
+ chance = AllZone.getPhaseHandler().isBefore(Constant.Phase.COMBAT_FIRST_STRIKE_DAMAGE);
} else {
- chance = AllZone.getPhase().isAfter(Constant.Phase.COMBAT_DAMAGE);
+ chance = AllZone.getPhaseHandler().isAfter(Constant.Phase.COMBAT_DAMAGE);
}
final AbilitySub subAb = sa.getSubAbility();
@@ -279,10 +279,10 @@ public final class AbilityFactoryCombat {
}
boolean chance;
- if (AllZone.getPhase().isPlayerTurn(sa.getActivatingPlayer().getOpponent())) {
- chance = AllZone.getPhase().isBefore(Constant.Phase.COMBAT_FIRST_STRIKE_DAMAGE);
+ if (AllZone.getPhaseHandler().isPlayerTurn(sa.getActivatingPlayer().getOpponent())) {
+ chance = AllZone.getPhaseHandler().isBefore(Constant.Phase.COMBAT_FIRST_STRIKE_DAMAGE);
} else {
- chance = AllZone.getPhase().isAfter(Constant.Phase.COMBAT_DAMAGE);
+ chance = AllZone.getPhaseHandler().isAfter(Constant.Phase.COMBAT_DAMAGE);
}
// check SubAbilities DoTrigger?
@@ -307,7 +307,7 @@ public final class AbilityFactoryCombat {
public static void fogResolve(final AbilityFactory af, final SpellAbility sa) {
// Expand Fog keyword here depending on what we need out of it.
- AllZone.getPhase().setPreventCombatDamageThisTurn(true);
+ AllZone.getPhaseHandler().setPreventCombatDamageThisTurn(true);
}
// **************************************************************
@@ -927,7 +927,7 @@ public final class AbilityFactoryCombat {
}
// only use on creatures that can attack
- if (!AllZone.getPhase().isBefore(Constant.Phase.MAIN2)) {
+ if (!AllZone.getPhaseHandler().isBefore(Constant.Phase.MAIN2)) {
return false;
}
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryCopy.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryCopy.java
index 23bf8564e39..a9b3d8df17b 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryCopy.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryCopy.java
@@ -231,7 +231,7 @@ public final class AbilityFactoryCopy {
// TODO - I'm sure someone can do this AI better
final HashMap params = af.getMapParams();
- if (params.containsKey("AtEOT") && !AllZone.getPhase().is(Constant.Phase.MAIN1)) {
+ if (params.containsKey("AtEOT") && !AllZone.getPhaseHandler().is(Constant.Phase.MAIN1)) {
return false;
} else {
double chance = .4; // 40 percent chance with instant speed stuff
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryCounters.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryCounters.java
index 36c7e43826c..83e26cfe756 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryCounters.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryCounters.java
@@ -33,7 +33,7 @@ import forge.Constant;
import forge.Constant.Zone;
import forge.Counters;
import forge.MyRandom;
-import forge.Phase;
+import forge.PhaseHandler;
import forge.Player;
import forge.PlayerZone;
import forge.card.cardfactory.CardFactoryUtil;
@@ -380,7 +380,7 @@ public class AbilityFactoryCounters {
}
// Don't use non P1P1/M1M1 counters before main 2 if possible
- if (AllZone.getPhase().isBefore(Constant.Phase.MAIN2) && !params.containsKey("ActivationPhases")
+ if (AllZone.getPhaseHandler().isBefore(Constant.Phase.MAIN2) && !params.containsKey("ActivationPhases")
&& !(type.equals("P1P1") || type.equals("M1M1"))) {
return false;
}
@@ -1691,7 +1691,7 @@ public class AbilityFactoryCounters {
}
//Check for cards that could profit from the ability
- Phase phase = AllZone.getPhase();
+ PhaseHandler phase = AllZone.getPhaseHandler();
if (type.equals("P1P1") && sa.isAbility() && source.isCreature()
&& sa.getPayCosts() != null && sa.getPayCosts().getTap()
&& (phase.isNextTurn(AllZone.getHumanPlayer())
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryDealDamage.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryDealDamage.java
index 62feb6cb88b..ed482df4179 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryDealDamage.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryDealDamage.java
@@ -349,7 +349,7 @@ public class AbilityFactoryDealDamage {
if (source.getName().equals("Stuffy Doll")) {
// Now stuffy sits around for blocking
// TODO(sol): this should also happen if Stuffy is going to die
- return AllZone.getPhase().is(Constant.Phase.END_OF_TURN, AllZone.getHumanPlayer());
+ return AllZone.getPhaseHandler().is(Constant.Phase.END_OF_TURN, AllZone.getHumanPlayer());
}
if (this.abilityFactory.isAbility()) {
@@ -425,8 +425,8 @@ public class AbilityFactoryDealDamage {
if (this.abilityFactory.isSpell()) {
// If this is a spell, cast it instead of discarding
- if ((AllZone.getPhase().is(Constant.Phase.END_OF_TURN) || AllZone.getPhase().is(Constant.Phase.MAIN2))
- && AllZone.getPhase().isPlayerTurn(comp) && (hand.size() > comp.getMaxHandSize())) {
+ if ((AllZone.getPhaseHandler().is(Constant.Phase.END_OF_TURN) || AllZone.getPhaseHandler().is(Constant.Phase.MAIN2))
+ && AllZone.getPhaseHandler().isPlayerTurn(comp) && (hand.size() > comp.getMaxHandSize())) {
return true;
}
}
@@ -572,8 +572,8 @@ public class AbilityFactoryDealDamage {
// on the stack
// or from taking combat damage
final boolean freePing = isTrigger || saMe.getPayCosts() == null || tgt.getNumTargeted() > 0
- || (AllZone.getPhase().is(Constant.Phase.END_OF_TURN) && saMe.isAbility()
- && AllZone.getPhase().isNextTurn(AllZone.getComputerPlayer()));
+ || (AllZone.getPhaseHandler().is(Constant.Phase.END_OF_TURN) && saMe.isAbility()
+ && AllZone.getPhaseHandler().isNextTurn(AllZone.getComputerPlayer()));
if (freePing && tgt.addTarget(AllZone.getHumanPlayer())) {
continue;
@@ -588,8 +588,8 @@ public class AbilityFactoryDealDamage {
// TODO: Improve Damage, we shouldn't just target the player just
// because we can
- else if (tgt.canTgtPlayer() && ((AllZone.getPhase().is(Constant.Phase.END_OF_TURN)
- && AllZone.getPhase().isNextTurn(AllZone.getComputerPlayer()))
+ else if (tgt.canTgtPlayer() && ((AllZone.getPhaseHandler().is(Constant.Phase.END_OF_TURN)
+ && AllZone.getPhaseHandler().isNextTurn(AllZone.getComputerPlayer()))
|| saMe.getPayCosts() == null || isTrigger)) {
if (tgt.addTarget(AllZone.getHumanPlayer())) {
System.out.println(saMe.getSourceCard() + "damageChoosingTargets");
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryDebuff.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryDebuff.java
index 46a6efe67e2..1bfb17a0e23 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryDebuff.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryDebuff.java
@@ -288,7 +288,7 @@ public final class AbilityFactoryDebuff {
final SpellAbilityRestriction restrict = sa.getRestrictions();
// Phase Restrictions
- if ((AllZone.getStack().size() == 0) && AllZone.getPhase().isBefore(Constant.Phase.COMBAT_BEGIN)) {
+ if ((AllZone.getStack().size() == 0) && AllZone.getPhaseHandler().isBefore(Constant.Phase.COMBAT_BEGIN)) {
// Instant-speed pumps should not be cast outside of combat when the
// stack is empty
if (!AbilityFactory.isSorcerySpeed(sa)) {
@@ -356,7 +356,7 @@ public final class AbilityFactoryDebuff {
private static boolean debuffTgtAI(final AbilityFactory af, final SpellAbility sa, final ArrayList kws,
final boolean mandatory) {
// this would be for evasive things like Flying, Unblockable, etc
- if (!mandatory && AllZone.getPhase().isAfter(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
+ if (!mandatory && AllZone.getPhaseHandler().isAfter(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
return false;
}
@@ -752,7 +752,7 @@ public final class AbilityFactoryDebuff {
});
// don't use DebuffAll after Combat_Begin until AI is improved
- if (AllZone.getPhase().isAfter(Constant.Phase.COMBAT_BEGIN)) {
+ if (AllZone.getPhaseHandler().isAfter(Constant.Phase.COMBAT_BEGIN)) {
return false;
}
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryEffect.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryEffect.java
index dac21e9c6ed..0c943487429 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryEffect.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryEffect.java
@@ -31,7 +31,7 @@ import forge.ComputerUtil;
import forge.Constant;
import forge.Constant.Zone;
import forge.MyRandom;
-import forge.Phase;
+import forge.PhaseHandler;
import forge.Player;
import forge.card.spellability.AbilityActivated;
import forge.card.spellability.AbilitySub;
@@ -225,23 +225,23 @@ public class AbilityFactoryEffect {
if (params.containsKey("AILogic")) {
logic = params.get("AILogic");
- final Phase phase = AllZone.getPhase();
+ final PhaseHandler phase = AllZone.getPhaseHandler();
if (logic.equals("BeginningOfOppTurn")) {
if (phase.isPlayerTurn(AllZone.getComputerPlayer()) || phase.isAfter(Constant.Phase.DRAW)) {
return false;
}
randomReturn = true;
} else if (logic.equals("Fog")) {
- if (AllZone.getPhase().isPlayerTurn(sa.getActivatingPlayer())) {
+ if (AllZone.getPhaseHandler().isPlayerTurn(sa.getActivatingPlayer())) {
return false;
}
- if (!AllZone.getPhase().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
+ if (!AllZone.getPhaseHandler().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
return false;
}
if (AllZone.getStack().size() != 0) {
return false;
}
- if (AllZone.getPhase().isPreventCombatDamageThisTurn()) {
+ if (AllZone.getPhaseHandler().isPreventCombatDamageThisTurn()) {
return false;
}
randomReturn = CombatUtil.lifeInDanger(AllZone.getCombat());
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryGainControl.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryGainControl.java
index cf825f30824..27b69628794 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryGainControl.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryGainControl.java
@@ -321,7 +321,7 @@ public class AbilityFactoryGainControl {
// Don't steal something if I can't Attack without, or prevent it from
// blocking at least
if ((this.lose != null) && this.lose.contains("EOT")
- && AllZone.getPhase().isAfter(Constant.Phase.COMBAT_DECLARE_BLOCKERS)) {
+ && AllZone.getPhaseHandler().isAfter(Constant.Phase.COMBAT_DECLARE_BLOCKERS)) {
return false;
}
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryPermanentState.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryPermanentState.java
index 7994324a3eb..e50a50f4a54 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryPermanentState.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryPermanentState.java
@@ -31,7 +31,7 @@ import forge.ComputerUtil;
import forge.Constant;
import forge.Constant.Zone;
import forge.MyRandom;
-import forge.Phase;
+import forge.PhaseHandler;
import forge.Player;
import forge.card.cardfactory.CardFactoryUtil;
import forge.card.cost.Cost;
@@ -798,7 +798,7 @@ public class AbilityFactoryPermanentState {
final Random r = MyRandom.getRandom();
boolean randomReturn = r.nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn());
- final Phase phase = AllZone.getPhase();
+ final PhaseHandler phase = AllZone.getPhaseHandler();
final Player turn = phase.getPlayerTurn();
if (turn.isHuman()) {
@@ -1546,7 +1546,7 @@ public class AbilityFactoryPermanentState {
final Card source = sa.getSourceCard();
final HashMap params = af.getMapParams();
- if (AllZone.getPhase().isAfter(Constant.Phase.COMBAT_BEGIN)) {
+ if (AllZone.getPhaseHandler().isAfter(Constant.Phase.COMBAT_BEGIN)) {
return false;
}
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryPreventDamage.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryPreventDamage.java
index f0072c665c2..ac17daca1f0 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryPreventDamage.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryPreventDamage.java
@@ -284,7 +284,7 @@ public class AbilityFactoryPreventDamage {
}
}
} else {
- if (AllZone.getPhase().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
+ if (AllZone.getPhaseHandler().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
boolean flag = false;
for (final Object o : objects) {
if (o instanceof Card) {
@@ -335,7 +335,7 @@ public class AbilityFactoryPreventDamage {
}
} // Protect combatants
- else if (AllZone.getPhase().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
+ else if (AllZone.getPhaseHandler().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
if (tgt.canTgtPlayer() && CombatUtil.wouldLoseLife(AllZone.getCombat())
&& (CombatUtil.lifeInDanger(AllZone.getCombat()) || sa.isAbility())) {
tgt.addTarget(AllZone.getComputerPlayer());
@@ -440,7 +440,7 @@ public class AbilityFactoryPreventDamage {
if (compTargetables.size() > 0) {
final CardList combatants = compTargetables.getType("Creature");
CardListUtil.sortByEvaluateCreature(combatants);
- if (AllZone.getPhase().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
+ if (AllZone.getPhaseHandler().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
for (final Card c : combatants) {
if (CombatUtil.combatantWouldBeDestroyed(c)) {
tgt.addTarget(c);
@@ -688,7 +688,7 @@ public class AbilityFactoryPreventDamage {
// control
} // Protect combatants
- else if (AllZone.getPhase().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
+ else if (AllZone.getPhaseHandler().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
// TODO
}
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryProtection.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryProtection.java
index d331c81656a..08536b172db 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryProtection.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryProtection.java
@@ -232,8 +232,8 @@ public final class AbilityFactoryProtection {
// will the creature attack (only relevant for sorcery speed)?
if (CardFactoryUtil.doesCreatureAttackAI(c)
- && AllZone.getPhase().isBefore(Constant.Phase.COMBAT_DECLARE_ATTACKERS)
- && AllZone.getPhase().isPlayerTurn(AllZone.getComputerPlayer())) {
+ && AllZone.getPhaseHandler().isBefore(Constant.Phase.COMBAT_DECLARE_ATTACKERS)
+ && AllZone.getPhaseHandler().isPlayerTurn(AllZone.getComputerPlayer())) {
return true;
}
@@ -246,7 +246,7 @@ public final class AbilityFactoryProtection {
}
// is the creature in blocked and the blocker would survive
- if (AllZone.getPhase().isAfter(Constant.Phase.COMBAT_DECLARE_BLOCKERS)
+ if (AllZone.getPhaseHandler().isAfter(Constant.Phase.COMBAT_DECLARE_BLOCKERS)
&& AllZone.getCombat().isAttacking(c) && AllZone.getCombat().isBlocked(c)
&& CombatUtil.blockerWouldBeDestroyed(AllZone.getCombat().getBlockers(c).get(0))) {
return true;
@@ -297,7 +297,7 @@ public final class AbilityFactoryProtection {
}
// Phase Restrictions
- if ((AllZone.getStack().size() == 0) && AllZone.getPhase().isBefore(Constant.Phase.COMBAT_FIRST_STRIKE_DAMAGE)) {
+ if ((AllZone.getStack().size() == 0) && AllZone.getPhaseHandler().isBefore(Constant.Phase.COMBAT_FIRST_STRIKE_DAMAGE)) {
// Instant-speed protections should not be cast outside of combat
// when the stack is empty
if (!AbilityFactory.isSorcerySpeed(sa)) {
@@ -344,7 +344,7 @@ public final class AbilityFactoryProtection {
* @return a boolean.
*/
private static boolean protectTgtAI(final AbilityFactory af, final SpellAbility sa, final boolean mandatory) {
- if (!mandatory && AllZone.getPhase().isAfter(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
+ if (!mandatory && AllZone.getPhaseHandler().isAfter(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
return false;
}
@@ -371,12 +371,12 @@ public final class AbilityFactoryProtection {
// If the cost is tapping, don't activate before declare
// attack/block
if ((sa.getPayCosts() != null) && sa.getPayCosts().getTap()) {
- if (AllZone.getPhase().isBefore(Constant.Phase.COMBAT_DECLARE_ATTACKERS)
- && AllZone.getPhase().isPlayerTurn(AllZone.getComputerPlayer())) {
+ if (AllZone.getPhaseHandler().isBefore(Constant.Phase.COMBAT_DECLARE_ATTACKERS)
+ && AllZone.getPhaseHandler().isPlayerTurn(AllZone.getComputerPlayer())) {
list.remove(sa.getSourceCard());
}
- if (AllZone.getPhase().isBefore(Constant.Phase.COMBAT_DECLARE_BLOCKERS)
- && AllZone.getPhase().isPlayerTurn(AllZone.getHumanPlayer())) {
+ if (AllZone.getPhaseHandler().isBefore(Constant.Phase.COMBAT_DECLARE_BLOCKERS)
+ && AllZone.getPhaseHandler().isPlayerTurn(AllZone.getHumanPlayer())) {
list.remove(sa.getSourceCard());
}
}
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryPump.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryPump.java
index 780bc099e27..2ae43ff169d 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryPump.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryPump.java
@@ -289,23 +289,23 @@ public class AbilityFactoryPump {
}
// give haste to creatures that could attack with it
- if (c.hasSickness() && kHaste && AllZone.getPhase().isPlayerTurn(AllZone.getComputerPlayer())
+ if (c.hasSickness() && kHaste && AllZone.getPhaseHandler().isPlayerTurn(AllZone.getComputerPlayer())
&& CombatUtil.canAttackNextTurn(c) && c.isUntapped()
- && AllZone.getPhase().isBefore(Constant.Phase.COMBAT_DECLARE_ATTACKERS)) {
+ && AllZone.getPhaseHandler().isBefore(Constant.Phase.COMBAT_DECLARE_ATTACKERS)) {
return true;
}
// give evasive keywords to creatures that can attack
- if (evasive && AllZone.getPhase().isPlayerTurn(AllZone.getComputerPlayer()) && CombatUtil.canAttack(c)
- && AllZone.getPhase().isBefore(Constant.Phase.COMBAT_DECLARE_ATTACKERS)
+ if (evasive && AllZone.getPhaseHandler().isPlayerTurn(AllZone.getComputerPlayer()) && CombatUtil.canAttack(c)
+ && AllZone.getPhaseHandler().isBefore(Constant.Phase.COMBAT_DECLARE_ATTACKERS)
&& (c.getNetCombatDamage() > 0)) {
return true;
}
// will the creature attack (only relevant for sorcery speed)?
if (CardFactoryUtil.doesCreatureAttackAI(c)
- && AllZone.getPhase().isBefore(Constant.Phase.COMBAT_DECLARE_ATTACKERS)
- && AllZone.getPhase().isPlayerTurn(AllZone.getComputerPlayer())) {
+ && AllZone.getPhaseHandler().isBefore(Constant.Phase.COMBAT_DECLARE_ATTACKERS)
+ && AllZone.getPhaseHandler().isPlayerTurn(AllZone.getComputerPlayer())) {
return true;
}
@@ -318,13 +318,13 @@ public class AbilityFactoryPump {
}
// is the creature unblocked and the spell will pump its power?
- if (AllZone.getPhase().isAfter(Constant.Phase.COMBAT_DECLARE_BLOCKERS)
+ if (AllZone.getPhaseHandler().isAfter(Constant.Phase.COMBAT_DECLARE_BLOCKERS)
&& AllZone.getCombat().isAttacking(c) && AllZone.getCombat().isUnblocked(c) && (attack > 0)) {
return true;
}
// is the creature blocked and the blocker would survive
- if (AllZone.getPhase().isAfter(Constant.Phase.COMBAT_DECLARE_BLOCKERS) && (attack > 0)
+ if (AllZone.getPhaseHandler().isAfter(Constant.Phase.COMBAT_DECLARE_BLOCKERS) && (attack > 0)
&& AllZone.getCombat().isAttacking(c) && AllZone.getCombat().isBlocked(c)
&& (AllZone.getCombat().getBlockers(c) != null)
&& !CombatUtil.blockerWouldBeDestroyed(AllZone.getCombat().getBlockers(c).get(0))) {
@@ -334,10 +334,10 @@ public class AbilityFactoryPump {
// if the life of the computer is in danger, try to pump
// potential blockers before declaring blocks
if (CombatUtil.lifeInDanger(AllZone.getCombat())
- && AllZone.getPhase().isAfter(Constant.Phase.COMBAT_DECLARE_ATTACKERS)
- && AllZone.getPhase().isBefore(Constant.Phase.MAIN2)
+ && AllZone.getPhaseHandler().isAfter(Constant.Phase.COMBAT_DECLARE_ATTACKERS)
+ && AllZone.getPhaseHandler().isBefore(Constant.Phase.MAIN2)
&& CombatUtil.canBlock(c, AllZone.getCombat())
- && AllZone.getPhase().isPlayerTurn(AllZone.getHumanPlayer())) {
+ && AllZone.getPhaseHandler().isPlayerTurn(AllZone.getHumanPlayer())) {
return true;
}
@@ -387,10 +387,10 @@ public class AbilityFactoryPump {
if (addsKeywords) {
if (!this.containsCombatRelevantKeyword(this.keywords)
- && AllZone.getPhase().isBefore(Constant.Phase.MAIN2)) {
+ && AllZone.getPhaseHandler().isBefore(Constant.Phase.MAIN2)) {
list.clear(); // this keyword is not combat relevenat
} else if (this.keywords.get(0).equals("HIDDEN CARDNAME attacks each turn if able.")
- && AllZone.getPhase().isPlayerTurn(AllZone.getComputerPlayer())) {
+ && AllZone.getPhaseHandler().isPlayerTurn(AllZone.getComputerPlayer())) {
list.clear();
}
@@ -456,7 +456,7 @@ public class AbilityFactoryPump {
final SpellAbilityRestriction restrict = sa.getRestrictions();
// Phase Restrictions
- if ((AllZone.getStack().size() == 0) && AllZone.getPhase().isBefore(Constant.Phase.COMBAT_BEGIN)) {
+ if ((AllZone.getStack().size() == 0) && AllZone.getPhaseHandler().isBefore(Constant.Phase.COMBAT_BEGIN)) {
// Instant-speed pumps should not be cast outside of combat when the
// stack is empty
if (!this.abilityFactory.isCurse() && !AbilityFactory.isSorcerySpeed(sa)) {
@@ -561,7 +561,7 @@ public class AbilityFactoryPump {
*/
private boolean pumpTgtAI(final SpellAbility sa, final int defense, final int attack, final boolean mandatory) {
if (!mandatory
- && AllZone.getPhase().isAfter(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)
+ && AllZone.getPhaseHandler().isAfter(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)
&& !(this.abilityFactory.isCurse() && ((defense < 0) || !this
.containsCombatRelevantKeyword(this.keywords)))) {
return false;
@@ -582,12 +582,12 @@ public class AbilityFactoryPump {
// If the cost is tapping, don't activate before declare
// attack/block
if ((sa.getPayCosts() != null) && sa.getPayCosts().getTap()) {
- if (AllZone.getPhase().isBefore(Constant.Phase.COMBAT_DECLARE_ATTACKERS)
- && AllZone.getPhase().isPlayerTurn(AllZone.getComputerPlayer())) {
+ if (AllZone.getPhaseHandler().isBefore(Constant.Phase.COMBAT_DECLARE_ATTACKERS)
+ && AllZone.getPhaseHandler().isPlayerTurn(AllZone.getComputerPlayer())) {
list.remove(sa.getSourceCard());
}
- if (AllZone.getPhase().isBefore(Constant.Phase.COMBAT_DECLARE_BLOCKERS)
- && AllZone.getPhase().isPlayerTurn(AllZone.getHumanPlayer())) {
+ if (AllZone.getPhaseHandler().isBefore(Constant.Phase.COMBAT_DECLARE_BLOCKERS)
+ && AllZone.getPhaseHandler().isPlayerTurn(AllZone.getHumanPlayer())) {
list.remove(sa.getSourceCard());
}
}
@@ -1182,7 +1182,7 @@ public class AbilityFactoryPump {
} // end Curse
// don't use non curse PumpAll after Combat_Begin until AI is improved
- if (AllZone.getPhase().isAfter(Constant.Phase.COMBAT_BEGIN)) {
+ if (AllZone.getPhaseHandler().isAfter(Constant.Phase.COMBAT_BEGIN)) {
return false;
}
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryRegenerate.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryRegenerate.java
index 3ee9ab43e5d..0eecdd9edf7 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryRegenerate.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryRegenerate.java
@@ -270,7 +270,7 @@ public class AbilityFactoryRegenerate {
}
}
} else {
- if (AllZone.getPhase().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
+ if (AllZone.getPhaseHandler().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
boolean flag = false;
for (final Card c : list) {
@@ -314,7 +314,7 @@ public class AbilityFactoryRegenerate {
chance = true;
}
} else {
- if (AllZone.getPhase().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
+ if (AllZone.getPhaseHandler().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
final CardList combatants = targetables.getType("Creature");
CardListUtil.sortByEvaluateCreature(combatants);
@@ -406,7 +406,7 @@ public class AbilityFactoryRegenerate {
if (compTargetables.size() > 0) {
final CardList combatants = compTargetables.getType("Creature");
CardListUtil.sortByEvaluateCreature(combatants);
- if (AllZone.getPhase().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
+ if (AllZone.getPhaseHandler().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
for (final Card c : combatants) {
if ((c.getShield() == 0) && CombatUtil.combatantWouldBeDestroyed(c)) {
tgt.addTarget(c);
@@ -688,7 +688,7 @@ public class AbilityFactoryRegenerate {
// i control
} else {
- if (AllZone.getPhase().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
+ if (AllZone.getPhaseHandler().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
final CardList combatants = list.getType("Creature");
for (final Card c : combatants) {
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryReveal.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryReveal.java
index 1facbb10bf2..24d768e3629 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryReveal.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryReveal.java
@@ -266,7 +266,7 @@ public final class AbilityFactoryReveal {
}
// Don't use draw abilities before main 2 if possible
- if (AllZone.getPhase().isBefore(Constant.Phase.MAIN2) && !params.containsKey("ActivationPhases")
+ if (AllZone.getPhaseHandler().isBefore(Constant.Phase.MAIN2) && !params.containsKey("ActivationPhases")
&& !params.containsKey("DestinationZone")) {
return false;
}
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryToken.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryToken.java
index 7ee8a93b4ca..0b032abc139 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryToken.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryToken.java
@@ -284,17 +284,17 @@ public class AbilityFactoryToken extends AbilityFactory {
}
// Don't generate tokens without haste before main 2 if possible
- if (AllZone.getPhase().isBefore(Constant.Phase.MAIN2)
- && AllZone.getPhase().isPlayerTurn(AllZone.getComputerPlayer()) && !haste
+ if (AllZone.getPhaseHandler().isBefore(Constant.Phase.MAIN2)
+ && AllZone.getPhaseHandler().isPlayerTurn(AllZone.getComputerPlayer()) && !haste
&& !mapParams.containsKey("ActivationPhases")) {
return false;
}
- if ((AllZone.getPhase().isPlayerTurn(AllZone.getComputerPlayer()) || AllZone.getPhase().isBefore(
+ if ((AllZone.getPhaseHandler().isPlayerTurn(AllZone.getComputerPlayer()) || AllZone.getPhaseHandler().isBefore(
Constant.Phase.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY))
&& !mapParams.containsKey("ActivationPhases") && !AbilityFactory.isSorcerySpeed(sa)) {
return false;
}
- if ((AllZone.getPhase().isAfter(Constant.Phase.COMBAT_BEGIN) || AllZone.getPhase().isPlayerTurn(
+ if ((AllZone.getPhaseHandler().isAfter(Constant.Phase.COMBAT_BEGIN) || AllZone.getPhaseHandler().isPlayerTurn(
AllZone.getHumanPlayer()))
&& oneShot) {
return false;
@@ -349,7 +349,7 @@ public class AbilityFactoryToken extends AbilityFactory {
return chance;
}
- if (AllZone.getPhase().is(Constant.Phase.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)) {
+ if (AllZone.getPhaseHandler().is(Constant.Phase.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)) {
return ((r.nextFloat() < .95) && chance);
}
if (sa.isAbility()) {
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryTurns.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryTurns.java
index b44af24d7ad..448a79de021 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryTurns.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryTurns.java
@@ -281,7 +281,7 @@ public class AbilityFactoryTurns {
for (final Player p : tgtPlayers) {
if ((tgt == null) || p.canBeTargetedBy(sa)) {
for (int i = 0; i < numTurns; i++) {
- AllZone.getPhase().addExtraTurn(p);
+ AllZone.getPhaseHandler().addExtraTurn(p);
}
}
}
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryZoneAffecting.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryZoneAffecting.java
index dc41cb1e6a9..75032b1b82b 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryZoneAffecting.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryZoneAffecting.java
@@ -295,7 +295,7 @@ public class AbilityFactoryZoneAffecting {
}
// Don't use draw abilities before main 2 if possible
- if (AllZone.getPhase().isBefore(Constant.Phase.MAIN2) && !params.containsKey("ActivationPhases")) {
+ if (AllZone.getPhaseHandler().isBefore(Constant.Phase.MAIN2) && !params.containsKey("ActivationPhases")) {
return false;
}
@@ -309,7 +309,7 @@ public class AbilityFactoryZoneAffecting {
if (AbilityFactory.isSorcerySpeed(sa)) {
chance = .667; // 66.7% chance for sorcery speed
}
- if ((AllZone.getPhase().is(Constant.Phase.END_OF_TURN) && AllZone.getPhase().isNextTurn(
+ if ((AllZone.getPhaseHandler().is(Constant.Phase.END_OF_TURN) && AllZone.getPhaseHandler().isNextTurn(
AllZone.getComputerPlayer()))) {
chance = .9; // 90% for end of opponents turn
}
@@ -412,7 +412,7 @@ public class AbilityFactoryZoneAffecting {
}
if (((computerHandSize + numCards) > computerMaxHandSize)
- && AllZone.getPhase().getPlayerTurn().isComputer()) {
+ && AllZone.getPhaseHandler().getPlayerTurn().isComputer()) {
if (xPaid) {
numCards = computerMaxHandSize - computerHandSize;
source.setSVar("PayX", Integer.toString(numCards));
@@ -446,7 +446,7 @@ public class AbilityFactoryZoneAffecting {
}
if (((computerHandSize + numCards) > computerMaxHandSize)
- && AllZone.getPhase().getPlayerTurn().isComputer()) {
+ && AllZone.getPhaseHandler().getPlayerTurn().isComputer()) {
// Don't draw too many cards and then risk discarding cards at
// EOT
if (!(params.containsKey("NextUpkeep") || (sa instanceof AbilitySub)) && !mandatory) {
@@ -796,7 +796,7 @@ public class AbilityFactoryZoneAffecting {
final Random r = MyRandom.getRandom();
// Don't use draw abilities before main 2 if possible
- if (AllZone.getPhase().isBefore(Constant.Phase.MAIN2) && !params.containsKey("ActivationPhases")) {
+ if (AllZone.getPhaseHandler().isBefore(Constant.Phase.MAIN2) && !params.containsKey("ActivationPhases")) {
return false;
}
@@ -811,7 +811,7 @@ public class AbilityFactoryZoneAffecting {
chance = .667; // 66.7% chance for sorcery speed
}
- if ((AllZone.getPhase().is(Constant.Phase.END_OF_TURN) && AllZone.getPhase().isNextTurn(
+ if ((AllZone.getPhaseHandler().is(Constant.Phase.END_OF_TURN) && AllZone.getPhaseHandler().isNextTurn(
AllZone.getComputerPlayer()))) {
chance = .9; // 90% for end of opponents turn
}
@@ -1471,7 +1471,7 @@ public class AbilityFactoryZoneAffecting {
}
// Don't use draw abilities before main 2 if possible
- if (AllZone.getPhase().isBefore(Constant.Phase.MAIN2) && !params.containsKey("ActivationPhases")) {
+ if (AllZone.getPhaseHandler().isBefore(Constant.Phase.MAIN2) && !params.containsKey("ActivationPhases")) {
return false;
}
@@ -1486,7 +1486,7 @@ public class AbilityFactoryZoneAffecting {
chance = .75; // 75% chance for sorcery speed
}
- if ((AllZone.getPhase().is(Constant.Phase.END_OF_TURN) && AllZone.getPhase().isNextTurn(
+ if ((AllZone.getPhaseHandler().is(Constant.Phase.END_OF_TURN) && AllZone.getPhaseHandler().isNextTurn(
AllZone.getComputerPlayer()))) {
chance = .9; // 90% for end of opponents turn
}
diff --git a/src/main/java/forge/card/cardfactory/CardFactoryEquipment.java b/src/main/java/forge/card/cardfactory/CardFactoryEquipment.java
index a1b0a2fbad0..4ed55a1600e 100644
--- a/src/main/java/forge/card/cardfactory/CardFactoryEquipment.java
+++ b/src/main/java/forge/card/cardfactory/CardFactoryEquipment.java
@@ -29,7 +29,7 @@ import forge.CardUtil;
import forge.Command;
import forge.Constant;
import forge.Counters;
-import forge.Phase;
+import forge.PhaseHandler;
import forge.PlayerZone;
import forge.card.cost.Cost;
import forge.card.spellability.Ability;
@@ -218,7 +218,7 @@ class CardFactoryEquipment {
@Override
public boolean canPlay() {
return AllZone.getZoneOf(card).is(Constant.Zone.Battlefield)
- && Phase.canCastSorcery(card.getController()) && super.canPlay();
+ && PhaseHandler.canCastSorcery(card.getController()) && super.canPlay();
}
// not changed
diff --git a/src/main/java/forge/card/cardfactory/CardFactoryInstants.java b/src/main/java/forge/card/cardfactory/CardFactoryInstants.java
index 92bce4993e1..fd85398aecb 100644
--- a/src/main/java/forge/card/cardfactory/CardFactoryInstants.java
+++ b/src/main/java/forge/card/cardfactory/CardFactoryInstants.java
@@ -384,7 +384,7 @@ public class CardFactoryInstants {
public boolean canPlayAI() {
CardList human = CardFactoryUtil.getHumanCreatureAI(this, true);
human = human.getNotType("Land");
- return (4 < AllZone.getPhase().getTurn()) && (0 < human.size());
+ return (4 < AllZone.getPhaseHandler().getTurn()) && (0 < human.size());
}
@Override
@@ -707,7 +707,7 @@ public class CardFactoryInstants {
@Override
public boolean canPlay() {
return PhaseUtil.isBeforeAttackersAreDeclared()
- && AllZone.getPhase().isPlayerTurn(card.getController().getOpponent());
+ && AllZone.getPhaseHandler().isPlayerTurn(card.getController().getOpponent());
} // canPlay
@Override
diff --git a/src/main/java/forge/card/cardfactory/CardFactoryLands.java b/src/main/java/forge/card/cardfactory/CardFactoryLands.java
index 0094dcadc63..4581f2daf7c 100644
--- a/src/main/java/forge/card/cardfactory/CardFactoryLands.java
+++ b/src/main/java/forge/card/cardfactory/CardFactoryLands.java
@@ -140,7 +140,7 @@ class CardFactoryLands {
@Override
public boolean addCard(final Card c) {
return AllZoneUtil.isCardInPlay(c) && c.isCreature()
- && (c.getTurnInZone() == AllZone.getPhase().getTurn());
+ && (c.getTurnInZone() == AllZone.getPhaseHandler().getTurn());
}
};
@@ -152,7 +152,7 @@ class CardFactoryLands {
@Override
public boolean canPlayAI() {
- if (!(AllZone.getPhase().getPhase().equals(Constant.Phase.MAIN1) && AllZone.getPhase()
+ if (!(AllZone.getPhaseHandler().getPhase().equals(Constant.Phase.MAIN1) && AllZone.getPhaseHandler()
.getPlayerTurn().isComputer())) {
return false;
}
diff --git a/src/main/java/forge/card/cardfactory/CardFactoryPlaneswalkers.java b/src/main/java/forge/card/cardfactory/CardFactoryPlaneswalkers.java
index 007622af052..c0c8e4aab6a 100644
--- a/src/main/java/forge/card/cardfactory/CardFactoryPlaneswalkers.java
+++ b/src/main/java/forge/card/cardfactory/CardFactoryPlaneswalkers.java
@@ -28,7 +28,7 @@ import forge.CardUtil;
import forge.Constant;
import forge.Constant.Zone;
import forge.Counters;
-import forge.Phase;
+import forge.PhaseHandler;
import forge.Player;
import forge.PlayerZone;
import forge.card.cost.Cost;
@@ -83,7 +83,7 @@ public class CardFactoryPlaneswalkers {
@Override
public void resolve() {
card.addCounterFromNonEffect(Counters.LOYALTY, 0);
- turn[0] = AllZone.getPhase().getTurn();
+ turn[0] = AllZone.getPhaseHandler().getTurn();
final Player player = card.getController();
final PlayerZone lib = player.getZone(Constant.Zone.Library);
@@ -115,7 +115,7 @@ public class CardFactoryPlaneswalkers {
// looks like standard Planeswalker stuff...
// maybe should check if library is empty, or 1 card?
return AllZone.getZoneOf(card).is(Constant.Zone.Battlefield)
- && (turn[0] != AllZone.getPhase().getTurn()) && Phase.canCastSorcery(card.getController());
+ && (turn[0] != AllZone.getPhaseHandler().getTurn()) && PhaseHandler.canCastSorcery(card.getController());
} // canPlay()
};
final StringBuilder ab1 = new StringBuilder();
@@ -142,7 +142,7 @@ public class CardFactoryPlaneswalkers {
@Override
public void resolve() {
// card.subtractCounter(Counters.LOYALTY, 2);
- turn[0] = AllZone.getPhase().getTurn();
+ turn[0] = AllZone.getPhaseHandler().getTurn();
final Card target = this.getTargetCard();
AllZone.getGameAction().sacrifice(target);
@@ -185,8 +185,8 @@ public class CardFactoryPlaneswalkers {
@Override
public boolean canPlay() {
return AllZone.getZoneOf(card).is(Constant.Zone.Battlefield)
- && (card.getCounters(Counters.LOYALTY) >= 2) && (turn[0] != AllZone.getPhase().getTurn())
- && Phase.canCastSorcery(card.getController());
+ && (card.getCounters(Counters.LOYALTY) >= 2) && (turn[0] != AllZone.getPhaseHandler().getTurn())
+ && PhaseHandler.canCastSorcery(card.getController());
} // canPlay()
};
final StringBuilder ab2 = new StringBuilder();
@@ -208,7 +208,7 @@ public class CardFactoryPlaneswalkers {
@Override
public void resolve() {
// card.subtractCounter(Counters.LOYALTY, 4);
- turn[0] = AllZone.getPhase().getTurn();
+ turn[0] = AllZone.getPhaseHandler().getTurn();
final Player target = this.getTargetPlayer();
final Player player = card.getController();
@@ -231,8 +231,8 @@ public class CardFactoryPlaneswalkers {
@Override
public boolean canPlay() {
return AllZone.getZoneOf(card).is(Constant.Zone.Battlefield)
- && (card.getCounters(Counters.LOYALTY) >= 4) && (turn[0] != AllZone.getPhase().getTurn())
- && Phase.canCastSorcery(card.getController());
+ && (card.getCounters(Counters.LOYALTY) >= 4) && (turn[0] != AllZone.getPhaseHandler().getTurn())
+ && PhaseHandler.canCastSorcery(card.getController());
} // canPlay()
};
final StringBuilder ab3 = new StringBuilder();
diff --git a/src/main/java/forge/card/cardfactory/CardFactorySorceries.java b/src/main/java/forge/card/cardfactory/CardFactorySorceries.java
index e104c20d606..44b8aa3fd85 100644
--- a/src/main/java/forge/card/cardfactory/CardFactorySorceries.java
+++ b/src/main/java/forge/card/cardfactory/CardFactorySorceries.java
@@ -239,7 +239,7 @@ public class CardFactorySorceries {
@Override
public boolean canPlayAI() {
final CardList creatures = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer());
- return (creatures.size() > 0) && AllZone.getPhase().getPhase().equals(Constant.Phase.MAIN1);
+ return (creatures.size() > 0) && AllZone.getPhaseHandler().getPhase().equals(Constant.Phase.MAIN1);
} // canPlayAI()
}; // SpellAbility
@@ -379,7 +379,7 @@ public class CardFactorySorceries {
@Override
public void execute() {
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
final PlayerZone play = player.getZone(Constant.Zone.Battlefield);
Card mindsD = card;
if (player.isHuman()) {
@@ -413,7 +413,7 @@ public class CardFactorySorceries {
@Override
public void execute() {
- final Player player = AllZone.getPhase().getPlayerTurn();
+ final Player player = AllZone.getPhaseHandler().getPlayerTurn();
final PlayerZone play = player.getZone(Constant.Zone.Battlefield);
play.remove(minds);
}
diff --git a/src/main/java/forge/card/cardfactory/CardFactoryUtil.java b/src/main/java/forge/card/cardfactory/CardFactoryUtil.java
index 687c11f0f26..df3c93c2847 100644
--- a/src/main/java/forge/card/cardfactory/CardFactoryUtil.java
+++ b/src/main/java/forge/card/cardfactory/CardFactoryUtil.java
@@ -46,7 +46,7 @@ import forge.Counters;
import forge.GameActionUtil;
import forge.HandSizeOp;
import forge.MyRandom;
-import forge.Phase;
+import forge.PhaseHandler;
import forge.Player;
import forge.PlayerZone;
import forge.card.abilityfactory.AbilityFactory;
@@ -892,8 +892,8 @@ public class CardFactoryUtil {
@Override
public boolean canPlayAI() {
- if (AllZone.getPhase().isAfter(Constant.Phase.MAIN1)
- || AllZone.getPhase().isPlayerTurn(AllZone.getHumanPlayer())) {
+ if (AllZone.getPhaseHandler().isAfter(Constant.Phase.MAIN1)
+ || AllZone.getPhaseHandler().isPlayerTurn(AllZone.getHumanPlayer())) {
return false;
}
return ComputerUtil.canPayCost(this);
@@ -935,7 +935,7 @@ public class CardFactoryUtil {
@Override
public boolean canPlay() {
- return Phase.canCastSorcery(sourceCard.getController()) && !AllZoneUtil.isCardInPlay(sourceCard);
+ return PhaseHandler.canCastSorcery(sourceCard.getController()) && !AllZoneUtil.isCardInPlay(sourceCard);
}
};
@@ -1026,7 +1026,7 @@ public class CardFactoryUtil {
@Override
public boolean canPlayAI() {
- if (AllZone.getPhase().isBefore(Constant.Phase.MAIN2)) {
+ if (AllZone.getPhaseHandler().isBefore(Constant.Phase.MAIN2)) {
return false;
}
@@ -1185,7 +1185,7 @@ public class CardFactoryUtil {
@Override
public boolean canPlay() {
- return super.canPlay() && Phase.canCastSorcery(sourceCard.getController());
+ return super.canPlay() && PhaseHandler.canCastSorcery(sourceCard.getController());
}
@Override
@@ -1259,7 +1259,7 @@ public class CardFactoryUtil {
return true;
}
- return Phase.canCastSorcery(sourceCard.getOwner());
+ return PhaseHandler.canCastSorcery(sourceCard.getOwner());
}
@Override
@@ -1332,7 +1332,7 @@ public class CardFactoryUtil {
// An animated artifact equipmemt can't equip a creature
@Override
public boolean canPlay() {
- return super.canPlay() && !sourceCard.isCreature() && Phase.canCastSorcery(sourceCard.getController());
+ return super.canPlay() && !sourceCard.isCreature() && PhaseHandler.canCastSorcery(sourceCard.getController());
}
@Override
@@ -1352,7 +1352,7 @@ public class CardFactoryUtil {
@Override
public boolean addCard(final Card c) {
return c.isCreature()
- && (CombatUtil.canAttack(c) || (CombatUtil.canAttackNextTurn(c) && AllZone.getPhase()
+ && (CombatUtil.canAttack(c) || (CombatUtil.canAttackNextTurn(c) && AllZone.getPhaseHandler()
.is(Constant.Phase.MAIN2)))
&& (((c.getNetDefense() + tough) > 0) || sourceCard.getName().equals("Skullclamp"));
}
@@ -3037,9 +3037,9 @@ public class CardFactoryUtil {
// Count$IfMainPhase.. // 7/10
if (sq[0].contains("IfMainPhase")) {
- final String cPhase = AllZone.getPhase().getPhase();
+ final String cPhase = AllZone.getPhaseHandler().getPhase();
if ((cPhase.equals(Constant.Phase.MAIN1) || cPhase.equals(Constant.Phase.MAIN2))
- && AllZone.getPhase().getPlayerTurn().equals(cardController)) {
+ && AllZone.getPhaseHandler().getPlayerTurn().equals(cardController)) {
return CardFactoryUtil.doXMath(Integer.parseInt(sq[1]), m, c);
} else {
return CardFactoryUtil.doXMath(Integer.parseInt(sq[2]), m, c);
diff --git a/src/main/java/forge/card/cost/CostMana.java b/src/main/java/forge/card/cost/CostMana.java
index 09d5925c971..e79e54a6922 100644
--- a/src/main/java/forge/card/cost/CostMana.java
+++ b/src/main/java/forge/card/cost/CostMana.java
@@ -24,7 +24,7 @@ import forge.ButtonUtil;
import forge.Card;
import forge.ComputerUtil;
import forge.Constant.Zone;
-import forge.Phase;
+import forge.PhaseHandler;
import forge.Player;
import forge.PlayerZone;
import forge.card.abilityfactory.AbilityFactory;
@@ -357,7 +357,7 @@ public class CostMana extends CostPart {
final int manaToAdd) {
final ManaCost manaCost;
- if (Phase.getGameBegins() == 1) {
+ if (PhaseHandler.getGameBegins() == 1) {
if (sa.getSourceCard().isCopiedSpell() && sa.isSpell()) {
manaCost = new ManaCost("0");
} else {
diff --git a/src/main/java/forge/card/spellability/Spell.java b/src/main/java/forge/card/spellability/Spell.java
index 436e0f3ae8f..2f423d63298 100644
--- a/src/main/java/forge/card/spellability/Spell.java
+++ b/src/main/java/forge/card/spellability/Spell.java
@@ -25,7 +25,7 @@ import forge.Card;
import forge.CardList;
import forge.Constant;
import forge.Constant.Zone;
-import forge.Phase;
+import forge.PhaseHandler;
import forge.Player;
import forge.card.cost.Cost;
import forge.card.cost.CostPayment;
@@ -117,7 +117,7 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable
return false;
}
- return (card.isInstant() || card.hasKeyword("Flash") || Phase.canCastSorcery(card.getController()));
+ return (card.isInstant() || card.hasKeyword("Flash") || PhaseHandler.canCastSorcery(card.getController()));
} // canPlay()
/** {@inheritDoc} */
diff --git a/src/main/java/forge/card/spellability/SpellAbilityCondition.java b/src/main/java/forge/card/spellability/SpellAbilityCondition.java
index 269387e4907..789ee79d0f1 100644
--- a/src/main/java/forge/card/spellability/SpellAbilityCondition.java
+++ b/src/main/java/forge/card/spellability/SpellAbilityCondition.java
@@ -23,7 +23,7 @@ import forge.AllZone;
import forge.AllZoneUtil;
import forge.CardList;
import forge.Constant.Zone;
-import forge.Phase;
+import forge.PhaseHandler;
import forge.Player;
import forge.card.abilityfactory.AbilityFactory;
import forge.card.cardfactory.CardFactoryUtil;
@@ -102,7 +102,7 @@ public class SpellAbilityCondition extends SpellAbilityVariables {
// Upkeep->Combat_Begin (Before Declare Attackers)
final String[] split = phases.split("->", 2);
- phases = AllZone.getPhase().buildActivateString(split[0], split[1]);
+ phases = AllZone.getPhaseHandler().buildActivateString(split[0], split[1]);
}
this.setPhases(phases);
@@ -192,15 +192,15 @@ public class SpellAbilityCondition extends SpellAbilityVariables {
}
}
- if (this.isSorcerySpeed() && !Phase.canCastSorcery(activator)) {
+ if (this.isSorcerySpeed() && !PhaseHandler.canCastSorcery(activator)) {
return false;
}
- if (this.isPlayerTurn() && !AllZone.getPhase().isPlayerTurn(activator)) {
+ if (this.isPlayerTurn() && !AllZone.getPhaseHandler().isPlayerTurn(activator)) {
return false;
}
- if (this.isOpponentTurn() && AllZone.getPhase().isPlayerTurn(activator)) {
+ if (this.isOpponentTurn() && AllZone.getPhaseHandler().isPlayerTurn(activator)) {
return false;
}
@@ -210,7 +210,7 @@ public class SpellAbilityCondition extends SpellAbilityVariables {
if (this.getPhases().size() > 0) {
boolean isPhase = false;
- final String currPhase = AllZone.getPhase().getPhase();
+ final String currPhase = AllZone.getPhaseHandler().getPhase();
for (final String s : this.getPhases()) {
if (s.equals(currPhase)) {
isPhase = true;
diff --git a/src/main/java/forge/card/spellability/SpellAbilityRestriction.java b/src/main/java/forge/card/spellability/SpellAbilityRestriction.java
index f46a1599162..719db92842f 100644
--- a/src/main/java/forge/card/spellability/SpellAbilityRestriction.java
+++ b/src/main/java/forge/card/spellability/SpellAbilityRestriction.java
@@ -25,7 +25,7 @@ import forge.AllZoneUtil;
import forge.Card;
import forge.CardList;
import forge.Constant.Zone;
-import forge.Phase;
+import forge.PhaseHandler;
import forge.Player;
import forge.PlayerZone;
import forge.card.abilityfactory.AbilityFactory;
@@ -134,7 +134,7 @@ public class SpellAbilityRestriction extends SpellAbilityVariables {
// Upkeep->Combat_Begin (Before Declare Attackers)
final String[] split = phases.split("->", 2);
- phases = AllZone.getPhase().buildActivateString(split[0], split[1]);
+ phases = AllZone.getPhaseHandler().buildActivateString(split[0], split[1]);
}
this.setPhases(phases);
@@ -215,15 +215,15 @@ public class SpellAbilityRestriction extends SpellAbilityVariables {
System.out.println(c.getName() + " Did not have activator set in SpellAbilityRestriction.canPlay()");
}
- if (this.isSorcerySpeed() && !Phase.canCastSorcery(activator)) {
+ if (this.isSorcerySpeed() && !PhaseHandler.canCastSorcery(activator)) {
return false;
}
- if (this.isPlayerTurn() && !AllZone.getPhase().isPlayerTurn(activator)) {
+ if (this.isPlayerTurn() && !AllZone.getPhaseHandler().isPlayerTurn(activator)) {
return false;
}
- if (this.isOpponentTurn() && AllZone.getPhase().isPlayerTurn(activator)) {
+ if (this.isOpponentTurn() && AllZone.getPhaseHandler().isPlayerTurn(activator)) {
return false;
}
@@ -237,7 +237,7 @@ public class SpellAbilityRestriction extends SpellAbilityVariables {
if (this.getPhases().size() > 0) {
boolean isPhase = false;
- final String currPhase = AllZone.getPhase().getPhase();
+ final String currPhase = AllZone.getPhaseHandler().getPhase();
for (final String s : this.getPhases()) {
if (s.equals(currPhase)) {
isPhase = true;
@@ -326,7 +326,7 @@ public class SpellAbilityRestriction extends SpellAbilityVariables {
if (this.isPwAbility()) {
// Planeswalker abilities can only be activated as Sorceries
- if (!Phase.canCastSorcery(activator)) {
+ if (!PhaseHandler.canCastSorcery(activator)) {
return false;
}
diff --git a/src/main/java/forge/card/spellability/SpellPermanent.java b/src/main/java/forge/card/spellability/SpellPermanent.java
index fbe5e083287..8be35e6170f 100644
--- a/src/main/java/forge/card/spellability/SpellPermanent.java
+++ b/src/main/java/forge/card/spellability/SpellPermanent.java
@@ -246,7 +246,7 @@ public class SpellPermanent extends Spell {
public boolean canPlay() {
final Card source = this.getSourceCard();
- final Player turn = AllZone.getPhase().getPlayerTurn();
+ final Player turn = AllZone.getPhaseHandler().getPlayerTurn();
if (source.getName().equals("Serra Avenger")) {
if (turn.equals(source.getController()) && (turn.getTurn() <= 3)) {
diff --git a/src/main/java/forge/card/staticability/StaticAbility.java b/src/main/java/forge/card/staticability/StaticAbility.java
index c576ebfc1d6..5000b148a1a 100644
--- a/src/main/java/forge/card/staticability/StaticAbility.java
+++ b/src/main/java/forge/card/staticability/StaticAbility.java
@@ -401,11 +401,11 @@ public class StaticAbility {
return false;
}
- if (this.mapParams.containsKey("PlayerTurn") && !AllZone.getPhase().isPlayerTurn(controller)) {
+ if (this.mapParams.containsKey("PlayerTurn") && !AllZone.getPhaseHandler().isPlayerTurn(controller)) {
return false;
}
- if (this.mapParams.containsKey("OpponentTurn") && !AllZone.getPhase().isPlayerTurn(controller.getOpponent())) {
+ if (this.mapParams.containsKey("OpponentTurn") && !AllZone.getPhaseHandler().isPlayerTurn(controller.getOpponent())) {
return false;
}
@@ -419,10 +419,10 @@ public class StaticAbility {
// Upkeep->Combat_Begin (Before Declare Attackers)
final String[] split = phases.split("->", 2);
- phases = AllZone.getPhase().buildActivateString(split[0], split[1]);
+ phases = AllZone.getPhaseHandler().buildActivateString(split[0], split[1]);
}
- if (!phases.contains(AllZone.getPhase().getPhase())) {
+ if (!phases.contains(AllZone.getPhaseHandler().getPhase())) {
return false;
}
}
diff --git a/src/main/java/forge/card/staticability/StaticAbilityCantBeCast.java b/src/main/java/forge/card/staticability/StaticAbilityCantBeCast.java
index 9dbca6fbdf9..81c7d00f282 100644
--- a/src/main/java/forge/card/staticability/StaticAbilityCantBeCast.java
+++ b/src/main/java/forge/card/staticability/StaticAbilityCantBeCast.java
@@ -20,7 +20,7 @@ package forge.card.staticability;
import java.util.HashMap;
import forge.Card;
-import forge.Phase;
+import forge.PhaseHandler;
import forge.Player;
import forge.card.spellability.AbilityMana;
import forge.card.spellability.SpellAbility;
@@ -55,7 +55,7 @@ public class StaticAbilityCantBeCast {
return false;
}
- if (params.containsKey("OnlySorcerySpeed") && (activator != null) && Phase.canCastSorcery(activator)) {
+ if (params.containsKey("OnlySorcerySpeed") && (activator != null) && PhaseHandler.canCastSorcery(activator)) {
return false;
}
diff --git a/src/main/java/forge/card/trigger/Trigger.java b/src/main/java/forge/card/trigger/Trigger.java
index d495cc4be37..598046b2f41 100644
--- a/src/main/java/forge/card/trigger/Trigger.java
+++ b/src/main/java/forge/card/trigger/Trigger.java
@@ -309,25 +309,25 @@ public abstract class Trigger extends TriggerReplacementBase {
// Upkeep->Combat_Begin (Before Declare Attackers)
final String[] split = phases.split("->", 2);
- phases = AllZone.getPhase().buildActivateString(split[0], split[1]);
+ phases = AllZone.getPhaseHandler().buildActivateString(split[0], split[1]);
}
final ArrayList triggerPhases = new ArrayList();
for (final String s : phases.split(",")) {
triggerPhases.add(s);
}
- if (!triggerPhases.contains(AllZone.getPhase().getPhase())) {
+ if (!triggerPhases.contains(AllZone.getPhaseHandler().getPhase())) {
return false;
}
}
if (this.getMapParams().containsKey("PlayerTurn")) {
- if (!AllZone.getPhase().isPlayerTurn(this.getHostCard().getController())) {
+ if (!AllZone.getPhaseHandler().isPlayerTurn(this.getHostCard().getController())) {
return false;
}
}
if (this.getMapParams().containsKey("OpponentTurn")) {
- if (AllZone.getPhase().isPlayerTurn(this.getHostCard().getController())) {
+ if (AllZone.getPhaseHandler().isPlayerTurn(this.getHostCard().getController())) {
return false;
}
}
diff --git a/src/main/java/forge/card/trigger/TriggerHandler.java b/src/main/java/forge/card/trigger/TriggerHandler.java
index f1c42167211..a82bec90b19 100644
--- a/src/main/java/forge/card/trigger/TriggerHandler.java
+++ b/src/main/java/forge/card/trigger/TriggerHandler.java
@@ -309,7 +309,7 @@ public class TriggerHandler {
System.out.println("Hiyo!");
}
- final Player playerAP = AllZone.getPhase().getPlayerTurn();
+ final Player playerAP = AllZone.getPhaseHandler().getPlayerTurn();
// This is done to allow the list of triggers to be modified while
// triggers are running.
@@ -456,7 +456,7 @@ public class TriggerHandler {
final Player[] controller = new Player[1];
// Any trigger should cause the phase not to skip
- AllZone.getPhase().setSkipPhase(false);
+ AllZone.getPhaseHandler().setSkipPhase(false);
regtrig.setRunParams(runParams);
diff --git a/src/main/java/forge/control/ControlMatchUI.java b/src/main/java/forge/control/ControlMatchUI.java
index 23469d2a63b..dc2a881c349 100644
--- a/src/main/java/forge/control/ControlMatchUI.java
+++ b/src/main/java/forge/control/ControlMatchUI.java
@@ -122,7 +122,7 @@ public class ControlMatchUI {
AllZone.getStack().deleteObservers();
AllZone.getGameLog().deleteObservers();
AllZone.getInputControl().deleteObservers();
- AllZone.getPhase().deleteObservers();
+ AllZone.getPhaseHandler().deleteObservers();
}
diff --git a/src/main/java/forge/control/match/ControlInput.java b/src/main/java/forge/control/match/ControlInput.java
index e7e0a77e738..b3acf07b1ce 100644
--- a/src/main/java/forge/control/match/ControlInput.java
+++ b/src/main/java/forge/control/match/ControlInput.java
@@ -50,10 +50,10 @@ public class ControlInput {
public void actionPerformed(final ActionEvent evt) {
ControlInput.this.btnOKActionPerformed(evt);
- if (AllZone.getPhase().isNeedToNextPhase()) {
+ if (AllZone.getPhaseHandler().isNeedToNextPhase()) {
// moves to next turn
- AllZone.getPhase().setNeedToNextPhase(false);
- AllZone.getPhase().nextPhase();
+ AllZone.getPhaseHandler().setNeedToNextPhase(false);
+ AllZone.getPhaseHandler().nextPhase();
}
ControlInput.this.view.getBtnOK().requestFocusInWindow();
}
diff --git a/src/main/java/forge/gui/input/Input.java b/src/main/java/forge/gui/input/Input.java
index 9ba2062e348..e3db6a17aeb 100644
--- a/src/main/java/forge/gui/input/Input.java
+++ b/src/main/java/forge/gui/input/Input.java
@@ -99,10 +99,10 @@ public abstract class Input implements java.io.Serializable {
// clears a "temp" Input like Input_PayManaCost if there is one
AllZone.getInputControl().resetInput();
- if (AllZone.getPhase().isNeedToNextPhase()) {
+ if (AllZone.getPhaseHandler().isNeedToNextPhase()) {
// mulligan needs this to move onto next phase
- AllZone.getPhase().setNeedToNextPhase(false);
- AllZone.getPhase().nextPhase();
+ AllZone.getPhaseHandler().setNeedToNextPhase(false);
+ AllZone.getPhaseHandler().nextPhase();
}
}
diff --git a/src/main/java/forge/gui/input/InputAttack.java b/src/main/java/forge/gui/input/InputAttack.java
index d5af0e1a894..4cf0e7b0c90 100644
--- a/src/main/java/forge/gui/input/InputAttack.java
+++ b/src/main/java/forge/gui/input/InputAttack.java
@@ -77,14 +77,14 @@ public class InputAttack extends Input {
@Override
public final void selectButtonOK() {
if (AllZone.getCombat().getAttackers().length > 0) {
- AllZone.getPhase().setCombat(true);
+ AllZone.getPhaseHandler().setCombat(true);
}
if (AllZone.getCombat().getRemainingDefenders() != 0) {
- AllZone.getPhase().repeatPhase();
+ AllZone.getPhaseHandler().repeatPhase();
}
- AllZone.getPhase().setNeedToNextPhase(true);
+ AllZone.getPhaseHandler().setNeedToNextPhase(true);
AllZone.getInputControl().resetInput();
}
diff --git a/src/main/java/forge/gui/input/InputBlock.java b/src/main/java/forge/gui/input/InputBlock.java
index 9bf400d6c11..4a78acc78b7 100644
--- a/src/main/java/forge/gui/input/InputBlock.java
+++ b/src/main/java/forge/gui/input/InputBlock.java
@@ -94,7 +94,7 @@ public class InputBlock extends Input {
// Done blocking
ButtonUtil.reset();
- AllZone.getPhase().setNeedToNextPhase(true);
+ AllZone.getPhaseHandler().setNeedToNextPhase(true);
}
}
diff --git a/src/main/java/forge/gui/input/InputCleanup.java b/src/main/java/forge/gui/input/InputCleanup.java
index aa5e07296c4..1e6958e426c 100644
--- a/src/main/java/forge/gui/input/InputCleanup.java
+++ b/src/main/java/forge/gui/input/InputCleanup.java
@@ -40,7 +40,7 @@ public class InputCleanup extends Input {
/** {@inheritDoc} */
@Override
public final void showMessage() {
- if (AllZone.getPhase().getPlayerTurn().isComputer()) {
+ if (AllZone.getPhaseHandler().getPlayerTurn().isComputer()) {
this.aiCleanupDiscard();
return;
}
@@ -59,8 +59,8 @@ public class InputCleanup extends Input {
if ((n <= AllZone.getHumanPlayer().getMaxHandSize()) || (AllZone.getHumanPlayer().getMaxHandSize() == -1)) {
CombatUtil.removeAllDamage();
- AllZone.getPhase().setNeedToNextPhase(true);
- AllZone.getPhase().nextPhase(); // TODO keep an eye on this code,
+ AllZone.getPhaseHandler().setNeedToNextPhase(true);
+ AllZone.getPhaseHandler().nextPhase(); // TODO keep an eye on this code,
// see if we can get rid of it.
}
}
@@ -90,6 +90,6 @@ public class InputCleanup extends Input {
}
CombatUtil.removeAllDamage();
- AllZone.getPhase().setNeedToNextPhase(true);
+ AllZone.getPhaseHandler().setNeedToNextPhase(true);
}
}
diff --git a/src/main/java/forge/gui/input/InputControl.java b/src/main/java/forge/gui/input/InputControl.java
index 54805d1962e..bd09f795e3a 100644
--- a/src/main/java/forge/gui/input/InputControl.java
+++ b/src/main/java/forge/gui/input/InputControl.java
@@ -23,7 +23,7 @@ import java.util.Stack;
import forge.ComputerAIInput;
import forge.Constant;
import forge.MyObservable;
-import forge.Phase;
+import forge.PhaseHandler;
import forge.Player;
import forge.model.FModel;
@@ -167,9 +167,9 @@ public class InputControl extends MyObservable implements java.io.Serializable {
* @return a {@link forge.gui.input.Input} object.
*/
public final Input updateInput() {
- final String phase = this.model.getGameState().getPhase().getPhase();
- final Player playerTurn = this.model.getGameState().getPhase().getPlayerTurn();
- final Player priority = this.model.getGameState().getPhase().getPriorityPlayer();
+ final String phase = this.model.getGameState().getPhaseHandler().getPhase();
+ final Player playerTurn = this.model.getGameState().getPhaseHandler().getPlayerTurn();
+ final Player priority = this.model.getGameState().getPhaseHandler().getPriorityPlayer();
// TODO this resolving portion needs more work, but fixes Death Cloud
// issues
@@ -195,15 +195,15 @@ public class InputControl extends MyObservable implements java.io.Serializable {
return this.input;
}
- if ((Phase.getGameBegins() != 0) && this.model.getGameState().getPhase().doPhaseEffects()) {
+ if ((PhaseHandler.getGameBegins() != 0) && this.model.getGameState().getPhaseHandler().doPhaseEffects()) {
// Handle begin phase stuff, then start back from the top
- this.model.getGameState().getPhase().handleBeginPhase();
+ this.model.getGameState().getPhaseHandler().handleBeginPhase();
return this.updateInput();
}
// If the Phase we're in doesn't allow for Priority, return null to move
// to next phase
- if (this.model.getGameState().getPhase().isNeedToNextPhase()) {
+ if (this.model.getGameState().getPhaseHandler().isNeedToNextPhase()) {
return null;
}
@@ -222,7 +222,7 @@ public class InputControl extends MyObservable implements java.io.Serializable {
} else {
if (this.model.getGameState().getCombat().getAttackers().length == 0) {
// no active attackers, skip the Blocking phase
- this.model.getGameState().getPhase().setNeedToNextPhase(true);
+ this.model.getGameState().getPhaseHandler().setNeedToNextPhase(true);
return null;
} else {
return new InputBlock();
@@ -243,11 +243,11 @@ public class InputControl extends MyObservable implements java.io.Serializable {
if (priority == null) {
return null;
} else if (priority.isHuman()) {
- final boolean skip = this.model.getGameState().getPhase().doSkipPhase();
- this.model.getGameState().getPhase().setSkipPhase(false);
+ final boolean skip = this.model.getGameState().getPhaseHandler().doSkipPhase();
+ this.model.getGameState().getPhaseHandler().setSkipPhase(false);
if ((this.model.getGameState().getStack().size() == 0)
&& !forge.AllZone.getDisplay().stopAtPhase(playerTurn, phase) && skip) {
- this.model.getGameState().getPhase().passPriority();
+ this.model.getGameState().getPhaseHandler().passPriority();
return null;
} else {
return new InputPassPriority();
diff --git a/src/main/java/forge/gui/input/InputMulligan.java b/src/main/java/forge/gui/input/InputMulligan.java
index bcbc9abbf5d..187c9cfc113 100644
--- a/src/main/java/forge/gui/input/InputMulligan.java
+++ b/src/main/java/forge/gui/input/InputMulligan.java
@@ -28,7 +28,7 @@ import forge.ComputerUtil;
import forge.Constant;
import forge.Constant.Zone;
import forge.GameActionUtil;
-import forge.Phase;
+import forge.PhaseHandler;
import forge.PhaseUtil;
import forge.Player;
import forge.PlayerZone;
@@ -206,9 +206,9 @@ public class InputMulligan extends Input {
AllZone.getGameAction().getComputerCut());
}
AllZone.getGameAction().checkStateEffects();
- Phase.setGameBegins(1);
- AllZone.getPhase().setNeedToNextPhase(false);
- PhaseUtil.visuallyActivatePhase(AllZone.getPhase().getPhase());
+ PhaseHandler.setGameBegins(1);
+ AllZone.getPhaseHandler().setNeedToNextPhase(false);
+ PhaseUtil.visuallyActivatePhase(AllZone.getPhaseHandler().getPhase());
this.stop();
}
diff --git a/src/main/java/forge/gui/input/InputPassPriority.java b/src/main/java/forge/gui/input/InputPassPriority.java
index c7a4f3cf353..0390f3ac7f9 100644
--- a/src/main/java/forge/gui/input/InputPassPriority.java
+++ b/src/main/java/forge/gui/input/InputPassPriority.java
@@ -43,8 +43,8 @@ public class InputPassPriority extends Input implements java.io.Serializable {
GuiDisplayUtil.updateGUI();
ButtonUtil.enableOnlyOK();
- final String phase = AllZone.getPhase().getPhase();
- final Player player = AllZone.getPhase().getPriorityPlayer();
+ final String phase = AllZone.getPhaseHandler().getPhase();
+ final Player player = AllZone.getPhaseHandler().getPriorityPlayer();
if (player.isComputer()) {
System.out.println(phase + ": Computer in passpriority");
@@ -52,7 +52,7 @@ public class InputPassPriority extends Input implements java.io.Serializable {
final StringBuilder sb = new StringBuilder();
- sb.append("Turn : ").append(AllZone.getPhase().getPlayerTurn()).append("\n");
+ sb.append("Turn : ").append(AllZone.getPhaseHandler().getPlayerTurn()).append("\n");
sb.append("Phase: ").append(phase).append("\n");
sb.append("Stack: ");
if (AllZone.getStack().size() != 0) {
@@ -69,7 +69,7 @@ public class InputPassPriority extends Input implements java.io.Serializable {
/** {@inheritDoc} */
@Override
public final void selectButtonOK() {
- AllZone.getPhase().passPriority();
+ AllZone.getPhaseHandler().passPriority();
GuiDisplayUtil.updateGUI();
final Input in = AllZone.getInputControl().getInput();
if ((in == this) || (in == null)) {
@@ -82,7 +82,7 @@ public class InputPassPriority extends Input implements java.io.Serializable {
@Override
public final void selectCard(final Card card, final PlayerZone zone) {
if (AllZone.getGameAction().playCard(card)) {
- AllZone.getPhase().setPriority(AllZone.getHumanPlayer());
+ AllZone.getPhaseHandler().setPriority(AllZone.getHumanPlayer());
}
else {
((GuiTopLevel) AllZone.getDisplay()).getController().getMatchController().getView().getInputController().remind();
diff --git a/src/main/java/forge/gui/input/InputPayManaCost.java b/src/main/java/forge/gui/input/InputPayManaCost.java
index 31428b4cfa9..cebff0db534 100644
--- a/src/main/java/forge/gui/input/InputPayManaCost.java
+++ b/src/main/java/forge/gui/input/InputPayManaCost.java
@@ -21,7 +21,7 @@ import forge.AllZone;
import forge.ButtonUtil;
import forge.Card;
import forge.Constant.Zone;
-import forge.Phase;
+import forge.PhaseHandler;
import forge.Player;
import forge.PlayerZone;
import forge.card.mana.ManaCost;
@@ -73,7 +73,7 @@ public class InputPayManaCost extends InputMana {
this.spell = sa;
- if (Phase.getGameBegins() == 1) {
+ if (PhaseHandler.getGameBegins() == 1) {
if (sa.getSourceCard().isCopiedSpell() && sa.isSpell()) {
if (this.spell.getAfterPayMana() != null) {
this.stopSetNext(this.spell.getAfterPayMana());
@@ -118,7 +118,7 @@ public class InputPayManaCost extends InputMana {
this.spell = sa;
- if (Phase.getGameBegins() == 1) {
+ if (PhaseHandler.getGameBegins() == 1) {
if (sa.getSourceCard().isCopiedSpell() && sa.isSpell()) {
if (this.spell.getAfterPayMana() != null) {
this.stopSetNext(this.spell.getAfterPayMana());
diff --git a/src/main/java/forge/model/FGameState.java b/src/main/java/forge/model/FGameState.java
index 5f140002076..cc70e30f3fc 100644
--- a/src/main/java/forge/model/FGameState.java
+++ b/src/main/java/forge/model/FGameState.java
@@ -28,7 +28,7 @@ import forge.GameAction;
import forge.GameLog;
import forge.HumanPlayer;
import forge.MagicStack;
-import forge.Phase;
+import forge.PhaseHandler;
import forge.Player;
import forge.PlayerZone;
import forge.StaticEffects;
@@ -55,7 +55,7 @@ public class FGameState {
private EndOfCombat endOfCombat = new EndOfCombat();
private Untap untap = new Untap();
private Upkeep upkeep = new Upkeep();
- private Phase phase = new Phase();
+ private PhaseHandler phaseHandler = new PhaseHandler();
private MagicStack stack = new MagicStack();
private GameAction gameAction = new GameAction();
private StaticEffects staticEffects = new StaticEffects();
@@ -199,22 +199,22 @@ public class FGameState {
}
/**
- * Gets the phase.
+ * Gets the phaseHandler.
*
- * @return the phase
+ * @return the phaseHandler
*/
- public final Phase getPhase() {
- return this.phase;
+ public final PhaseHandler getPhaseHandler() {
+ return this.phaseHandler;
}
/**
* Sets the phase.
*
- * @param phase0
- * the phase to set
+ * @param phaseHandlerIn
+ * the phaseHandler to set
*/
- protected final void setPhase(final Phase phase0) {
- this.phase = phase0;
+ protected final void setPhaseHandler(final PhaseHandler phaseHandlerIn) {
+ this.phaseHandler = phaseHandlerIn;
}
/**
@@ -396,7 +396,7 @@ public class FGameState {
this.getHumanPlayer().reset();
this.getComputerPlayer().reset();
- this.getPhase().reset();
+ this.getPhaseHandler().reset();
this.getStack().reset();
this.getCombat().reset();
diff --git a/src/main/java/forge/quest/data/pet/QuestPetPlant.java b/src/main/java/forge/quest/data/pet/QuestPetPlant.java
index f822c1de91a..fe74a571bf8 100644
--- a/src/main/java/forge/quest/data/pet/QuestPetPlant.java
+++ b/src/main/java/forge/quest/data/pet/QuestPetPlant.java
@@ -91,7 +91,7 @@ public class QuestPetPlant extends QuestPetAbstract {
@Override
public boolean canPlayAI() {
- return AllZone.getPhase().getPhase().equals(Constant.Phase.MAIN2);
+ return AllZone.getPhaseHandler().getPhase().equals(Constant.Phase.MAIN2);
}
@Override
diff --git a/src/main/java/forge/view/match/ViewWinLose.java b/src/main/java/forge/view/match/ViewWinLose.java
index e49a2dab141..90f8c27f478 100644
--- a/src/main/java/forge/view/match/ViewWinLose.java
+++ b/src/main/java/forge/view/match/ViewWinLose.java
@@ -12,7 +12,7 @@ import net.miginfocom.swing.MigLayout;
import forge.AllZone;
import forge.Constant;
import forge.MatchState;
-import forge.Phase;
+import forge.PhaseHandler;
import forge.Player;
import forge.control.match.ControlWinLose;
import forge.game.GameType;
@@ -81,7 +81,7 @@ public class ViewWinLose {
btnQuit.setFont(AllZone.getSkin().getFont(22));
// End game and set state of "continue" button
- Phase.setGameBegins(0);
+ PhaseHandler.setGameBegins(0);
if (matchState.isMatchOver()) {
this.getBtnContinue().setEnabled(false);
diff --git a/src/test/java/forge/PhaseTest.java b/src/test/java/forge/PhaseHandlerTest.java
similarity index 81%
rename from src/test/java/forge/PhaseTest.java
rename to src/test/java/forge/PhaseHandlerTest.java
index e83b888dd8c..cf993e71cf0 100644
--- a/src/test/java/forge/PhaseTest.java
+++ b/src/test/java/forge/PhaseHandlerTest.java
@@ -6,14 +6,14 @@ import org.testng.annotations.Test;
* Created by IntelliJ IDEA. User: dhudson
*/
@Test(groups = { "UnitTest" }, timeOut = 5000, enabled = false)
-public class PhaseTest {
+public class PhaseHandlerTest {
/**
- * Phase test1.
+ * PhaseHandler test1.
*/
@Test(groups = { "UnitTest", "fast" }, timeOut = 5000, enabled = false)
public void phaseTest1() {
- final Phase phase = new Phase();
+ final PhaseHandler phase = new PhaseHandler();
for (int i = 0; i < phase.getPhaseOrder().length; i++) {
System.out.println(phase.getPlayerTurn() + " " + phase.getPhase());
phase.nextPhase();