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.

This commit is contained in:
slapshot5
2012-01-17 02:55:29 +00:00
parent 63198022de
commit 05dfac1250
73 changed files with 1762 additions and 1840 deletions

3
.gitattributes vendored
View File

@@ -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

View File

@@ -289,19 +289,19 @@ public final class AllZone {
/**
* <p>
* getPhase.
* getPhaseHandler.
* </p>
*
* 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;

View File

@@ -306,9 +306,9 @@ public class Card extends GameEntity implements Comparable<Card> {
}
/**
* 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<Card> {
// 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<Card> {
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")) {

View File

@@ -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<Card, Integer> defMap = AllZone.getCombat().getDefendingDamageMap();

View File

@@ -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();
}
};

View File

@@ -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();
}
}

View File

@@ -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();

View File

@@ -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++) {

View File

@@ -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();
}

View File

@@ -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 <code>serialVersionUID=3035250030566186842L</code>. */
private static final long serialVersionUID = 3035250030566186842L;
private final CommandList at = new CommandList();
private final CommandList until = new CommandList();
/**
* <p>
* Add a hardcoded trigger that will execute "at end of combat".
* </p>
*
* @param c
* a {@link forge.Command} object.
*/
public final void addAt(final Command c) {
this.at.add(c);
}
/**
* <p>
* Add a Command that will terminate an effect with "until end of combat".
* </p>
*
* @param c
* a {@link forge.Command} object.
*/
public final void addUntil(final Command c) {
this.until.add(c);
}
/**
* <p>
* Executes any hardcoded triggers that happen "at end of combat".
* </p>
*/
public final void executeAt() {
this.execute(this.at);
}
/**
* <p>
* Executes the termination of effects that apply "until end of combat".
* </p>
*/
public final void executeUntil() {
this.execute(this.until);
}
/**
* <p>
* execute.
* </p>
*
* @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

View File

@@ -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 <code>serialVersionUID=-3656715295379727275L</code>. */
private static final long serialVersionUID = -3656715295379727275L;
private final CommandList at = new CommandList();
private final CommandList until = new CommandList();
/**
* <p>
* Add a Command that will act as a trigger for "at end of turn".
* </p>
*
* @param c
* a {@link forge.Command} object.
*/
public final void addAt(final Command c) {
this.at.add(c);
}
/**
* <p>
* Add a Command that will terminate an effect with "until end of turn".
* </p>
*
* @param c
* a {@link forge.Command} object.
*/
public final void addUntil(final Command c) {
this.until.add(c);
}
/**
* <p>
* Handles all the hardcoded events that happen "at end of turn".
* </p>
*/
@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()
/**
* <p>
* Executes the termination of effects that apply "until end of turn".
* </p>
*/
public final void executeUntil() {
this.execute(this.until);
}
/**
* <p>
* Executes each Command in a CommandList.
* </p>
*
* @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++) {

View File

@@ -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 + " ";

View File

@@ -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;
}
}

View File

@@ -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();

View File

@@ -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} */

View File

@@ -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 {
* </p>
*/
public final void chooseOrderOfSimultaneousStackEntryAll() {
final Player playerTurn = AllZone.getPhase().getPlayerTurn();
final Player playerTurn = AllZone.getPhaseHandler().getPlayerTurn();
this.chooseOrderOfSimultaneousStackEntry(playerTurn);

View File

@@ -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();
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -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 {
* </p>
*/
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();
}
}
}
/**
* <p>
* doUntap.
* </p>
*/
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<Card> 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<Card> 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
/**
* <p>
* canUntap.
* </p>
*
* @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;
}
/**
* <p>
* canOnlyUntapOneLand.
* </p>
*
* @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 {
* </p>
*/
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 {
* </p>
*/
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

View File

@@ -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));
}

View File

