mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
PhaseType switched to enum
This commit is contained in:
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -11397,6 +11397,7 @@ src/main/java/forge/MyObservable.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/PhaseType.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
|
||||
@@ -11918,7 +11919,6 @@ src/test/java/forge/GuiMigrateLocalMWSSetPicturesHQTest.java svneol=native#text/
|
||||
src/test/java/forge/GuiMultipleBlockers4Test.java svneol=native#text/plain
|
||||
src/test/java/forge/GuiProgressBarWindowTest.java svneol=native#text/plain
|
||||
src/test/java/forge/PanelTest.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/mana/ManaPartTest.java svneol=native#text/plain
|
||||
|
||||
@@ -265,7 +265,6 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
if ((cur == CardCharactersticName.Original && state == CardCharactersticName.Transformed)
|
||||
|| (cur == CardCharactersticName.Transformed && state == CardCharactersticName.Original)) {
|
||||
HashMap<String, Object> runParams = new HashMap<String, Object>();
|
||||
runParams.put("Mode", "Transformed");
|
||||
runParams.put("Transformer", this);
|
||||
AllZone.getTriggerHandler().runTrigger(TriggerType.Transformed, runParams);
|
||||
}
|
||||
|
||||
@@ -625,7 +625,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)
|
||||
&& Singletons.getModel().getGameState().getPhaseHandler().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS)) {
|
||||
&& Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS)) {
|
||||
this.blocked.remove(a);
|
||||
}
|
||||
}
|
||||
@@ -880,7 +880,7 @@ public class Combat {
|
||||
// This function handles both Regular and First Strike combat assignment
|
||||
final Player player = AllZone.getCombat().getDefendingPlayer();
|
||||
|
||||
final boolean bFirstStrike = Singletons.getModel().getGameState().getPhaseHandler().is(Constant.Phase.COMBAT_FIRST_STRIKE_DAMAGE);
|
||||
final boolean bFirstStrike = Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.COMBAT_FIRST_STRIKE_DAMAGE);
|
||||
|
||||
final HashMap<Card, Integer> defMap = AllZone.getCombat().getDefendingDamageMap();
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.regex.Pattern;
|
||||
|
||||
import com.esotericsoftware.minlog.Log;
|
||||
|
||||
import forge.PhaseType;
|
||||
import forge.Constant.Zone;
|
||||
import forge.card.TriggerReplacementBase;
|
||||
import forge.card.abilityfactory.AbilityFactory;
|
||||
@@ -1428,7 +1429,7 @@ public class CombatUtil {
|
||||
combat = AllZone.getCombat();
|
||||
}
|
||||
|
||||
if (!trigger.zonesCheck()) {
|
||||
if (!trigger.zonesCheck(AllZone.getZoneOf(trigger.getHostCard()))) {
|
||||
return false;
|
||||
}
|
||||
if (!trigger.requirementsCheck()) {
|
||||
@@ -2505,10 +2506,10 @@ public class CombatUtil {
|
||||
|
||||
final Card crd = c;
|
||||
|
||||
final String phase = Singletons.getModel().getGameState().getPhaseHandler().getPhase();
|
||||
final PhaseType phase = Singletons.getModel().getGameState().getPhaseHandler().getPhase();
|
||||
|
||||
if (phase.equals(Constant.Phase.COMBAT_DECLARE_ATTACKERS)
|
||||
|| phase.equals(Constant.Phase.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)) {
|
||||
if (phase.equals(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
|| phase.equals(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)) {
|
||||
if (!cost.equals("0")) {
|
||||
final Ability ability = new Ability(c, cost) {
|
||||
@Override
|
||||
|
||||
@@ -355,7 +355,7 @@ public class ComputerAIGeneral implements Computer {
|
||||
if (AllZone.getStack().size() == 0) {
|
||||
final ArrayList<SpellAbility> sas = this.getSpellAbilities(cards);
|
||||
boolean pass = (sas.size() == 0)
|
||||
|| Singletons.getModel().getGameState().getPhaseHandler().is(Constant.Phase.END_OF_TURN, AllZone.getComputerPlayer());
|
||||
|| Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.END_OF_TURN, AllZone.getComputerPlayer());
|
||||
if (!pass) { // Each AF should check the phase individually
|
||||
pass = ComputerUtil.playSpellAbilities(sas);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package forge;
|
||||
|
||||
import com.esotericsoftware.minlog.Log;
|
||||
|
||||
import forge.PhaseType;
|
||||
import forge.control.input.Input;
|
||||
|
||||
/**
|
||||
@@ -89,28 +90,39 @@ public class ComputerAIInput extends Input {
|
||||
*/
|
||||
private void think() {
|
||||
// TODO instead of setNextPhase, pass priority
|
||||
final String phase = Singletons.getModel().getGameState().getPhaseHandler().getPhase();
|
||||
final PhaseType phase = Singletons.getModel().getGameState().getPhaseHandler().getPhase();
|
||||
|
||||
if (AllZone.getStack().size() > 0) {
|
||||
this.computer.stackNotEmpty();
|
||||
} else if (phase.equals(Constant.Phase.MAIN1)) {
|
||||
} else {
|
||||
switch(phase) {
|
||||
case MAIN1:
|
||||
Log.debug("Computer main1");
|
||||
this.computer.main();
|
||||
} else if (phase.equals(Constant.Phase.COMBAT_BEGIN)) {
|
||||
break;
|
||||
case COMBAT_BEGIN:
|
||||
this.computer.beginCombat();
|
||||
} else if (phase.equals(Constant.Phase.COMBAT_DECLARE_ATTACKERS)) {
|
||||
break;
|
||||
case COMBAT_DECLARE_ATTACKERS:
|
||||
this.computer.declareAttackers();
|
||||
} else if (phase.equals(Constant.Phase.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)) {
|
||||
break;
|
||||
case COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY:
|
||||
this.computer.declareAttackersAfter();
|
||||
} else if (phase.equals(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
break;
|
||||
case COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY:
|
||||
this.computer.declareBlockersAfter();
|
||||
} else if (phase.equals(Constant.Phase.COMBAT_END)) {
|
||||
break;
|
||||
case COMBAT_END:
|
||||
this.computer.endOfCombat();
|
||||
} else if (phase.equals(Constant.Phase.MAIN2)) {
|
||||
break;
|
||||
case MAIN2:
|
||||
Log.debug("Computer main2");
|
||||
this.computer.main();
|
||||
} else {
|
||||
break;
|
||||
default:
|
||||
this.computer.stackNotEmpty();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // think
|
||||
|
||||
@@ -124,57 +124,6 @@ public final class Constant {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Interface Phase.
|
||||
*/
|
||||
public static class Phase {
|
||||
|
||||
/** The Constant Untap. */
|
||||
public static final String UNTAP = "Untap";
|
||||
|
||||
/** The Constant Upkeep. */
|
||||
public static final String UPKEEP = "Upkeep";
|
||||
|
||||
/** The Constant Draw. */
|
||||
public static final String DRAW = "Draw";
|
||||
|
||||
/** The Constant Main1. */
|
||||
public static final String MAIN1 = "Main1";
|
||||
|
||||
/** The Constant Combat_Begin. */
|
||||
public static final String COMBAT_BEGIN = "BeginCombat";
|
||||
|
||||
/** The Constant Combat_Declare_Attackers. */
|
||||
public static final String COMBAT_DECLARE_ATTACKERS = "Declare Attackers";
|
||||
|
||||
/** The Constant Combat_Declare_Attackers_InstantAbility. */
|
||||
public static final String COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY = "Declare Attackers - Play Instants and Abilities";
|
||||
|
||||
/** The Constant Combat_Declare_Blockers. */
|
||||
public static final String COMBAT_DECLARE_BLOCKERS = "Declare Blockers";
|
||||
|
||||
/** The Constant Combat_Declare_Blockers_InstantAbility. */
|
||||
public static final String COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY = "Declare Blockers - Play Instants and Abilities";
|
||||
|
||||
/** The Constant Combat_Damage. */
|
||||
public static final String COMBAT_DAMAGE = "Combat Damage";
|
||||
|
||||
/** The Constant Combat_FirstStrikeDamage. */
|
||||
public static final String COMBAT_FIRST_STRIKE_DAMAGE = "First Strike Damage";
|
||||
|
||||
/** The Constant Combat_End. */
|
||||
public static final String COMBAT_END = "EndCombat";
|
||||
|
||||
/** The Constant Main2. */
|
||||
public static final String MAIN2 = "Main2";
|
||||
|
||||
/** The Constant End_Of_Turn. */
|
||||
public static final String END_OF_TURN = "End of Turn";
|
||||
|
||||
/** The Constant Cleanup. */
|
||||
public static final String CLEANUP = "Cleanup";
|
||||
}
|
||||
|
||||
/**
|
||||
* The Enum Zone.
|
||||
*/
|
||||
@@ -205,20 +154,14 @@ public final class Constant {
|
||||
/** Ante. */
|
||||
Ante(false);
|
||||
|
||||
public static final Zone[] StaticAbilitiesSourceZones = new Zone[]{Battlefield, Graveyard, Exile, Hand};
|
||||
public static final Zone[] StaticAbilitiesSourceZones = new Zone[]{Battlefield, Graveyard, Exile/*, Hand*/};
|
||||
|
||||
private final boolean holdsHiddenInfo;
|
||||
private Zone(boolean holdsHidden) {
|
||||
holdsHiddenInfo = holdsHidden;
|
||||
}
|
||||
|
||||
/**
|
||||
* Smart value of.
|
||||
*
|
||||
* @param value
|
||||
* the value
|
||||
* @return the zone
|
||||
*/
|
||||
|
||||
public static Zone smartValueOf(final String value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
@@ -235,13 +178,6 @@ public final class Constant {
|
||||
throw new IllegalArgumentException("No element named " + value + " in enum Zone");
|
||||
}
|
||||
|
||||
/**
|
||||
* List value of.
|
||||
*
|
||||
* @param values
|
||||
* the values
|
||||
* @return the list
|
||||
*/
|
||||
public static List<Zone> listValueOf(final String values) {
|
||||
final List<Zone> result = new ArrayList<Constant.Zone>();
|
||||
for (final String s : values.split("[, ]+")) {
|
||||
@@ -355,3 +291,5 @@ public final class Constant {
|
||||
}
|
||||
|
||||
} // Constant
|
||||
|
||||
|
||||
|
||||
@@ -1303,7 +1303,7 @@ public final class GuiDisplayUtil {
|
||||
}
|
||||
|
||||
if (!tChangePhase.trim().toLowerCase().equals("none")) {
|
||||
Singletons.getModel().getGameState().getPhaseHandler().setDevPhaseState(tChangePhase);
|
||||
Singletons.getModel().getGameState().getPhaseHandler().setDevPhaseState(forge.PhaseType.smartValueOf(tChangePhase));
|
||||
}
|
||||
|
||||
if (!tHumanSetupCardsInPlay.trim().toLowerCase().equals("none")) {
|
||||
|
||||
@@ -421,7 +421,7 @@ public class MagicStack extends MyObservable {
|
||||
System.out.println(sp.getSourceCard().getName() + " - activatingPlayer not set before adding to stack.");
|
||||
}
|
||||
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().is(Constant.Phase.CLEANUP)) { // If something
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.CLEANUP)) { // If something
|
||||
// triggers during
|
||||
// Cleanup, need to
|
||||
// repeat
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.Stack;
|
||||
|
||||
import com.esotericsoftware.minlog.Log;
|
||||
|
||||
import forge.PhaseType;
|
||||
import forge.Constant.Zone;
|
||||
import forge.card.trigger.TriggerType;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
@@ -257,14 +258,6 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
this.bRepeat = true;
|
||||
}
|
||||
|
||||
/** The phase order. */
|
||||
private String[] phaseOrder = { Constant.Phase.UNTAP, Constant.Phase.UPKEEP, Constant.Phase.DRAW,
|
||||
Constant.Phase.MAIN1, Constant.Phase.COMBAT_BEGIN, Constant.Phase.COMBAT_DECLARE_ATTACKERS,
|
||||
Constant.Phase.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY, Constant.Phase.COMBAT_DECLARE_BLOCKERS,
|
||||
Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY, Constant.Phase.COMBAT_FIRST_STRIKE_DAMAGE,
|
||||
Constant.Phase.COMBAT_DAMAGE, Constant.Phase.COMBAT_END, Constant.Phase.MAIN2, Constant.Phase.END_OF_TURN,
|
||||
Constant.Phase.CLEANUP };
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Constructor for PhaseHandler.
|
||||
@@ -313,35 +306,35 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
public final void handleBeginPhase() {
|
||||
Singletons.getModel().getGameState().getPhaseHandler().setPhaseEffects(false);
|
||||
// Handle effects that happen at the beginning of phases
|
||||
final String phase = Singletons.getModel().getGameState().getPhaseHandler().getPhase();
|
||||
final PhaseType phase = Singletons.getModel().getGameState().getPhaseHandler().getPhase();
|
||||
final Player turn = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn();
|
||||
Singletons.getModel().getGameState().getPhaseHandler().setSkipPhase(true);
|
||||
Singletons.getModel().getGameAction().checkStateEffects();
|
||||
|
||||
// UNTAP
|
||||
if (phase.equals(Constant.Phase.UNTAP)) {
|
||||
if (phase.equals(PhaseType.UNTAP)) {
|
||||
Singletons.getControl().getControlMatch().showStack();
|
||||
PhaseUtil.handleUntap();
|
||||
}
|
||||
// UPKEEP
|
||||
else if (phase.equals(Constant.Phase.UPKEEP)) {
|
||||
else if (phase.equals(PhaseType.UPKEEP)) {
|
||||
PhaseUtil.handleUpkeep();
|
||||
}
|
||||
// DRAW
|
||||
else if (phase.equals(Constant.Phase.DRAW)) {
|
||||
else if (phase.equals(PhaseType.DRAW)) {
|
||||
PhaseUtil.handleDraw();
|
||||
}
|
||||
// COMBAT_BEGIN
|
||||
else if (phase.equals(Constant.Phase.COMBAT_BEGIN)) {
|
||||
else if (phase.equals(PhaseType.COMBAT_BEGIN)) {
|
||||
PhaseUtil.verifyCombat();
|
||||
PhaseUtil.handleCombatBegin();
|
||||
}
|
||||
// COMBAT_DECLARE_ATTACKERS
|
||||
else if (phase.equals(Constant.Phase.COMBAT_DECLARE_ATTACKERS)) {
|
||||
else if (phase.equals(PhaseType.COMBAT_DECLARE_ATTACKERS)) {
|
||||
PhaseUtil.handleCombatDeclareAttackers();
|
||||
}
|
||||
// COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY
|
||||
else if (phase.equals(Constant.Phase.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)) {
|
||||
else if (phase.equals(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)) {
|
||||
if (this.inCombat()) {
|
||||
PhaseUtil.handleDeclareAttackers();
|
||||
CombatUtil.showCombat();
|
||||
@@ -351,7 +344,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
}
|
||||
// COMBAT_DECLARE_BLOCKERS: we can skip AfterBlockers and AfterAttackers
|
||||
// if necessary
|
||||
else if (phase.equals(Constant.Phase.COMBAT_DECLARE_BLOCKERS)) {
|
||||
else if (phase.equals(PhaseType.COMBAT_DECLARE_BLOCKERS)) {
|
||||
if (this.inCombat()) {
|
||||
PhaseUtil.verifyCombat();
|
||||
CombatUtil.showCombat();
|
||||
@@ -360,7 +353,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
}
|
||||
}
|
||||
// COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY
|
||||
else if (phase.equals(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
else if (phase.equals(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
// After declare blockers are finished being declared mark them
|
||||
// blocked and trigger blocking things
|
||||
if (this.inCombat()) {
|
||||
@@ -371,7 +364,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
}
|
||||
}
|
||||
// COMBAT_FIRST_STRIKE_DAMAGE
|
||||
else if (phase.equals(Constant.Phase.COMBAT_FIRST_STRIKE_DAMAGE)) {
|
||||
else if (phase.equals(PhaseType.COMBAT_FIRST_STRIKE_DAMAGE)) {
|
||||
if (!this.inCombat()) {
|
||||
Singletons.getModel().getGameState().getPhaseHandler().setNeedToNextPhase(true);
|
||||
} else {
|
||||
@@ -388,7 +381,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
}
|
||||
}
|
||||
// COMBAT_DAMAGE
|
||||
else if (phase.equals(Constant.Phase.COMBAT_DAMAGE)) {
|
||||
else if (phase.equals(PhaseType.COMBAT_DAMAGE)) {
|
||||
if (!this.inCombat()) {
|
||||
Singletons.getModel().getGameState().getPhaseHandler().setNeedToNextPhase(true);
|
||||
} else {
|
||||
@@ -401,22 +394,22 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
}
|
||||
}
|
||||
// COMBAT_END
|
||||
else if (phase.equals(Constant.Phase.COMBAT_END)) {
|
||||
else if (phase.equals(PhaseType.COMBAT_END)) {
|
||||
// End Combat always happens
|
||||
AllZone.getEndOfCombat().executeUntil();
|
||||
AllZone.getEndOfCombat().executeAt();
|
||||
CombatUtil.showCombat();
|
||||
Singletons.getControl().getControlMatch().showStack();
|
||||
} else if (phase.equals(Constant.Phase.MAIN2)) {
|
||||
} else if (phase.equals(PhaseType.MAIN2)) {
|
||||
CombatUtil.showCombat();
|
||||
Singletons.getControl().getControlMatch().showStack();
|
||||
}
|
||||
// END_OF_TURN
|
||||
else if (phase.equals(Constant.Phase.END_OF_TURN)) {
|
||||
else if (phase.equals(PhaseType.END_OF_TURN)) {
|
||||
AllZone.getEndOfTurn().executeAt();
|
||||
}
|
||||
// CLEANUP
|
||||
else if (phase.equals(Constant.Phase.CLEANUP)) {
|
||||
else if (phase.equals(PhaseType.CLEANUP)) {
|
||||
Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn().clearAssignedDamage();
|
||||
|
||||
// Reset Damage received map
|
||||
@@ -474,7 +467,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
AllZone.getStack().unfreezeStack();
|
||||
|
||||
// UNTAP
|
||||
if (!phase.equals(Constant.Phase.UNTAP)) {
|
||||
if (!phase.equals(PhaseType.UNTAP)) {
|
||||
// during untap
|
||||
this.resetPriority();
|
||||
}
|
||||
@@ -512,32 +505,32 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.getPhase().equals(Constant.Phase.COMBAT_DECLARE_ATTACKERS)) {
|
||||
if (this.getPhase().equals(PhaseType.COMBAT_DECLARE_ATTACKERS)) {
|
||||
AllZone.getStack().unfreezeStack();
|
||||
this.nCombatsThisTurn++;
|
||||
} else if (this.getPhase().equals(Constant.Phase.UNTAP)) {
|
||||
} else if (this.getPhase().equals(PhaseType.UNTAP)) {
|
||||
this.nCombatsThisTurn = 0;
|
||||
}
|
||||
|
||||
if (this.getPhase().equals(Constant.Phase.COMBAT_END)) {
|
||||
if (this.getPhase().equals(PhaseType.COMBAT_END)) {
|
||||
Singletons.getControl().getControlMatch().showStack();
|
||||
AllZone.getCombat().reset();
|
||||
this.resetAttackedThisCombat(this.getPlayerTurn());
|
||||
this.bCombat = false;
|
||||
}
|
||||
|
||||
if (this.getPhaseOrder()[this.phaseIndex].equals(Constant.Phase.CLEANUP)) {
|
||||
if (this.phaseIndex == PhaseType.CLEANUP.Index) {
|
||||
this.bPreventCombatDamageThisTurn = false;
|
||||
if (!this.bRepeat) {
|
||||
Singletons.getModel().getGameState().getPhaseHandler().setPlayerTurn(this.handleNextTurn());
|
||||
}
|
||||
}
|
||||
|
||||
if (this.is(Constant.Phase.COMBAT_DECLARE_BLOCKERS)) {
|
||||
if (this.is(PhaseType.COMBAT_DECLARE_BLOCKERS)) {
|
||||
AllZone.getStack().unfreezeStack();
|
||||
}
|
||||
|
||||
if (this.is(Constant.Phase.COMBAT_END) && (this.extraCombats > 0)) {
|
||||
if (this.is(PhaseType.COMBAT_END) && (this.extraCombats > 0)) {
|
||||
// TODO: ExtraCombat needs to be changed for other spell/abilities
|
||||
// that give extra combat
|
||||
// can do it like ExtraTurn stack ExtraPhases
|
||||
@@ -550,11 +543,11 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
AllZone.getCombat().reset();
|
||||
AllZone.getCombat().setAttackingPlayer(player);
|
||||
AllZone.getCombat().setDefendingPlayer(opp);
|
||||
this.phaseIndex = this.findIndex(Constant.Phase.COMBAT_DECLARE_ATTACKERS);
|
||||
this.phaseIndex = PhaseType.COMBAT_DECLARE_ATTACKERS.Index;
|
||||
} else {
|
||||
if (!this.bRepeat) { // for when Cleanup needs to repeat itself
|
||||
this.phaseIndex++;
|
||||
this.phaseIndex %= this.getPhaseOrder().length;
|
||||
this.phaseIndex %= PhaseType.values().length;
|
||||
} else {
|
||||
this.bRepeat = false;
|
||||
}
|
||||
@@ -564,7 +557,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
|
||||
// **** Anything BELOW Here is actually in the next phase. Maybe move
|
||||
// this to handleBeginPhase
|
||||
if (this.getPhase().equals(Constant.Phase.UNTAP)) {
|
||||
if (this.getPhase().equals(PhaseType.UNTAP)) {
|
||||
this.turn++;
|
||||
AllZone.getGameLog().add("Turn", "Turn " + this.turn + " (" + this.getPlayerTurn() + ")", 0);
|
||||
}
|
||||
@@ -647,7 +640,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
* a {@link forge.Player} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final synchronized boolean is(final String phase, final Player player) {
|
||||
public final synchronized boolean is(final PhaseType phase, final Player player) {
|
||||
return this.getPhase().equals(phase) && this.getPlayerTurn().isPlayer(player);
|
||||
}
|
||||
|
||||
@@ -660,54 +653,10 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
* a {@link java.lang.String} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final synchronized boolean is(final String phase) {
|
||||
public final synchronized boolean is(final PhaseType phase) {
|
||||
return (this.getPhase().equals(phase));
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* isAfter.
|
||||
* </p>
|
||||
*
|
||||
* @param phase
|
||||
* a {@link java.lang.String} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean isAfter(final String phase) {
|
||||
return this.phaseIndex > this.findIndex(phase);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* isBefore.
|
||||
* </p>
|
||||
*
|
||||
* @param phase
|
||||
* a {@link java.lang.String} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean isBefore(final String phase) {
|
||||
return this.phaseIndex < this.findIndex(phase);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* findIndex.
|
||||
* </p>
|
||||
*
|
||||
* @param phase
|
||||
* a {@link java.lang.String} object.
|
||||
* @return a int.
|
||||
*/
|
||||
private int findIndex(final String phase) {
|
||||
for (int i = 0; i < this.getPhaseOrder().length; i++) {
|
||||
if (phase.equals(this.getPhaseOrder()[i])) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("Phase : findIndex() invalid argument, phase = " + phase);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* getPhase.
|
||||
@@ -715,8 +664,8 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
*
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public final String getPhase() {
|
||||
return this.getPhaseOrder()[this.phaseIndex];
|
||||
public final PhaseType getPhase() {
|
||||
return PhaseType.getByIndex(this.phaseIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -947,44 +896,11 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
*/
|
||||
public static boolean canCastSorcery(final Player player) {
|
||||
return Singletons.getModel().getGameState().getPhaseHandler().isPlayerTurn(player)
|
||||
&& (Singletons.getModel().getGameState().getPhaseHandler().getPhase().equals(Constant.Phase.MAIN2) || Singletons.getModel().getGameState().getPhaseHandler()
|
||||
.getPhase().equals(Constant.Phase.MAIN1)) && (AllZone.getStack().size() == 0);
|
||||
&& (Singletons.getModel().getGameState().getPhaseHandler().getPhase().equals(PhaseType.MAIN2) || Singletons.getModel().getGameState().getPhaseHandler()
|
||||
.getPhase().equals(PhaseType.MAIN1)) && (AllZone.getStack().size() == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* buildActivateString.
|
||||
* </p>
|
||||
*
|
||||
* @param startPhase
|
||||
* a {@link java.lang.String} object.
|
||||
* @param endPhase
|
||||
* a {@link java.lang.String} object.
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public final String buildActivateString(final String startPhase, final String endPhase) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
|
||||
boolean add = false;
|
||||
for (int i = 0; i < this.getPhaseOrder().length; i++) {
|
||||
if (this.getPhaseOrder()[i].equals(startPhase)) {
|
||||
add = true;
|
||||
}
|
||||
|
||||
if (add) {
|
||||
if (sb.length() != 0) {
|
||||
sb.append(",");
|
||||
}
|
||||
sb.append(this.getPhaseOrder()[i]);
|
||||
}
|
||||
|
||||
if (this.getPhaseOrder()[i].equals(endPhase)) {
|
||||
add = false;
|
||||
}
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -1021,8 +937,8 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
* @param phaseID
|
||||
* a {@link java.lang.String} object.
|
||||
*/
|
||||
public final void setDevPhaseState(final String phaseID) {
|
||||
this.phaseIndex = this.findIndex(phaseID);
|
||||
public final void setDevPhaseState(final PhaseType phase) {
|
||||
this.phaseIndex = phase.Index;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1030,8 +946,8 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
*
|
||||
* @param phaseID the new phase state
|
||||
*/
|
||||
public final void setPhaseState(final String phaseID) {
|
||||
this.phaseIndex = this.findIndex(phaseID);
|
||||
public final void setPhaseState(final PhaseType phaseID) {
|
||||
this.phaseIndex = phaseID.Index;
|
||||
this.handleBeginPhase();
|
||||
}
|
||||
|
||||
@@ -1045,23 +961,4 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
public final void setPreventCombatDamageThisTurn(final boolean b) {
|
||||
this.bPreventCombatDamageThisTurn = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the phase order.
|
||||
*
|
||||
* @return the phaseOrder
|
||||
*/
|
||||
public String[] getPhaseOrder() {
|
||||
return this.phaseOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the phase order.
|
||||
*
|
||||
* @param phaseOrder0
|
||||
* the phaseOrder to set
|
||||
*/
|
||||
public void setPhaseOrder(final String[] phaseOrder0) {
|
||||
this.phaseOrder = phaseOrder0;
|
||||
}
|
||||
}
|
||||
|
||||
98
src/main/java/forge/PhaseType.java
Normal file
98
src/main/java/forge/PhaseType.java
Normal file
@@ -0,0 +1,98 @@
|
||||
package forge;
|
||||
|
||||
import java.security.InvalidParameterException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
|
||||
public enum PhaseType {
|
||||
UNTAP("Untap", 0),
|
||||
UPKEEP("Upkeep", 1),
|
||||
DRAW("Draw", 2),
|
||||
MAIN1("Main1", 3),
|
||||
COMBAT_BEGIN("BeginCombat", 4),
|
||||
COMBAT_DECLARE_ATTACKERS("Declare Attackers", 5),
|
||||
COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY("Declare Attackers - Play Instants and Abilities", 6),
|
||||
COMBAT_DECLARE_BLOCKERS("Declare Blockers", 7),
|
||||
COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY("Declare Blockers - Play Instants and Abilities", 8),
|
||||
COMBAT_FIRST_STRIKE_DAMAGE("First Strike Damage", 9),
|
||||
COMBAT_DAMAGE("Combat Damage", 10),
|
||||
COMBAT_END("EndCombat", 11),
|
||||
MAIN2("Main2", 12),
|
||||
END_OF_TURN("End of Turn", 13),
|
||||
CLEANUP("Cleanup", 14);
|
||||
|
||||
public final String Name;
|
||||
public final int Index;
|
||||
private PhaseType(String name, int index) {
|
||||
Name = name;
|
||||
Index = index;
|
||||
}
|
||||
|
||||
public static PhaseType getByIndex(int idx) {
|
||||
for( PhaseType ph : PhaseType.values() )
|
||||
{
|
||||
if ( ph.Index == idx ) return ph;
|
||||
}
|
||||
throw new InvalidParameterException("No PhaseType found with index " + idx );
|
||||
}
|
||||
|
||||
|
||||
public final boolean isAfter(final PhaseType phase) {
|
||||
return this.Index > phase.Index;
|
||||
}
|
||||
|
||||
|
||||
public final boolean isBefore(final PhaseType phase) {
|
||||
return this.Index < phase.Index;
|
||||
}
|
||||
|
||||
public static PhaseType smartValueOf(final String value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if ("All".equals(value)) {
|
||||
return null;
|
||||
}
|
||||
final String valToCompate = value.trim();
|
||||
for (final PhaseType v : PhaseType.values()) {
|
||||
if (v.Name.compareToIgnoreCase(valToCompate) == 0) {
|
||||
return v;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("No element named " + value + " in enum PhaseType");
|
||||
}
|
||||
|
||||
public static List<PhaseType> listValueOf(final String values) {
|
||||
final List<PhaseType> result = new ArrayList<PhaseType>();
|
||||
for (final String s : values.split("[, ]+")) {
|
||||
result.add(PhaseType.smartValueOf(s));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this method.
|
||||
* @param string
|
||||
* @return
|
||||
*/
|
||||
public static List<PhaseType> parseRange(String values) {
|
||||
final List<PhaseType> result = new ArrayList<PhaseType>();
|
||||
for (final String s : values.split(",")) {
|
||||
int idxArrow = s.indexOf("->");
|
||||
if ( idxArrow >= 0 ) {
|
||||
PhaseType from = PhaseType.smartValueOf(s.substring(0, idxArrow));
|
||||
String sTo = s.substring(idxArrow + 2);
|
||||
PhaseType to = StringUtils.isBlank(sTo) ? PhaseType.CLEANUP : PhaseType.smartValueOf(sTo);
|
||||
for( int i = from.Index; i <= to.Index; i++) {
|
||||
result.add(PhaseType.getByIndex(i));
|
||||
}
|
||||
}
|
||||
else
|
||||
result.add(PhaseType.smartValueOf(s));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ package forge;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import forge.PhaseType;
|
||||
import forge.Constant.Zone;
|
||||
import forge.card.trigger.TriggerType;
|
||||
import forge.control.ControlMatchUI;
|
||||
@@ -363,10 +364,10 @@ public class PhaseUtil {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public static boolean isBeforeAttackersAreDeclared() {
|
||||
final String phase = Singletons.getModel().getGameState().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);
|
||||
final PhaseType phase = Singletons.getModel().getGameState().getPhaseHandler().getPhase();
|
||||
return phase.equals(PhaseType.UNTAP) || phase.equals(PhaseType.UPKEEP)
|
||||
|| phase.equals(PhaseType.DRAW) || phase.equals(PhaseType.MAIN1)
|
||||
|| phase.equals(PhaseType.COMBAT_BEGIN);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -376,7 +377,7 @@ public class PhaseUtil {
|
||||
* @param s
|
||||
*   Phase state
|
||||
*/
|
||||
public static void visuallyActivatePhase(final String s) {
|
||||
public static void visuallyActivatePhase(final PhaseType s) {
|
||||
PhaseLabel lbl = null;
|
||||
final Player p = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn();
|
||||
final ControlMatchUI t = Singletons.getControl().getControlMatch();
|
||||
@@ -388,29 +389,29 @@ public class PhaseUtil {
|
||||
i = 1;
|
||||
}
|
||||
|
||||
if (s.equals(Constant.Phase.UPKEEP)) {
|
||||
if (s.equals(PhaseType.UPKEEP)) {
|
||||
lbl = t.getFieldControls().get(i).getView().getLblUpkeep();
|
||||
} else if (s.equals(Constant.Phase.DRAW)) {
|
||||
} else if (s.equals(PhaseType.DRAW)) {
|
||||
lbl = t.getFieldControls().get(i).getView().getLblDraw();
|
||||
} else if (s.equals(Constant.Phase.MAIN1)) {
|
||||
} else if (s.equals(PhaseType.MAIN1)) {
|
||||
lbl = t.getFieldControls().get(i).getView().getLblMain1();
|
||||
} else if (s.equals(Constant.Phase.COMBAT_BEGIN)) {
|
||||
} else if (s.equals(PhaseType.COMBAT_BEGIN)) {
|
||||
lbl = t.getFieldControls().get(i).getView().getLblBeginCombat();
|
||||
} else if (s.equals(Constant.Phase.COMBAT_DECLARE_ATTACKERS)) {
|
||||
} else if (s.equals(PhaseType.COMBAT_DECLARE_ATTACKERS)) {
|
||||
lbl = t.getFieldControls().get(i).getView().getLblDeclareAttackers();
|
||||
} else if (s.equals(Constant.Phase.COMBAT_DECLARE_BLOCKERS)) {
|
||||
} else if (s.equals(PhaseType.COMBAT_DECLARE_BLOCKERS)) {
|
||||
lbl = t.getFieldControls().get(i).getView().getLblDeclareBlockers();
|
||||
} else if (s.equals(Constant.Phase.COMBAT_DAMAGE)) {
|
||||
} else if (s.equals(PhaseType.COMBAT_DAMAGE)) {
|
||||
lbl = t.getFieldControls().get(i).getView().getLblCombatDamage();
|
||||
} else if (s.equals(Constant.Phase.COMBAT_FIRST_STRIKE_DAMAGE)) {
|
||||
} else if (s.equals(PhaseType.COMBAT_FIRST_STRIKE_DAMAGE)) {
|
||||
lbl = t.getFieldControls().get(i).getView().getLblFirstStrike();
|
||||
} else if (s.equals(Constant.Phase.COMBAT_END)) {
|
||||
} else if (s.equals(PhaseType.COMBAT_END)) {
|
||||
lbl = t.getFieldControls().get(i).getView().getLblEndCombat();
|
||||
} else if (s.equals(Constant.Phase.MAIN2)) {
|
||||
} else if (s.equals(PhaseType.MAIN2)) {
|
||||
lbl = t.getFieldControls().get(i).getView().getLblMain2();
|
||||
} else if (s.equals(Constant.Phase.END_OF_TURN)) {
|
||||
} else if (s.equals(PhaseType.END_OF_TURN)) {
|
||||
lbl = t.getFieldControls().get(i).getView().getLblEndTurn();
|
||||
} else if (s.equals(Constant.Phase.CLEANUP)) {
|
||||
} else if (s.equals(PhaseType.CLEANUP)) {
|
||||
lbl = t.getFieldControls().get(i).getView().getLblCleanup();
|
||||
} else {
|
||||
return;
|
||||
|
||||
@@ -30,6 +30,7 @@ import forge.ComputerUtil;
|
||||
import forge.Constant;
|
||||
import forge.Constant.Zone;
|
||||
import forge.GameActionUtil;
|
||||
import forge.PhaseType;
|
||||
import forge.Player;
|
||||
import forge.Singletons;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
@@ -1438,11 +1439,11 @@ public class AbilityFactory {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sa.getRestrictions().getPlaneswalker() && Singletons.getModel().getGameState().getPhaseHandler().is(Constant.Phase.MAIN2)) {
|
||||
if (sa.getRestrictions().getPlaneswalker() && Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.MAIN2)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return (Singletons.getModel().getGameState().getPhaseHandler().is(Constant.Phase.END_OF_TURN) && Singletons.getModel().getGameState().getPhaseHandler().isNextTurn(
|
||||
return (Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.END_OF_TURN) && Singletons.getModel().getGameState().getPhaseHandler().isNextTurn(
|
||||
AllZone.getComputerPlayer()));
|
||||
}
|
||||
|
||||
@@ -1458,8 +1459,8 @@ public class AbilityFactory {
|
||||
*/
|
||||
public static boolean waitForBlocking(final SpellAbility sa) {
|
||||
|
||||
return (sa.getSourceCard().isCreature() && sa.getPayCosts().getTap() && (Singletons.getModel().getGameState().getPhaseHandler().isBefore(
|
||||
Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY) || Singletons.getModel().getGameState().getPhaseHandler().isNextTurn(
|
||||
return (sa.getSourceCard().isCreature() && sa.getPayCosts().getTap() && (Singletons.getModel().getGameState().getPhaseHandler().getPhase().isBefore(
|
||||
PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY) || Singletons.getModel().getGameState().getPhaseHandler().isNextTurn(
|
||||
AllZone.getHumanPlayer())));
|
||||
}
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@ import forge.AllZone;
|
||||
import forge.AllZoneUtil;
|
||||
import forge.Card;
|
||||
import forge.ComputerUtil;
|
||||
import forge.Constant;
|
||||
import forge.Counters;
|
||||
import forge.PhaseType;
|
||||
import forge.Player;
|
||||
import forge.Singletons;
|
||||
import forge.card.cost.Cost;
|
||||
@@ -309,7 +309,7 @@ public class AbilityFactoryAlterLife {
|
||||
}
|
||||
|
||||
// Don't use lifegain before main 2 if possible
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().isBefore(Constant.Phase.MAIN2) && !params.containsKey("ActivationPhases")) {
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2) && !params.containsKey("ActivationPhases")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -704,7 +704,7 @@ public class AbilityFactoryAlterLife {
|
||||
}
|
||||
|
||||
// Don't use loselife before main 2 if possible
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().isBefore(Constant.Phase.MAIN2) && !params.containsKey("ActivationPhases") && !priority) {
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2) && !params.containsKey("ActivationPhases") && !priority) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1158,7 +1158,7 @@ public class AbilityFactoryAlterLife {
|
||||
}
|
||||
|
||||
// Don't use poison before main 2 if possible
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().isBefore(Constant.Phase.MAIN2) && !params.containsKey("ActivationPhases")) {
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2) && !params.containsKey("ActivationPhases")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1377,7 +1377,7 @@ public class AbilityFactoryAlterLife {
|
||||
}
|
||||
|
||||
// Don't use setLife before main 2 if possible
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().isBefore(Constant.Phase.MAIN2) && !params.containsKey("ActivationPhases")) {
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2) && !params.containsKey("ActivationPhases")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,8 +30,8 @@ import forge.CardList;
|
||||
import forge.CardUtil;
|
||||
import forge.Command;
|
||||
import forge.ComputerUtil;
|
||||
import forge.Constant;
|
||||
import forge.Constant.Zone;
|
||||
import forge.PhaseType;
|
||||
import forge.Player;
|
||||
import forge.Singletons;
|
||||
import forge.card.replacement.ReplacementEffect;
|
||||
@@ -323,7 +323,7 @@ public final class AbilityFactoryAnimate {
|
||||
|
||||
// don't use instant speed animate abilities outside computers
|
||||
// Combat_Begin step
|
||||
if (!Singletons.getModel().getGameState().getPhaseHandler().is(Constant.Phase.COMBAT_BEGIN)
|
||||
if (!Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.COMBAT_BEGIN)
|
||||
&& Singletons.getModel().getGameState().getPhaseHandler().isPlayerTurn(AllZone.getComputerPlayer()) && !AbilityFactory.isSorcerySpeed(sa)
|
||||
&& !params.containsKey("ActivationPhases") && !params.containsKey("Permanent")) {
|
||||
return false;
|
||||
@@ -331,13 +331,13 @@ public final class AbilityFactoryAnimate {
|
||||
|
||||
// don't use instant speed animate abilities outside humans
|
||||
// Combat_Declare_Attackers_InstantAbility step
|
||||
if ((!Singletons.getModel().getGameState().getPhaseHandler().is(Constant.Phase.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY) || (AllZone.getCombat()
|
||||
if ((!Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY) || (AllZone.getCombat()
|
||||
.getAttackers().isEmpty())) && Singletons.getModel().getGameState().getPhaseHandler().isPlayerTurn(AllZone.getHumanPlayer())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// don't activate during main2 unless this effect is permanent
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().is(Constant.Phase.MAIN2) && !params.containsKey("Permanent")) {
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.MAIN2) && !params.containsKey("Permanent")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,10 +32,10 @@ import forge.CardUtil;
|
||||
import forge.CombatUtil;
|
||||
import forge.Command;
|
||||
import forge.ComputerUtil;
|
||||
import forge.Constant;
|
||||
import forge.Constant.Zone;
|
||||
import forge.GameActionUtil;
|
||||
import forge.GameEntity;
|
||||
import forge.PhaseType;
|
||||
import forge.Player;
|
||||
import forge.Singletons;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
@@ -920,7 +920,7 @@ public class AbilityFactoryAttach {
|
||||
source.setSVar("PayX", Integer.toString(xPay));
|
||||
}
|
||||
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().isAfter(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)
|
||||
&& !"Curse".equals(af.getMapParams().get("AILogic"))) {
|
||||
return false;
|
||||
}
|
||||
@@ -1421,7 +1421,7 @@ public class AbilityFactoryAttach {
|
||||
source.setSVar("PayX", Integer.toString(xPay));
|
||||
}
|
||||
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().isAfter(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)
|
||||
&& !"Curse".equals(af.getMapParams().get("AILogic"))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import forge.Constant;
|
||||
import forge.Constant.Zone;
|
||||
import forge.GameActionUtil;
|
||||
import forge.GameEntity;
|
||||
import forge.PhaseType;
|
||||
import forge.Player;
|
||||
import forge.PlayerZone;
|
||||
import forge.Singletons;
|
||||
@@ -497,7 +498,7 @@ public final class AbilityFactoryChangeZone {
|
||||
}
|
||||
|
||||
// don't use fetching to top of library/graveyard before main2
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().isBefore(Constant.Phase.MAIN2) && !params.containsKey("ActivationPhases")
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2) && !params.containsKey("ActivationPhases")
|
||||
&& !destination.equals("Battlefield") && !destination.equals("Hand")) {
|
||||
return false;
|
||||
}
|
||||
@@ -1476,7 +1477,7 @@ public final class AbilityFactoryChangeZone {
|
||||
}
|
||||
}
|
||||
// Save combatants
|
||||
else if (Singletons.getModel().getGameState().getPhaseHandler().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
else if (Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
final CardList combatants = aiPermanents.getType("Creature");
|
||||
CardListUtil.sortByEvaluateCreature(combatants);
|
||||
|
||||
@@ -1528,7 +1529,7 @@ public final class AbilityFactoryChangeZone {
|
||||
if (origin.equals(Zone.Battlefield)
|
||||
&& destination.equals(Zone.Exile)
|
||||
&& (subAPI.equals("DelayedTrigger") || (subAPI.equals("ChangeZone") && subAffected.equals("Remembered")))
|
||||
&& !(Singletons.getModel().getGameState().getPhaseHandler().is(Constant.Phase.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY) || sa
|
||||
&& !(Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY) || sa
|
||||
.isAbility())) {
|
||||
return false;
|
||||
}
|
||||
@@ -1538,7 +1539,7 @@ public final class AbilityFactoryChangeZone {
|
||||
|
||||
// don't rush bouncing stuff when not going to attack
|
||||
if (!sa.isTrigger() && sa.getPayCosts() != null
|
||||
&& Singletons.getModel().getGameState().getPhaseHandler().isBefore(Constant.Phase.MAIN2)
|
||||
&& Singletons.getModel().getGameState().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)
|
||||
&& Singletons.getModel().getGameState().getPhaseHandler().isPlayerTurn(AllZone.getComputerPlayer())
|
||||
&& AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()).isEmpty()) {
|
||||
return false;
|
||||
@@ -2237,7 +2238,7 @@ public final class AbilityFactoryChangeZone {
|
||||
}
|
||||
|
||||
// Don't cast during main1?
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().is(Constant.Phase.MAIN1, AllZone.getComputerPlayer())) {
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.MAIN1, AllZone.getComputerPlayer())) {
|
||||
return false;
|
||||
}
|
||||
} else if (origin.equals(Zone.Graveyard)) {
|
||||
|
||||
@@ -26,8 +26,8 @@ import forge.CardList;
|
||||
import forge.CardListFilter;
|
||||
import forge.CombatUtil;
|
||||
import forge.ComputerUtil;
|
||||
import forge.Constant;
|
||||
import forge.Constant.Zone;
|
||||
import forge.PhaseType;
|
||||
import forge.Player;
|
||||
import forge.Singletons;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
@@ -207,7 +207,7 @@ public final class AbilityFactoryCombat {
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().isPlayerTurn(sa.getActivatingPlayer())) {
|
||||
return false;
|
||||
}
|
||||
if (!Singletons.getModel().getGameState().getPhaseHandler().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
if (!Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -247,9 +247,9 @@ public final class AbilityFactoryCombat {
|
||||
// AI should only activate this during Human's turn
|
||||
boolean chance;
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().isPlayerTurn(sa.getActivatingPlayer().getOpponent())) {
|
||||
chance = Singletons.getModel().getGameState().getPhaseHandler().isBefore(Constant.Phase.COMBAT_FIRST_STRIKE_DAMAGE);
|
||||
chance = Singletons.getModel().getGameState().getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_FIRST_STRIKE_DAMAGE);
|
||||
} else {
|
||||
chance = Singletons.getModel().getGameState().getPhaseHandler().isAfter(Constant.Phase.COMBAT_DAMAGE);
|
||||
chance = Singletons.getModel().getGameState().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DAMAGE);
|
||||
}
|
||||
|
||||
final AbilitySub subAb = sa.getSubAbility();
|
||||
@@ -281,9 +281,9 @@ public final class AbilityFactoryCombat {
|
||||
|
||||
boolean chance;
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().isPlayerTurn(sa.getActivatingPlayer().getOpponent())) {
|
||||
chance = Singletons.getModel().getGameState().getPhaseHandler().isBefore(Constant.Phase.COMBAT_FIRST_STRIKE_DAMAGE);
|
||||
chance = Singletons.getModel().getGameState().getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_FIRST_STRIKE_DAMAGE);
|
||||
} else {
|
||||
chance = Singletons.getModel().getGameState().getPhaseHandler().isAfter(Constant.Phase.COMBAT_DAMAGE);
|
||||
chance = Singletons.getModel().getGameState().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DAMAGE);
|
||||
}
|
||||
|
||||
// check SubAbilities DoTrigger?
|
||||
@@ -928,7 +928,7 @@ public final class AbilityFactoryCombat {
|
||||
}
|
||||
|
||||
// only use on creatures that can attack
|
||||
if (!Singletons.getModel().getGameState().getPhaseHandler().isBefore(Constant.Phase.MAIN2)) {
|
||||
if (!Singletons.getModel().getGameState().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@ import forge.CardList;
|
||||
import forge.CardListFilter;
|
||||
import forge.Command;
|
||||
import forge.ComputerUtil;
|
||||
import forge.Constant;
|
||||
import forge.Constant.Zone;
|
||||
import forge.PhaseType;
|
||||
import forge.Player;
|
||||
import forge.Singletons;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
@@ -235,7 +235,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") && !Singletons.getModel().getGameState().getPhaseHandler().is(Constant.Phase.MAIN1)) {
|
||||
if (params.containsKey("AtEOT") && !Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.MAIN1)) {
|
||||
return false;
|
||||
} else {
|
||||
double chance = .4; // 40 percent chance with instant speed stuff
|
||||
|
||||
@@ -34,6 +34,7 @@ import forge.Constant;
|
||||
import forge.Constant.Zone;
|
||||
import forge.Counters;
|
||||
import forge.PhaseHandler;
|
||||
import forge.PhaseType;
|
||||
import forge.Player;
|
||||
import forge.PlayerZone;
|
||||
import forge.Singletons;
|
||||
@@ -390,7 +391,7 @@ public class AbilityFactoryCounters {
|
||||
}
|
||||
|
||||
// Don't use non P1P1/M1M1 counters before main 2 if possible
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().isBefore(Constant.Phase.MAIN2) && !params.containsKey("ActivationPhases")
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2) && !params.containsKey("ActivationPhases")
|
||||
&& !(type.equals("P1P1") || type.equals("M1M1"))) {
|
||||
return false;
|
||||
}
|
||||
@@ -1819,7 +1820,7 @@ public class AbilityFactoryCounters {
|
||||
if (type.equals("P1P1") && sa.isAbility() && source.isCreature()
|
||||
&& sa.getPayCosts() != null && sa.getPayCosts().getTap()
|
||||
&& (phase.isNextTurn(AllZone.getHumanPlayer())
|
||||
|| phase.isBefore(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY))) {
|
||||
|| phase.getPhase().isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY))) {
|
||||
boolean combatants = false;
|
||||
for (Card c : hList) {
|
||||
if (!c.equals(source) && c.isUntapped()) {
|
||||
|
||||
@@ -28,8 +28,8 @@ import forge.CardList;
|
||||
import forge.CardListFilter;
|
||||
import forge.CardUtil;
|
||||
import forge.ComputerUtil;
|
||||
import forge.Constant;
|
||||
import forge.Constant.Zone;
|
||||
import forge.PhaseType;
|
||||
import forge.Player;
|
||||
import forge.Singletons;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
@@ -359,7 +359,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 Singletons.getModel().getGameState().getPhaseHandler().is(Constant.Phase.END_OF_TURN, AllZone.getHumanPlayer());
|
||||
return Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.END_OF_TURN, AllZone.getHumanPlayer());
|
||||
}
|
||||
|
||||
if (this.abilityFactory.isAbility()) {
|
||||
@@ -438,7 +438,7 @@ public class AbilityFactoryDealDamage {
|
||||
|
||||
if (this.abilityFactory.isSpell()) {
|
||||
// If this is a spell, cast it instead of discarding
|
||||
if ((Singletons.getModel().getGameState().getPhaseHandler().is(Constant.Phase.END_OF_TURN) || Singletons.getModel().getGameState().getPhaseHandler().is(Constant.Phase.MAIN2))
|
||||
if ((Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.END_OF_TURN) || Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.MAIN2))
|
||||
&& Singletons.getModel().getGameState().getPhaseHandler().isPlayerTurn(comp) && (hand.size() > comp.getMaxHandSize())) {
|
||||
return true;
|
||||
}
|
||||
@@ -589,7 +589,7 @@ public class AbilityFactoryDealDamage {
|
||||
// on the stack
|
||||
// or from taking combat damage
|
||||
final boolean freePing = isTrigger || saMe.getPayCosts() == null || tgt.getNumTargeted() > 0
|
||||
|| (Singletons.getModel().getGameState().getPhaseHandler().is(Constant.Phase.END_OF_TURN) && saMe.isAbility()
|
||||
|| (Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.END_OF_TURN) && saMe.isAbility()
|
||||
&& Singletons.getModel().getGameState().getPhaseHandler().isNextTurn(AllZone.getComputerPlayer()));
|
||||
|
||||
if (freePing && saMe.canTarget(AllZone.getHumanPlayer()) && tgt.addTarget(AllZone.getHumanPlayer())) {
|
||||
@@ -605,7 +605,7 @@ public class AbilityFactoryDealDamage {
|
||||
|
||||
// TODO: Improve Damage, we shouldn't just target the player just
|
||||
// because we can
|
||||
else if (saMe.canTarget(AllZone.getHumanPlayer()) && ((Singletons.getModel().getGameState().getPhaseHandler().is(Constant.Phase.END_OF_TURN)
|
||||
else if (saMe.canTarget(AllZone.getHumanPlayer()) && ((Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.END_OF_TURN)
|
||||
&& Singletons.getModel().getGameState().getPhaseHandler().isNextTurn(AllZone.getComputerPlayer()))
|
||||
|| saMe.getPayCosts() == null || isTrigger)) {
|
||||
if (tgt.addTarget(AllZone.getHumanPlayer())) {
|
||||
|
||||
@@ -31,8 +31,8 @@ import forge.CardListFilter;
|
||||
import forge.CombatUtil;
|
||||
import forge.Command;
|
||||
import forge.ComputerUtil;
|
||||
import forge.Constant;
|
||||
import forge.Constant.Zone;
|
||||
import forge.PhaseType;
|
||||
import forge.Singletons;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.cost.Cost;
|
||||
@@ -289,7 +289,7 @@ public final class AbilityFactoryDebuff {
|
||||
final SpellAbilityRestriction restrict = sa.getRestrictions();
|
||||
|
||||
// Phase Restrictions
|
||||
if ((AllZone.getStack().size() == 0) && Singletons.getModel().getGameState().getPhaseHandler().isBefore(Constant.Phase.COMBAT_BEGIN)) {
|
||||
if ((AllZone.getStack().size() == 0) && Singletons.getModel().getGameState().getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_BEGIN)) {
|
||||
// Instant-speed pumps should not be cast outside of combat when the
|
||||
// stack is empty
|
||||
if (!AbilityFactory.isSorcerySpeed(sa)) {
|
||||
@@ -357,7 +357,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 && Singletons.getModel().getGameState().getPhaseHandler().isAfter(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
if (!mandatory && Singletons.getModel().getGameState().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -753,7 +753,7 @@ public final class AbilityFactoryDebuff {
|
||||
});
|
||||
|
||||
// don't use DebuffAll after Combat_Begin until AI is improved
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().isAfter(Constant.Phase.COMBAT_BEGIN)) {
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_BEGIN)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,9 +28,9 @@ import forge.CardListFilter;
|
||||
import forge.CombatUtil;
|
||||
import forge.Command;
|
||||
import forge.ComputerUtil;
|
||||
import forge.Constant;
|
||||
import forge.Constant.Zone;
|
||||
import forge.PhaseHandler;
|
||||
import forge.PhaseType;
|
||||
import forge.Player;
|
||||
import forge.Singletons;
|
||||
import forge.card.replacement.ReplacementEffect;
|
||||
@@ -231,7 +231,7 @@ public class AbilityFactoryEffect {
|
||||
logic = params.get("AILogic");
|
||||
final PhaseHandler phase = Singletons.getModel().getGameState().getPhaseHandler();
|
||||
if (logic.equals("BeginningOfOppTurn")) {
|
||||
if (phase.isPlayerTurn(AllZone.getComputerPlayer()) || phase.isAfter(Constant.Phase.DRAW)) {
|
||||
if (phase.isPlayerTurn(AllZone.getComputerPlayer()) || phase.getPhase().isAfter(PhaseType.DRAW)) {
|
||||
return false;
|
||||
}
|
||||
randomReturn = true;
|
||||
@@ -239,7 +239,7 @@ public class AbilityFactoryEffect {
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().isPlayerTurn(sa.getActivatingPlayer())) {
|
||||
return false;
|
||||
}
|
||||
if (!Singletons.getModel().getGameState().getPhaseHandler().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
if (!Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
return false;
|
||||
}
|
||||
if (AllZone.getStack().size() != 0) {
|
||||
|
||||
@@ -32,6 +32,7 @@ import forge.ComputerUtil;
|
||||
import forge.Constant;
|
||||
import forge.Constant.Zone;
|
||||
import forge.GameEntity;
|
||||
import forge.PhaseType;
|
||||
import forge.Player;
|
||||
import forge.Singletons;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
@@ -323,7 +324,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")
|
||||
&& Singletons.getModel().getGameState().getPhaseHandler().isAfter(Constant.Phase.COMBAT_DECLARE_BLOCKERS)) {
|
||||
&& Singletons.getModel().getGameState().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -524,7 +525,7 @@ public class AbilityFactoryGainControl {
|
||||
}
|
||||
}
|
||||
if ((this.lose != null) && this.lose.contains("EOT")
|
||||
&& Singletons.getModel().getGameState().getPhaseHandler().isAfter(Constant.Phase.COMBAT_DECLARE_ATTACKERS)) {
|
||||
&& Singletons.getModel().getGameState().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -28,9 +28,9 @@ import forge.Card;
|
||||
import forge.CardList;
|
||||
import forge.CardListFilter;
|
||||
import forge.ComputerUtil;
|
||||
import forge.Constant;
|
||||
import forge.Constant.Zone;
|
||||
import forge.PhaseHandler;
|
||||
import forge.PhaseType;
|
||||
import forge.Player;
|
||||
import forge.Singletons;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
@@ -804,7 +804,7 @@ public class AbilityFactoryPermanentState {
|
||||
|
||||
if (turn.isHuman()) {
|
||||
// Tap things down if it's Human's turn
|
||||
} else if (phase.inCombat() && phase.isBefore(Constant.Phase.COMBAT_DECLARE_BLOCKERS)) {
|
||||
} else if (phase.inCombat() && phase.getPhase().isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS)) {
|
||||
// TODO Tap creatures down if in combat
|
||||
} else {
|
||||
// Generally don't want to tap things during AI turn outside of
|
||||
@@ -1564,7 +1564,7 @@ public class AbilityFactoryPermanentState {
|
||||
final Card source = sa.getSourceCard();
|
||||
final HashMap<String, String> params = af.getMapParams();
|
||||
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().isAfter(Constant.Phase.COMBAT_BEGIN)) {
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_BEGIN)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@ import forge.CardListUtil;
|
||||
import forge.CardUtil;
|
||||
import forge.CombatUtil;
|
||||
import forge.ComputerUtil;
|
||||
import forge.Constant;
|
||||
import forge.Constant.Zone;
|
||||
import forge.PhaseType;
|
||||
import forge.Player;
|
||||
import forge.Singletons;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
@@ -285,7 +285,7 @@ public class AbilityFactoryPreventDamage {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
boolean flag = false;
|
||||
for (final Object o : objects) {
|
||||
if (o instanceof Card) {
|
||||
@@ -336,7 +336,7 @@ public class AbilityFactoryPreventDamage {
|
||||
}
|
||||
|
||||
} // Protect combatants
|
||||
else if (Singletons.getModel().getGameState().getPhaseHandler().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
else if (Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
if (sa.canTarget(AllZone.getComputerPlayer()) && CombatUtil.wouldLoseLife(AllZone.getCombat())
|
||||
&& (CombatUtil.lifeInDanger(AllZone.getCombat()) || sa.isAbility())) {
|
||||
tgt.addTarget(AllZone.getComputerPlayer());
|
||||
@@ -441,7 +441,7 @@ public class AbilityFactoryPreventDamage {
|
||||
if (compTargetables.size() > 0) {
|
||||
final CardList combatants = compTargetables.getType("Creature");
|
||||
CardListUtil.sortByEvaluateCreature(combatants);
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
for (final Card c : combatants) {
|
||||
if (CombatUtil.combatantWouldBeDestroyed(c)) {
|
||||
tgt.addTarget(c);
|
||||
@@ -689,7 +689,7 @@ public class AbilityFactoryPreventDamage {
|
||||
// control
|
||||
|
||||
} // Protect combatants
|
||||
else if (Singletons.getModel().getGameState().getPhaseHandler().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
else if (Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ import forge.Command;
|
||||
import forge.ComputerUtil;
|
||||
import forge.Constant;
|
||||
import forge.Constant.Zone;
|
||||
import forge.PhaseType;
|
||||
import forge.Player;
|
||||
import forge.Singletons;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
@@ -233,7 +234,7 @@ public final class AbilityFactoryProtection {
|
||||
}
|
||||
|
||||
// will the creature attack (only relevant for sorcery speed)?
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().isBefore(Constant.Phase.COMBAT_DECLARE_ATTACKERS)
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
&& Singletons.getModel().getGameState().getPhaseHandler().isPlayerTurn(AllZone.getComputerPlayer())
|
||||
&& CardFactoryUtil.doesCreatureAttackAI(c)) {
|
||||
return true;
|
||||
@@ -248,7 +249,7 @@ public final class AbilityFactoryProtection {
|
||||
}
|
||||
|
||||
// is the creature in blocked and the blocker would survive
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().isAfter(Constant.Phase.COMBAT_DECLARE_BLOCKERS)
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS)
|
||||
&& AllZone.getCombat().isAttacking(c) && AllZone.getCombat().isBlocked(c)
|
||||
&& CombatUtil.blockerWouldBeDestroyed(AllZone.getCombat().getBlockers(c).get(0))) {
|
||||
return true;
|
||||
@@ -299,7 +300,7 @@ public final class AbilityFactoryProtection {
|
||||
}
|
||||
|
||||
// Phase Restrictions
|
||||
if ((AllZone.getStack().size() == 0) && Singletons.getModel().getGameState().getPhaseHandler().isBefore(Constant.Phase.COMBAT_FIRST_STRIKE_DAMAGE)) {
|
||||
if ((AllZone.getStack().size() == 0) && Singletons.getModel().getGameState().getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_FIRST_STRIKE_DAMAGE)) {
|
||||
// Instant-speed protections should not be cast outside of combat
|
||||
// when the stack is empty
|
||||
if (!AbilityFactory.isSorcerySpeed(sa)) {
|
||||
@@ -346,7 +347,7 @@ public final class AbilityFactoryProtection {
|
||||
* @return a boolean.
|
||||
*/
|
||||
private static boolean protectTgtAI(final AbilityFactory af, final SpellAbility sa, final boolean mandatory) {
|
||||
if (!mandatory && Singletons.getModel().getGameState().getPhaseHandler().isAfter(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
if (!mandatory && Singletons.getModel().getGameState().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -373,11 +374,11 @@ public final class AbilityFactoryProtection {
|
||||
// If the cost is tapping, don't activate before declare
|
||||
// attack/block
|
||||
if ((sa.getPayCosts() != null) && sa.getPayCosts().getTap()) {
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().isBefore(Constant.Phase.COMBAT_DECLARE_ATTACKERS)
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
&& Singletons.getModel().getGameState().getPhaseHandler().isPlayerTurn(AllZone.getComputerPlayer())) {
|
||||
list.remove(sa.getSourceCard());
|
||||
}
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().isBefore(Constant.Phase.COMBAT_DECLARE_BLOCKERS)
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS)
|
||||
&& Singletons.getModel().getGameState().getPhaseHandler().isPlayerTurn(AllZone.getHumanPlayer())) {
|
||||
list.remove(sa.getSourceCard());
|
||||
}
|
||||
|
||||
@@ -30,10 +30,10 @@ import forge.CardUtil;
|
||||
import forge.CombatUtil;
|
||||
import forge.Command;
|
||||
import forge.ComputerUtil;
|
||||
import forge.Constant;
|
||||
import forge.Constant.Zone;
|
||||
import forge.GameEntity;
|
||||
import forge.PhaseHandler;
|
||||
import forge.PhaseType;
|
||||
import forge.Player;
|
||||
import forge.Singletons;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
@@ -290,21 +290,21 @@ public class AbilityFactoryPump {
|
||||
} else if (keyword.equals("Defender") || keyword.endsWith("CARDNAME can't attack.")) {
|
||||
if (ph.isPlayerTurn(computer) || !CombatUtil.canAttack(card)
|
||||
|| (card.getNetCombatDamage() <= 0)
|
||||
|| ph.isAfter(Constant.Phase.COMBAT_DECLARE_ATTACKERS)) {
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)) {
|
||||
return false;
|
||||
}
|
||||
} else if (keyword.endsWith("CARDNAME can't block.")) {
|
||||
if (ph.isPlayerTurn(human) || !CombatUtil.canBlock(card)
|
||||
|| ph.isAfter(Constant.Phase.COMBAT_DECLARE_BLOCKERS)) {
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS)) {
|
||||
return false;
|
||||
}
|
||||
} else if (keyword.endsWith("This card doesn't untap during your next untap step.")) {
|
||||
if (ph.isBefore(Constant.Phase.MAIN2) || card.isUntapped() || ph.isPlayerTurn(human)) {
|
||||
if (ph.getPhase().isBefore(PhaseType.MAIN2) || card.isUntapped() || ph.isPlayerTurn(human)) {
|
||||
return false;
|
||||
}
|
||||
} else if (keyword.endsWith("CARDNAME attacks each turn if able.")) {
|
||||
if (ph.isPlayerTurn(human) || !CombatUtil.canAttack(card) || !CombatUtil.canBeBlocked(card)
|
||||
|| ph.isAfter(Constant.Phase.COMBAT_DECLARE_ATTACKERS)) {
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -338,48 +338,48 @@ public class AbilityFactoryPump {
|
||||
if (evasive) {
|
||||
if (ph.isPlayerTurn(human) || !(CombatUtil.canAttack(card) || card.isAttacking())
|
||||
|| !CombatUtil.canBeBlocked(card)
|
||||
|| ph.isAfter(Constant.Phase.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)
|
||||
|| (card.getNetCombatDamage() <= 0) || (AllZoneUtil.getCreaturesInPlay(human).size() < 1)) {
|
||||
return false;
|
||||
}
|
||||
} else if (keyword.endsWith("Haste")) {
|
||||
if (!card.hasSickness() || ph.isPlayerTurn(human) || card.isTapped()
|
||||
|| card.hasKeyword("CARDNAME can attack as though it had haste.")
|
||||
|| ph.isAfter(Constant.Phase.COMBAT_DECLARE_ATTACKERS)
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
|| !CombatUtil.canAttackNextTurn(card)) {
|
||||
return false;
|
||||
}
|
||||
} else if (combatRelevant) {
|
||||
if (ph.isPlayerTurn(human) || !(CombatUtil.canAttack(card) || card.isAttacking())
|
||||
|| !CombatUtil.canBeBlocked(card)
|
||||
|| ph.isAfter(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)
|
||||
|| (AllZoneUtil.getCreaturesInPlay(human).size() < 1)) {
|
||||
return false;
|
||||
}
|
||||
} else if (keyword.equals("Double Strike")) {
|
||||
if (ph.isPlayerTurn(human) || !(CombatUtil.canAttack(card) || card.isAttacking())
|
||||
|| card.getNetCombatDamage() <= 0
|
||||
|| ph.isAfter(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
return false;
|
||||
}
|
||||
} else if (keyword.startsWith("Rampage")) {
|
||||
if (ph.isPlayerTurn(human) || !(CombatUtil.canAttack(card) || card.isAttacking())
|
||||
|| !CombatUtil.canBeBlocked(card)
|
||||
|| ph.isAfter(Constant.Phase.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)
|
||||
|| (AllZoneUtil.getCreaturesInPlay(human).size() < 2)) {
|
||||
return false;
|
||||
}
|
||||
} else if (keyword.startsWith("Flanking")) {
|
||||
if (ph.isPlayerTurn(human) || !(CombatUtil.canAttack(card) || card.isAttacking())
|
||||
|| !CombatUtil.canBeBlocked(card)
|
||||
|| ph.isAfter(Constant.Phase.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)
|
||||
|| AllZoneUtil.getCreaturesInPlay(human).getNotKeyword("Flanking").size() < 1) {
|
||||
return false;
|
||||
}
|
||||
} else if (keyword.startsWith("Trample")) {
|
||||
if (ph.isPlayerTurn(human) || !(CombatUtil.canAttack(card) || card.isAttacking())
|
||||
|| !CombatUtil.canBeBlocked(card)
|
||||
|| ph.isAfter(Constant.Phase.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)
|
||||
|| (AllZoneUtil.getCreaturesInPlay(human).size() < 1)
|
||||
|| card.getNetCombatDamage() + attack <= 1) {
|
||||
return false;
|
||||
@@ -393,7 +393,7 @@ public class AbilityFactoryPump {
|
||||
}
|
||||
if ((ph.isPlayerTurn(human))
|
||||
|| !(CombatUtil.canAttack(card) || card.isAttacking())
|
||||
|| ph.isAfter(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
return false;
|
||||
}
|
||||
} else if (keyword.endsWith("Wither")) {
|
||||
@@ -416,13 +416,13 @@ public class AbilityFactoryPump {
|
||||
}
|
||||
} else if (keyword.equals("Vigilance")) {
|
||||
if (ph.isPlayerTurn(human) || !CombatUtil.canAttack(card)
|
||||
|| ph.isAfter(Constant.Phase.COMBAT_DECLARE_ATTACKERS)
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
|| (AllZoneUtil.getCreaturesInPlay(human).size() < 1)) {
|
||||
return false;
|
||||
}
|
||||
} else if (keyword.equals("Reach")) {
|
||||
if (ph.isPlayerTurn(computer)
|
||||
|| ph.isAfter(Constant.Phase.COMBAT_DECLARE_BLOCKERS)
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS)
|
||||
|| !AllZone.getCombat().getAttackerList().getKeyword("Flying").isEmpty()
|
||||
|| !card.hasKeyword("Flying")) {
|
||||
return false;
|
||||
@@ -453,7 +453,7 @@ public class AbilityFactoryPump {
|
||||
}
|
||||
|
||||
// will the creature attack (only relevant for sorcery speed)?
|
||||
if (phase.isBefore(Constant.Phase.COMBAT_DECLARE_ATTACKERS)
|
||||
if (phase.getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
&& phase.isPlayerTurn(AllZone.getComputerPlayer())
|
||||
&& CardFactoryUtil.doesCreatureAttackAI(c)
|
||||
&& attack > 0) {
|
||||
@@ -469,13 +469,13 @@ public class AbilityFactoryPump {
|
||||
}
|
||||
|
||||
// is the creature unblocked and the spell will pump its power?
|
||||
if (phase.is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)
|
||||
if (phase.is(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)
|
||||
&& AllZone.getCombat().isAttacking(c) && AllZone.getCombat().isUnblocked(c) && (attack > 0)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// is the creature blocked and the blocker would survive
|
||||
if (phase.is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY) && (attack > 0)
|
||||
if (phase.is(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY) && (attack > 0)
|
||||
&& AllZone.getCombat().isAttacking(c) && AllZone.getCombat().isBlocked(c)
|
||||
&& AllZone.getCombat().getBlockers(c) != null
|
||||
&& !AllZone.getCombat().getBlockers(c).isEmpty()
|
||||
@@ -485,8 +485,8 @@ public class AbilityFactoryPump {
|
||||
|
||||
// if the life of the computer is in danger, try to pump
|
||||
// potential blockers before declaring blocks
|
||||
if (phase.isAfter(Constant.Phase.COMBAT_DECLARE_ATTACKERS)
|
||||
&& phase.isBefore(Constant.Phase.COMBAT_DAMAGE)
|
||||
if (phase.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
&& phase.getPhase().isBefore(PhaseType.COMBAT_DAMAGE)
|
||||
&& phase.isPlayerTurn(AllZone.getHumanPlayer())
|
||||
&& !AllZone.getCombat().getAttackers().isEmpty()
|
||||
&& CombatUtil.canBlock(c, AllZone.getCombat())
|
||||
@@ -611,7 +611,7 @@ public class AbilityFactoryPump {
|
||||
final SpellAbilityRestriction restrict = sa.getRestrictions();
|
||||
|
||||
// Phase Restrictions
|
||||
if ((AllZone.getStack().size() == 0) && Singletons.getModel().getGameState().getPhaseHandler().isBefore(Constant.Phase.COMBAT_BEGIN)) {
|
||||
if ((AllZone.getStack().size() == 0) && Singletons.getModel().getGameState().getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_BEGIN)) {
|
||||
// Instant-speed pumps should not be cast outside of combat when the
|
||||
// stack is empty
|
||||
if (!this.abilityFactory.isCurse() && !AbilityFactory.isSorcerySpeed(sa)) {
|
||||
@@ -713,7 +713,7 @@ public class AbilityFactoryPump {
|
||||
private boolean pumpTgtAI(final SpellAbility sa, final int defense, final int attack, final boolean mandatory) {
|
||||
if (!mandatory
|
||||
&& !sa.isTrigger()
|
||||
&& Singletons.getModel().getGameState().getPhaseHandler().isAfter(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)
|
||||
&& Singletons.getModel().getGameState().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)
|
||||
&& !(this.abilityFactory.isCurse() && (defense < 0))
|
||||
&& !this.containsNonCombatKeyword(this.keywords)) {
|
||||
return false;
|
||||
@@ -746,11 +746,11 @@ public class AbilityFactoryPump {
|
||||
// If the cost is tapping, don't activate before declare
|
||||
// attack/block
|
||||
if ((sa.getPayCosts() != null) && sa.getPayCosts().getTap()) {
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().isBefore(Constant.Phase.COMBAT_DECLARE_ATTACKERS)
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
&& Singletons.getModel().getGameState().getPhaseHandler().isPlayerTurn(AllZone.getComputerPlayer())) {
|
||||
list.remove(sa.getSourceCard());
|
||||
}
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().isBefore(Constant.Phase.COMBAT_DECLARE_BLOCKERS)
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS)
|
||||
&& Singletons.getModel().getGameState().getPhaseHandler().isPlayerTurn(AllZone.getHumanPlayer())) {
|
||||
list.remove(sa.getSourceCard());
|
||||
}
|
||||
@@ -1428,7 +1428,7 @@ public class AbilityFactoryPump {
|
||||
} // end Curse
|
||||
|
||||
// don't use non curse PumpAll after Combat_Begin until AI is improved
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().isAfter(Constant.Phase.COMBAT_BEGIN)) {
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_BEGIN)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,8 +29,8 @@ import forge.CardListUtil;
|
||||
import forge.CombatUtil;
|
||||
import forge.Command;
|
||||
import forge.ComputerUtil;
|
||||
import forge.Constant;
|
||||
import forge.Constant.Zone;
|
||||
import forge.PhaseType;
|
||||
import forge.Singletons;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.cost.Cost;
|
||||
@@ -271,7 +271,7 @@ public class AbilityFactoryRegenerate {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
boolean flag = false;
|
||||
|
||||
for (final Card c : list) {
|
||||
@@ -315,7 +315,7 @@ public class AbilityFactoryRegenerate {
|
||||
chance = true;
|
||||
}
|
||||
} else {
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
final CardList combatants = targetables.getType("Creature");
|
||||
CardListUtil.sortByEvaluateCreature(combatants);
|
||||
|
||||
@@ -407,7 +407,7 @@ public class AbilityFactoryRegenerate {
|
||||
if (compTargetables.size() > 0) {
|
||||
final CardList combatants = compTargetables.getType("Creature");
|
||||
CardListUtil.sortByEvaluateCreature(combatants);
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
for (final Card c : combatants) {
|
||||
if ((c.getShield() == 0) && CombatUtil.combatantWouldBeDestroyed(c)) {
|
||||
tgt.addTarget(c);
|
||||
@@ -689,7 +689,7 @@ public class AbilityFactoryRegenerate {
|
||||
// i control
|
||||
} else {
|
||||
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
final CardList combatants = list.getType("Creature");
|
||||
|
||||
for (final Card c : combatants) {
|
||||
|
||||
@@ -35,6 +35,7 @@ import forge.ComputerUtil;
|
||||
import forge.Constant;
|
||||
import forge.Constant.Zone;
|
||||
import forge.GameActionUtil;
|
||||
import forge.PhaseType;
|
||||
import forge.Player;
|
||||
import forge.PlayerZone;
|
||||
import forge.Singletons;
|
||||
@@ -268,7 +269,7 @@ public final class AbilityFactoryReveal {
|
||||
}
|
||||
|
||||
// Don't use draw abilities before main 2 if possible
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().isBefore(Constant.Phase.MAIN2) && !params.containsKey("ActivationPhases")
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2) && !params.containsKey("ActivationPhases")
|
||||
&& !params.containsKey("DestinationZone")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ import forge.AllZoneUtil;
|
||||
import forge.Card;
|
||||
import forge.CardList;
|
||||
import forge.ComputerUtil;
|
||||
import forge.Constant;
|
||||
import forge.Constant.Zone;
|
||||
import forge.PhaseType;
|
||||
import forge.Player;
|
||||
import forge.Singletons;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
@@ -293,18 +293,19 @@ public class AbilityFactoryToken extends AbilityFactory {
|
||||
}
|
||||
|
||||
// Don't generate tokens without haste before main 2 if possible
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().isBefore(Constant.Phase.MAIN2)
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)
|
||||
&& Singletons.getModel().getGameState().getPhaseHandler().isPlayerTurn(AllZone.getComputerPlayer()) && !haste
|
||||
&& !mapParams.containsKey("ActivationPhases")) {
|
||||
return false;
|
||||
}
|
||||
if ((Singletons.getModel().getGameState().getPhaseHandler().isPlayerTurn(AllZone.getComputerPlayer()) || Singletons.getModel().getGameState().getPhaseHandler().isBefore(
|
||||
Constant.Phase.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY))
|
||||
if ((Singletons.getModel().getGameState().getPhaseHandler().isPlayerTurn(AllZone.getComputerPlayer())
|
||||
|| Singletons.getModel().getGameState().getPhaseHandler().getPhase().isBefore(
|
||||
PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY))
|
||||
&& !mapParams.containsKey("ActivationPhases") && !AbilityFactory.isSorcerySpeed(sa)
|
||||
&& !haste) {
|
||||
return false;
|
||||
}
|
||||
if ((Singletons.getModel().getGameState().getPhaseHandler().isAfter(Constant.Phase.COMBAT_BEGIN) || Singletons.getModel().getGameState().getPhaseHandler().isPlayerTurn(
|
||||
if ((Singletons.getModel().getGameState().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_BEGIN) || Singletons.getModel().getGameState().getPhaseHandler().isPlayerTurn(
|
||||
AllZone.getHumanPlayer()))
|
||||
&& oneShot) {
|
||||
return false;
|
||||
@@ -359,7 +360,7 @@ public class AbilityFactoryToken extends AbilityFactory {
|
||||
return chance;
|
||||
}
|
||||
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().is(Constant.Phase.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)) {
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)) {
|
||||
return ((r.nextFloat() < .95) && chance);
|
||||
}
|
||||
if (sa.isAbility()) {
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.HashMap;
|
||||
import forge.AllZone;
|
||||
import forge.Card;
|
||||
import forge.ComputerUtil;
|
||||
import forge.Constant;
|
||||
import forge.PhaseType;
|
||||
import forge.Player;
|
||||
import forge.Singletons;
|
||||
import forge.card.spellability.AbilityActivated;
|
||||
@@ -459,7 +459,7 @@ public class AbilityFactoryTurns {
|
||||
|
||||
// 4) The current phase and/or step ends. The game skips straight to the
|
||||
// cleanup step. The cleanup step happens in its entirety.
|
||||
Singletons.getModel().getGameState().getPhaseHandler().setPhaseState(Constant.Phase.CLEANUP);
|
||||
Singletons.getModel().getGameState().getPhaseHandler().setPhaseState(PhaseType.CLEANUP);
|
||||
|
||||
// Update observers
|
||||
AllZone.getStack().updateObservers();
|
||||
|
||||
@@ -31,6 +31,7 @@ import forge.ComputerUtil;
|
||||
import forge.Constant;
|
||||
import forge.Constant.Zone;
|
||||
import forge.GameActionUtil;
|
||||
import forge.PhaseType;
|
||||
import forge.Player;
|
||||
import forge.Singletons;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
@@ -296,7 +297,7 @@ public class AbilityFactoryZoneAffecting {
|
||||
}
|
||||
|
||||
// Don't use draw abilities before main 2 if possible
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().isBefore(Constant.Phase.MAIN2) && !params.containsKey("ActivationPhases")) {
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2) && !params.containsKey("ActivationPhases")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -310,7 +311,7 @@ public class AbilityFactoryZoneAffecting {
|
||||
if (AbilityFactory.isSorcerySpeed(sa)) {
|
||||
chance = .667; // 66.7% chance for sorcery speed
|
||||
}
|
||||
if ((Singletons.getModel().getGameState().getPhaseHandler().is(Constant.Phase.END_OF_TURN) && Singletons.getModel().getGameState().getPhaseHandler().isNextTurn(
|
||||
if ((Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.END_OF_TURN) && Singletons.getModel().getGameState().getPhaseHandler().isNextTurn(
|
||||
AllZone.getComputerPlayer()))) {
|
||||
chance = .9; // 90% for end of opponents turn
|
||||
}
|
||||
@@ -801,7 +802,7 @@ public class AbilityFactoryZoneAffecting {
|
||||
final Random r = MyRandom.getRandom();
|
||||
|
||||
// Don't use draw abilities before main 2 if possible
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().isBefore(Constant.Phase.MAIN2) && !params.containsKey("ActivationPhases")) {
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2) && !params.containsKey("ActivationPhases")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -816,7 +817,7 @@ public class AbilityFactoryZoneAffecting {
|
||||
chance = .667; // 66.7% chance for sorcery speed
|
||||
}
|
||||
|
||||
if ((Singletons.getModel().getGameState().getPhaseHandler().is(Constant.Phase.END_OF_TURN) && Singletons.getModel().getGameState().getPhaseHandler().isNextTurn(
|
||||
if ((Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.END_OF_TURN) && Singletons.getModel().getGameState().getPhaseHandler().isNextTurn(
|
||||
AllZone.getComputerPlayer()))) {
|
||||
chance = .9; // 90% for end of opponents turn
|
||||
}
|
||||
@@ -1488,7 +1489,7 @@ public class AbilityFactoryZoneAffecting {
|
||||
}
|
||||
|
||||
// Don't use draw abilities before main 2 if possible
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().isBefore(Constant.Phase.MAIN2) && !params.containsKey("ActivationPhases")) {
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2) && !params.containsKey("ActivationPhases")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1503,7 +1504,7 @@ public class AbilityFactoryZoneAffecting {
|
||||
chance = .75; // 75% chance for sorcery speed
|
||||
}
|
||||
|
||||
if ((Singletons.getModel().getGameState().getPhaseHandler().is(Constant.Phase.END_OF_TURN) && Singletons.getModel().getGameState().getPhaseHandler().isNextTurn(
|
||||
if ((Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.END_OF_TURN) && Singletons.getModel().getGameState().getPhaseHandler().isNextTurn(
|
||||
AllZone.getComputerPlayer()))) {
|
||||
chance = .9; // 90% for end of opponents turn
|
||||
}
|
||||
|
||||
@@ -414,6 +414,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
|
||||
return this.blankCard;
|
||||
}
|
||||
|
||||
//System.out.println(cardName);
|
||||
return this.getCard2(cardName, owner);
|
||||
}
|
||||
|
||||
@@ -1504,12 +1505,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
|
||||
|
||||
// *************** START *********** START **************************
|
||||
else if (cardName.equals("Sylvan Library")) {
|
||||
final Trigger drawStepTrigger = forge.card.trigger.TriggerHandler.parseTrigger(
|
||||
"Mode$ Phase | Phase$ Draw | ValidPlayer$ You | OptionalDecider$ You | "
|
||||
+ "TriggerZones$ Battlefield | Secondary$ True | TriggerDescription$ At the beginning of "
|
||||
+ "your draw step, you may draw two additional cards. If you do, choose two "
|
||||
+ "cards in your hand drawn this turn. For each of those cards, "
|
||||
+ "pay 4 life or put the card on top of your library.", card, true);
|
||||
|
||||
final Ability ability = new Ability(card, "") {
|
||||
@Override
|
||||
public void resolve() {
|
||||
@@ -1557,8 +1553,13 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
|
||||
sb.append("pay 4 life or put the card on top of your library.");
|
||||
ability.setStackDescription(sb.toString());
|
||||
|
||||
final Trigger drawStepTrigger = forge.card.trigger.TriggerHandler.parseTrigger(
|
||||
"Mode$ Phase | Phase$ Draw | ValidPlayer$ You | OptionalDecider$ You | "
|
||||
+ "TriggerZones$ Battlefield | Secondary$ True | TriggerDescription$ At the beginning of "
|
||||
+ "your draw step, you may draw two additional cards. If you do, choose two "
|
||||
+ "cards in your hand drawn this turn. For each of those cards, "
|
||||
+ "pay 4 life or put the card on top of your library.", card, true);
|
||||
drawStepTrigger.setOverridingAbility(ability);
|
||||
|
||||
card.addTrigger(drawStepTrigger);
|
||||
} // *************** END ************ END **************************
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import forge.Counters;
|
||||
import forge.GameActionUtil;
|
||||
import forge.Player;
|
||||
import forge.PlayerZone;
|
||||
import forge.PhaseType;
|
||||
import forge.Singletons;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.spellability.Ability;
|
||||
@@ -108,16 +109,13 @@ class CardFactoryLands {
|
||||
final int life = card.getController().getLife();
|
||||
if (2 < life) {
|
||||
|
||||
final StringBuilder question = new StringBuilder();
|
||||
question.append("Pay 2 life? If you don't, ").append(card.getName());
|
||||
question.append(" enters the battlefield tapped.");
|
||||
final String question = String.format("Pay 2 life? If you don't, %s enters the battlefield tapped.", card.getName());
|
||||
|
||||
if (GameActionUtil.showYesNoDialog(card, question.toString())) {
|
||||
AllZone.getHumanPlayer().loseLife(2, card);
|
||||
} else {
|
||||
this.tapCard();
|
||||
}
|
||||
|
||||
} // if
|
||||
else {
|
||||
this.tapCard();
|
||||
@@ -153,7 +151,7 @@ class CardFactoryLands {
|
||||
|
||||
@Override
|
||||
public boolean canPlayAI() {
|
||||
if (!(Singletons.getModel().getGameState().getPhaseHandler().getPhase().equals(Constant.Phase.MAIN1) && Singletons.getModel().getGameState().getPhaseHandler()
|
||||
if (!(Singletons.getModel().getGameState().getPhaseHandler().getPhase().equals(PhaseType.MAIN1) && Singletons.getModel().getGameState().getPhaseHandler()
|
||||
.getPlayerTurn().isComputer())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ import forge.Command;
|
||||
import forge.CommandArgs;
|
||||
import forge.ComputerUtil;
|
||||
import forge.Constant;
|
||||
import forge.PhaseType;
|
||||
import forge.Constant.Zone;
|
||||
import forge.Counters;
|
||||
import forge.GameActionUtil;
|
||||
@@ -899,7 +900,7 @@ public class CardFactoryUtil {
|
||||
|
||||
@Override
|
||||
public boolean canPlayAI() {
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().isAfter(Constant.Phase.MAIN1)
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().getPhase().isAfter(PhaseType.MAIN1)
|
||||
|| Singletons.getModel().getGameState().getPhaseHandler().isPlayerTurn(AllZone.getHumanPlayer())) {
|
||||
return false;
|
||||
}
|
||||
@@ -1033,7 +1034,7 @@ public class CardFactoryUtil {
|
||||
@Override
|
||||
public boolean canPlayAI() {
|
||||
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().isBefore(Constant.Phase.MAIN2)) {
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1361,7 +1362,7 @@ public class CardFactoryUtil {
|
||||
public boolean addCard(final Card c) {
|
||||
return c.isCreature()
|
||||
&& (CombatUtil.canAttack(c) || (CombatUtil.canAttackNextTurn(c)
|
||||
&& Singletons.getModel().getGameState().getPhaseHandler().is(Constant.Phase.MAIN2)))
|
||||
&& Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.MAIN2)))
|
||||
&& (((c.getNetDefense() + tough) > 0) || sourceCard.getName().equals("Skullclamp"));
|
||||
}
|
||||
});
|
||||
@@ -3113,8 +3114,8 @@ public class CardFactoryUtil {
|
||||
|
||||
// Count$IfMainPhase.<numMain>.<numNotMain> // 7/10
|
||||
if (sq[0].contains("IfMainPhase")) {
|
||||
final String cPhase = Singletons.getModel().getGameState().getPhaseHandler().getPhase();
|
||||
if ((cPhase.equals(Constant.Phase.MAIN1) || cPhase.equals(Constant.Phase.MAIN2))
|
||||
final PhaseType cPhase = Singletons.getModel().getGameState().getPhaseHandler().getPhase();
|
||||
if ((cPhase.equals(PhaseType.MAIN1) || cPhase.equals(PhaseType.MAIN2))
|
||||
&& Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn().equals(cardController)) {
|
||||
return CardFactoryUtil.doXMath(Integer.parseInt(sq[1]), m, c);
|
||||
} else {
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.HashMap;
|
||||
|
||||
import forge.AllZoneUtil;
|
||||
import forge.CardList;
|
||||
import forge.PhaseType;
|
||||
import forge.Constant.Zone;
|
||||
import forge.PhaseHandler;
|
||||
import forge.Player;
|
||||
@@ -93,19 +94,7 @@ public class SpellAbilityCondition extends SpellAbilityVariables {
|
||||
}
|
||||
|
||||
if (params.containsKey("ConditionPhases")) {
|
||||
String phases = params.get("ConditionPhases");
|
||||
|
||||
if (phases.contains("->")) {
|
||||
// If phases lists a Range, split and Build Activate String
|
||||
// Combat_Begin->Combat_End (During Combat)
|
||||
// Draw-> (After Upkeep)
|
||||
// Upkeep->Combat_Begin (Before Declare Attackers)
|
||||
|
||||
final String[] split = phases.split("->", 2);
|
||||
phases = Singletons.getModel().getGameState().getPhaseHandler().buildActivateString(split[0], split[1]);
|
||||
}
|
||||
|
||||
this.setPhases(phases);
|
||||
this.setPhases(PhaseType.parseRange(params.get("ConditionPhases")));
|
||||
}
|
||||
|
||||
if (params.containsKey("ConditionAllM12Empires")) {
|
||||
@@ -210,8 +199,8 @@ public class SpellAbilityCondition extends SpellAbilityVariables {
|
||||
|
||||
if (this.getPhases().size() > 0) {
|
||||
boolean isPhase = false;
|
||||
final String currPhase = Singletons.getModel().getGameState().getPhaseHandler().getPhase();
|
||||
for (final String s : this.getPhases()) {
|
||||
final PhaseType currPhase = Singletons.getModel().getGameState().getPhaseHandler().getPhase();
|
||||
for (final PhaseType s : this.getPhases()) {
|
||||
if (s.equals(currPhase)) {
|
||||
isPhase = true;
|
||||
break;
|
||||
|
||||
@@ -19,11 +19,11 @@ package forge.card.spellability;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import forge.AllZone;
|
||||
import forge.AllZoneUtil;
|
||||
import forge.Card;
|
||||
import forge.CardList;
|
||||
import forge.PhaseType;
|
||||
import forge.Constant.Zone;
|
||||
import forge.PhaseHandler;
|
||||
import forge.Player;
|
||||
@@ -126,19 +126,7 @@ public class SpellAbilityRestriction extends SpellAbilityVariables {
|
||||
}
|
||||
|
||||
if (params.containsKey("ActivationPhases")) {
|
||||
String phases = params.get("ActivationPhases");
|
||||
|
||||
if (phases.contains("->")) {
|
||||
// If phases lists a Range, split and Build Activate String
|
||||
// Combat_Begin->Combat_End (During Combat)
|
||||
// Draw-> (After Upkeep)
|
||||
// Upkeep->Combat_Begin (Before Declare Attackers)
|
||||
|
||||
final String[] split = phases.split("->", 2);
|
||||
phases = Singletons.getModel().getGameState().getPhaseHandler().buildActivateString(split[0], split[1]);
|
||||
}
|
||||
|
||||
this.setPhases(phases);
|
||||
this.setPhases(PhaseType.parseRange(params.get("ActivationPhases")) );
|
||||
}
|
||||
|
||||
if (params.containsKey("ActivationCardsInHand")) {
|
||||
@@ -233,8 +221,8 @@ public class SpellAbilityRestriction extends SpellAbilityVariables {
|
||||
|
||||
if (this.getPhases().size() > 0) {
|
||||
boolean isPhase = false;
|
||||
final String currPhase = Singletons.getModel().getGameState().getPhaseHandler().getPhase();
|
||||
for (final String s : this.getPhases()) {
|
||||
final PhaseType currPhase = Singletons.getModel().getGameState().getPhaseHandler().getPhase();
|
||||
for (final PhaseType s : this.getPhases()) {
|
||||
if (s.equals(currPhase)) {
|
||||
isPhase = true;
|
||||
break;
|
||||
|
||||
@@ -18,8 +18,10 @@
|
||||
package forge.card.spellability;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import forge.Constant;
|
||||
import forge.PhaseType;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -52,7 +54,7 @@ public class SpellAbilityVariables {
|
||||
*/
|
||||
public void setVariables(SpellAbilityVariables sav) {
|
||||
this.zone = sav.getZone();
|
||||
this.phases = new ArrayList<String>(sav.getPhases());
|
||||
this.phases = new ArrayList<PhaseType>(sav.getPhases());
|
||||
this.sorcerySpeed = sav.isSorcerySpeed();
|
||||
this.instantSpeed = sav.isInstantSpeed();
|
||||
this.anyPlayer = sav.isAnyPlayer();
|
||||
@@ -86,7 +88,7 @@ public class SpellAbilityVariables {
|
||||
private Constant.Zone zone = Constant.Zone.Battlefield;
|
||||
|
||||
/** The phases. */
|
||||
private ArrayList<String> phases = new ArrayList<String>();
|
||||
private List<PhaseType> phases = new ArrayList<PhaseType>();
|
||||
|
||||
/** The b sorcery speed. */
|
||||
private boolean sorcerySpeed = false;
|
||||
@@ -435,10 +437,8 @@ public class SpellAbilityVariables {
|
||||
* @param phasesString
|
||||
* a {@link java.lang.String} object.
|
||||
*/
|
||||
public final void setPhases(final String phasesString) {
|
||||
for (final String s : phasesString.split(",")) {
|
||||
this.phases.add(s);
|
||||
}
|
||||
public final void setPhases(final List<PhaseType> phases) {
|
||||
this.phases.addAll(phases);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -745,19 +745,10 @@ public class SpellAbilityVariables {
|
||||
*
|
||||
* @return the phases
|
||||
*/
|
||||
public final ArrayList<String> getPhases() {
|
||||
public final List<PhaseType> getPhases() {
|
||||
return this.phases;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the phases.
|
||||
*
|
||||
* @param phases0
|
||||
* the new phases
|
||||
*/
|
||||
public final void setPhases(final ArrayList<String> phases0) {
|
||||
this.phases = phases0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the present defined.
|
||||
|
||||
@@ -31,6 +31,7 @@ import forge.ComputerAIGeneral;
|
||||
import forge.ComputerUtil;
|
||||
import forge.Constant;
|
||||
import forge.Constant.Zone;
|
||||
import forge.PhaseType;
|
||||
import forge.Player;
|
||||
import forge.Singletons;
|
||||
import forge.card.abilityfactory.AbilityFactory;
|
||||
@@ -277,7 +278,7 @@ public class SpellPermanent extends Spell {
|
||||
card.setSVar("PayX", Integer.toString(xPay));
|
||||
}
|
||||
// Wait for Main2 if possible
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().is(Constant.Phase.MAIN1)) {
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.MAIN1)) {
|
||||
boolean wait = true;
|
||||
if (card.getSVar("PlayMain1").equals("TRUE")) {
|
||||
wait = false;
|
||||
@@ -335,14 +336,14 @@ public class SpellPermanent extends Spell {
|
||||
// save cards with flash for surprise blocking
|
||||
if (card.hasKeyword("Flash")
|
||||
&& !ComputerAIGeneral.hasETBTrigger(card)
|
||||
&& (Singletons.getModel().getGameState().getPhaseHandler().isPlayerTurn(AllZone.getComputerPlayer()) || Singletons.getModel().getGameState().getPhaseHandler()
|
||||
.isBefore(Constant.Phase.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY))) {
|
||||
&& (Singletons.getModel().getGameState().getPhaseHandler().isPlayerTurn(AllZone.getComputerPlayer())
|
||||
|| Singletons.getModel().getGameState().getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY))) {
|
||||
return false;
|
||||
}
|
||||
// Prevent the computer from summoning Ball Lightning type creatures after attacking
|
||||
if (card.hasKeyword("At the beginning of the end step, sacrifice CARDNAME.")
|
||||
&& (Singletons.getModel().getGameState().getPhaseHandler().isPlayerTurn(AllZone.getHumanPlayer()) || Singletons.getModel().getGameState().getPhaseHandler()
|
||||
.isAfter(Constant.Phase.COMBAT_DECLARE_ATTACKERS))) {
|
||||
&& (Singletons.getModel().getGameState().getPhaseHandler().isPlayerTurn(AllZone.getHumanPlayer())
|
||||
|| Singletons.getModel().getGameState().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,11 +18,13 @@
|
||||
package forge.card.staticability;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import forge.AllZone;
|
||||
import forge.AllZoneUtil;
|
||||
import forge.Card;
|
||||
import forge.PhaseType;
|
||||
import forge.Constant.Zone;
|
||||
import forge.GameEntity;
|
||||
import forge.Player;
|
||||
@@ -422,18 +424,7 @@ public class StaticAbility {
|
||||
}
|
||||
|
||||
if (this.mapParams.containsKey("Phases")) {
|
||||
String phases = this.mapParams.get("Phases");
|
||||
|
||||
if (phases.contains("->")) {
|
||||
// If phases lists a Range, split and Build Activate String
|
||||
// Combat_Begin->Combat_End (During Combat)
|
||||
// Draw-> (After Upkeep)
|
||||
// Upkeep->Combat_Begin (Before Declare Attackers)
|
||||
|
||||
final String[] split = phases.split("->", 2);
|
||||
phases = Singletons.getModel().getGameState().getPhaseHandler().buildActivateString(split[0], split[1]);
|
||||
}
|
||||
|
||||
List<PhaseType> phases = PhaseType.parseRange(this.mapParams.get("Phases"));
|
||||
if (!phases.contains(Singletons.getModel().getGameState().getPhaseHandler().getPhase())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -17,16 +17,16 @@
|
||||
*/
|
||||
package forge.card.trigger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import forge.AllZone;
|
||||
import forge.AllZoneUtil;
|
||||
import forge.Card;
|
||||
import forge.CardList;
|
||||
import forge.CardUtil;
|
||||
import forge.PhaseType;
|
||||
import forge.Constant.Zone;
|
||||
import forge.PlayerZone;
|
||||
import forge.Singletons;
|
||||
@@ -186,6 +186,8 @@ public abstract class Trigger extends TriggerReplacementBase {
|
||||
/** The is intrinsic. */
|
||||
private boolean isIntrinsic;
|
||||
|
||||
private List<PhaseType> validPhases;
|
||||
|
||||
/**
|
||||
* Gets the checks if is intrinsic.
|
||||
*
|
||||
@@ -275,22 +277,11 @@ public abstract class Trigger extends TriggerReplacementBase {
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean zonesCheck() {
|
||||
if (this.getMapParams().containsKey("TriggerZones")) {
|
||||
final List<Zone> triggerZones = new ArrayList<Zone>();
|
||||
final PlayerZone zone = AllZone.getZoneOf(this.getHostCard());
|
||||
for (final String s : this.getMapParams().get("TriggerZones").split(",")) {
|
||||
triggerZones.add(Zone.smartValueOf(s));
|
||||
}
|
||||
if (zone == null) {
|
||||
return false;
|
||||
}
|
||||
if (!triggerZones.contains(zone.getZoneType()) || this.getHostCard().isPhasedOut()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
public final boolean zonesCheck(PlayerZone hostCardZone) {
|
||||
return !this.getHostCard().isPhasedOut() &&
|
||||
( validHostZones == null || validHostZones.isEmpty() ||
|
||||
( hostCardZone != null && validHostZones.contains(hostCardZone.getZoneType()))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -301,23 +292,8 @@ public abstract class Trigger extends TriggerReplacementBase {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean phasesCheck() {
|
||||
if (this.getMapParams().containsKey("TriggerPhases")) {
|
||||
String phases = this.getMapParams().get("TriggerPhases");
|
||||
|
||||
if (phases.contains("->")) {
|
||||
// If phases lists a Range, split and Build Activate String
|
||||
// Combat_Begin->Combat_End (During Combat)
|
||||
// Draw-> (After Upkeep)
|
||||
// Upkeep->Combat_Begin (Before Declare Attackers)
|
||||
|
||||
final String[] split = phases.split("->", 2);
|
||||
phases = Singletons.getModel().getGameState().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(Singletons.getModel().getGameState().getPhaseHandler().getPhase())) {
|
||||
if ( null != validPhases ) {
|
||||
if (!validPhases.contains(Singletons.getModel().getGameState().getPhaseHandler().getPhase())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -603,6 +579,7 @@ public abstract class Trigger extends TriggerReplacementBase {
|
||||
|
||||
/** The temporary. */
|
||||
private boolean temporary = false;
|
||||
private EnumSet<Zone> validHostZones;
|
||||
|
||||
/**
|
||||
* Sets the temporary.
|
||||
@@ -724,13 +701,20 @@ public abstract class Trigger extends TriggerReplacementBase {
|
||||
copy.setName(this.getName());
|
||||
copy.setID(this.getId());
|
||||
copy.setMode(this.getMode());
|
||||
copy.setTriggerPhases(this.validPhases);
|
||||
copy.setTriggerZone(validHostZones);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this method.
|
||||
* @return
|
||||
*/
|
||||
public boolean isStatic() {
|
||||
return getMapParams().containsKey("Static"); // && params.get("Static").equals("True") [always true if present]
|
||||
}
|
||||
|
||||
|
||||
public void setTriggerZone(EnumSet<Zone> zones) {
|
||||
validHostZones = zones;
|
||||
}
|
||||
|
||||
public void setTriggerPhases(List<PhaseType> phases) {
|
||||
validPhases = phases;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package forge.card.trigger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import forge.AllZone;
|
||||
@@ -28,6 +29,7 @@ import forge.Command;
|
||||
import forge.CommandArgs;
|
||||
import forge.ComputerUtil;
|
||||
import forge.Constant;
|
||||
import forge.PhaseType;
|
||||
import forge.Constant.Zone;
|
||||
import forge.GameActionUtil;
|
||||
import forge.Player;
|
||||
@@ -42,6 +44,7 @@ import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.SpellAbilityRestriction;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.control.input.Input;
|
||||
import forge.util.TextUtil;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -200,75 +203,16 @@ public class TriggerHandler {
|
||||
public static Trigger parseTrigger(final HashMap<String, String> mapParams, final Card host, final boolean intrinsic) {
|
||||
Trigger ret = null;
|
||||
|
||||
// final String mode = mapParams.get("Mode");
|
||||
final TriggerType type = TriggerType.smartValueOf(mapParams.get("Mode"));
|
||||
final TriggerType type = TriggerType.smartValueOf(mapParams.remove("Mode"));
|
||||
ret = type.createTrigger(mapParams, host, intrinsic);
|
||||
//
|
||||
// if (mode.equals("AbilityCast")) {
|
||||
// ret = new TriggerSpellAbilityCast(mapParams, host, intrinsic);
|
||||
// } else if (mode.equals("Always")) {
|
||||
// ret = new TriggerAlways(mapParams, host, intrinsic);
|
||||
// } else if (mode.equals("AttackerBlocked")) {
|
||||
// ret = new TriggerAttackerBlocked(mapParams, host, intrinsic);
|
||||
// } else if (mode.equals("AttackersDeclared")) {
|
||||
// ret = new TriggerAttackersDeclared(mapParams, host, intrinsic);
|
||||
// } else if (mode.equals("AttackerUnblocked")) {
|
||||
// ret = new TriggerAttackerUnblocked(mapParams, host, intrinsic);
|
||||
// } else if (mode.equals("Attacks")) {
|
||||
// ret = new TriggerAttacks(mapParams, host, intrinsic);
|
||||
// } else if (mode.equals("BecomesTarget")) {
|
||||
// ret = new TriggerBecomesTarget(mapParams, host, intrinsic);
|
||||
// } else if (mode.equals("Blocks")) {
|
||||
// ret = new TriggerBlocks(mapParams, host, intrinsic);
|
||||
// } else if (mode.equals("Championed")) {
|
||||
// ret = new TriggerChampioned(mapParams, host, intrinsic);
|
||||
// } else if (mode.equals("ChangesController")) {
|
||||
// ret = new TriggerChangesController(mapParams, host, intrinsic);
|
||||
// } else if (mode.equals("ChangesZone")) {
|
||||
// ret = new TriggerChangesZone(mapParams, host, intrinsic);
|
||||
// } else if (mode.equals("Clashed")) {
|
||||
// ret = new TriggerClashed(mapParams, host, intrinsic);
|
||||
// } else if (mode.equals("CounterAdded")) {
|
||||
// ret = new TriggerCounterAdded(mapParams, host, intrinsic);
|
||||
// } else if (mode.equals("CounterRemoved")) {
|
||||
// ret = new TriggerCounterRemoved(mapParams, host, intrinsic);
|
||||
// } else if (mode.equals("Cycled")) {
|
||||
// ret = new TriggerCycled(mapParams, host, intrinsic);
|
||||
// } else if (mode.equals("DamageDone")) {
|
||||
// ret = new TriggerDamageDone(mapParams, host, intrinsic);
|
||||
// } else if (mode.equals("Discarded")) {
|
||||
// ret = new TriggerDiscarded(mapParams, host, intrinsic);
|
||||
// } else if (mode.equals("Drawn")) {
|
||||
// ret = new TriggerDrawn(mapParams, host, intrinsic);
|
||||
// } else if (mode.equals("LandPlayed")) {
|
||||
// ret = new TriggerLandPlayed(mapParams, host, intrinsic);
|
||||
// } else if (mode.equals("LifeGained")) {
|
||||
// ret = new TriggerLifeGained(mapParams, host, intrinsic);
|
||||
// } else if (mode.equals("LifeLost")) {
|
||||
// ret = new TriggerLifeLost(mapParams, host, intrinsic);
|
||||
// } else if (mode.equals("Phase")) {
|
||||
// ret = new TriggerPhase(mapParams, host, intrinsic);
|
||||
// } else if (mode.equals("Sacrificed")) {
|
||||
// ret = new TriggerSacrificed(mapParams, host, intrinsic);
|
||||
// } else if (mode.equals("Shuffled")) {
|
||||
// ret = new TriggerShuffled(mapParams, host, intrinsic);
|
||||
// } else if (mode.equals("SpellAbilityCast")) {
|
||||
// ret = new TriggerSpellAbilityCast(mapParams, host, intrinsic);
|
||||
// } else if (mode.equals("SpellCast")) {
|
||||
// ret = new TriggerSpellAbilityCast(mapParams, host, intrinsic);
|
||||
// } else if (mode.equals("Taps")) {
|
||||
// ret = new TriggerTaps(mapParams, host, intrinsic);
|
||||
// } else if (mode.equals("TapsForMana")) {
|
||||
// ret = new TriggerTapsForMana(mapParams, host, intrinsic);
|
||||
// } else if (mode.equals("Transformed")) {
|
||||
// ret = new TriggerTransformed(mapParams, host, intrinsic);
|
||||
// } else if (mode.equals("TurnFaceUp")) {
|
||||
// ret = new TriggerTurnFaceUp(mapParams, host, intrinsic);
|
||||
// } else if (mode.equals("Unequip")) {
|
||||
// ret = new TriggerUnequip(mapParams, host, intrinsic);
|
||||
// } else if (mode.equals("Untaps")) {
|
||||
// ret = new TriggerUntaps(mapParams, host, intrinsic);
|
||||
// }
|
||||
|
||||
String triggerZones = mapParams.remove("TriggerZones");
|
||||
if ( null != triggerZones )
|
||||
ret.setTriggerZone(EnumSet.copyOf(Zone.listValueOf(triggerZones)));
|
||||
|
||||
String triggerPhases = mapParams.remove("TriggerPhases");
|
||||
if ( null != triggerPhases )
|
||||
ret.setTriggerPhases(PhaseType.parseRange(triggerPhases));
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -336,7 +280,9 @@ public class TriggerHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
//System.out.println("T:" + mode.toString() + " > " + TextUtil.mapToString(runParams) );
|
||||
if( 0 == 1 ) {
|
||||
System.out.println("T:" + mode.toString() + " > " + TextUtil.mapToString(runParams) );
|
||||
}
|
||||
|
||||
// This is done to allow the list of triggers to be modified while
|
||||
// triggers are running.
|
||||
@@ -414,7 +360,7 @@ public class TriggerHandler {
|
||||
* a {@link java.lang.String} object.
|
||||
* @param runParams
|
||||
* a {@link java.util.HashMap} object.
|
||||
* @return a boolean.
|
||||
* @return false if trigger is not happening.
|
||||
*/
|
||||
private boolean runSingleTrigger(final Trigger regtrig, final TriggerType mode, final Map<String, Object> runParams) {
|
||||
final Map<String, String> params = regtrig.getMapParams();
|
||||
@@ -422,7 +368,10 @@ public class TriggerHandler {
|
||||
if (regtrig.getMode() != mode) {
|
||||
return false; // Not the right mode.
|
||||
}
|
||||
if (!regtrig.zonesCheck()) {
|
||||
|
||||
// System.out.println( " " + regtrig.getMode().toString() + "@" + regtrig.getHostCard() + "> " + TextUtil.mapToString(params));
|
||||
|
||||
if (!regtrig.zonesCheck(AllZone.getZoneOf(regtrig.getHostCard()))) {
|
||||
return false; // Host card isn't where it needs to be.
|
||||
}
|
||||
if (!regtrig.phasesCheck()) {
|
||||
|
||||
@@ -29,6 +29,7 @@ import forge.Card;
|
||||
import forge.CardContainer;
|
||||
import forge.CardList;
|
||||
import forge.Constant;
|
||||
import forge.PhaseType;
|
||||
import forge.Constant.Zone;
|
||||
import forge.GuiMultipleBlockers;
|
||||
import forge.Player;
|
||||
@@ -253,62 +254,62 @@ public class ControlMatchUI implements CardContainer {
|
||||
* @param phase   {@link java.lang.String}
|
||||
* @return boolean
|
||||
*/
|
||||
public final boolean stopAtPhase(final Player turn, final String phase) {
|
||||
public final boolean stopAtPhase(final Player turn, final PhaseType phase) {
|
||||
final List<ControlField> fieldControllers = ControlMatchUI.this.getFieldControls();
|
||||
|
||||
// AI field is at index [0]
|
||||
if (turn.isComputer()) {
|
||||
if (phase.equals(Constant.Phase.UPKEEP)) {
|
||||
if (phase.equals(PhaseType.UPKEEP)) {
|
||||
return fieldControllers.get(0).getView().getLblUpkeep().getEnabled();
|
||||
} else if (phase.equals(Constant.Phase.DRAW)) {
|
||||
} else if (phase.equals(PhaseType.DRAW)) {
|
||||
return fieldControllers.get(0).getView().getLblDraw().getEnabled();
|
||||
} else if (phase.equals(Constant.Phase.MAIN1)) {
|
||||
} else if (phase.equals(PhaseType.MAIN1)) {
|
||||
return fieldControllers.get(0).getView().getLblMain1().getEnabled();
|
||||
} else if (phase.equals(Constant.Phase.COMBAT_BEGIN)) {
|
||||
} else if (phase.equals(PhaseType.COMBAT_BEGIN)) {
|
||||
return fieldControllers.get(0).getView().getLblBeginCombat().getEnabled();
|
||||
} else if (phase.equals(Constant.Phase.COMBAT_DECLARE_ATTACKERS)) {
|
||||
} else if (phase.equals(PhaseType.COMBAT_DECLARE_ATTACKERS)) {
|
||||
return fieldControllers.get(0).getView().getLblDeclareAttackers().getEnabled();
|
||||
} else if (phase.equals(Constant.Phase.COMBAT_DECLARE_BLOCKERS)) {
|
||||
} else if (phase.equals(PhaseType.COMBAT_DECLARE_BLOCKERS)) {
|
||||
return fieldControllers.get(0).getView().getLblDeclareBlockers().getEnabled();
|
||||
} else if (phase.equals(Constant.Phase.COMBAT_FIRST_STRIKE_DAMAGE)) {
|
||||
} else if (phase.equals(PhaseType.COMBAT_FIRST_STRIKE_DAMAGE)) {
|
||||
return fieldControllers.get(0).getView().getLblFirstStrike().getEnabled();
|
||||
} else if (phase.equals(Constant.Phase.COMBAT_DAMAGE)) {
|
||||
} else if (phase.equals(PhaseType.COMBAT_DAMAGE)) {
|
||||
return fieldControllers.get(0).getView().getLblCombatDamage().getEnabled();
|
||||
} else if (phase.equals(Constant.Phase.COMBAT_END)) {
|
||||
} else if (phase.equals(PhaseType.COMBAT_END)) {
|
||||
return fieldControllers.get(0).getView().getLblEndCombat().getEnabled();
|
||||
} else if (phase.equals(Constant.Phase.MAIN2)) {
|
||||
} else if (phase.equals(PhaseType.MAIN2)) {
|
||||
return fieldControllers.get(0).getView().getLblMain2().getEnabled();
|
||||
} else if (phase.equals(Constant.Phase.END_OF_TURN)) {
|
||||
} else if (phase.equals(PhaseType.END_OF_TURN)) {
|
||||
return fieldControllers.get(0).getView().getLblEndTurn().getEnabled();
|
||||
} else if (phase.equals(Constant.Phase.DRAW)) {
|
||||
} else if (phase.equals(PhaseType.DRAW)) {
|
||||
return fieldControllers.get(0).getView().getLblDraw().getEnabled();
|
||||
}
|
||||
}
|
||||
// Human field is at index [1]
|
||||
else {
|
||||
if (phase.equals(Constant.Phase.UPKEEP)) {
|
||||
if (phase.equals(PhaseType.UPKEEP)) {
|
||||
return fieldControllers.get(1).getView().getLblUpkeep().getEnabled();
|
||||
} else if (phase.equals(Constant.Phase.DRAW)) {
|
||||
} else if (phase.equals(PhaseType.DRAW)) {
|
||||
return fieldControllers.get(1).getView().getLblDraw().getEnabled();
|
||||
} else if (phase.equals(Constant.Phase.MAIN1)) {
|
||||
} else if (phase.equals(PhaseType.MAIN1)) {
|
||||
return fieldControllers.get(1).getView().getLblMain1().getEnabled();
|
||||
} else if (phase.equals(Constant.Phase.COMBAT_BEGIN)) {
|
||||
} else if (phase.equals(PhaseType.COMBAT_BEGIN)) {
|
||||
return fieldControllers.get(1).getView().getLblBeginCombat().getEnabled();
|
||||
} else if (phase.equals(Constant.Phase.COMBAT_DECLARE_ATTACKERS)) {
|
||||
} else if (phase.equals(PhaseType.COMBAT_DECLARE_ATTACKERS)) {
|
||||
return fieldControllers.get(1).getView().getLblDeclareAttackers().getEnabled();
|
||||
} else if (phase.equals(Constant.Phase.COMBAT_DECLARE_BLOCKERS)) {
|
||||
} else if (phase.equals(PhaseType.COMBAT_DECLARE_BLOCKERS)) {
|
||||
return fieldControllers.get(1).getView().getLblDeclareBlockers().getEnabled();
|
||||
} else if (phase.equals(Constant.Phase.COMBAT_FIRST_STRIKE_DAMAGE)) {
|
||||
} else if (phase.equals(PhaseType.COMBAT_FIRST_STRIKE_DAMAGE)) {
|
||||
return fieldControllers.get(1).getView().getLblFirstStrike().getEnabled();
|
||||
} else if (phase.equals(Constant.Phase.COMBAT_DAMAGE)) {
|
||||
} else if (phase.equals(PhaseType.COMBAT_DAMAGE)) {
|
||||
return fieldControllers.get(1).getView().getLblCombatDamage().getEnabled();
|
||||
} else if (phase.equals(Constant.Phase.COMBAT_END)) {
|
||||
} else if (phase.equals(PhaseType.COMBAT_END)) {
|
||||
return fieldControllers.get(1).getView().getLblEndCombat().getEnabled();
|
||||
} else if (phase.equals(Constant.Phase.MAIN2)) {
|
||||
} else if (phase.equals(PhaseType.MAIN2)) {
|
||||
return fieldControllers.get(1).getView().getLblMain2().getEnabled();
|
||||
} else if (phase.equals(Constant.Phase.END_OF_TURN)) {
|
||||
} else if (phase.equals(PhaseType.END_OF_TURN)) {
|
||||
return fieldControllers.get(1).getView().getLblEndTurn().getEnabled();
|
||||
} else if (phase.equals(Constant.Phase.DRAW)) {
|
||||
} else if (phase.equals(PhaseType.DRAW)) {
|
||||
return fieldControllers.get(1).getView().getLblDraw().getEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.LinkedList;
|
||||
import java.util.Stack;
|
||||
|
||||
import forge.ComputerAIInput;
|
||||
import forge.Constant;
|
||||
import forge.PhaseType;
|
||||
import forge.MyObservable;
|
||||
import forge.PhaseHandler;
|
||||
import forge.Player;
|
||||
@@ -168,7 +168,7 @@ public class InputControl extends MyObservable implements java.io.Serializable {
|
||||
* @return a {@link forge.control.input.Input} object.
|
||||
*/
|
||||
public final Input updateInput() {
|
||||
final String phase = this.model.getGameState().getPhaseHandler().getPhase();
|
||||
final PhaseType phase = this.model.getGameState().getPhaseHandler().getPhase();
|
||||
final Player playerTurn = this.model.getGameState().getPhaseHandler().getPlayerTurn();
|
||||
final Player priority = this.model.getGameState().getPhaseHandler().getPriorityPlayer();
|
||||
|
||||
@@ -209,13 +209,13 @@ public class InputControl extends MyObservable implements java.io.Serializable {
|
||||
}
|
||||
|
||||
// Special Inputs needed for the following phases:
|
||||
if (phase.equals(Constant.Phase.COMBAT_DECLARE_ATTACKERS)) {
|
||||
if (phase.equals(PhaseType.COMBAT_DECLARE_ATTACKERS)) {
|
||||
this.model.getGameState().getStack().freezeStack();
|
||||
|
||||
if (playerTurn.isHuman()) {
|
||||
return new InputAttack();
|
||||
}
|
||||
} else if (phase.equals(Constant.Phase.COMBAT_DECLARE_BLOCKERS)) {
|
||||
} else if (phase.equals(PhaseType.COMBAT_DECLARE_BLOCKERS)) {
|
||||
this.model.getGameState().getStack().freezeStack();
|
||||
if (playerTurn.isHuman()) {
|
||||
this.aiInput.getComputer().declareBlockers();
|
||||
@@ -229,7 +229,7 @@ public class InputControl extends MyObservable implements java.io.Serializable {
|
||||
return new InputBlock();
|
||||
}
|
||||
}
|
||||
} else if (phase.equals(Constant.Phase.CLEANUP)) {
|
||||
} else if (phase.equals(PhaseType.CLEANUP)) {
|
||||
// discard
|
||||
if (this.model.getGameState().getStack().size() == 0) {
|
||||
// resolve things
|
||||
|
||||
@@ -20,6 +20,7 @@ package forge.control.input;
|
||||
import forge.AllZone;
|
||||
import forge.ButtonUtil;
|
||||
import forge.Card;
|
||||
import forge.PhaseType;
|
||||
import forge.GuiDisplayUtil;
|
||||
import forge.Player;
|
||||
import forge.PlayerZone;
|
||||
@@ -43,7 +44,7 @@ public class InputPassPriority extends Input implements java.io.Serializable {
|
||||
GuiDisplayUtil.updateGUI();
|
||||
ButtonUtil.enableOnlyOK();
|
||||
|
||||
final String phase = Singletons.getModel().getGameState().getPhaseHandler().getPhase();
|
||||
final PhaseType phase = Singletons.getModel().getGameState().getPhaseHandler().getPhase();
|
||||
final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPriorityPlayer();
|
||||
|
||||
if (player.isComputer()) {
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
package forge;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA. User: dhudson
|
||||
*/
|
||||
@Test(groups = { "UnitTest" }, timeOut = 5000, enabled = false)
|
||||
public class PhaseHandlerTest {
|
||||
|
||||
/**
|
||||
* PhaseHandler test1.
|
||||
*/
|
||||
@Test(groups = { "UnitTest", "fast" }, timeOut = 5000, enabled = false)
|
||||
public void phaseTest1() {
|
||||
final PhaseHandler phase = new PhaseHandler();
|
||||
for (int i = 0; i < phase.getPhaseOrder().length; i++) {
|
||||
System.out.println(phase.getPlayerTurn() + " " + phase.getPhase());
|
||||
phase.nextPhase();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user