diff --git a/.gitattributes b/.gitattributes
index 3cedae507e4..ff06272d192 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -12386,7 +12386,6 @@ src/main/java/forge/Color.java svneol=native#text/plain
src/main/java/forge/ColorChanger.java -text
src/main/java/forge/Command.java svneol=native#text/plain
src/main/java/forge/CommandList.java svneol=native#text/plain
-src/main/java/forge/CommandReturn.java svneol=native#text/plain
src/main/java/forge/Constant.java svneol=native#text/plain
src/main/java/forge/Counters.java svneol=native#text/plain
src/main/java/forge/GameAction.java svneol=native#text/plain
diff --git a/src/main/java/forge/AllZone.java b/src/main/java/forge/AllZone.java
index 9a9a8a19014..af2d1330ada 100644
--- a/src/main/java/forge/AllZone.java
+++ b/src/main/java/forge/AllZone.java
@@ -19,7 +19,6 @@ package forge;
import forge.card.cardfactory.CardFactory;
import forge.card.cardfactory.CardFactoryInterface;
-import forge.control.input.InputControl;
import forge.game.limited.GauntletMini;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
@@ -54,9 +53,6 @@ public final class AllZone {
/** Global cardFactory. */
private static CardFactoryInterface cardFactory = null;
- /** Constant inputControl. */
- private static InputControl inputControl = null;
-
// initialized at Runtime since it has to be the last object constructed
// shared between Input_Attack, Input_Block, Input_CombatDamage ,
@@ -103,23 +99,6 @@ public final class AllZone {
AllZone.cardFactory = factory;
}
- /**
- *
- * getInputControl.
- *
- *
- * @return a {@link forge.control.input.InputControl} object.
- * @since 1.0.15
- */
- public static InputControl getInputControl() {
- return AllZone.inputControl;
- }
-
- /** @param i0 {@link forge.control.input.InputControl} */
- public static void setInputControl(InputControl i0) {
- AllZone.inputControl = i0;
- }
-
/**
* Create and return the next timestamp.
*
diff --git a/src/main/java/forge/Card.java b/src/main/java/forge/Card.java
index 8b7fc6c8946..051bbe80415 100644
--- a/src/main/java/forge/Card.java
+++ b/src/main/java/forge/Card.java
@@ -34,6 +34,7 @@ import java.util.TreeMap;
import com.esotericsoftware.minlog.Log;
import com.google.common.collect.Iterables;
+import forge.CardPredicates.Presets;
import forge.card.CardCharacteristics;
import forge.card.CardManaCost;
import forge.card.EditionInfo;
@@ -53,7 +54,6 @@ import forge.card.staticability.StaticAbility;
import forge.card.trigger.Trigger;
import forge.card.trigger.TriggerType;
import forge.card.trigger.ZCTrigger;
-import forge.game.GameState;
import forge.game.player.ComputerUtil;
import forge.game.player.Player;
import forge.game.zone.ZoneType;
@@ -1226,7 +1226,7 @@ public class Card extends GameEntity implements Comparable {
return false;
}
if (this.isCreature() && counterName.equals(Counters.M1M1)) {
- for (final Card c : GameState.getCreaturesInPlay(this.getController())) { // look
+ for (final Card c : this.getController().getCreaturesInPlay()) { // look
// for
// Melira,
// Sylvok
@@ -1287,7 +1287,7 @@ public class Card extends GameEntity implements Comparable {
if (!this.canHaveCountersPlacedOnIt(counterName)) {
return;
}
- final int multiplier = GameState.getCounterDoublersMagnitude(this.getController(),counterName);
+ final int multiplier = this.getController().getCounterDoublersMagnitude(counterName);
if (this.counters.containsKey(counterName)) {
final Integer aux = this.counters.get(counterName) + (multiplier * n);
this.counters.put(counterName, aux);
@@ -1335,11 +1335,11 @@ public class Card extends GameEntity implements Comparable {
if (counterName.equals(Counters.TIME) && (aux == 0)) {
final boolean hasVanish = CardFactoryUtil.hasKeyword(this, "Vanishing") != -1;
- if (hasVanish && GameState.isCardInPlay(this)) {
+ if (hasVanish && this.isInPlay()) {
Singletons.getModel().getGameAction().sacrifice(this, null);
}
- if (this.hasSuspend() && GameState.isCardExiled(this)) {
+ if (this.hasSuspend() && Singletons.getModel().getGameState().isCardExiled(this)) {
final Card c = this;
c.setSuspendCast(true);
@@ -4753,7 +4753,7 @@ public class Card extends GameEntity implements Comparable {
return 0;
}
- if (GameState.isCardInPlay("Doran, the Siege Tower")) {
+ if (Singletons.getModel().getGameState().isCardInPlay("Doran, the Siege Tower")) {
return this.getNetDefense();
}
return this.getNetAttack();
@@ -6491,7 +6491,7 @@ public class Card extends GameEntity implements Comparable {
}
} else if (property.startsWith("RememberedPlayerCtrl")) {
if (source.getRemembered().isEmpty()) {
- final Card newCard = GameState.getCardState(source);
+ final Card newCard = Singletons.getModel().getGameState().getCardState(source);
for (final Object o : newCard.getRemembered()) {
if (o instanceof Player) {
if (!this.getController().equals((Player) o)) {
@@ -6724,7 +6724,7 @@ public class Card extends GameEntity implements Comparable {
}
} else if (restriction.equals("MostProminentColor")) {
for (final String color : CardUtil.getColors(this)) {
- if (CardFactoryUtil.isMostProminentColor(GameState.getCardsIn(ZoneType.Battlefield), color)) {
+ if (CardFactoryUtil.isMostProminentColor(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), color)) {
return true;
}
}
@@ -6813,12 +6813,12 @@ public class Card extends GameEntity implements Comparable {
return false;
}
} else if (restriction.equals(ZoneType.Battlefield.toString())) {
- final List list = GameState.getCardsIn(ZoneType.Battlefield);
+ final List list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
if (list.isEmpty()) {
return false;
}
boolean shares = false;
- for (final Card card : GameState.getCardsIn(ZoneType.Battlefield)) {
+ for (final Card card : Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield)) {
if (this.getName().equals(card.getName())) {
shares = true;
}
@@ -6986,28 +6986,28 @@ public class Card extends GameEntity implements Comparable {
return false;
}
} else if (property.startsWith("greatestPower")) {
- final List list = GameState.getCreaturesInPlay();
+ final List list = CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), Presets.CREATURES);
for (final Card crd : list) {
if (crd.getNetAttack() > this.getNetAttack()) {
return false;
}
}
} else if (property.startsWith("leastPower")) {
- final List list = GameState.getCreaturesInPlay();
+ final List list = CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), Presets.CREATURES);
for (final Card crd : list) {
if (crd.getNetAttack() < this.getNetAttack()) {
return false;
}
}
} else if (property.startsWith("greatestCMC")) {
- final List list = GameState.getCreaturesInPlay();
+ final List list = CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), Presets.CREATURES);
for (final Card crd : list) {
if (crd.getCMC() > this.getCMC()) {
return false;
}
}
} else if (property.startsWith("lowestCMC")) {
- final List list = GameState.getCardsIn(ZoneType.Battlefield);
+ final List list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
for (final Card crd : list) {
if (!crd.isLand() && !crd.isImmutable() && (crd.getCMC() < this.getCMC())) {
return false;
@@ -7052,7 +7052,7 @@ public class Card extends GameEntity implements Comparable {
}
}
} else if (property.startsWith("suspended")) {
- if (!this.hasSuspend() || !GameState.isCardExiled(this)
+ if (!this.hasSuspend() || !Singletons.getModel().getGameState().isCardExiled(this)
|| !(this.getCounters(Counters.getType("TIME")) >= 1)) {
return false;
}
@@ -7273,7 +7273,7 @@ public class Card extends GameEntity implements Comparable {
return false;
}
} else if (property.startsWith("OnBattlefield")) {
- final List list = GameState.getCardsIn(ZoneType.Battlefield);
+ final List list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
if (!list.contains(this)) {
return false;
}
@@ -7952,7 +7952,7 @@ public class Card extends GameEntity implements Comparable {
map.put(source, damageToAdd);
}
- if (GameState.isCardInPlay(this)) {
+ if (this.isInPlay()) {
this.addDamage(map);
}
}
@@ -8006,7 +8006,7 @@ public class Card extends GameEntity implements Comparable {
public final int staticDamagePrevention(final int damage, final int possiblePrvenetion, final Card source,
final boolean isCombat) {
- if (GameState.isCardInPlay("Leyline of Punishment")) {
+ if (Singletons.getModel().getGameState().isCardInPlay("Leyline of Punishment")) {
return damage;
}
@@ -8035,7 +8035,7 @@ public class Card extends GameEntity implements Comparable {
@Override
public final int staticDamagePrevention(final int damageIn, final Card source, final boolean isCombat) {
- if (GameState.isCardInPlay("Leyline of Punishment")) {
+ if (Singletons.getModel().getGameState().isCardInPlay("Leyline of Punishment")) {
return damageIn;
}
@@ -8098,7 +8098,7 @@ public class Card extends GameEntity implements Comparable {
}
// Prevent Damage static abilities
- final List allp = GameState.getCardsIn(ZoneType.Battlefield);
+ final List allp = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
for (final Card ca : allp) {
final ArrayList staticAbilities = ca.getStaticAbilities();
for (final StaticAbility stAb : staticAbilities) {
@@ -8112,7 +8112,7 @@ public class Card extends GameEntity implements Comparable {
return 0;
}
- if ((source.isCreature() && GameState.isCardInPlay("Well-Laid Plans") && source.sharesColorWith(this))) {
+ if ((source.isCreature() && Singletons.getModel().getGameState().isCardInPlay("Well-Laid Plans") && source.sharesColorWith(this))) {
return 0;
}
} // Creature end
@@ -8140,7 +8140,7 @@ public class Card extends GameEntity implements Comparable {
@Override
public final int preventDamage(final int damage, final Card source, final boolean isCombat) {
- if (GameState.isCardInPlay("Leyline of Punishment")
+ if (Singletons.getModel().getGameState().isCardInPlay("Leyline of Punishment")
|| source.hasKeyword("Damage that would be dealt by CARDNAME can't be prevented.")) {
return damage;
}
@@ -8206,7 +8206,7 @@ public class Card extends GameEntity implements Comparable {
public final int staticReplaceDamage(final int damage, final Card source, final boolean isCombat) {
int restDamage = damage;
- for (Card c : GameState.getCardsIn(ZoneType.Battlefield)) {
+ for (Card c : Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield)) {
if (c.getName().equals("Sulfuric Vapors")) {
if (source.isSpell() && source.isRed()) {
restDamage += 1;
@@ -8365,12 +8365,12 @@ public class Card extends GameEntity implements Comparable {
GameActionUtil.executeDamageToCreatureEffects(source, this, damageToAdd);
- if (GameState.isCardInPlay(this) && wither) {
+ if (this.isInPlay() && wither) {
this.addCounter(Counters.M1M1, damageToAdd);
}
if (source.hasKeyword("Deathtouch") && this.isCreature()) {
Singletons.getModel().getGameAction().destroy(this);
- } else if (GameState.isCardInPlay(this) && !wither) {
+ } else if (this.isInPlay() && !wither) {
this.damage += damageToAdd;
}
return true;
@@ -8869,7 +8869,7 @@ public class Card extends GameEntity implements Comparable {
* @return boolean
*/
public boolean isInZone(final ZoneType zone) {
- return GameState.isCardInZone(this, zone);
+ return Singletons.getModel().getGameState().isCardInZone(this, zone);
}
/**
@@ -8887,7 +8887,7 @@ public class Card extends GameEntity implements Comparable {
}
// CantTarget static abilities
- final List allp = GameState.getCardsIn(ZoneType.Battlefield);
+ final List allp = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
for (final Card ca : allp) {
final ArrayList staticAbilities = ca.getStaticAbilities();
for (final StaticAbility stAb : staticAbilities) {
@@ -9078,4 +9078,11 @@ public class Card extends GameEntity implements Comparable {
this.startsGameInPlay = startsGameInPlay;
}
+ public boolean isInPlay() {
+ if (getController() == null) {
+ return false;
+ }
+ return getController().getCardsIn(ZoneType.Battlefield).contains(this);
+ }
+
} // end Card class
diff --git a/src/main/java/forge/CardUtil.java b/src/main/java/forge/CardUtil.java
index d99acd8c3a4..8bffc5d8b3c 100644
--- a/src/main/java/forge/CardUtil.java
+++ b/src/main/java/forge/CardUtil.java
@@ -38,7 +38,6 @@ import forge.card.CardManaCost;
import forge.card.EditionInfo;
import forge.card.mana.ManaCost;
import forge.control.input.InputPayManaCostUtil;
-import forge.game.GameState;
import forge.game.player.Player;
import forge.game.zone.ZoneType;
import forge.gui.GuiDisplayUtil;
@@ -212,7 +211,7 @@ public final class CardUtil {
int xPaid = 0;
// 2012-07-22 - If a card is on the stack, count the xManaCost in with it's CMC
- if (GameState.getCardsIn(ZoneType.Stack).contains(c) && c.getManaCost() != null) {
+ if (Singletons.getModel().getGameState().getCardsIn(ZoneType.Stack).contains(c) && c.getManaCost() != null) {
xPaid = c.getXManaCostPaid() * c.getManaCost().countX();
}
return c.getManaCost().getCMC() + xPaid;
@@ -829,7 +828,7 @@ public final class CardUtil {
if (strCol.equalsIgnoreCase("Colorless")) {
continue;
}
- for (final Card c : GameState.getColorInPlay(strCol)) {
+ for (final Card c : Singletons.getModel().getGameState().getColoredCardsInPlay(strCol)) {
if (!res.contains(c) && c.isValid(valid, source.getController(), source) && !c.equals(origin)) {
res.add(c);
}
diff --git a/src/main/java/forge/CommandReturn.java b/src/main/java/forge/CommandReturn.java
deleted file mode 100644
index 8da20bc2585..00000000000
--- a/src/main/java/forge/CommandReturn.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Forge: Play Magic: the Gathering.
- * Copyright (C) 2011 Forge Team
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package forge;
-
-/**
- *
- * CommandReturn interface.
- *
- *
- * @author Forge
- * @version $Id$
- */
-public interface CommandReturn {
- /**
- *
- * execute.
- *
- *
- * @return a {@link java.lang.Object} object.
- */
- Object execute();
-}
diff --git a/src/main/java/forge/GameAction.java b/src/main/java/forge/GameAction.java
index fca7140b8e3..a3a04385a2c 100644
--- a/src/main/java/forge/GameAction.java
+++ b/src/main/java/forge/GameAction.java
@@ -76,8 +76,14 @@ public class GameAction {
* resetActivationsPerTurn.
*
*/
+
+ private final GameState game;
+ public GameAction(GameState game0) {
+ game = game0;
+ }
+
public final void resetActivationsPerTurn() {
- final List all = GameState.getCardsInGame();
+ final List all = game.getCardsInGame();
// Reset Activations per Turn
for (final Card card : all) {
@@ -101,7 +107,7 @@ public class GameAction {
* @param position TODO
* @return a {@link forge.Card} object.
*/
- public static Card changeZone(final PlayerZone zoneFrom, final PlayerZone zoneTo, final Card c, Integer position) {
+ public Card changeZone(final PlayerZone zoneFrom, final PlayerZone zoneTo, final Card c, Integer position) {
if (c.isCopiedSpell()) {
if ((zoneFrom != null)) {
zoneFrom.remove(c);
@@ -177,9 +183,9 @@ public class GameAction {
repParams.put("Origin", zoneFrom != null ? zoneFrom.getZoneType() : null);
repParams.put("Destination", zoneTo.getZoneType());
- ReplacementResult repres = Singletons.getModel().getGameState().getReplacementHandler().run(repParams);
+ ReplacementResult repres = game.getReplacementHandler().run(repParams);
if (repres != ReplacementResult.NotReplaced) {
- if (Singletons.getModel().getGameState().getStack().isResolving(c) && !zoneTo.is(ZoneType.Graveyard) && repres == ReplacementResult.Prevented) {
+ if (game.getStack().isResolving(c) && !zoneTo.is(ZoneType.Graveyard) && repres == ReplacementResult.Prevented) {
return Singletons.getModel().getGameAction().moveToGraveyard(c);
}
return c;
@@ -191,7 +197,7 @@ public class GameAction {
}
if (suppress) {
- Singletons.getModel().getGameState().getTriggerHandler().suppressMode(TriggerType.ChangesZone);
+ game.getTriggerHandler().suppressMode(TriggerType.ChangesZone);
}
// "enter the battlefield as a copy" - apply code here
@@ -210,7 +216,7 @@ public class GameAction {
if (zoneFrom != null) {
if (zoneFrom.is(ZoneType.Battlefield) && c.isCreature()) {
- Singletons.getModel().getGameState().getCombat().removeFromCombat(c);
+ game.getCombat().removeFromCombat(c);
}
zoneFrom.remove(c);
}
@@ -228,11 +234,11 @@ public class GameAction {
runParams.put("Origin", null);
}
runParams.put("Destination", zoneTo.getZoneType().name());
- Singletons.getModel().getGameState().getTriggerHandler().runTrigger(TriggerType.ChangesZone, runParams);
+ game.getTriggerHandler().runTrigger(TriggerType.ChangesZone, runParams);
// AllZone.getStack().chooseOrderOfSimultaneousStackEntryAll();
if (suppress) {
- Singletons.getModel().getGameState().getTriggerHandler().clearSuppression(TriggerType.ChangesZone);
+ game.getTriggerHandler().clearSuppression(TriggerType.ChangesZone);
}
if (zoneFrom == null) {
@@ -256,7 +262,7 @@ public class GameAction {
if (copied.isEquipped()) {
final List equipments = new ArrayList(copied.getEquippedBy());
for (final Card equipment : equipments) {
- if (GameState.isCardInPlay(equipment)) {
+ if (equipment.isInPlay()) {
equipment.unEquipCard(copied);
}
}
@@ -265,7 +271,7 @@ public class GameAction {
if (copied.isEquipped()) {
final List equipments = new ArrayList(copied.getEquippedBy());
for (final Card equipment : equipments) {
- if (GameState.isCardInPlay(equipment)) {
+ if (equipment.isInPlay()) {
equipment.unEquipCard(copied);
}
}
@@ -273,7 +279,7 @@ public class GameAction {
// equipment moving off battlefield
if (copied.isEquipping()) {
final Card equippedCreature = copied.getEquipping().get(0);
- if (GameState.isCardInPlay(equippedCreature)) {
+ if (equippedCreature.isInPlay()) {
copied.unEquipCard(equippedCreature);
}
}
@@ -342,7 +348,7 @@ public class GameAction {
public final Card moveTo(final PlayerZone zoneTo, Card c, Integer position) {
// Ideally move to should never be called without a prevZone
// Remove card from Current Zone, if it has one
- final PlayerZone zoneFrom = GameState.getZoneOf(c);
+ final PlayerZone zoneFrom = game.getZoneOf(c);
// String prevName = prev != null ? prev.getZoneName() : "";
if (c.hasKeyword("If CARDNAME would leave the battlefield, exile it instead of putting it anywhere else.")
@@ -355,7 +361,7 @@ public class GameAction {
// Card lastKnownInfo = c;
- c = GameAction.changeZone(zoneFrom, zoneTo, c, position);
+ c = changeZone(zoneFrom, zoneTo, c, position);
if (zoneTo.is(ZoneType.Stack)) {
c.setCastFrom(zoneFrom.getZoneType());
@@ -390,7 +396,7 @@ public class GameAction {
final PlayerZone hand = c.getOwner().getZone(ZoneType.Hand);
final PlayerZone play = c.getController().getZone(ZoneType.Battlefield);
- c = GameAction.changeZone(hand, play, c, null);
+ c = Singletons.getModel().getGameAction().changeZone(hand, play, c, null);
return c;
}
@@ -403,7 +409,7 @@ public class GameAction {
*/
public final void controllerChangeZoneCorrection(final Card c) {
System.out.println("Correcting zone for " + c.toString());
- final PlayerZone oldBattlefield = GameState.getZoneOf(c);
+ final PlayerZone oldBattlefield = game.getZoneOf(c);
if (oldBattlefield == null || oldBattlefield.getZoneType() == ZoneType.Stack) {
return;
}
@@ -413,8 +419,8 @@ public class GameAction {
return;
}
- Singletons.getModel().getGameState().getTriggerHandler().suppressMode(TriggerType.ChangesZone);
- for (Player p: Singletons.getModel().getGameState().getPlayers()) {
+ game.getTriggerHandler().suppressMode(TriggerType.ChangesZone);
+ for (Player p: game.getPlayers()) {
((PlayerZoneBattlefield)p.getZone(ZoneType.Battlefield)).setTriggers(false);
}
@@ -426,16 +432,16 @@ public class GameAction {
if (c.hasStartOfKeyword("Echo")) {
c.addExtrinsicKeyword("(Echo unpaid)");
}
- Singletons.getModel().getGameState().getCombat().removeFromCombat(c);
+ game.getCombat().removeFromCombat(c);
c.setTurnInZone(tiz);
final HashMap runParams = new HashMap();
runParams.put("Card", c);
- Singletons.getModel().getGameState().getTriggerHandler().runTrigger(TriggerType.ChangesController, runParams);
+ game.getTriggerHandler().runTrigger(TriggerType.ChangesController, runParams);
- Singletons.getModel().getGameState().getTriggerHandler().clearSuppression(TriggerType.ChangesZone);
- for (Player p: Singletons.getModel().getGameState().getPlayers()) {
+ game.getTriggerHandler().clearSuppression(TriggerType.ChangesZone);
+ for (Player p: game.getPlayers()) {
((PlayerZoneBattlefield)p.getZone(ZoneType.Battlefield)).setTriggers(true);
}
}
@@ -450,7 +456,7 @@ public class GameAction {
* @return a {@link forge.Card} object.
*/
public final Card moveToStack(final Card c) {
- final PlayerZone stack = Singletons.getModel().getGameState().getStackZone();
+ final PlayerZone stack = game.getStackZone();
return this.moveTo(stack, c);
}
@@ -464,7 +470,7 @@ public class GameAction {
* @return a {@link forge.Card} object.
*/
public final Card moveToGraveyard(Card c) {
- final PlayerZone origZone = GameState.getZoneOf(c);
+ final PlayerZone origZone = game.getZoneOf(c);
final Player owner = c.getOwner();
final PlayerZone grave = owner.getZone(ZoneType.Graveyard);
final PlayerZone exile = owner.getZone(ZoneType.Exile);
@@ -561,7 +567,7 @@ public class GameAction {
};
recoverAbility.setStackDescription(sb.toString());
- Singletons.getModel().getGameState().getStack().addSimultaneousStackEntry(recoverAbility);
+ game.getStack().addSimultaneousStackEntry(recoverAbility);
}
}
}
@@ -651,7 +657,7 @@ public class GameAction {
* @return a {@link forge.Card} object.
*/
public final Card moveToLibrary(Card c, int libPosition) {
- final PlayerZone p = GameState.getZoneOf(c);
+ final PlayerZone p = game.getZoneOf(c);
final PlayerZone library = c.getOwner().getZone(ZoneType.Library);
if (c.hasKeyword("If CARDNAME would leave the battlefield, exile it instead of putting it anywhere else.")) {
@@ -695,7 +701,7 @@ public class GameAction {
runParams.put("Origin", null);
}
runParams.put("Destination", ZoneType.Library.name());
- Singletons.getModel().getGameState().getTriggerHandler().runTrigger(TriggerType.ChangesZone, runParams);
+ game.getTriggerHandler().runTrigger(TriggerType.ChangesZone, runParams);
if (p != null) {
Player owner = p.getPlayer();
@@ -723,7 +729,7 @@ public class GameAction {
* @return a {@link forge.Card} object.
*/
public final Card exile(final Card c) {
- if (GameState.isCardExiled(c)) {
+ if (game.isCardExiled(c)) {
return c;
}
@@ -824,7 +830,7 @@ public class GameAction {
activate.setActivatingPlayer(card.getOwner());
activate.setTrigger(true);
- Singletons.getModel().getGameState().getStack().add(activate);
+ game.getStack().add(activate);
}
/**
@@ -888,7 +894,7 @@ public class GameAction {
activate.setStackDescription(sbAct.toString());
activate.setActivatingPlayer(card.getOwner());
- Singletons.getModel().getGameState().getStack().add(activate);
+ game.getStack().add(activate);
}
/**
@@ -940,10 +946,10 @@ public class GameAction {
/** */
public final void checkStaticAbilities() {
// remove old effects
- Singletons.getModel().getGameState().getStaticEffects().clearStaticEffects();
+ game.getStaticEffects().clearStaticEffects();
// search for cards with static abilities
- final List allCards = GameState.getCardsInGame();
+ final List allCards = game.getCardsInGame();
final ArrayList staticAbilities = new ArrayList();
for (final Card card : allCards) {
for (StaticAbility sa : card.getStaticAbilities()) {
@@ -977,7 +983,7 @@ public class GameAction {
}
// card state effects like Glorious Anthem
- for (final String effect : Singletons.getModel().getGameState().getStaticEffects().getStateBasedMap().keySet()) {
+ for (final String effect : game.getStaticEffects().getStateBasedMap().keySet()) {
final Command com = GameActionUtil.getCommands().get(effect);
com.execute();
}
@@ -994,12 +1000,12 @@ public class GameAction {
// sol(10/29) added for Phase updates, state effects shouldn't be
// checked during Spell Resolution (except when persist-returning
- if (Singletons.getModel().getGameState().getStack().getResolving()) {
+ if (game.getStack().isResolving()) {
return;
}
- final boolean refreeze = Singletons.getModel().getGameState().getStack().isFrozen();
- Singletons.getModel().getGameState().getStack().setFrozen(true);
+ final boolean refreeze = game.getStack().isFrozen();
+ game.getStack().setFrozen(true);
final JFrame frame = Singletons.getView().getFrame();
if (!frame.isDisplayable()) {
@@ -1012,7 +1018,7 @@ public class GameAction {
new ViewWinLose(match);
match.getCurrentGame().getStack().clearSimultaneousStack();
if (!refreeze) {
- Singletons.getModel().getGameState().getStack().unfreezeStack();
+ game.getStack().unfreezeStack();
}
return;
}
@@ -1026,14 +1032,14 @@ public class GameAction {
this.checkStaticAbilities();
final HashMap runParams = new HashMap();
- Singletons.getModel().getGameState().getTriggerHandler().runTrigger(TriggerType.Always, runParams);
+ game.getTriggerHandler().runTrigger(TriggerType.Always, runParams);
- for (Card c : GameState.getCardsIn(ZoneType.Battlefield)) {
+ for (Card c : game.getCardsIn(ZoneType.Battlefield)) {
if (c.isEquipped()) {
final List equipments = new ArrayList(c.getEquippedBy());
for (final Card equipment : equipments) {
- if (!GameState.isCardInPlay(equipment)) {
+ if (!equipment.isInPlay()) {
equipment.unEquipCard(c);
checkAgain = true;
}
@@ -1042,7 +1048,7 @@ public class GameAction {
if (c.isEquipping()) {
final Card equippedCreature = c.getEquipping().get(0);
- if (!equippedCreature.isCreature() || !GameState.isCardInPlay(equippedCreature)) {
+ if (!equippedCreature.isCreature() || !equippedCreature.isInPlay()) {
c.unEquipCard(equippedCreature);
checkAgain = true;
}
@@ -1066,7 +1072,7 @@ public class GameAction {
if (entity instanceof Card) {
final Card perm = (Card) entity;
- if (!GameState.isCardInPlay(perm) || !perm.canBeEnchantedBy(c)) {
+ if (!perm.isInPlay() || !perm.canBeEnchantedBy(c)) {
c.unEnchantEntity(perm);
this.moveToGraveyard(c);
checkAgain = true;
@@ -1089,7 +1095,7 @@ public class GameAction {
}
}
- if (GameState.isCardInPlay(c) && !c.isEnchanting()) {
+ if (c.isInPlay() && !c.isEnchanting()) {
this.moveToGraveyard(c);
checkAgain = true;
}
@@ -1105,13 +1111,13 @@ public class GameAction {
this.destroy(c);
// this is untested with instants and abilities but
// required for First Strike combat phase
- Singletons.getModel().getGameState().getCombat().removeFromCombat(c);
+ game.getCombat().removeFromCombat(c);
checkAgain = true;
} else if (c.getNetDefense() <= 0) {
// TODO This shouldn't be a destroy, and should happen
// before the damage check probably
this.destroy(c);
- Singletons.getModel().getGameState().getCombat().removeFromCombat(c);
+ game.getCombat().removeFromCombat(c);
checkAgain = true;
}
// Soulbond unpairing
@@ -1192,7 +1198,7 @@ public class GameAction {
this.destroyPlaneswalkers();
if (!refreeze) {
- Singletons.getModel().getGameState().getStack().unfreezeStack();
+ game.getStack().unfreezeStack();
}
} // checkStateEffects()
@@ -1203,7 +1209,7 @@ public class GameAction {
*/
private void destroyPlaneswalkers() {
// get all Planeswalkers
- final List list = CardLists.filter(GameState.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.PLANEWALKERS);
+ final List list = CardLists.filter(game.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.PLANEWALKERS);
Card c;
for (int i = 0; i < list.size(); i++) {
@@ -1236,13 +1242,13 @@ public class GameAction {
*
*/
private void destroyLegendaryCreatures() {
- final List a = CardLists.getType(GameState.getCardsIn(ZoneType.Battlefield), "Legendary");
- if (a.isEmpty() || GameState.isCardInPlay("Mirror Gallery")) {
+ final List a = CardLists.getType(game.getCardsIn(ZoneType.Battlefield), "Legendary");
+ if (a.isEmpty() || game.isCardInPlay("Mirror Gallery")) {
return;
}
while (!a.isEmpty()) {
- List b = GameState.getCardsIn(ZoneType.Battlefield, a.get(0).getName());
+ List b = CardLists.filter(game.getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals(a.get(0).getName()));
b = CardLists.getType(b, "Legendary");
b = CardLists.filter(b, new Predicate() {
@Override
@@ -1285,7 +1291,7 @@ public class GameAction {
// Run triggers
final HashMap runParams = new HashMap();
runParams.put("Card", c);
- Singletons.getModel().getGameState().getTriggerHandler().runTrigger(TriggerType.Sacrificed, runParams);
+ game.getTriggerHandler().runTrigger(TriggerType.Sacrificed, runParams);
return true;
}
@@ -1300,7 +1306,7 @@ public class GameAction {
* @return a boolean.
*/
public final boolean destroyNoRegeneration(final Card c) {
- if (!GameState.isCardInPlay(c) || c.hasKeyword("Indestructible")) {
+ if (!c.isInPlay() || c.hasKeyword("Indestructible")) {
return false;
}
@@ -1340,7 +1346,7 @@ public class GameAction {
sb.append(crd).append(" - Totem armor: destroy this aura.");
ability.setStackDescription(sb.toString());
- Singletons.getModel().getGameState().getStack().add(ability);
+ game.getStack().add(ability);
return false;
}
} // totem armor
@@ -1365,7 +1371,7 @@ public class GameAction {
@Override
public void execute() {
- if (GameState.isCardInPlay(c) && c.isCreature()) {
+ if (c.isInPlay() && c.isCreature()) {
c.addExtrinsicKeyword("Haste");
}
} // execute()
@@ -1400,7 +1406,7 @@ public class GameAction {
* @return a boolean.
*/
public final boolean sacrificeDestroy(final Card c) {
- if (!GameState.isCardInPlay(c)) {
+ if (!c.isInPlay()) {
return false;
}
@@ -1433,7 +1439,7 @@ public class GameAction {
@Override
public void resolve() {
- if (GameState.getZoneOf(persistCard).is(ZoneType.Graveyard)) {
+ if (game.getZoneOf(persistCard).is(ZoneType.Graveyard)) {
final PlayerZone ownerPlay = persistCard.getOwner().getZone(ZoneType.Battlefield);
final Card card = GameAction.this.moveTo(ownerPlay, persistCard);
card.addCounter(Counters.M1M1, 1);
@@ -1444,7 +1450,7 @@ public class GameAction {
persistAb.setDescription(newCard.getName() + " - Returning from Persist");
persistAb.setActivatingPlayer(c.getController());
- Singletons.getModel().getGameState().getStack().addSimultaneousStackEntry(persistAb);
+ game.getStack().addSimultaneousStackEntry(persistAb);
}
if (undying) {
@@ -1453,7 +1459,7 @@ public class GameAction {
@Override
public void resolve() {
- if (GameState.getZoneOf(undyingCard).is(ZoneType.Graveyard)) {
+ if (game.getZoneOf(undyingCard).is(ZoneType.Graveyard)) {
final PlayerZone ownerPlay = undyingCard.getOwner().getZone(ZoneType.Battlefield);
final Card card = GameAction.this.moveTo(ownerPlay, undyingCard);
card.addCounter(Counters.P1P1, 1);
@@ -1464,7 +1470,7 @@ public class GameAction {
undyingAb.setDescription(newCard.getName() + " - Returning from Undying");
undyingAb.setActivatingPlayer(c.getController());
- Singletons.getModel().getGameState().getStack().addSimultaneousStackEntry(undyingAb);
+ game.getStack().addSimultaneousStackEntry(undyingAb);
}
return true;
} // sacrificeDestroy()
@@ -1479,7 +1485,7 @@ public class GameAction {
* @return a boolean.
*/
public final boolean destroy(final Card c) {
- if (!GameState.isCardInPlay(c)
+ if (!c.isInPlay()
|| (c.hasKeyword("Indestructible") && (!c.isCreature() || (c.getNetDefense() > 0)))) {
return false;
}
@@ -1489,7 +1495,7 @@ public class GameAction {
c.setDamage(0);
c.tap();
c.addRegeneratedThisTurn();
- Singletons.getModel().getGameState().getCombat().removeFromCombat(c);
+ game.getCombat().removeFromCombat(c);
return false;
}
@@ -1541,7 +1547,7 @@ public class GameAction {
final ArrayList abilities = c.getSpellAbilities();
final ArrayList choices = new ArrayList();
final Player human = Singletons.getControl().getPlayer();
- final PlayerZone zone = GameState.getZoneOf(c);
+ final PlayerZone zone = game.getZoneOf(c);
if (c.isLand() && human.canPlayLand()) {
if (zone.is(ZoneType.Hand) || ((!zone.is(ZoneType.Battlefield)) && c.hasStartOfKeyword("May be played"))) {
@@ -1647,11 +1653,10 @@ public class GameAction {
}
boolean x = sa.getSourceCard().getManaCost().getShardCount(ManaCostShard.X) > 0;
- Singletons.getModel().getGameState().getStack().add(sa, x);
+ game.getStack().add(sa, x);
} else {
sa.setManaCost("0"); // Beached As
- sa.getBeforePayMana().setFree(true);
- AllZone.getInputControl().setInput(sa.getBeforePayMana());
+ Singletons.getModel().getMatch().getInput().setInput(sa.getBeforePayMana());
}
}
@@ -1682,7 +1687,7 @@ public class GameAction {
originalCard.setXManaCostPaid(0);
}
- if (Singletons.getModel().getGameState() != null || sa.isTrigger()) {
+ if (game != null || sa.isTrigger()) {
return manaCost;
}
@@ -1835,11 +1840,11 @@ public class GameAction {
// AND that you can't use mana tapabilities of convoked
// creatures
// to pay the convoked cost.
- Singletons.getModel().getGameState().getTriggerHandler().suppressMode(TriggerType.Taps);
+ game.getTriggerHandler().suppressMode(TriggerType.Taps);
for (final Card c : sa.getTappedForConvoke()) {
c.tap();
}
- Singletons.getModel().getGameState().getTriggerHandler().clearSuppression(TriggerType.Taps);
+ game.getTriggerHandler().clearSuppression(TriggerType.Taps);
manaCost = newCost;
}
@@ -1848,7 +1853,7 @@ public class GameAction {
}
} // isSpell
- List cardsOnBattlefield = GameState.getCardsIn(ZoneType.Battlefield);
+ List cardsOnBattlefield = game.getCardsIn(ZoneType.Battlefield);
cardsOnBattlefield.add(originalCard);
final ArrayList raiseAbilities = new ArrayList();
final ArrayList reduceAbilities = new ArrayList();
@@ -1973,7 +1978,7 @@ public class GameAction {
sa.setSourceCard(Singletons.getModel().getGameAction().moveToStack(source));
}
- Singletons.getModel().getGameState().getStack().add(sa);
+ game.getStack().add(sa);
if (sa.isTapAbility() && !sa.wasCancelled()) {
sa.getSourceCard().tap();
}
@@ -1982,12 +1987,12 @@ public class GameAction {
}
return;
} else {
- AllZone.getInputControl().setInput(sa.getAfterPayMana());
+ Singletons.getModel().getMatch().getInput().setInput(sa.getAfterPayMana());
}
} else if (sa.getBeforePayMana() == null) {
- AllZone.getInputControl().setInput(new InputPayManaCost(sa, manaCost));
+ Singletons.getModel().getMatch().getInput().setInput(new InputPayManaCost(sa, manaCost));
} else {
- AllZone.getInputControl().setInput(sa.getBeforePayMana());
+ Singletons.getModel().getMatch().getInput().setInput(sa.getBeforePayMana());
}
}
}
@@ -2034,12 +2039,12 @@ public class GameAction {
}
return;
} else {
- AllZone.getInputControl().setInput(sa.getAfterPayMana());
+ Singletons.getModel().getMatch().getInput().setInput(sa.getAfterPayMana());
}
} else if (sa.getBeforePayMana() == null) {
- AllZone.getInputControl().setInput(new InputPayManaCost(sa, true));
+ Singletons.getModel().getMatch().getInput().setInput(new InputPayManaCost(sa, true));
} else {
- AllZone.getInputControl().setInput(sa.getBeforePayMana());
+ Singletons.getModel().getMatch().getInput().setInput(sa.getBeforePayMana());
}
}
}
diff --git a/src/main/java/forge/GameActionUtil.java b/src/main/java/forge/GameActionUtil.java
index a9abefc86db..3b1d31cf90f 100644
--- a/src/main/java/forge/GameActionUtil.java
+++ b/src/main/java/forge/GameActionUtil.java
@@ -50,7 +50,6 @@ import forge.control.input.InputPayManaCostAbility;
import forge.control.input.InputPayReturnCost;
import forge.control.input.InputPaySacCost;
import forge.game.GameLossReason;
-import forge.game.GameState;
import forge.game.player.ComputerUtil;
import forge.game.player.Player;
import forge.game.zone.ZoneType;
@@ -106,7 +105,7 @@ public final class GameActionUtil {
public void execute() {
if (!c.isCopiedSpell()) {
- final List maelstromNexii = GameState.getCardsIn(ZoneType.Battlefield, "Maelstrom Nexus");
+ final List maelstromNexii = CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Maelstrom Nexus"));
for (final Card nexus : maelstromNexii) {
if (CardUtil.getThisTurnCast("Card.YouCtrl", nexus).size() == 1) {
@@ -346,9 +345,9 @@ public final class GameActionUtil {
final Command unpaid) {
// temporarily disable the Resolve flag, so the user can payMana for the
// resolving Ability
- final boolean bResolving = Singletons.getModel().getGameState().getStack().getResolving();
+ final boolean bResolving = Singletons.getModel().getGameState().getStack().isResolving();
Singletons.getModel().getGameState().getStack().setResolving(false);
- AllZone.getInputControl().setInput(new InputPayManaCostAbility(message, manaCost, paid, unpaid));
+ Singletons.getModel().getMatch().getInput().setInput(new InputPayManaCostAbility(message, manaCost, paid, unpaid));
Singletons.getModel().getGameState().getStack().setResolving(bResolving);
}
@@ -491,29 +490,29 @@ public final class GameActionUtil {
//the following costs need inputs and can't be combined at the moment
if (costPart instanceof CostSacrifice) {
- final boolean bResolving = Singletons.getModel().getGameState().getStack().getResolving();
+ final boolean bResolving = Singletons.getModel().getGameState().getStack().isResolving();
Singletons.getModel().getGameState().getStack().setResolving(false);
- AllZone.getInputControl().setInput(new InputPaySacCost((CostSacrifice) costPart, ability, paid, unpaid));
+ Singletons.getModel().getMatch().getInput().setInput(new InputPaySacCost((CostSacrifice) costPart, ability, paid, unpaid));
Singletons.getModel().getGameState().getStack().setResolving(bResolving);
}
else if (costPart instanceof CostReturn) {
- final boolean bResolving = Singletons.getModel().getGameState().getStack().getResolving();
+ final boolean bResolving = Singletons.getModel().getGameState().getStack().isResolving();
Singletons.getModel().getGameState().getStack().setResolving(false);
- AllZone.getInputControl().setInput(new InputPayReturnCost((CostReturn) costPart, ability, paid, unpaid));
+ Singletons.getModel().getMatch().getInput().setInput(new InputPayReturnCost((CostReturn) costPart, ability, paid, unpaid));
Singletons.getModel().getGameState().getStack().setResolving(bResolving);
}
else if (costPart instanceof CostDiscard) {
- final boolean bResolving = Singletons.getModel().getGameState().getStack().getResolving();
+ final boolean bResolving = Singletons.getModel().getGameState().getStack().isResolving();
Singletons.getModel().getGameState().getStack().setResolving(false);
- AllZone.getInputControl().setInput(new InputPayDiscardCost((CostDiscard) costPart, ability, paid, unpaid));
+ Singletons.getModel().getMatch().getInput().setInput(new InputPayDiscardCost((CostDiscard) costPart, ability, paid, unpaid));
Singletons.getModel().getGameState().getStack().setResolving(bResolving);
}
else if (costPart instanceof CostMana) {
// temporarily disable the Resolve flag, so the user can payMana for the
// resolving Ability
- final boolean bResolving = Singletons.getModel().getGameState().getStack().getResolving();
+ final boolean bResolving = Singletons.getModel().getGameState().getStack().isResolving();
Singletons.getModel().getGameState().getStack().setResolving(false);
- AllZone.getInputControl().setInput(new InputPayManaCostAbility(source + "\r\n", ability.getManaCost(), paid, unpaid));
+ Singletons.getModel().getMatch().getInput().setInput(new InputPayManaCostAbility(source + "\r\n", ability.getManaCost(), paid, unpaid));
Singletons.getModel().getGameState().getStack().setResolving(bResolving);
}
}
@@ -698,7 +697,7 @@ public final class GameActionUtil {
public static void executeVampiricEffects(final Card c) {
final ArrayList a = c.getKeyword();
for (int i = 0; i < a.size(); i++) {
- if (GameState.isCardInPlay(c)
+ if (c.isInPlay()
&& a.get(i)
.toString()
.startsWith(
@@ -713,7 +712,7 @@ public final class GameActionUtil {
if (kw.contains("+2/+2")) {
counter = Counters.P2P2;
}
- if (GameState.isCardInPlay(thisCard)) {
+ if (thisCard.isInPlay()) {
thisCard.addCounter(counter, 1);
}
}
@@ -984,7 +983,7 @@ public final class GameActionUtil {
produces.put("Plains", "W");
produces.put("Swamp", "B");
- List lands = GameState.getCardsInGame();
+ List lands = Singletons.getModel().getGameState().getCardsInGame();
lands = CardLists.filter(lands, Presets.LANDS);
// remove all abilities granted by this Command
@@ -1055,8 +1054,8 @@ public final class GameActionUtil {
}
// add +1/+1 to cards
list.clear();
- final int num = GameState.getCardsIn(ZoneType.Battlefield, "Coat of Arms").size();
- final List creatures = CardLists.filter(GameState.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES);
+ final int num = CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Coat of Arms")).size();
+ final List creatures = CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES);
for (Card c : creatures) {
for (Card c2 : creatures) {
@@ -1080,9 +1079,9 @@ public final class GameActionUtil {
@Override
public void execute() {
- final List alphaStatuses = GameState.getCardsIn(ZoneType.Battlefield, "Alpha Status");
+ final List alphaStatuses = CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Alpha Status"));
- final List allCreatures = GameState.getCreaturesInPlay();
+ final List allCreatures = CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), Presets.CREATURES);
for (int i = 0; i < this.previouslyPumped.size(); i++) {
this.previouslyPumped.get(i).addSemiPermanentAttackBoost(0 - this.previouslyPumpedValue.get(i));
@@ -1117,7 +1116,7 @@ public final class GameActionUtil {
@Override
public void execute() {
// get all creatures
- final List cards = GameState.getCardsIn(ZoneType.Battlefield, "Umbra Stalker");
+ final List cards = CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Umbra Stalker"));
for (final Card c : cards) {
final Player player = c.getController();
final List grave = player.getCardsIn(ZoneType.Graveyard);
@@ -1134,7 +1133,7 @@ public final class GameActionUtil {
@Override
public void execute() {
- List list = GameState.getCardsIn(ZoneType.Battlefield);
+ List list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
list = CardLists.filter(list, new Predicate() {
@Override
@@ -1157,7 +1156,7 @@ public final class GameActionUtil {
@Override
public void execute() {
- final List list = GameState.getCardsIn(ZoneType.Battlefield, "Old Man of the Sea");
+ final List list = CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Old Man of the Sea"));
for (final Card oldman : list) {
if (!oldman.getGainControlTargets().isEmpty()) {
if (oldman.getNetAttack() < oldman.getGainControlTargets().get(0).getNetAttack()) {
@@ -1178,7 +1177,7 @@ public final class GameActionUtil {
@Override
public void execute() {
- final List list = GameState.getCardsIn(ZoneType.Battlefield, "Liu Bei, Lord of Shu");
+ final List list = CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Liu Bei, Lord of Shu"));
if (list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
@@ -1217,7 +1216,7 @@ public final class GameActionUtil {
@Override
public void execute() {
- List list = GameState.getCardsIn(ZoneType.Battlefield);
+ List list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
list = CardLists.filter(list, new Predicate() {
@Override
public boolean apply(final Card c) {
@@ -1235,7 +1234,7 @@ public final class GameActionUtil {
}
private int countSoundTheCalls() {
- List list = GameState.getCardsIn(ZoneType.Graveyard, "Sound the Call");
+ List list = CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Graveyard), CardPredicates.nameEquals("Sound the Call"));
return list.size();
}
@@ -1248,7 +1247,7 @@ public final class GameActionUtil {
@Override
public void execute() {
// get all creatures
- final List list = GameState.getCardsIn(ZoneType.Battlefield, "Tarmogoyf");
+ final List list = CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Tarmogoyf"));
for (int i = 0; i < list.size(); i++) {
final Card c = list.get(i);
@@ -1259,7 +1258,7 @@ public final class GameActionUtil {
} // execute()
private int countDiffTypes() {
- final List list = GameState.getCardsIn(ZoneType.Graveyard);
+ final List list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Graveyard);
int count = 0;
for (int q = 0; q < list.size(); q++) {
@@ -1347,7 +1346,7 @@ public final class GameActionUtil {
*/
public static void doPowerSink(final Player p) {
// get all lands with mana abilities
- List lands = GameState.getPlayerLandsInPlay(p);
+ List lands = p.getLandsInPlay();
lands = CardLists.filter(lands, new Predicate() {
@Override
public boolean apply(final Card c) {
diff --git a/src/main/java/forge/StaticEffects.java b/src/main/java/forge/StaticEffects.java
index 2a08569adbd..71d97bad192 100644
--- a/src/main/java/forge/StaticEffects.java
+++ b/src/main/java/forge/StaticEffects.java
@@ -27,7 +27,6 @@ import com.esotericsoftware.minlog.Log;
import forge.card.replacement.ReplacementEffect;
import forge.card.spellability.SpellAbility;
import forge.card.staticability.StaticAbility;
-import forge.game.GameState;
import forge.game.player.Player;
import forge.game.zone.ZoneType;
@@ -326,7 +325,7 @@ public class StaticEffects {
public final void rePopulateStateBasedList() {
this.reset();
- final List cards = GameState.getCardsIn(ZoneType.Battlefield);
+ final List cards = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
Log.debug("== Start add state effects ==");
for (int i = 0; i < cards.size(); i++) {
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactory.java b/src/main/java/forge/card/abilityfactory/AbilityFactory.java
index 498d631d5f6..3e509068de8 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactory.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactory.java
@@ -39,7 +39,6 @@ import forge.card.spellability.SpellAbilityCondition;
import forge.card.spellability.SpellAbilityRestriction;
import forge.card.spellability.SpellPermanent;
import forge.card.spellability.Target;
-import forge.game.GameState;
import forge.game.phase.PhaseType;
import forge.game.player.ComputerUtil;
import forge.game.player.Player;
@@ -1631,10 +1630,10 @@ public class AbilityFactory {
// Add whole Remembered list to handlePaid
final List list = new ArrayList();
if (card.getRemembered().isEmpty()) {
- final Card newCard = GameState.getCardState(card);
+ final Card newCard = Singletons.getModel().getGameState().getCardState(card);
for (final Object o : newCard.getRemembered()) {
if (o instanceof Card) {
- list.add(GameState.getCardState((Card) o));
+ list.add(Singletons.getModel().getGameState().getCardState((Card) o));
}
}
}
@@ -1648,7 +1647,7 @@ public class AbilityFactory {
} else {
for (final Object o : card.getRemembered()) {
if (o instanceof Card) {
- list.add(GameState.getCardState((Card) o));
+ list.add(Singletons.getModel().getGameState().getCardState((Card) o));
}
}
}
@@ -1658,7 +1657,7 @@ public class AbilityFactory {
// Add whole Imprinted list to handlePaid
final List list = new ArrayList();
for (final Card c : card.getImprinted()) {
- list.add(GameState.getCardState(c));
+ list.add(Singletons.getModel().getGameState().getCardState(c));
}
return CardFactoryUtil.handlePaid(list, calcX[1], card) * multiplier;
@@ -1668,7 +1667,7 @@ public class AbilityFactory {
if (card.isEnchanting()) {
Object o = card.getEnchanting();
if (o instanceof Card) {
- list.add(GameState.getCardState((Card) o));
+ list.add(Singletons.getModel().getGameState().getCardState((Card) o));
}
}
return CardFactoryUtil.handlePaid(list, calcX[1], card) * multiplier;
@@ -1928,7 +1927,7 @@ public class AbilityFactory {
else {
final Object crd = root.getTriggeringObject(defined.substring(9));
if (crd instanceof Card) {
- c = GameState.getCardState((Card) crd);
+ c = Singletons.getModel().getGameState().getCardState((Card) crd);
c = (Card) crd;
} else if (crd instanceof List>) {
for (final Card cardItem : (List) crd) {
@@ -1940,7 +1939,7 @@ public class AbilityFactory {
final SpellAbility root = sa.getRootSpellAbility();
final Object crd = root.getReplacingObject(defined.substring(8));
if (crd instanceof Card) {
- c = GameState.getCardState((Card) crd);
+ c = Singletons.getModel().getGameState().getCardState((Card) crd);
} else if (crd instanceof List>) {
for (final Card cardItem : (List) crd) {
cards.add(cardItem);
@@ -1948,26 +1947,26 @@ public class AbilityFactory {
}
} else if (defined.equals("Remembered")) {
if (hostCard.getRemembered().isEmpty()) {
- final Card newCard = GameState.getCardState(hostCard);
+ final Card newCard = Singletons.getModel().getGameState().getCardState(hostCard);
for (final Object o : newCard.getRemembered()) {
if (o instanceof Card) {
- cards.add(GameState.getCardState((Card) o));
+ cards.add(Singletons.getModel().getGameState().getCardState((Card) o));
}
}
}
for (final Object o : hostCard.getRemembered()) {
if (o instanceof Card) {
- cards.add(GameState.getCardState((Card) o));
+ cards.add(Singletons.getModel().getGameState().getCardState((Card) o));
}
}
} else if (defined.equals("Clones")) {
for (final Card clone : hostCard.getClones()) {
- cards.add(GameState.getCardState(clone));
+ cards.add(Singletons.getModel().getGameState().getCardState(clone));
}
} else if (defined.equals("Imprinted")) {
for (final Card imprint : hostCard.getImprinted()) {
- cards.add(GameState.getCardState(imprint));
+ cards.add(Singletons.getModel().getGameState().getCardState(imprint));
}
} else if (defined.startsWith("ThisTurnEntered")) {
final String[] workingCopy = defined.split("_");
@@ -2263,7 +2262,7 @@ public class AbilityFactory {
for (final Object o : card.getRemembered()) {
if (o instanceof Card) {
final Card rem = (Card) o;
- sas.addAll(GameState.getCardState(rem).getSpellAbilities());
+ sas.addAll(Singletons.getModel().getGameState().getCardState(rem).getSpellAbilities());
}
}
} else if (defined.equals("Imprinted")) {
@@ -2284,7 +2283,7 @@ public class AbilityFactory {
final SpellAbility root = sa.getRootSpellAbility();
final Object crd = root.getTriggeringObject("Card");
if (crd instanceof Card) {
- triggeredCard = GameState.getCardState((Card) crd);
+ triggeredCard = Singletons.getModel().getGameState().getCardState((Card) crd);
} //find the imprinted card that does not share a name with the triggered card
for (final SpellAbility spell : imprintedCards) {
if (!spell.getSourceCard().getName().equals(triggeredCard.getName())) {
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryAlterLife.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryAlterLife.java
index 13aea5ae93a..d1967deea23 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryAlterLife.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryAlterLife.java
@@ -33,7 +33,6 @@ import forge.card.spellability.AbilitySub;
import forge.card.spellability.Spell;
import forge.card.spellability.SpellAbility;
import forge.card.spellability.Target;
-import forge.game.GameState;
import forge.game.phase.CombatUtil;
import forge.game.phase.PhaseType;
import forge.game.player.ComputerUtil;
@@ -1616,7 +1615,7 @@ public class AbilityFactoryAlterLife {
}
if (source.getName().equals("Eternity Vessel")
- && (GameState.isCardInPlay("Vampire Hexmage", opponent) || (source
+ && (opponent.isCardInPlay("Vampire Hexmage") || (source
.getCounters(Counters.CHARGE) == 0))) {
return false;
}
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryAnimate.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryAnimate.java
index 202c5a26b1d..bafb18c5d3a 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryAnimate.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryAnimate.java
@@ -44,7 +44,6 @@ import forge.card.cost.Cost;
import forge.card.staticability.StaticAbility;
import forge.card.trigger.Trigger;
import forge.card.trigger.TriggerHandler;
-import forge.game.GameState;
import forge.game.phase.PhaseType;
import forge.game.player.ComputerUtil;
import forge.game.player.Player;
@@ -538,7 +537,7 @@ public final class AbilityFactoryAnimate {
//if host is not on the battlefield don't apply
if (params.containsKey("UntilHostLeavesPlay")
- && !GameState.isCardInPlay(sa.getSourceCard())) {
+ && !sa.getSourceCard().isInPlay()) {
return;
}
@@ -1296,7 +1295,7 @@ public final class AbilityFactoryAnimate {
}
if ((tgtPlayers == null) || tgtPlayers.isEmpty()) {
- list = GameState.getCardsIn(ZoneType.Battlefield);
+ list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
} else {
list = tgtPlayers.get(0).getCardsIn(ZoneType.Battlefield);
}
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryAttach.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryAttach.java
index 1101a2f160b..2feb08fdef9 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryAttach.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryAttach.java
@@ -46,7 +46,6 @@ import forge.card.spellability.SpellAbility;
import forge.card.spellability.SpellPermanent;
import forge.card.spellability.Target;
import forge.card.staticability.StaticAbility;
-import forge.game.GameState;
import forge.game.phase.CombatUtil;
import forge.game.phase.PhaseHandler;
import forge.game.phase.PhaseType;
@@ -347,7 +346,7 @@ public class AbilityFactoryAttach {
return null;
}
- List list = GameState.getCardsIn(tgt.getZone());
+ List list = Singletons.getModel().getGameState().getCardsIn(tgt.getZone());
list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), attachSource);
if (params.containsKey("AITgts")) {
list = CardLists.getValidCards(list, params.get("AITgts"), sa.getActivatingPlayer(), attachSource);
@@ -1313,7 +1312,7 @@ public class AbilityFactoryAttach {
return;
}
- if (GameState.isCardInPlay(crd)) {
+ if (crd.isInPlay()) {
crd.removeController(card);
}
@@ -1417,7 +1416,7 @@ public class AbilityFactoryAttach {
return true;
}
} else {
- List list = GameState.getCardsIn(tgt.getZone());
+ List list = Singletons.getModel().getGameState().getCardsIn(tgt.getZone());
list = CardLists.getValidCards(list, tgt.getValidTgts(), aura.getActivatingPlayer(), source);
final Object o = GuiChoose.one(source + " - Select a card to attach to.", list);
@@ -1711,7 +1710,7 @@ public class AbilityFactoryAttach {
// If Cast Targets will be checked on the Stack
for (final Object o : targets) {
String valid = params.get("UnattachValid");
- List unattachList = GameState.getCardsIn(ZoneType.Battlefield);
+ List unattachList = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
unattachList = CardLists.getValidCards(unattachList, valid.split(","), source.getController(), source);
for (final Card c : unattachList) {
AbilityFactoryAttach.handleUnattachment(o, c, af);
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryBond.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryBond.java
index 19c6895d31a..2c82501b7cc 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryBond.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryBond.java
@@ -22,6 +22,7 @@ import java.util.HashMap;
import java.util.List;
import forge.Card;
+import forge.Singletons;
import forge.card.spellability.AbilityActivated;
import forge.card.spellability.AbilitySub;
@@ -29,7 +30,6 @@ import forge.card.spellability.SpellAbility;
import forge.card.spellability.Target;
import forge.card.cardfactory.CardFactoryUtil;
import forge.card.cost.Cost;
-import forge.game.GameState;
import forge.game.player.ComputerUtil;
import forge.game.player.Player;
import forge.game.zone.ZoneType;
@@ -325,7 +325,7 @@ public final class AbilityFactoryBond {
}
// find list of valid cards to pair with
- List cards = GameState.getCardsIn(ZoneType.Battlefield);
+ List cards = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
cards = AbilityFactory.filterListByType(cards, params.get("ValidCards"), sa);
if (cards.isEmpty()) {
return;
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryChangeZone.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryChangeZone.java
index 6faf91e722f..056c795eaae 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryChangeZone.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryChangeZone.java
@@ -49,7 +49,6 @@ import forge.card.spellability.SpellAbility;
import forge.card.spellability.SpellAbilityStackInstance;
import forge.card.spellability.SpellPermanent;
import forge.card.spellability.Target;
-import forge.game.GameState;
import forge.game.phase.Combat;
import forge.game.phase.CombatUtil;
import forge.game.phase.PhaseType;
@@ -512,7 +511,7 @@ public final class AbilityFactoryChangeZone {
//Ninjutsu
if (params.containsKey("Ninjutsu")) {
- if (source.isType("Legendary") && !GameState.isCardInPlay("Mirror Gallery")) {
+ if (source.isType("Legendary") && !Singletons.getModel().getGameState().isCardInPlay("Mirror Gallery")) {
final List list = ai.getCardsIn(ZoneType.Battlefield);
if (Iterables.any(list, CardPredicates.nameEquals(source.getName()))) {
return false;
@@ -975,7 +974,7 @@ public final class AbilityFactoryChangeZone {
}
} else if (!origin.contains(ZoneType.Library) && !origin.contains(ZoneType.Hand)
&& !params.containsKey("DefinedPlayer")) {
- fetchList = GameState.getCardsIn(origin);
+ fetchList = Singletons.getModel().getGameState().getCardsIn(origin);
} else {
fetchList = player.getCardsIn(origin);
}
@@ -1161,7 +1160,7 @@ public final class AbilityFactoryChangeZone {
}
} else if (!origin.contains(ZoneType.Library) && !origin.contains(ZoneType.Hand)
&& !params.containsKey("DefinedPlayer")) {
- fetchList = GameState.getCardsIn(origin);
+ fetchList = Singletons.getModel().getGameState().getCardsIn(origin);
fetchList = AbilityFactory.filterListByType(fetchList, type, sa);
} else {
fetchList = player.getCardsIn(origin);
@@ -1461,11 +1460,11 @@ public final class AbilityFactoryChangeZone {
Card card = null;
Combat combat = new Combat();
combat.initiatePossibleDefenders(ai);
- List attackers = GameState.getCreaturesInPlay(ai.getOpponent());
+ List attackers = ai.getOpponent().getCreaturesInPlay();
for (Card att : attackers) {
combat.addAttacker(att);
}
- combat = ComputerUtilBlock.getBlockers(ai, combat, GameState.getCreaturesInPlay(ai));
+ combat = ComputerUtilBlock.getBlockers(ai, combat, ai.getCreaturesInPlay());
if (CombatUtil.lifeInDanger(ai, combat)) {
// need something AI can cast now
@@ -1665,7 +1664,7 @@ public final class AbilityFactoryChangeZone {
tgt.resetTargets();
}
- List list = GameState.getCardsIn(origin);
+ List list = Singletons.getModel().getGameState().getCardsIn(origin);
list = CardLists.getValidCards(list, tgt.getValidTgts(), ai, source);
if (params.containsKey("AITgts")) {
list = CardLists.getValidCards(list, params.get("AITgts"), sa.getActivatingPlayer(), source);
@@ -1775,7 +1774,7 @@ public final class AbilityFactoryChangeZone {
if (!sa.isTrigger() && sa.getPayCosts() != null
&& Singletons.getModel().getGameState().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)
&& Singletons.getModel().getGameState().getPhaseHandler().isPlayerTurn(ai)
- && GameState.getCreaturesInPlay(ai).isEmpty()) {
+ && ai.getCreaturesInPlay().isEmpty()) {
return false;
}
list = CardLists.filterControlledBy(list, ai.getOpponent());
@@ -1900,7 +1899,7 @@ public final class AbilityFactoryChangeZone {
final ZoneType destination = ZoneType.smartValueOf(params.get("Destination"));
final Target tgt = sa.getTarget();
- List list = GameState.getCardsIn(origin);
+ List list = Singletons.getModel().getGameState().getCardsIn(origin);
list = CardLists.getValidCards(list, tgt.getValidTgts(), ai, source);
// Narrow down the list:
@@ -2235,7 +2234,7 @@ public final class AbilityFactoryChangeZone {
&& !GameActionUtil.showYesNoDialog(hostCard, sb.toString())) {
continue;
}
- final PlayerZone originZone = GameState.getZoneOf(tgtC);
+ final PlayerZone originZone = Singletons.getModel().getGameState().getZoneOf(tgtC);
// if Target isn't in the expected Zone, continue
@@ -2348,7 +2347,7 @@ public final class AbilityFactoryChangeZone {
final ArrayList list = AbilityFactory.getDefinedCards(sa.getSourceCard(), defined, sa);
for (final Card c : list) {
- final Card actualCard = GameState.getCardState(c);
+ final Card actualCard = Singletons.getModel().getGameState().getCardState(c);
ret.add(actualCard);
}
return ret;
@@ -2926,7 +2925,7 @@ public final class AbilityFactoryChangeZone {
}
if ((tgtPlayers == null) || tgtPlayers.isEmpty()) {
- cards = GameState.getCardsIn(origin);
+ cards = Singletons.getModel().getGameState().getCardsIn(origin);
} else {
cards = tgtPlayers.get(0).getCardsIn(origin);
}
@@ -2971,7 +2970,7 @@ public final class AbilityFactoryChangeZone {
}
if (remember != null) {
- GameState.getCardState(sa.getSourceCard()).addRemembered(c);
+ Singletons.getModel().getGameState().getCardState(sa.getSourceCard()).addRemembered(c);
}
}
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryChoose.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryChoose.java
index a5d57d1f287..608c3772d93 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryChoose.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryChoose.java
@@ -46,7 +46,6 @@ import forge.card.spellability.Spell;
import forge.card.spellability.SpellAbility;
import forge.card.spellability.Target;
import forge.card.cost.Cost;
-import forge.game.GameState;
import forge.game.player.ComputerUtil;
import forge.game.player.Player;
import forge.game.zone.ZoneType;
@@ -382,8 +381,7 @@ public final class AbilityFactoryChoose {
if (params.containsKey("AILogic")) {
final String logic = params.get("AILogic");
if (logic.equals("MostProminentOnBattlefield")) {
- chosen = CardFactoryUtil.getMostProminentCreatureType(GameState
- .getCardsIn(ZoneType.Battlefield));
+ chosen = CardFactoryUtil.getMostProminentCreatureType(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield));
}
if (logic.equals("MostProminentComputerControls")) {
chosen = CardFactoryUtil.getMostProminentCreatureType(ai.getCardsIn(ZoneType.Battlefield));
@@ -391,11 +389,11 @@ public final class AbilityFactoryChoose {
if (logic.equals("MostProminentHumanControls")) {
chosen = CardFactoryUtil.getMostProminentCreatureType(opp.getCardsIn(ZoneType.Battlefield));
if (!CardUtil.isACreatureType(chosen) || invalidTypes.contains(chosen)) {
- chosen = CardFactoryUtil.getMostProminentCreatureType(CardLists.filterControlledBy(GameState.getCardsInGame(), opp));
+ chosen = CardFactoryUtil.getMostProminentCreatureType(CardLists.filterControlledBy(Singletons.getModel().getGameState().getCardsInGame(), opp));
}
}
if (logic.equals("MostProminentInComputerDeck")) {
- chosen = CardFactoryUtil.getMostProminentCreatureType(CardLists.filterControlledBy(GameState.getCardsInGame(), ai));
+ chosen = CardFactoryUtil.getMostProminentCreatureType(CardLists.filterControlledBy(Singletons.getModel().getGameState().getCardsInGame(), ai));
}
if (logic.equals("MostProminentInComputerGraveyard")) {
chosen = CardFactoryUtil.getMostProminentCreatureType(ai.getCardsIn(ZoneType.Graveyard));
@@ -730,21 +728,21 @@ public final class AbilityFactoryChoose {
if (params.containsKey("AILogic")) {
final String logic = params.get("AILogic");
if (logic.equals("MostProminentInHumanDeck")) {
- chosen.add(CardFactoryUtil.getMostProminentColor(CardLists.filterControlledBy(GameState.getCardsInGame(), opp)));
+ chosen.add(CardFactoryUtil.getMostProminentColor(CardLists.filterControlledBy(Singletons.getModel().getGameState().getCardsInGame(), opp)));
} else if (logic.equals("MostProminentInComputerDeck")) {
- chosen.add(CardFactoryUtil.getMostProminentColor(CardLists.filterControlledBy(GameState.getCardsInGame(), ai)));
+ chosen.add(CardFactoryUtil.getMostProminentColor(CardLists.filterControlledBy(Singletons.getModel().getGameState().getCardsInGame(), ai)));
} else if (logic.equals("MostProminentDualInComputerDeck")) {
- List prominence = CardFactoryUtil.getColorByProminence(CardLists.filterControlledBy(GameState.getCardsInGame(), ai));
+ List prominence = CardFactoryUtil.getColorByProminence(CardLists.filterControlledBy(Singletons.getModel().getGameState().getCardsInGame(), ai));
chosen.add(prominence.get(0));
chosen.add(prominence.get(1));
}
else if (logic.equals("MostProminentInGame")) {
- chosen.add(CardFactoryUtil.getMostProminentColor(GameState.getCardsInGame()));
+ chosen.add(CardFactoryUtil.getMostProminentColor(Singletons.getModel().getGameState().getCardsInGame()));
}
else if (logic.equals("MostProminentHumanCreatures")) {
- List list = GameState.getCreaturesInPlay(opp);
+ List list = opp.getCreaturesInPlay();
if (list.isEmpty()) {
- list = CardLists.filter(CardLists.filterControlledBy(GameState.getCardsInGame(), opp), CardPredicates.Presets.CREATURES);
+ list = CardLists.filter(CardLists.filterControlledBy(Singletons.getModel().getGameState().getCardsInGame(), opp), CardPredicates.Presets.CREATURES);
}
chosen.add(CardFactoryUtil.getMostProminentColor(list));
}
@@ -752,7 +750,7 @@ public final class AbilityFactoryChoose {
chosen.add(CardFactoryUtil.getMostProminentColor(ai.getCardsIn(ZoneType.Battlefield)));
}
else if (logic.equals("MostProminentPermanent")) {
- final List list = GameState.getCardsIn(ZoneType.Battlefield);
+ final List list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
chosen.add(CardFactoryUtil.getMostProminentColor(list));
}
else if (logic.equals("MostProminentAttackers")) {
@@ -1646,7 +1644,7 @@ public final class AbilityFactoryChoose {
chosen = CardFactoryUtil.getMostProminentCardName(p.getOpponent().getCardsIn(ZoneType.Library));
}
} else {
- List list = CardLists.filterControlledBy(GameState.getCardsInGame(), p.getOpponent());
+ List list = CardLists.filterControlledBy(Singletons.getModel().getGameState().getCardsInGame(), p.getOpponent());
list = CardLists.filter(list, Predicates.not(Presets.LANDS));
if (!list.isEmpty()) {
chosen = list.get(0).getName();
@@ -1872,7 +1870,7 @@ public final class AbilityFactoryChoose {
if (params.containsKey("ChoiceZone")) {
choiceZone = ZoneType.smartValueOf(params.get("ChoiceZone"));
}
- List choices = GameState.getCardsIn(choiceZone);
+ List choices = Singletons.getModel().getGameState().getCardsIn(choiceZone);
if (params.containsKey("Choices")) {
choices = CardLists.getValidCards(choices, params.get("Choices"), host.getController(), host);
}
@@ -1941,7 +1939,7 @@ public final class AbilityFactoryChoose {
if (params.containsKey("ChoiceZone")) {
choiceZone = ZoneType.smartValueOf(params.get("ChoiceZone"));
}
- List choices = GameState.getCardsIn(choiceZone);
+ List choices = Singletons.getModel().getGameState().getCardsIn(choiceZone);
if (params.containsKey("Choices")) {
choices = CardLists.getValidCards(choices, params.get("Choices"), host.getController(), host);
}
@@ -1954,7 +1952,7 @@ public final class AbilityFactoryChoose {
? CardFactoryUtil.xCount(host, host.getSVar(params.get("Amount"))) : Integer.parseInt(numericAmount);
if (params.containsKey("SunderingTitan")) {
- final List land = GameState.getLandsInPlay();
+ final List land = Singletons.getModel().getGameState().getLandsInPlay();
final ArrayList basic = CardUtil.getBasicTypes();
for (final String type : basic) {
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryCleanup.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryCleanup.java
index b98ad6d4363..93096043d81 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryCleanup.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryCleanup.java
@@ -25,7 +25,6 @@ import forge.card.cardfactory.CardFactoryUtil;
import forge.card.spellability.AbilitySub;
import forge.card.spellability.SpellAbility;
import forge.card.spellability.Target;
-import forge.game.GameState;
// Cleanup is not the same as other AFs, it is only used as a Drawback, and only used to Cleanup particular card states
// That need to be reset. I'm creating this to clear Remembered Cards at the
@@ -106,7 +105,7 @@ public final class AbilityFactoryCleanup {
if (params.containsKey("ClearRemembered")) {
source.clearRemembered();
- GameState.getCardState(source).clearRemembered();
+ Singletons.getModel().getGameState().getCardState(source).clearRemembered();
}
if (params.containsKey("ClearImprinted")) {
source.clearImprinted();
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryCopy.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryCopy.java
index b5ebe47bfd4..9b30d2c8f55 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryCopy.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryCopy.java
@@ -40,7 +40,6 @@ import forge.card.spellability.AbilitySub;
import forge.card.spellability.Spell;
import forge.card.spellability.SpellAbility;
import forge.card.spellability.Target;
-import forge.game.GameState;
import forge.game.phase.PhaseType;
import forge.game.player.ComputerUtil;
import forge.game.player.Player;
@@ -307,7 +306,7 @@ public final class AbilityFactoryCopy {
final Target abTgt = sa.getTarget();
if (abTgt != null) {
- List list = GameState.getCardsIn(ZoneType.Battlefield);
+ List list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
list = CardLists.getValidCards(list, abTgt.getValidTgts(), source.getController(), source);
list = CardLists.getTargetableCards(list, sa);
abTgt.resetTargets();
@@ -402,7 +401,7 @@ public final class AbilityFactoryCopy {
}
// start copied Kiki code
- int multiplier = GameState.getTokenDoublersMagnitude(hostCard.getController());
+ int multiplier = hostCard.getController().getTokenDoublersMagnitude();
multiplier *= numCopies;
final Card[] crds = new Card[multiplier];
@@ -487,7 +486,7 @@ public final class AbilityFactoryCopy {
public void resolve() {
// technically your opponent could steal the token
// and the token shouldn't be sacrificed
- if (GameState.isCardInPlay(target[index])) {
+ if (target[index].isInPlay()) {
if (params.get("AtEOT").equals("Sacrifice")) {
// maybe do a setSacrificeAtEOT, but
// probably not.
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryCounters.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryCounters.java
index 366ca11d931..7be804cf2ef 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryCounters.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryCounters.java
@@ -27,7 +27,6 @@ import java.util.Random;
import com.google.common.base.Predicate;
-import forge.AllZone;
import forge.Card;
import forge.CardLists;
@@ -42,7 +41,6 @@ import forge.card.spellability.Spell;
import forge.card.spellability.SpellAbility;
import forge.card.spellability.Target;
import forge.control.input.Input;
-import forge.game.GameState;
import forge.game.phase.PhaseHandler;
import forge.game.phase.PhaseType;
import forge.game.player.ComputerUtil;
@@ -756,7 +754,7 @@ public class AbilityFactoryCounters {
if (max != -1) {
counterAmount = max - tgtCard.getCounters(Counters.valueOf(type));
}
- final PlayerZone zone = GameState.getZoneOf(tgtCard);
+ final PlayerZone zone = Singletons.getModel().getGameState().getZoneOf(tgtCard);
if (zone == null) {
// Do nothing, token disappeared
} else if (zone.is(ZoneType.Battlefield)) {
@@ -1177,7 +1175,7 @@ public class AbilityFactoryCounters {
}
for (final Card tgtCard : tgtCards) {
if ((tgt == null) || tgtCard.canBeTargetedBy(sa)) {
- final PlayerZone zone = GameState.getZoneOf(tgtCard);
+ final PlayerZone zone = Singletons.getModel().getGameState().getZoneOf(tgtCard);
if (params.get("CounterNum").equals("All")) {
counterAmount = tgtCard.getCounters(Counters.valueOf(type));
}
@@ -1526,8 +1524,8 @@ public class AbilityFactoryCounters {
}
private static void proliferateResolveHuman(final AbilityFactory af, final SpellAbility sa) {
- final List unchosen = GameState.getCardsIn(ZoneType.Battlefield);
- AllZone.getInputControl().setInput(new Input() {
+ final List unchosen = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
+ Singletons.getModel().getMatch().getInput().setInput(new Input() {
private static final long serialVersionUID = -1779224307654698954L;
@Override
@@ -1599,7 +1597,7 @@ public class AbilityFactoryCounters {
}
};
- List cardsToProliferate = CardLists.filter(GameState.getCardsIn(ZoneType.Battlefield), predProliferate);
+ List cardsToProliferate = CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), predProliferate);
List playersToPoison = new ArrayList();
for( Player e : enemies ) {
if ( e.getPoisonCounters() > 0 )
@@ -1990,7 +1988,7 @@ public class AbilityFactoryCounters {
final String valid = params.get("ValidCards");
final ZoneType zone = params.containsKey("ValidZone") ? ZoneType.smartValueOf(params.get("ValidZone")) : ZoneType.Battlefield;
- List cards = GameState.getCardsIn(zone);
+ List cards = Singletons.getModel().getGameState().getCardsIn(zone);
cards = CardLists.getValidCards(cards, valid, sa.getSourceCard().getController(), sa.getSourceCard());
final Target tgt = sa.getTarget();
@@ -2000,7 +1998,7 @@ public class AbilityFactoryCounters {
}
for (final Card tgtCard : cards) {
- if (GameState.getZoneOf(tgtCard).is(ZoneType.Battlefield)) {
+ if (Singletons.getModel().getGameState().getZoneOf(tgtCard).is(ZoneType.Battlefield)) {
tgtCard.addCounter(Counters.valueOf(type), counterAmount);
} else {
// adding counters to something like re-suspend cards
@@ -2245,7 +2243,7 @@ public class AbilityFactoryCounters {
final String valid = params.get("ValidCards");
final ZoneType zone = params.containsKey("ValidZone") ? ZoneType.smartValueOf(params.get("ValidZone")) : ZoneType.Battlefield;
- List cards = GameState.getCardsIn(zone);
+ List cards = Singletons.getModel().getGameState().getCardsIn(zone);
cards = CardLists.getValidCards(cards, valid, sa.getSourceCard().getController(), sa.getSourceCard());
final Target tgt = sa.getTarget();
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryDealDamage.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryDealDamage.java
index 949a458d2f0..7e4160d7e0e 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryDealDamage.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryDealDamage.java
@@ -40,7 +40,6 @@ import forge.card.spellability.Spell;
import forge.card.spellability.SpellAbility;
import forge.card.spellability.Target;
import forge.card.spellability.TargetSelection;
-import forge.game.GameState;
import forge.game.phase.PhaseHandler;
import forge.game.phase.PhaseType;
import forge.game.player.ComputerUtil;
@@ -907,7 +906,7 @@ public class AbilityFactoryDealDamage {
for (final Object o : tgts) {
if (o instanceof Card) {
final Card c = (Card) o;
- if (GameState.isCardInPlay(c) && (!targeted || c.canBeTargetedBy(saMe))) {
+ if (c.isInPlay() && (!targeted || c.canBeTargetedBy(saMe))) {
if (noPrevention) {
c.addDamageWithoutPrevention(dmg, source);
} else if (combatDmg) {
@@ -1383,7 +1382,7 @@ public class AbilityFactoryDealDamage {
}
if (params.containsKey("ValidCards")) {
- list = GameState.getCardsIn(ZoneType.Battlefield);
+ list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
}
if (targetPlayer != null) {
@@ -1647,7 +1646,7 @@ public class AbilityFactoryDealDamage {
final HashMap params = af.getMapParams();
final Card card = sa.getSourceCard();
- List sources = GameState.getCardsIn(ZoneType.Battlefield);
+ List sources = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
if (params.containsKey("ValidCards")) {
sources = CardLists.getValidCards(sources, params.get("ValidCards"), card.getController(), card);
}
@@ -1667,7 +1666,7 @@ public class AbilityFactoryDealDamage {
// System.out.println(source+" deals "+dmg+" damage to "+o.toString());
if (o instanceof Card) {
final Card c = (Card) o;
- if (GameState.isCardInPlay(c) && (!targeted || c.canBeTargetedBy(sa))) {
+ if (c.isInPlay() && (!targeted || c.canBeTargetedBy(sa))) {
c.addDamage(dmg, source);
}
@@ -1907,7 +1906,7 @@ public class AbilityFactoryDealDamage {
Target tgt = sa.getTarget();
tgt.resetTargets();
- List aiCreatures = GameState.getCreaturesInPlay(ai);
+ List aiCreatures = ai.getCreaturesInPlay();
aiCreatures = CardLists.getTargetableCards(aiCreatures, sa);
aiCreatures = CardLists.filter(aiCreatures, new Predicate() {
@Override
@@ -1916,7 +1915,7 @@ public class AbilityFactoryDealDamage {
}
});
- List humCreatures = GameState.getCreaturesInPlay(ai.getOpponent());
+ List humCreatures = ai.getOpponent().getCreaturesInPlay();
humCreatures = CardLists.getTargetableCards(humCreatures, sa);
final Random r = MyRandom.getRandom();
@@ -2000,8 +1999,8 @@ public class AbilityFactoryDealDamage {
fighter2 = tgts.get(1);
}
- if (fighter1 == null || fighter2 == null || !GameState.isCardInPlay(fighter1)
- || !GameState.isCardInPlay(fighter2)) {
+ if (fighter1 == null || fighter2 == null || !fighter1.isInPlay()
+ || !fighter2.isInPlay()) {
return;
}
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryDebuff.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryDebuff.java
index a5166f169b0..51df55ddbf0 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryDebuff.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryDebuff.java
@@ -40,7 +40,6 @@ import forge.card.spellability.Spell;
import forge.card.spellability.SpellAbility;
import forge.card.spellability.SpellAbilityRestriction;
import forge.card.spellability.Target;
-import forge.game.GameState;
import forge.game.phase.CombatUtil;
import forge.game.phase.PhaseHandler;
import forge.game.phase.PhaseType;
@@ -297,7 +296,7 @@ public final class AbilityFactoryDebuff {
private static boolean debuffCanPlayAI(final Player ai, final AbilityFactory af, final SpellAbility sa) {
// if there is no target and host card isn't in play, don't activate
final Card source = sa.getSourceCard();
- if ((sa.getTarget() == null) && !GameState.isCardInPlay(source)) {
+ if ((sa.getTarget() == null) && !source.isInPlay()) {
return false;
}
@@ -466,7 +465,7 @@ public final class AbilityFactoryDebuff {
private static List getCurseCreatures(final Player ai, final AbilityFactory af, final SpellAbility sa,
final ArrayList kws) {
final Player opp = ai.getOpponent();
- List list = GameState.getCreaturesInPlay(opp);
+ List list = opp.getCreaturesInPlay();
list = CardLists.getTargetableCards(list, sa);
if (!list.isEmpty()) {
@@ -496,7 +495,7 @@ public final class AbilityFactoryDebuff {
* @return a boolean.
*/
private static boolean debuffMandatoryTarget(final Player ai, final AbilityFactory af, final SpellAbility sa, final boolean mandatory) {
- List list = GameState.getCardsIn(ZoneType.Battlefield);
+ List list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
final Target tgt = sa.getTarget();
list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard());
@@ -617,7 +616,7 @@ public final class AbilityFactoryDebuff {
for (final Card tgtC : tgtCards) {
final ArrayList hadIntrinsic = new ArrayList();
- if (GameState.isCardInPlay(tgtC) && tgtC.canBeTargetedBy(sa)) {
+ if (tgtC.isInPlay() && tgtC.canBeTargetedBy(sa)) {
for (final String kw : kws) {
if (tgtC.getIntrinsicKeyword().contains(kw)) {
hadIntrinsic.add(kw);
@@ -632,7 +631,7 @@ public final class AbilityFactoryDebuff {
@Override
public void execute() {
- if (GameState.isCardInPlay(tgtC)) {
+ if (tgtC.isInPlay()) {
for (final String kw : hadIntrinsic) {
tgtC.addIntrinsicKeyword(kw);
}
@@ -858,12 +857,12 @@ public final class AbilityFactoryDebuff {
valid = params.get("ValidCards");
}
- List list = GameState.getCardsIn(ZoneType.Battlefield);
+ List list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
list = CardLists.getValidCards(list, valid.split(","), hostCard.getController(), hostCard);
for (final Card tgtC : list) {
final ArrayList hadIntrinsic = new ArrayList();
- if (GameState.isCardInPlay(tgtC) && tgtC.canBeTargetedBy(sa)) {
+ if (tgtC.isInPlay() && tgtC.canBeTargetedBy(sa)) {
for (final String kw : kws) {
if (tgtC.getIntrinsicKeyword().contains(kw)) {
hadIntrinsic.add(kw);
@@ -878,7 +877,7 @@ public final class AbilityFactoryDebuff {
@Override
public void execute() {
- if (GameState.isCardInPlay(tgtC)) {
+ if (tgtC.isInPlay()) {
for (final String kw : hadIntrinsic) {
tgtC.addIntrinsicKeyword(kw);
}
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryDestroy.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryDestroy.java
index 17989c1125b..f0e99e7f76d 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryDestroy.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryDestroy.java
@@ -39,7 +39,6 @@ import forge.card.spellability.AbilitySub;
import forge.card.spellability.Spell;
import forge.card.spellability.SpellAbility;
import forge.card.spellability.Target;
-import forge.game.GameState;
import forge.game.player.ComputerUtil;
import forge.game.player.Player;
import forge.game.zone.ZoneType;
@@ -376,7 +375,7 @@ public class AbilityFactoryDestroy {
final Player opp = ai.getOpponent();
if (tgt != null) {
List list;
- list = GameState.getCardsIn(ZoneType.Battlefield);
+ list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
list = CardLists.getTargetableCards(list, sa);
list = CardLists.getValidCards(list, tgt.getValidTgts(), source.getController(), source);
@@ -591,7 +590,7 @@ public class AbilityFactoryDestroy {
}
for (final Card tgtC : tgtCards) {
- if (GameState.isCardInPlay(tgtC) && ((tgt == null) || tgtC.canBeTargetedBy(sa))) {
+ if (tgtC.isInPlay() && ((tgt == null) || tgtC.canBeTargetedBy(sa))) {
boolean destroyed = false;
if (sac) {
destroyed = Singletons.getModel().getGameAction().sacrifice(tgtC, sa);
@@ -606,7 +605,7 @@ public class AbilityFactoryDestroy {
}
for (final Card unTgtC : untargetedCards) {
- if (GameState.isCardInPlay(unTgtC)) {
+ if (unTgtC.isInPlay()) {
boolean destroyed = false;
if (sac) {
destroyed = Singletons.getModel().getGameAction().sacrifice(unTgtC, sa);
@@ -1037,7 +1036,7 @@ public class AbilityFactoryDestroy {
valid = valid.replace("X", Integer.toString(AbilityFactory.calculateAmount(card, "X", sa)));
}
- List list = GameState.getCardsIn(ZoneType.Battlefield);
+ List list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
if (targetPlayer != null) {
list = CardLists.filterControlledBy(list, targetPlayer);
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryEffect.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryEffect.java
index d404891e1f5..f80744b1cd1 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryEffect.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryEffect.java
@@ -41,7 +41,6 @@ import forge.card.spellability.Target;
import forge.card.trigger.Trigger;
import forge.card.trigger.TriggerHandler;
import forge.card.trigger.TriggerType;
-import forge.game.GameState;
import forge.game.phase.CombatUtil;
import forge.game.phase.PhaseHandler;
import forge.game.phase.PhaseType;
@@ -298,8 +297,8 @@ public class AbilityFactoryEffect {
} else if (logic.equals("Always")) {
randomReturn = true;
} else if (logic.equals("Evasion")) {
- List comp = GameState.getCreaturesInPlay(ai);
- List human = GameState.getCreaturesInPlay(ai.getOpponent());
+ List comp = ai.getCreaturesInPlay();
+ List human = ai.getOpponent().getCreaturesInPlay();
// only count creatures that can attack or block
comp = CardLists.filter(comp, new Predicate() {
@@ -447,7 +446,7 @@ public class AbilityFactoryEffect {
}
// Unique Effects shouldn't be duplicated
- if (params.containsKey("Unique") && GameState.isCardInPlay(name)) {
+ if (params.containsKey("Unique") && Singletons.getModel().getGameState().isCardInPlay(name)) {
return;
}
@@ -553,7 +552,7 @@ public class AbilityFactoryEffect {
// Remember created effect
if (params.containsKey("RememberEffect")) {
- GameState.getCardState(card).addRemembered(eff);
+ Singletons.getModel().getGameState().getCardState(card).addRemembered(eff);
}
// Duration
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryGainControl.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryGainControl.java
index 4a00caa380b..278b0a4ac73 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryGainControl.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryGainControl.java
@@ -39,7 +39,6 @@ import forge.card.spellability.Spell;
import forge.card.spellability.SpellAbility;
import forge.card.spellability.Target;
import forge.card.cost.Cost;
-import forge.game.GameState;
import forge.game.phase.PhaseType;
import forge.game.player.ComputerUtil;
import forge.game.player.Player;
@@ -424,7 +423,7 @@ public class AbilityFactoryGainControl {
final Target tgt = sa.getTarget();
if (this.params.containsKey("AllValid")) {
- tgtCards = GameState.getCardsIn(ZoneType.Battlefield);
+ tgtCards = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
tgtCards = AbilityFactory.filterListByType(tgtCards, this.params.get("AllValid"), sa);
} else if ((tgt != null) && !this.params.containsKey("Defined")) {
tgtCards.addAll(tgt.getTargetCards());
@@ -468,7 +467,7 @@ public class AbilityFactoryGainControl {
sa.getSourceCard().addGainControlTarget(tgtC);
}
- if (GameState.isCardInPlay(tgtC)) {
+ if (tgtC.isInPlay()) {
if (!tgtC.equals(newController)) {
tgtC.addController(newController);
@@ -561,7 +560,7 @@ public class AbilityFactoryGainControl {
private boolean gainControlDrawbackAI(final Player ai, final SpellAbility sa) {
if ((sa.getTarget() == null) || !sa.getTarget().doesTarget()) {
if (this.params.containsKey("AllValid")) {
- List tgtCards = CardLists.filterControlledBy(GameState.getCardsIn(ZoneType.Battlefield), ai.getOpponent());
+ List tgtCards = CardLists.filterControlledBy(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), ai.getOpponent());
tgtCards = AbilityFactory.filterListByType(tgtCards, this.params.get("AllValid"), sa);
if (tgtCards.isEmpty()) {
return false;
@@ -650,7 +649,7 @@ public class AbilityFactoryGainControl {
if (null == c) {
return;
}
- if (GameState.isCardInPlay(c)) {
+ if (c.isInPlay()) {
c.removeController(newController);
// Singletons.getModel().getGameAction().changeController(new ArrayList(c),
// c.getController(), originalController);
@@ -908,8 +907,8 @@ public class AbilityFactoryGainControl {
object2 = tgts.get(1);
}
- if (object1 == null || object2 == null || !GameState.isCardInPlay(object1)
- || !GameState.isCardInPlay(object2)) {
+ if (object1 == null || object2 == null || !object1.isInPlay()
+ || !object2.isInPlay()) {
return;
}
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryMana.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryMana.java
index 1f76b13cb77..8b21e629d62 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryMana.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryMana.java
@@ -41,7 +41,6 @@ import forge.card.spellability.Spell;
import forge.card.spellability.SpellAbility;
import forge.card.spellability.Target;
import forge.control.input.InputPayManaCostUtil;
-import forge.game.GameState;
import forge.game.player.ComputerUtil;
import forge.game.player.Player;
import forge.game.zone.ZoneType;
@@ -772,7 +771,7 @@ public class AbilityFactoryMana {
cards.add(c);
}
} else {
- cards = CardLists.getValidCards(GameState.getCardsIn(ZoneType.Battlefield), validCard, abMana.getActivatingPlayer(), card);
+ cards = CardLists.getValidCards(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), validCard, abMana.getActivatingPlayer(), card);
}
// remove anything cards that is already in parents
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryPermanentState.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryPermanentState.java
index 27efc6be2ea..adc0c77ef15 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryPermanentState.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryPermanentState.java
@@ -26,7 +26,6 @@ import java.util.Random;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
-import forge.AllZone;
import forge.Card;
import forge.CardLists;
@@ -41,7 +40,6 @@ import forge.card.spellability.AbilitySub;
import forge.card.spellability.Spell;
import forge.card.spellability.SpellAbility;
import forge.card.spellability.Target;
-import forge.game.GameState;
import forge.game.phase.PhaseHandler;
import forge.game.phase.PhaseType;
import forge.game.player.ComputerUtil;
@@ -476,7 +474,7 @@ public class AbilityFactoryPermanentState {
final Card source = sa.getSourceCard();
final Target tgt = sa.getTarget();
- List list = GameState.getCardsIn(ZoneType.Battlefield);
+ List list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
list = CardLists.getValidCards(list, tgt.getValidTgts(), source.getController(), source);
list = CardLists.getTargetableCards(list, sa);
@@ -606,7 +604,7 @@ public class AbilityFactoryPermanentState {
}
for (final Card tgtC : tgtCards) {
- if (GameState.isCardInPlay(tgtC) && ((tgt == null) || tgtC.canBeTargetedBy(sa))) {
+ if (tgtC.isInPlay() && ((tgt == null) || tgtC.canBeTargetedBy(sa))) {
tgtC.untap();
}
}
@@ -635,7 +633,7 @@ public class AbilityFactoryPermanentState {
for (final Player p : definedPlayers) {
if (p.isHuman()) {
- AllZone.getInputControl().setInput(CardFactoryUtil.inputUntapUpToNType(num, valid));
+ Singletons.getModel().getMatch().getInput().setInput(CardFactoryUtil.inputUntapUpToNType(num, valid));
} else {
List list = p.getCardsIn(ZoneType.Battlefield);
list = CardLists.getType(list, valid);
@@ -1101,7 +1099,7 @@ public class AbilityFactoryPermanentState {
final Card source = sa.getSourceCard();
final Target tgt = sa.getTarget();
- List list = GameState.getCardsIn(ZoneType.Battlefield);
+ List list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
list = CardLists.getValidCards(list, tgt.getValidTgts(), source.getController(), source);
list = CardLists.getTargetableCards(list, sa);
@@ -1230,7 +1228,7 @@ public class AbilityFactoryPermanentState {
}
for (final Card tgtC : tgtCards) {
- if ((GameState.isCardInPlay(tgtC) || params.containsKey("ETB")) && ((tgt == null) || tgtC.canBeTargetedBy(sa))) {
+ if ((tgtC.isInPlay() || params.containsKey("ETB")) && ((tgt == null) || tgtC.canBeTargetedBy(sa))) {
if (tgtC.isUntapped() && (remTapped)) {
card.addRemembered(tgtC);
}
@@ -1421,7 +1419,7 @@ public class AbilityFactoryPermanentState {
}
if ((tgtPlayers == null) || tgtPlayers.isEmpty()) {
- list = GameState.getCardsIn(ZoneType.Battlefield);
+ list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
} else {
list = tgtPlayers.get(0).getCardsIn(ZoneType.Battlefield);
}
@@ -1679,7 +1677,7 @@ public class AbilityFactoryPermanentState {
}
if ((tgtPlayers == null) || tgtPlayers.isEmpty()) {
- cards = GameState.getCardsIn(ZoneType.Battlefield);
+ cards = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
} else {
cards = tgtPlayers.get(0).getCardsIn(ZoneType.Battlefield);
}
@@ -1723,7 +1721,7 @@ public class AbilityFactoryPermanentState {
valid = params.get("ValidCards");
}
- List validTappables = GameState.getCardsIn(ZoneType.Battlefield);
+ List validTappables = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
final Target tgt = sa.getTarget();
@@ -1774,7 +1772,7 @@ public class AbilityFactoryPermanentState {
* @return a {@link forge.CardList} object.
*/
private static List getTapAllTargets(final String valid, final Card source) {
- List tmpList = GameState.getCardsIn(ZoneType.Battlefield);
+ List tmpList = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
tmpList = CardLists.getValidCards(tmpList, valid, source.getController(), source);
tmpList = CardLists.filter(tmpList, Presets.UNTAPPED);
return tmpList;
@@ -2227,7 +2225,7 @@ public class AbilityFactoryPermanentState {
}
for (final Card tgtC : tgtCards) {
- if (GameState.isCardInPlay(tgtC) && ((tgt == null) || tgtC.canBeTargetedBy(sa))) {
+ if (tgtC.isInPlay() && ((tgt == null) || tgtC.canBeTargetedBy(sa))) {
if (sa.getActivatingPlayer().isHuman()) {
final String[] tapOrUntap = new String[] { "Tap", "Untap" };
final Object z = GuiChoose.oneOrNone("Tap or Untap " + tgtC + "?", tapOrUntap);
@@ -2602,7 +2600,7 @@ public class AbilityFactoryPermanentState {
final Card source = sa.getSourceCard();
final Target tgt = sa.getTarget();
- List list = GameState.getCardsIn(ZoneType.Battlefield);
+ List list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
list = CardLists.getTargetableCards(CardLists.getValidCards(list, tgt.getValidTgts(), source.getController(), source), sa);
return false;
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryPlay.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryPlay.java
index 14cdd241d9e..37d41962d66 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryPlay.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryPlay.java
@@ -43,7 +43,6 @@ import forge.card.spellability.Spell;
import forge.card.spellability.SpellAbility;
import forge.card.spellability.SpellAbilityRestriction;
import forge.card.spellability.Target;
-import forge.game.GameState;
import forge.game.player.ComputerUtil;
import forge.game.player.Player;
import forge.game.zone.ZoneType;
@@ -304,7 +303,7 @@ public final class AbilityFactoryPlay {
final Target tgt = sa.getTarget();
if (tgt != null) {
ZoneType zone = tgt.getZone().get(0);
- cards = GameState.getCardsIn(zone);
+ cards = Singletons.getModel().getGameState().getCardsIn(zone);
cards = CardLists.getValidCards(cards, tgt.getValidTgts(), ai, source);
if (cards.isEmpty()) {
return false;
@@ -376,7 +375,7 @@ public final class AbilityFactoryPlay {
if (params.containsKey("ValidZone")) {
zone = ZoneType.smartValueOf(params.get("ValidZone"));
}
- tgtCards = GameState.getCardsIn(zone);
+ tgtCards = Singletons.getModel().getGameState().getCardsIn(zone);
tgtCards = AbilityFactory.filterListByType(tgtCards, params.get("Valid"), sa);
} else if (params.containsKey("Defined")) {
tgtCards = new ArrayList(AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("Defined"), sa));
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryPreventDamage.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryPreventDamage.java
index 77d3c28ea92..fab7ecb8036 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryPreventDamage.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryPreventDamage.java
@@ -35,7 +35,6 @@ import forge.card.spellability.AbilitySub;
import forge.card.spellability.Spell;
import forge.card.spellability.SpellAbility;
import forge.card.spellability.Target;
-import forge.game.GameState;
import forge.game.phase.CombatUtil;
import forge.game.phase.PhaseHandler;
import forge.game.phase.PhaseType;
@@ -457,7 +456,7 @@ public class AbilityFactoryPreventDamage {
final Target tgt = sa.getTarget();
tgt.resetTargets();
// filter AIs battlefield by what I can target
- List targetables = GameState.getCardsIn(ZoneType.Battlefield);
+ List targetables = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
targetables = CardLists.getValidCards(targetables, tgt.getValidTgts(), ai, hostCard);
final List compTargetables = CardLists.filterControlledBy(targetables, ai);
@@ -535,7 +534,7 @@ public class AbilityFactoryPreventDamage {
for (final Object o : tgts) {
if (o instanceof Card) {
final Card c = (Card) o;
- if (GameState.isCardInPlay(c) && (!targeted || c.canBeTargetedBy(sa))) {
+ if (c.isInPlay() && (!targeted || c.canBeTargetedBy(sa))) {
c.addPreventNextDamage(numDam);
}
@@ -548,7 +547,7 @@ public class AbilityFactoryPreventDamage {
}
for (final Card c : untargetedCards) {
- if (GameState.isCardInPlay(c)) {
+ if (c.isInPlay()) {
c.addPreventNextDamage(numDam);
}
}
@@ -787,7 +786,7 @@ public class AbilityFactoryPreventDamage {
}
if (params.containsKey("ValidCards")) {
- list = GameState.getCardsIn(ZoneType.Battlefield);
+ list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
}
list = AbilityFactory.filterListByType(list, params.get("ValidCards"), sa);
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryProtection.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryProtection.java
index 149148ea5cf..350b7d33d46 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryProtection.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryProtection.java
@@ -42,7 +42,6 @@ import forge.card.spellability.AbilitySub;
import forge.card.spellability.Spell;
import forge.card.spellability.SpellAbility;
import forge.card.spellability.Target;
-import forge.game.GameState;
import forge.game.phase.CombatUtil;
import forge.game.phase.PhaseType;
import forge.game.player.ComputerUtil;
@@ -248,7 +247,7 @@ public final class AbilityFactoryProtection {
final Card hostCard = af.getHostCard();
final ArrayList gains = AbilityFactoryProtection.getProtectionList(hostCard, af.getMapParams());
- List list = GameState.getCreaturesInPlay(ai);
+ List list = ai.getCreaturesInPlay();
list = CardLists.filter(list, new Predicate() {
@Override
public boolean apply(final Card c) {
@@ -303,7 +302,7 @@ public final class AbilityFactoryProtection {
final HashMap params = af.getMapParams();
final Card hostCard = af.getHostCard();
// if there is no target and host card isn't in play, don't activate
- if ((sa.getTarget() == null) && !GameState.isCardInPlay(hostCard)) {
+ if ((sa.getTarget() == null) && !hostCard.isInPlay()) {
return false;
}
@@ -469,7 +468,7 @@ public final class AbilityFactoryProtection {
final HashMap params = af.getMapParams();
final Card host = af.getHostCard();
- List list = GameState.getCardsIn(ZoneType.Battlefield);
+ List list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
final Target tgt = sa.getTarget();
list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard());
@@ -744,9 +743,9 @@ public final class AbilityFactoryProtection {
if (params.containsKey("AILogic")) {
final String logic = params.get("AILogic");
if (logic.equals("MostProminentHumanCreatures")) {
- List list = GameState.getCreaturesInPlay(ai.getOpponent());
+ List list = ai.getOpponent().getCreaturesInPlay();
if (list.isEmpty()) {
- list = CardLists.filterControlledBy(GameState.getCardsInGame(), ai.getOpponent());
+ list = CardLists.filterControlledBy(Singletons.getModel().getGameState().getCardsInGame(), ai.getOpponent());
}
if (!list.isEmpty()) {
choice = CardFactoryUtil.getMostProminentColor(list);
@@ -787,7 +786,7 @@ public final class AbilityFactoryProtection {
final Card tgtC = tgtCards.get(j);
// only pump things in play
- if (!GameState.isCardInPlay(tgtC)) {
+ if (!tgtC.isInPlay()) {
continue;
}
@@ -807,7 +806,7 @@ public final class AbilityFactoryProtection {
@Override
public void execute() {
- if (GameState.isCardInPlay(tgtC)) {
+ if (tgtC.isInPlay()) {
for (final String gain : gains) {
tgtC.removeExtrinsicKeyword("Protection from " + gain);
}
@@ -824,7 +823,7 @@ public final class AbilityFactoryProtection {
for (final Card unTgtC : untargetedCards) {
// only pump things in play
- if (!GameState.isCardInPlay(unTgtC)) {
+ if (!unTgtC.isInPlay()) {
continue;
}
@@ -839,7 +838,7 @@ public final class AbilityFactoryProtection {
@Override
public void execute() {
- if (GameState.isCardInPlay(unTgtC)) {
+ if (unTgtC.isInPlay()) {
for (final String gain : gains) {
unTgtC.removeExtrinsicKeyword("Protection from " + gain);
}
@@ -1031,7 +1030,7 @@ public final class AbilityFactoryProtection {
private static boolean protectAllCanPlayAI(final Player ai, final AbilityFactory af, final SpellAbility sa) {
final Card hostCard = af.getHostCard();
// if there is no target and host card isn't in play, don't activate
- if ((sa.getTarget() == null) && !GameState.isCardInPlay(hostCard)) {
+ if ((sa.getTarget() == null) && !hostCard.isInPlay()) {
return false;
}
@@ -1191,11 +1190,11 @@ public final class AbilityFactoryProtection {
valid = params.get("ValidCards");
}
if (!valid.equals("")) {
- List list = GameState.getCardsIn(ZoneType.Battlefield);
+ List list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
list = CardLists.getValidCards(list, valid, sa.getActivatingPlayer(), host);
for (final Card tgtC : list) {
- if (GameState.isCardInPlay(tgtC)) {
+ if (tgtC.isInPlay()) {
for (final String gain : gains) {
tgtC.addExtrinsicKeyword("Protection from " + gain);
}
@@ -1207,7 +1206,7 @@ public final class AbilityFactoryProtection {
@Override
public void execute() {
- if (GameState.isCardInPlay(tgtC)) {
+ if (tgtC.isInPlay()) {
for (final String gain : gains) {
tgtC.removeExtrinsicKeyword("Protection from " + gain);
}
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryPump.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryPump.java
index 5b8e7d106c2..9013e32d368 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryPump.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryPump.java
@@ -30,6 +30,7 @@ import forge.Card;
import forge.CardLists;
import forge.CardPredicates;
+import forge.CardPredicates.Presets;
import forge.CardUtil;
import forge.Command;
import forge.GameActionUtil;
@@ -44,7 +45,6 @@ import forge.card.spellability.Spell;
import forge.card.spellability.SpellAbility;
import forge.card.spellability.SpellAbilityRestriction;
import forge.card.spellability.Target;
-import forge.game.GameState;
import forge.game.phase.Combat;
import forge.game.phase.CombatUtil;
import forge.game.phase.PhaseHandler;
@@ -371,7 +371,7 @@ public class AbilityFactoryPump {
|| card.getNetCombatDamage() <= 0
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)
|| ph.getPhase().isBefore(PhaseType.MAIN1)
- || CardLists.getNotKeyword(GameState.getCreaturesInPlay(ai), "Defender").isEmpty())) {
+ || CardLists.getNotKeyword(ai.getCreaturesInPlay(), "Defender").isEmpty())) {
return false;
}
if (ph.isPlayerTurn(human) && (!card.isAttacking()
@@ -413,7 +413,7 @@ public class AbilityFactoryPump {
}
Predicate opBlockers = CardPredicates.possibleBlockers(card);
- List cardsCanBlock = CardLists.filter(GameState.getCreaturesInPlay(opp), opBlockers);
+ List cardsCanBlock = CardLists.filter(opp.getCreaturesInPlay(), opBlockers);
final boolean evasive = (keyword.endsWith("Unblockable") || keyword.endsWith("Fear")
|| keyword.endsWith("Intimidate") || keyword.endsWith("Shadow"));
@@ -478,7 +478,7 @@ public class AbilityFactoryPump {
}
} else if (ph.isPlayerTurn(ai) && ph.getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS)
&& CombatUtil.canAttack(card)) {
- List blockers = GameState.getCreaturesInPlay(opp);
+ List blockers = opp.getCreaturesInPlay();
for (Card blocker : blockers) {
if (CombatUtil.canBlock(card, blocker, combat)
&& !CombatUtil.canDestroyBlocker(blocker, card, combat, false)) {
@@ -490,7 +490,7 @@ public class AbilityFactoryPump {
} else if (combatRelevant) {
if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card) || card.isAttacking())
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)
- || (GameState.getCreaturesInPlay(opp).size() < 1)
+ || (opp.getCreaturesInPlay().size() < 1)
|| cardsCanBlock.isEmpty()) {
return false;
}
@@ -553,7 +553,7 @@ public class AbilityFactoryPump {
} else if (keyword.equals("Vigilance")) {
if (ph.isPlayerTurn(opp) || !CombatUtil.canAttack(card)
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
- || CardLists.getNotKeyword(GameState.getCreaturesInPlay(opp), "Defender").size() < 1) {
+ || CardLists.getNotKeyword(opp.getCreaturesInPlay(), "Defender").size() < 1) {
return false;
}
} else if (keyword.equals("Reach")) {
@@ -590,7 +590,7 @@ public class AbilityFactoryPump {
if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card) || card.isAttacking())
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)
|| card.getNetCombatDamage() <= 0
- || CardLists.getType(GameState.getPlayerLandsInPlay(opp), "Island").isEmpty()
+ || CardLists.getType(opp.getLandsInPlay(), "Island").isEmpty()
|| cardsCanBlock.isEmpty()) {
return false;
}
@@ -598,7 +598,7 @@ public class AbilityFactoryPump {
if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card) || card.isAttacking())
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)
|| card.getNetCombatDamage() <= 0
- || CardLists.getType(GameState.getPlayerLandsInPlay(opp), "Swamp").isEmpty()
+ || CardLists.getType(opp.getLandsInPlay(), "Swamp").isEmpty()
|| cardsCanBlock.isEmpty()) {
return false;
}
@@ -606,7 +606,7 @@ public class AbilityFactoryPump {
if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card) || card.isAttacking())
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)
|| card.getNetCombatDamage() <= 0
- || CardLists.getType(GameState.getPlayerLandsInPlay(opp), "Mountain").isEmpty()
+ || CardLists.getType(opp.getLandsInPlay(), "Mountain").isEmpty()
|| cardsCanBlock.isEmpty()) {
return false;
}
@@ -614,7 +614,7 @@ public class AbilityFactoryPump {
if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card) || card.isAttacking())
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)
|| card.getNetCombatDamage() <= 0
- || CardLists.getType(GameState.getPlayerLandsInPlay(opp), "Forest").isEmpty()
+ || CardLists.getType(opp.getLandsInPlay(), "Forest").isEmpty()
|| cardsCanBlock.isEmpty()) {
return false;
}
@@ -704,7 +704,7 @@ public class AbilityFactoryPump {
*/
private List getPumpCreatures(final Player ai, final SpellAbility sa) {
- List list = GameState.getCreaturesInPlay(ai);
+ List list = ai.getCreaturesInPlay();
list = CardLists.filter(list, new Predicate() {
@Override
public boolean apply(final Card c) {
@@ -728,7 +728,7 @@ public class AbilityFactoryPump {
* @return a {@link forge.CardList} object.
*/
private List getCurseCreatures(final Player ai, final SpellAbility sa, final int defense, final int attack) {
- List list = GameState.getCreaturesInPlay(ai.getOpponent());
+ List list = ai.getOpponent().getCreaturesInPlay();
list = CardLists.getTargetableCards(list, sa);
if ((defense < 0) && !list.isEmpty()) { // with spells that give -X/-X,
// compi will try to destroy a
@@ -981,7 +981,7 @@ public class AbilityFactoryPump {
List list = new ArrayList();
if (this.abilityFactory.getMapParams().containsKey("AILogic")) {
if (this.abilityFactory.getMapParams().get("AILogic").equals("HighestPower")) {
- list = CardLists.getValidCards(GameState.getCreaturesInPlay(), tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard());
+ list = CardLists.getValidCards(CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), Presets.CREATURES), tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard());
list = CardLists.getTargetableCards(list, sa);
CardLists.sortAttack(list);
if (!list.isEmpty()) {
@@ -1000,7 +1000,7 @@ public class AbilityFactoryPump {
} else {
if (!tgt.canTgtCreature()) {
ZoneType zone = tgt.getZone().get(0);
- list = GameState.getCardsIn(zone);
+ list = Singletons.getModel().getGameState().getCardsIn(zone);
} else {
list = this.getPumpCreatures(ai, sa);
}
@@ -1080,7 +1080,7 @@ public class AbilityFactoryPump {
* @return a boolean.
*/
private boolean pumpMandatoryTarget(final Player ai, final AbilityFactory af, final SpellAbility sa, final boolean mandatory) {
- List list = GameState.getCardsIn(ZoneType.Battlefield);
+ List list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
final Target tgt = sa.getTarget();
final Player opp = ai.getOpponent();
list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard());
@@ -1444,7 +1444,7 @@ public class AbilityFactoryPump {
final Card tgtC = tgtCards.get(j);
// only pump things in PumpZone
- if (!GameState.getCardsIn(pumpZone).contains(tgtC)) {
+ if (!Singletons.getModel().getGameState().getCardsIn(pumpZone).contains(tgtC)) {
continue;
}
@@ -1459,7 +1459,7 @@ public class AbilityFactoryPump {
for (int i = 0; i < untargetedCards.size(); i++) {
final Card tgtC = untargetedCards.get(i);
// only pump things in PumpZone
- if (!GameState.getCardsIn(pumpZone).contains(tgtC)) {
+ if (!Singletons.getModel().getGameState().getCardsIn(pumpZone).contains(tgtC)) {
continue;
}
@@ -1479,7 +1479,7 @@ public class AbilityFactoryPump {
//if host is not on the battlefield don't apply
if (this.params.containsKey("UntilLoseControlOfHost")
- && !GameState.isCardInPlay(sa.getSourceCard())) {
+ && !sa.getSourceCard().isInPlay()) {
return;
}
final int a = this.getNumAttack(sa);
@@ -1858,7 +1858,7 @@ public class AbilityFactoryPump {
list = new ArrayList();
if ((tgtPlayers == null) || tgtPlayers.isEmpty()) {
for (final ZoneType zone : affectedZones) {
- list.addAll(GameState.getCardsIn(zone));
+ list.addAll(Singletons.getModel().getGameState().getCardsIn(zone));
}
} else {
@@ -1906,7 +1906,7 @@ public class AbilityFactoryPump {
@Override
public void execute() {
- if (GameState.isCardInPlay(tgtC)) {
+ if (tgtC.isInPlay()) {
tgtC.addTempAttackBoost(-1 * a);
tgtC.addTempDefenseBoost(-1 * d);
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryRegenerate.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryRegenerate.java
index ad4b7118a32..9f97d9d44ba 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryRegenerate.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryRegenerate.java
@@ -36,7 +36,6 @@ import forge.card.spellability.AbilitySub;
import forge.card.spellability.Spell;
import forge.card.spellability.SpellAbility;
import forge.card.spellability.Target;
-import forge.game.GameState;
import forge.game.phase.CombatUtil;
import forge.game.phase.PhaseType;
import forge.game.player.ComputerUtil;
@@ -424,7 +423,7 @@ public class AbilityFactoryRegenerate {
final Target tgt = sa.getTarget();
tgt.resetTargets();
// filter AIs battlefield by what I can target
- List targetables = GameState.getCardsIn(ZoneType.Battlefield);
+ List targetables = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
targetables = CardLists.getValidCards(targetables, tgt.getValidTgts(), ai, hostCard);
targetables = CardLists.getTargetableCards(targetables, sa);
final List compTargetables = CardLists.filterControlledBy(targetables, ai);
@@ -511,7 +510,7 @@ public class AbilityFactoryRegenerate {
}
};
- if (GameState.isCardInPlay(tgtC) && ((tgt == null) || tgtC.canBeTargetedBy(sa))) {
+ if (tgtC.isInPlay() && ((tgt == null) || tgtC.canBeTargetedBy(sa))) {
tgtC.addShield();
Singletons.getModel().getGameState().getEndOfTurn().addUntil(untilEOT);
}
@@ -739,7 +738,7 @@ public class AbilityFactoryRegenerate {
valid = params.get("ValidCards");
}
- List list = GameState.getCardsIn(ZoneType.Battlefield);
+ List list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
list = CardLists.getValidCards(list, valid.split(","), hostCard.getController(), hostCard);
list = CardLists.filter(list, CardPredicates.isController(ai));
@@ -828,7 +827,7 @@ public class AbilityFactoryRegenerate {
valid = params.get("ValidCards");
}
- List list = GameState.getCardsIn(ZoneType.Battlefield);
+ List list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
list = CardLists.getValidCards(list, valid.split(","), hostCard.getController(), hostCard);
for (final Card c : list) {
@@ -841,7 +840,7 @@ public class AbilityFactoryRegenerate {
}
};
- if (GameState.isCardInPlay(c)) {
+ if (c.isInPlay()) {
c.addShield();
Singletons.getModel().getGameState().getEndOfTurn().addUntil(untilEOT);
}
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryRepeat.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryRepeat.java
index 7a7d439c25f..3733129cdb5 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryRepeat.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryRepeat.java
@@ -23,6 +23,7 @@ import java.util.List;
import forge.Card;
import forge.CardLists;
+import forge.Singletons;
import forge.card.cost.Cost;
import forge.GameActionUtil;
@@ -32,7 +33,6 @@ import forge.card.spellability.AbilitySub;
import forge.card.spellability.Spell;
import forge.card.spellability.SpellAbility;
import forge.card.spellability.Target;
-import forge.game.GameState;
import forge.game.player.Player;
import forge.game.zone.ZoneType;
import forge.util.Expressions;
@@ -279,7 +279,7 @@ public final class AbilityFactoryRepeat {
if (params.containsKey("RepeatDefined")) {
list.addAll(AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("RepeatDefined"), sa));
} else {
- list = GameState.getCardsIn(ZoneType.Battlefield);
+ list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
}
list = CardLists.getValidCards(list, repeatPresent.split(","), sa.getActivatingPlayer(), sa.getSourceCard());
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryReveal.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryReveal.java
index 655ea192d52..d090b0adc9f 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryReveal.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryReveal.java
@@ -42,7 +42,6 @@ import forge.card.spellability.AbilitySub;
import forge.card.spellability.Spell;
import forge.card.spellability.SpellAbility;
import forge.card.spellability.Target;
-import forge.game.GameState;
import forge.game.phase.PhaseType;
import forge.game.player.ComputerUtil;
import forge.game.player.Player;
@@ -669,7 +668,7 @@ public final class AbilityFactoryReveal {
*/
private static List sharesNameWithCardOnBattlefield(final List list) {
final List toReturn = new ArrayList();
- final List play = GameState.getCardsIn(ZoneType.Battlefield);
+ final List play = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
for (final Card c : list) {
for (final Card p : play) {
if (p.getName().equals(c.getName()) && !toReturn.contains(c)) {
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactorySacrifice.java b/src/main/java/forge/card/abilityfactory/AbilityFactorySacrifice.java
index 1aba2e396df..30536ac5a48 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactorySacrifice.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactorySacrifice.java
@@ -35,7 +35,6 @@ import forge.card.spellability.AbilitySub;
import forge.card.spellability.Spell;
import forge.card.spellability.SpellAbility;
import forge.card.spellability.Target;
-import forge.game.GameState;
import forge.game.player.ComputerUtil;
import forge.game.player.Player;
import forge.game.zone.ZoneType;
@@ -495,7 +494,7 @@ public class AbilityFactorySacrifice {
final boolean remSacrificed = params.containsKey("RememberSacrificed");
if (valid.equals("Self")) {
- if (GameState.getZoneOf(card).is(ZoneType.Battlefield)) {
+ if (Singletons.getModel().getGameState().getZoneOf(card).is(ZoneType.Battlefield)) {
if (Singletons.getModel().getGameAction().sacrifice(card, sa) && remSacrificed) {
card.addRemembered(card);
}
@@ -934,7 +933,7 @@ public class AbilityFactorySacrifice {
if (params.containsKey("Defined")) {
list = new ArrayList(AbilityFactory.getDefinedCards(af.getHostCard(), params.get("Defined"), sa));
} else {
- list = GameState.getCardsIn(ZoneType.Battlefield);
+ list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
}
final boolean remSacrificed = params.containsKey("RememberSacrificed");
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactorySetState.java b/src/main/java/forge/card/abilityfactory/AbilityFactorySetState.java
index 984f0a2cc1f..4dbae8291f5 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactorySetState.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactorySetState.java
@@ -25,6 +25,7 @@ import java.util.Map;
import forge.Card;
import forge.CardCharacteristicName;
+import forge.Singletons;
import forge.CardLists;
import forge.card.spellability.AbilityActivated;
@@ -34,7 +35,6 @@ import forge.card.spellability.SpellAbility;
import forge.card.spellability.Target;
import forge.card.cardfactory.CardFactoryUtil;
import forge.card.cost.Cost;
-import forge.game.GameState;
import forge.game.player.Player;
import forge.game.zone.ZoneType;
@@ -471,7 +471,7 @@ public class AbilityFactorySetState {
valid = valid.replace("X", Integer.toString(AbilityFactory.calculateAmount(card, "X", sa)));
}
- List list = GameState.getCardsIn(ZoneType.Battlefield);
+ List list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
if (targetPlayer != null) {
list = CardLists.filterControlledBy(list, targetPlayer);
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryToken.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryToken.java
index e2cce2d437e..c8316c8900e 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryToken.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryToken.java
@@ -35,7 +35,6 @@ import forge.card.spellability.SpellAbility;
import forge.card.spellability.Target;
import forge.card.trigger.Trigger;
import forge.card.trigger.TriggerHandler;
-import forge.game.GameState;
import forge.game.phase.PhaseHandler;
import forge.game.phase.PhaseType;
import forge.game.player.ComputerUtil;
@@ -640,10 +639,10 @@ public class AbilityFactoryToken extends AbilityFactory {
Singletons.getModel().getGameState().getCombat().addAttacker(c);
}
if (remember != null) {
- GameState.getCardState(sa.getSourceCard()).addRemembered(c);
+ Singletons.getModel().getGameState().getCardState(sa.getSourceCard()).addRemembered(c);
}
if (this.abilityFactory.getMapParams().get("RememberSource") != null) {
- GameState.getCardState(c).addRemembered(host);
+ Singletons.getModel().getGameState().getCardState(c).addRemembered(host);
}
}
}
diff --git a/src/main/java/forge/card/cardfactory/CardFactoryArtifacts.java b/src/main/java/forge/card/cardfactory/CardFactoryArtifacts.java
index 57540f77bc7..3dc776e6364 100644
--- a/src/main/java/forge/card/cardfactory/CardFactoryArtifacts.java
+++ b/src/main/java/forge/card/cardfactory/CardFactoryArtifacts.java
@@ -5,7 +5,6 @@ import java.util.List;
import javax.swing.JOptionPane;
-import forge.AllZone;
import forge.Card;
import forge.Command;
@@ -17,7 +16,6 @@ import forge.card.spellability.AbilityActivated;
import forge.card.spellability.SpellAbility;
import forge.card.spellability.Target;
import forge.control.input.Input;
-import forge.game.GameState;
import forge.game.player.ComputerUtil;
import forge.game.player.Player;
import forge.game.zone.PlayerZone;
@@ -212,7 +210,7 @@ class CardFactoryArtifacts {
}
if (this.getTargetCard() != null) {
- if (GameState.isCardInPlay(this.getTargetCard())
+ if (this.getTargetCard().isInPlay()
&& this.getTargetCard().canBeTargetedBy(this)) {
this.getTargetCard().addDamage(damage, card);
}
@@ -370,7 +368,7 @@ class CardFactoryArtifacts {
public void resolve() {
// not implemented for compy
if (card.getController().isHuman()) {
- AllZone.getInputControl().setInput(new Input() {
+ Singletons.getModel().getMatch().getInput().setInput(new Input() {
private static final long serialVersionUID = -2305549394512889450L;
private final List exiled = new ArrayList();
diff --git a/src/main/java/forge/card/cardfactory/CardFactoryAuras.java b/src/main/java/forge/card/cardfactory/CardFactoryAuras.java
index ee2eccb42fe..d733439cbe8 100644
--- a/src/main/java/forge/card/cardfactory/CardFactoryAuras.java
+++ b/src/main/java/forge/card/cardfactory/CardFactoryAuras.java
@@ -40,7 +40,6 @@ import forge.card.spellability.SpellAbility;
import forge.card.spellability.SpellPermanent;
import forge.card.spellability.Target;
import forge.control.input.Input;
-import forge.game.GameState;
import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
@@ -87,7 +86,7 @@ class CardFactoryAuras {
final Player opp = getActivatingPlayer().getOpponent();
final String[] landTypes = new String[] { "Plains", "Island", "Swamp", "Mountain", "Forest" };
final HashMap humanLandCount = new HashMap();
- final List