@@ -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;
/**
* <p>
@@ -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<Player, CommandList> until = new HashMap<Player, CommandList>();
/**
* <p>
* Add a Command that will terminate an effect with "until <Player's> next untap".
* Executes any hardcoded triggers that happen "at end of combat".
* </p>
*/
@Override
public void executeAt() {
this.execute(this.at);
final Player turn = AllZone.getPhaseHandler().getPlayerTurn();
Untap.doPhasing(turn);
Untap.doUntap();
}
/**
* <p>
* canUntap.
* </p>
*
* @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;
}
/**
* <p>
* Executes the termination of effects that apply "until <Player's> next untap".
* </p>
*
* @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();
}
}
/**
* <p>
* 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.
* </p>
*/
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<Card> 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<Card> 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

View File

@@ -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<Player, CommandList> until = new HashMap<Player, CommandList>();
/**
* <p>
* Add a Command that will terminate an effect with "until <Player's> next upkeep".
* </p>
*
* @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));
}
}
/**
* <p>
* Executes the termination of effects that apply "until <Player's> next upkeep".
* </p>
*
* @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();
}
}
/**
* <p>
* 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.
* </p>
*/
@Override
public final void executeAt() {
AllZone.getStack().freezeStack();
Upkeep.upkeepBraidOfFire();
@@ -157,7 +111,7 @@ public class Upkeep implements java.io.Serializable {
* </p>
*/
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 {
* </p>
*/
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 {
* </p>
*/
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 {
* </p>
*/
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 {
* </p>
*/
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 {
* </p>
*/
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 {
* </p>
*/
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 {
* </p>
*/
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 {
* </p>
*/
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 {
* </p>
*/
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 {
* </p>
*/
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 {
* </p>
*/
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 {
* </p>
*/
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 {
* </p>
*/
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 {
* </p>
*/
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 {
* </p>
*/
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 {
* </p>
*/
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 {
* </p>
*/
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 {
* </p>
*/
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 {
* </p>
*/
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 {
* </p>
*/
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 {
* </p>
*/
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 {
* </p>
*/
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 {
* </p>
*/
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 {
* </p>
*/
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 {
* </p>
*/
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()) {

View File

@@ -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")) {

View File

@@ -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;
}

View File

@@ -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()))) {

View File

@@ -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;
}

View File

@@ -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)) {

View File

@@ -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;
}

View File

@@ -231,7 +231,7 @@ public final class AbilityFactoryCopy {
// TODO - I'm sure someone can do this AI better
final HashMap<String, String> 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

View File

@@ -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())

View File

@@ -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");

View File

@@ -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<String> 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;
}

View File

@@ -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());

View File

@@ -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;
}

View File

@@ -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<String, String> params = af.getMapParams();
if (AllZone.getPhase().isAfter(Constant.Phase.COMBAT_BEGIN)) {
if (AllZone.getPhaseHandler().isAfter(Constant.Phase.COMBAT_BEGIN)) {
return false;
}

View File

@@ -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
}

View File

@@ -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());
}
}

View File

@@ -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;
}

View File

@@ -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) {

View File

@@ -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;
}

View File

@@ -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()) {

View File

@@ -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);
}
}
}

View File

@@ -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
}

View File

@@ -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

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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();

View File

@@ -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);
}

View File

@@ -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.<numMain>.<numNotMain> // 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);

View File

@@ -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 {

View File

@@ -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} */

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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)) {

View File

@@ -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;
}
}

View File

@@ -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;
}

View File

@@ -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<String> triggerPhases = new ArrayList<String>();
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;
}
}

View File

@@ -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);

View File

@@ -122,7 +122,7 @@ public class ControlMatchUI {
AllZone.getStack().deleteObservers();
AllZone.getGameLog().deleteObservers();
AllZone.getInputControl().deleteObservers();
AllZone.getPhase().deleteObservers();
AllZone.getPhaseHandler().deleteObservers();
}

View File

@@ -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();
}

View File

@@ -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();
}
}

View File

@@ -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();
}

View File

@@ -94,7 +94,7 @@ public class InputBlock extends Input {
// Done blocking
ButtonUtil.reset();
AllZone.getPhase().setNeedToNextPhase(true);
AllZone.getPhaseHandler().setNeedToNextPhase(true);
}
}

View File

@@ -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);
}
}

View File

@@ -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();

View File

@@ -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();
}

View File

@@ -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();

View File

@@ -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());

View File

@@ -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();

View File

@@ -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

View File

@@ -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);

View File

@@ -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();