1. MatchController contains inputControl, subscribes listeners to event by itself

2. most of AllZone methods static moved into instances, consider retrieving frequently used values into class fields or local variables
This commit is contained in:
Maxmtg
2012-10-19 22:39:09 +00:00
parent 9ed4b92dc7
commit c92faa2d87
98 changed files with 780 additions and 1135 deletions

View File

@@ -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 <code>cardFactory</code>. */
private static CardFactoryInterface cardFactory = null;
/** Constant <code>inputControl</code>. */
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;
}
/**
* <p>
* getInputControl.
* </p>
*
* @return a {@link forge.control.input.InputControl} object.
* @since 1.0.15
*/
public static InputControl getInputControl() {
return AllZone.inputControl;
}
/** @param i0 &emsp; {@link forge.control.input.InputControl} */
public static void setInputControl(InputControl i0) {
AllZone.inputControl = i0;
}
/**
* Create and return the next timestamp.
*

View File

@@ -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<Card> {
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<Card> {
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<Card> {
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<Card> {
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<Card> {
}
} 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<Card> {
}
} 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<Card> {
return false;
}
} else if (restriction.equals(ZoneType.Battlefield.toString())) {
final List<Card> list = GameState.getCardsIn(ZoneType.Battlefield);
final List<Card> 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<Card> {
return false;
}
} else if (property.startsWith("greatestPower")) {
final List<Card> list = GameState.getCreaturesInPlay();
final List<Card> 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<Card> list = GameState.getCreaturesInPlay();
final List<Card> 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<Card> list = GameState.getCreaturesInPlay();
final List<Card> 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<Card> list = GameState.getCardsIn(ZoneType.Battlefield);
final List<Card> 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<Card> {
}
}
} 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<Card> {
return false;
}
} else if (property.startsWith("OnBattlefield")) {
final List<Card> list = GameState.getCardsIn(ZoneType.Battlefield);
final List<Card> list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
if (!list.contains(this)) {
return false;
}
@@ -7952,7 +7952,7 @@ public class Card extends GameEntity implements Comparable<Card> {
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<Card> {
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<Card> {
@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<Card> {
}
// Prevent Damage static abilities
final List<Card> allp = GameState.getCardsIn(ZoneType.Battlefield);
final List<Card> allp = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
for (final Card ca : allp) {
final ArrayList<StaticAbility> staticAbilities = ca.getStaticAbilities();
for (final StaticAbility stAb : staticAbilities) {
@@ -8112,7 +8112,7 @@ public class Card extends GameEntity implements Comparable<Card> {
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<Card> {
@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<Card> {
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<Card> {
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<Card> {
* @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<Card> {
}
// CantTarget static abilities
final List<Card> allp = GameState.getCardsIn(ZoneType.Battlefield);
final List<Card> allp = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
for (final Card ca : allp) {
final ArrayList<StaticAbility> staticAbilities = ca.getStaticAbilities();
for (final StaticAbility stAb : staticAbilities) {
@@ -9078,4 +9078,11 @@ public class Card extends GameEntity implements Comparable<Card> {
this.startsGameInPlay = startsGameInPlay;
}
public boolean isInPlay() {
if (getController() == null) {
return false;
}
return getController().getCardsIn(ZoneType.Battlefield).contains(this);
}
} // end Card class

View File

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

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
package forge;
/**
* <p>
* CommandReturn interface.
* </p>
*
* @author Forge
* @version $Id$
*/
public interface CommandReturn {
/**
* <p>
* execute.
* </p>
*
* @return a {@link java.lang.Object} object.
*/
Object execute();
}

View File

@@ -76,8 +76,14 @@ public class GameAction {
* resetActivationsPerTurn.
* </p>
*/
private final GameState game;
public GameAction(GameState game0) {
game = game0;
}
public final void resetActivationsPerTurn() {
final List<Card> all = GameState.getCardsInGame();
final List<Card> 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<Card> equipments = new ArrayList<Card>(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<Card> equipments = new ArrayList<Card>(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<String, Object> runParams = new HashMap<String, Object>();
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<Card> allCards = GameState.getCardsInGame();
final List<Card> allCards = game.getCardsInGame();
final ArrayList<StaticAbility> staticAbilities = new ArrayList<StaticAbility>();
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<String, Object> runParams = new HashMap<String, Object>();
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<Card> equipments = new ArrayList<Card>(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<Card> list = CardLists.filter(GameState.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.PLANEWALKERS);
final List<Card> 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 {
* </p>
*/
private void destroyLegendaryCreatures() {
final List<Card> a = CardLists.getType(GameState.getCardsIn(ZoneType.Battlefield), "Legendary");
if (a.isEmpty() || GameState.isCardInPlay("Mirror Gallery")) {
final List<Card> a = CardLists.getType(game.getCardsIn(ZoneType.Battlefield), "Legendary");
if (a.isEmpty() || game.isCardInPlay("Mirror Gallery")) {
return;
}
while (!a.isEmpty()) {
List<Card> b = GameState.getCardsIn(ZoneType.Battlefield, a.get(0).getName());
List<Card> b = CardLists.filter(game.getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals(a.get(0).getName()));
b = CardLists.getType(b, "Legendary");
b = CardLists.filter(b, new Predicate<Card>() {
@Override
@@ -1285,7 +1291,7 @@ public class GameAction {
// Run triggers
final HashMap<String, Object> runParams = new HashMap<String, Object>();
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<SpellAbility> abilities = c.getSpellAbilities();
final ArrayList<String> choices = new ArrayList<String>();
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<Card> cardsOnBattlefield = GameState.getCardsIn(ZoneType.Battlefield);
List<Card> cardsOnBattlefield = game.getCardsIn(ZoneType.Battlefield);
cardsOnBattlefield.add(originalCard);
final ArrayList<StaticAbility> raiseAbilities = new ArrayList<StaticAbility>();
final ArrayList<StaticAbility> reduceAbilities = new ArrayList<StaticAbility>();
@@ -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());
}
}
}

View File

@@ -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<Card> maelstromNexii = GameState.getCardsIn(ZoneType.Battlefield, "Maelstrom Nexus");
final List<Card> 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<String> 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<Card> lands = GameState.getCardsInGame();
List<Card> 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<Card> 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<Card> 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<Card> alphaStatuses = GameState.getCardsIn(ZoneType.Battlefield, "Alpha Status");
final List<Card> alphaStatuses = CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Alpha Status"));
final List<Card> allCreatures = GameState.getCreaturesInPlay();
final List<Card> 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<Card> cards = GameState.getCardsIn(ZoneType.Battlefield, "Umbra Stalker");
final List<Card> 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<Card> grave = player.getCardsIn(ZoneType.Graveyard);
@@ -1134,7 +1133,7 @@ public final class GameActionUtil {
@Override
public void execute() {
List<Card> list = GameState.getCardsIn(ZoneType.Battlefield);
List<Card> list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
list = CardLists.filter(list, new Predicate<Card>() {
@Override
@@ -1157,7 +1156,7 @@ public final class GameActionUtil {
@Override
public void execute() {
final List<Card> list = GameState.getCardsIn(ZoneType.Battlefield, "Old Man of the Sea");
final List<Card> 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<Card> list = GameState.getCardsIn(ZoneType.Battlefield, "Liu Bei, Lord of Shu");
final List<Card> 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<Card> list = GameState.getCardsIn(ZoneType.Battlefield);
List<Card> list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
list = CardLists.filter(list, new Predicate<Card>() {
@Override
public boolean apply(final Card c) {
@@ -1235,7 +1234,7 @@ public final class GameActionUtil {
}
private int countSoundTheCalls() {
List<Card> list = GameState.getCardsIn(ZoneType.Graveyard, "Sound the Call");
List<Card> 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<Card> list = GameState.getCardsIn(ZoneType.Battlefield, "Tarmogoyf");
final List<Card> 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<Card> list = GameState.getCardsIn(ZoneType.Graveyard);
final List<Card> 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<Card> lands = GameState.getPlayerLandsInPlay(p);
List<Card> lands = p.getLandsInPlay();
lands = CardLists.filter(lands, new Predicate<Card>() {
@Override
public boolean apply(final Card c) {

View File

@@ -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<Card> cards = GameState.getCardsIn(ZoneType.Battlefield);
final List<Card> cards = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
Log.debug("== Start add state effects ==");
for (int i = 0; i < cards.size(); i++) {

View File

@@ -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<Card> list = new ArrayList<Card>();
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<Card> list = new ArrayList<Card>();
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<Card>) 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<Card>) 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())) {

View File

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

View File

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

View File

@@ -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<Card> list = GameState.getCardsIn(tgt.getZone());
List<Card> 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<Card> list = GameState.getCardsIn(tgt.getZone());
List<Card> 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<Card> unattachList = GameState.getCardsIn(ZoneType.Battlefield);
List<Card> 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);

View File

@@ -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<Card> cards = GameState.getCardsIn(ZoneType.Battlefield);
List<Card> cards = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
cards = AbilityFactory.filterListByType(cards, params.get("ValidCards"), sa);
if (cards.isEmpty()) {
return;

View File

@@ -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<Card> 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<Card> attackers = GameState.getCreaturesInPlay(ai.getOpponent());
List<Card> 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<Card> list = GameState.getCardsIn(origin);
List<Card> 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<Card> list = GameState.getCardsIn(origin);
List<Card> 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<Card> 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);
}
}

View File

@@ -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<String> prominence = CardFactoryUtil.getColorByProminence(CardLists.filterControlledBy(GameState.getCardsInGame(), ai));
List<String> 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<Card> list = GameState.getCreaturesInPlay(opp);
List<Card> 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<Card> list = GameState.getCardsIn(ZoneType.Battlefield);
final List<Card> 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<Card> list = CardLists.filterControlledBy(GameState.getCardsInGame(), p.getOpponent());
List<Card> 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<Card> choices = GameState.getCardsIn(choiceZone);
List<Card> 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<Card> choices = GameState.getCardsIn(choiceZone);
List<Card> 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<Card> land = GameState.getLandsInPlay();
final List<Card> land = Singletons.getModel().getGameState().getLandsInPlay();
final ArrayList<String> basic = CardUtil.getBasicTypes();
for (final String type : basic) {

View File

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

View File

@@ -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<Card> list = GameState.getCardsIn(ZoneType.Battlefield);
List<Card> 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.

View File

@@ -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<Card> unchosen = GameState.getCardsIn(ZoneType.Battlefield);
AllZone.getInputControl().setInput(new Input() {
final List<Card> 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<Card> cardsToProliferate = CardLists.filter(GameState.getCardsIn(ZoneType.Battlefield), predProliferate);
List<Card> cardsToProliferate = CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), predProliferate);
List<Player> playersToPoison = new ArrayList<Player>();
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<Card> cards = GameState.getCardsIn(zone);
List<Card> 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<Card> cards = GameState.getCardsIn(zone);
List<Card> cards = Singletons.getModel().getGameState().getCardsIn(zone);
cards = CardLists.getValidCards(cards, valid, sa.getSourceCard().getController(), sa.getSourceCard());
final Target tgt = sa.getTarget();

View File

@@ -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<String, String> params = af.getMapParams();
final Card card = sa.getSourceCard();
List<Card> sources = GameState.getCardsIn(ZoneType.Battlefield);
List<Card> 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<Card> aiCreatures = GameState.getCreaturesInPlay(ai);
List<Card> aiCreatures = ai.getCreaturesInPlay();
aiCreatures = CardLists.getTargetableCards(aiCreatures, sa);
aiCreatures = CardLists.filter(aiCreatures, new Predicate<Card>() {
@Override
@@ -1916,7 +1915,7 @@ public class AbilityFactoryDealDamage {
}
});
List<Card> humCreatures = GameState.getCreaturesInPlay(ai.getOpponent());
List<Card> 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;
}

View File

@@ -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<Card> getCurseCreatures(final Player ai, final AbilityFactory af, final SpellAbility sa,
final ArrayList<String> kws) {
final Player opp = ai.getOpponent();
List<Card> list = GameState.getCreaturesInPlay(opp);
List<Card> 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<Card> list = GameState.getCardsIn(ZoneType.Battlefield);
List<Card> 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<String> hadIntrinsic = new ArrayList<String>();
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<Card> list = GameState.getCardsIn(ZoneType.Battlefield);
List<Card> list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
list = CardLists.getValidCards(list, valid.split(","), hostCard.getController(), hostCard);
for (final Card tgtC : list) {
final ArrayList<String> hadIntrinsic = new ArrayList<String>();
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);
}

View File

@@ -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<Card> 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<Card> list = GameState.getCardsIn(ZoneType.Battlefield);
List<Card> list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
if (targetPlayer != null) {
list = CardLists.filterControlledBy(list, targetPlayer);

View File

@@ -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<Card> comp = GameState.getCreaturesInPlay(ai);
List<Card> human = GameState.getCreaturesInPlay(ai.getOpponent());
List<Card> comp = ai.getCreaturesInPlay();
List<Card> human = ai.getOpponent().getCreaturesInPlay();
// only count creatures that can attack or block
comp = CardLists.filter(comp, new Predicate<Card>() {
@@ -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

View File

@@ -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<Card> tgtCards = CardLists.filterControlledBy(GameState.getCardsIn(ZoneType.Battlefield), ai.getOpponent());
List<Card> 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<Card>(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;
}

View File

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

View File

@@ -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<Card> list = GameState.getCardsIn(ZoneType.Battlefield);
List<Card> 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<Card> 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<Card> list = GameState.getCardsIn(ZoneType.Battlefield);
List<Card> 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<Card> validTappables = GameState.getCardsIn(ZoneType.Battlefield);
List<Card> 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<Card> getTapAllTargets(final String valid, final Card source) {
List<Card> tmpList = GameState.getCardsIn(ZoneType.Battlefield);
List<Card> 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<Card> list = GameState.getCardsIn(ZoneType.Battlefield);
List<Card> list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
list = CardLists.getTargetableCards(CardLists.getValidCards(list, tgt.getValidTgts(), source.getController(), source), sa);
return false;

View File

@@ -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<Card>(AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("Defined"), sa));

View File

@@ -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<Card> targetables = GameState.getCardsIn(ZoneType.Battlefield);
List<Card> targetables = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
targetables = CardLists.getValidCards(targetables, tgt.getValidTgts(), ai, hostCard);
final List<Card> 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);

View File

@@ -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<String> gains = AbilityFactoryProtection.getProtectionList(hostCard, af.getMapParams());
List<Card> list = GameState.getCreaturesInPlay(ai);
List<Card> list = ai.getCreaturesInPlay();
list = CardLists.filter(list, new Predicate<Card>() {
@Override
public boolean apply(final Card c) {
@@ -303,7 +302,7 @@ public final class AbilityFactoryProtection {
final HashMap<String, String> 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<String, String> params = af.getMapParams();
final Card host = af.getHostCard();
List<Card> list = GameState.getCardsIn(ZoneType.Battlefield);
List<Card> 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<Card> list = GameState.getCreaturesInPlay(ai.getOpponent());
List<Card> 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<Card> list = GameState.getCardsIn(ZoneType.Battlefield);
List<Card> 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);
}

View File

@@ -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<Card> opBlockers = CardPredicates.possibleBlockers(card);
List<Card> cardsCanBlock = CardLists.filter(GameState.getCreaturesInPlay(opp), opBlockers);
List<Card> 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<Card> blockers = GameState.getCreaturesInPlay(opp);
List<Card> 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<Card> getPumpCreatures(final Player ai, final SpellAbility sa) {
List<Card> list = GameState.getCreaturesInPlay(ai);
List<Card> list = ai.getCreaturesInPlay();
list = CardLists.filter(list, new Predicate<Card>() {
@Override
public boolean apply(final Card c) {
@@ -728,7 +728,7 @@ public class AbilityFactoryPump {
* @return a {@link forge.CardList} object.
*/
private List<Card> getCurseCreatures(final Player ai, final SpellAbility sa, final int defense, final int attack) {
List<Card> list = GameState.getCreaturesInPlay(ai.getOpponent());
List<Card> 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<Card> list = new ArrayList<Card>();
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<Card> list = GameState.getCardsIn(ZoneType.Battlefield);
List<Card> 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<Card>();
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);

View File

@@ -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<Card> targetables = GameState.getCardsIn(ZoneType.Battlefield);
List<Card> targetables = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
targetables = CardLists.getValidCards(targetables, tgt.getValidTgts(), ai, hostCard);
targetables = CardLists.getTargetableCards(targetables, sa);
final List<Card> 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<Card> list = GameState.getCardsIn(ZoneType.Battlefield);
List<Card> 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<Card> list = GameState.getCardsIn(ZoneType.Battlefield);
List<Card> 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);
}

View File

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

View File

@@ -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<Card> sharesNameWithCardOnBattlefield(final List<Card> list) {
final List<Card> toReturn = new ArrayList<Card>();
final List<Card> play = GameState.getCardsIn(ZoneType.Battlefield);
final List<Card> 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)) {

View File

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

View File

@@ -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<Card> list = GameState.getCardsIn(ZoneType.Battlefield);
List<Card> list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
if (targetPlayer != null) {
list = CardLists.filterControlledBy(list, targetPlayer);

View File

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

View File

@@ -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<Card> exiled = new ArrayList<Card>();

View File

@@ -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<String, Integer> humanLandCount = new HashMap<String, Integer>();
final List<Card> humanlands = GameState.getPlayerLandsInPlay(opp);
final List<Card> humanlands = opp.getLandsInPlay();
for (final String landType : landTypes) {
humanLandCount.put(landType, 0);
@@ -115,7 +114,7 @@ class CardFactoryAuras {
}
newType[0] = landTypes[minAt];
List<Card> list = GameState.getPlayerLandsInPlay(opp);
List<Card> list = opp.getLandsInPlay();
list = CardLists.getNotType(list, newType[0]); // Don't enchant lands
// that already have the
// type
@@ -136,7 +135,7 @@ class CardFactoryAuras {
final Card c = this.getTargetCard();
if (GameState.isCardInPlay(c) && c.canBeTargetedBy(this)) {
if (c.isInPlay() && c.canBeTargetedBy(this)) {
card.enchantEntity(c);
}
@@ -250,7 +249,7 @@ class CardFactoryAuras {
@Override
public void showMessage() {
final List<Card> land = GameState.getLandsInPlay();
final List<Card> land = Singletons.getModel().getGameState().getLandsInPlay();
this.stopSetNext(CardFactoryUtil
.inputTargetSpecific(spell, land, "Select target land", true, false));
}
@@ -268,7 +267,7 @@ class CardFactoryAuras {
@Override
public boolean canPlayAI() {
List<Card> list = GameState.getCreaturesInPlay(getActivatingPlayer().getOpponent());
List<Card> list = getActivatingPlayer().getOpponent().getCreaturesInPlay();
list = CardLists.getKeyword(list, "Flying");
if (list.isEmpty()) {
return false;
@@ -300,7 +299,7 @@ class CardFactoryAuras {
final Card c = this.getTargetCard();
if (GameState.isCardInPlay(c) && c.canBeTargetedBy(this)) {
if (c.isInPlay() && c.canBeTargetedBy(this)) {
card.enchantEntity(c);
Log.debug("Enchanted: " + this.getTargetCard());
}
@@ -378,7 +377,7 @@ class CardFactoryAuras {
this.setTargetCard(stuffy.get(0));
return true;
} else {
final List<Card> list = GameState.getCreaturesInPlay(getActivatingPlayer().getOpponent());
final List<Card> list = getActivatingPlayer().getOpponent().getCreaturesInPlay();
if (list.isEmpty()) {
return false;
@@ -407,7 +406,7 @@ class CardFactoryAuras {
final Card c = this.getTargetCard();
if (GameState.isCardInPlay(c) && c.canBeTargetedBy(this)) {
if (c.isInPlay() && c.canBeTargetedBy(this)) {
aura.enchantEntity(c);
}
} // resolve()
@@ -427,7 +426,7 @@ class CardFactoryAuras {
// This includes creatures Animate Dead can't enchant once
// in play.
// The human may try to Animate them, the AI will not.
return CardLists.filter(GameState.getCardsIn(ZoneType.Graveyard), Presets.CREATURES);
return CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Graveyard), Presets.CREATURES);
}
@Override
@@ -481,7 +480,7 @@ class CardFactoryAuras {
}
final Card animated = targetC[0];
final PlayerZone grave = GameState.getZoneOf(animated);
final PlayerZone grave = Singletons.getModel().getGameState().getZoneOf(animated);
if (!grave.is(ZoneType.Graveyard)) {
// Animated Creature got removed before ability resolved

View File

@@ -52,7 +52,6 @@ import forge.card.spellability.Target;
import forge.card.trigger.Trigger;
import forge.card.trigger.TriggerHandler;
import forge.control.input.Input;
import forge.game.GameState;
import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
@@ -103,7 +102,7 @@ public class CardFactoryCreatures {
if (c.sumAllCounters() == 0) {
return;
} else if (GameState.isCardInPlay(c) && c.canBeTargetedBy(this)) {
} else if (c.isInPlay() && c.canBeTargetedBy(this)) {
// zerker clean up:
for (final Counters c1 : Counters.values()) {
if (c.getCounters(c1) > 0) {
@@ -199,7 +198,7 @@ public class CardFactoryCreatures {
@Override
public boolean canPlayAI() {
return Iterables.any(getActivatingPlayer().getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.ARTIFACTS)
&& GameState.getZoneOf(this.getSourceCard()).is(ZoneType.Hand);
&& Singletons.getModel().getGameState().getZoneOf(this.getSourceCard()).is(ZoneType.Hand);
}
});
card.addComesIntoPlayCommand(intoPlay);
@@ -276,7 +275,7 @@ public class CardFactoryCreatures {
@Override
public void execute() {
if (GameState.isCardInPlay(card)) {
if (card.isInPlay()) {
Singletons.getModel().getGameAction().sacrifice(card, null);
}
}
@@ -304,7 +303,7 @@ public class CardFactoryCreatures {
@Override
public void execute() {
final List<Card> list = GameState.getCardsIn(ZoneType.Battlefield, "Stangg Twin");
final List<Card> list = CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Stangg Twin"));
if (list.size() == 1) {
Singletons.getModel().getGameAction().exile(list.get(0));
@@ -330,7 +329,7 @@ public class CardFactoryCreatures {
@Override
public void resolve() {
List<Card> allTokens = GameState.getCreaturesInPlay(card.getController());
List<Card> allTokens = card.getController().getCreaturesInPlay();
allTokens = CardLists.filter(allTokens, Presets.TOKEN);
CardFactoryUtil.copyTokens(allTokens);
@@ -338,7 +337,7 @@ public class CardFactoryCreatures {
@Override
public boolean canPlayAI() {
List<Card> allTokens = GameState.getCreaturesInPlay(getActivatingPlayer());
List<Card> allTokens = getActivatingPlayer().getCreaturesInPlay();
allTokens = CardLists.filter(allTokens, Presets.TOKEN);
return allTokens.size() >= 2;
@@ -451,7 +450,7 @@ public class CardFactoryCreatures {
return;
}
if (!(target.canBeTargetedBy(this) && GameState.isCardInPlay(target))) {
if (!(target.canBeTargetedBy(this) && target.isInPlay())) {
return;
}
@@ -463,7 +462,7 @@ public class CardFactoryCreatures {
if (target.getController().isHuman()) { // Human choose
// spread damage
for (int x = 0; x < target.getNetAttack(); x++) {
AllZone.getInputControl().setInput(
Singletons.getModel().getMatch().getInput().setInput(
CardFactoryUtil.masterOfTheWildHuntInputTargetCreature(this, wolves, new Command() {
private static final long serialVersionUID = -328305150127775L;
@@ -890,7 +889,7 @@ public class CardFactoryCreatures {
if (p.canBeTargetedBy(this)) {
p.setSkipNextUntap(true);
for (final Card c : targetPerms) {
if (GameState.isCardInPlay(c) && c.canBeTargetedBy(this)) {
if (c.isInPlay() && c.canBeTargetedBy(this)) {
c.tap();
}
}
@@ -978,9 +977,9 @@ public class CardFactoryCreatures {
final Player player = card.getController();
if (player.isHuman()) {
AllZone.getInputControl().setInput(playerInput);
Singletons.getModel().getMatch().getInput().setInput(playerInput);
} else {
List<Card> list = GameState.getCreaturesInPlay(player.getOpponent());
List<Card> list = player.getOpponent().getCreaturesInPlay();
list = CardLists.getTargetableCards(list, ability);
if ( !list.isEmpty() )
{
@@ -1046,7 +1045,7 @@ public class CardFactoryCreatures {
this.stop();
}
}; // Input
AllZone.getInputControl().setInput(target);
Singletons.getModel().getMatch().getInput().setInput(target);
}
} // end resolve

View File

@@ -4,7 +4,6 @@ import java.util.List;
import com.google.common.collect.Iterables;
import forge.AllZone;
import forge.Card;
import forge.CardLists;
@@ -18,7 +17,6 @@ import forge.card.trigger.Trigger;
import forge.card.trigger.TriggerHandler;
import forge.control.input.Input;
import forge.game.GameLossReason;
import forge.game.GameState;
import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
@@ -160,8 +158,8 @@ class CardFactoryEnchantments {
@Override
public boolean canPlayAI() {
final List<Card> compCreats = GameState.getCreaturesInPlay(getActivatingPlayer());
final List<Card> humCreats = GameState.getCreaturesInPlay(getActivatingPlayer().getOpponent());
final List<Card> compCreats = getActivatingPlayer().getCreaturesInPlay();
final List<Card> humCreats = getActivatingPlayer().getOpponent().getCreaturesInPlay();
// only play standstill if comp controls more creatures than
// human
@@ -247,7 +245,7 @@ class CardFactoryEnchantments {
sb.append(card).append(" - Select a card drawn this turn: ").append(numPutBack - i)
.append(" of " + numPutBack);
final String prompt = sb.toString();
AllZone.getInputControl().setInput(new Input() {
Singletons.getModel().getMatch().getInput().setInput(new Input() {
private static final long serialVersionUID = -3389565833121544797L;
@Override

View File

@@ -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.PhaseUtil;
import forge.game.player.ComputerUtil;
import forge.game.player.Player;
@@ -91,7 +90,7 @@ public class CardFactoryInstants {
@Override
public void resolve() {
Player player = getTargetPlayer();
List<Card> artifacts = GameState.getCardsIn(ZoneType.Battlefield);
List<Card> artifacts = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
artifacts = CardLists.filter(artifacts, CardPredicates.Presets.ARTIFACTS);
for (int i = 0; i < artifacts.size(); i++) {
@@ -303,7 +302,7 @@ public class CardFactoryInstants {
// the siren flag
final Player player = card.getController();
final Player opponent = player.getOpponent();
final List<Card> creatures = GameState.getCreaturesInPlay(opponent);
final List<Card> creatures = opponent.getCreaturesInPlay();
for (final Card creature : creatures) {
// skip walls, skip creatures with summoning sickness
// also skip creatures with haste if they came onto the
@@ -319,7 +318,7 @@ public class CardFactoryInstants {
public void resolve() {
final Player player = card.getController();
final Player opponent = player.getOpponent();
final List<Card> creatures = GameState.getCreaturesInPlay(opponent);
final List<Card> creatures = opponent.getCreaturesInPlay();
for (final Card creature : creatures) {
// System.out.println("Siren's Call - EOT - "+creature.getName()
@@ -327,7 +326,7 @@ public class CardFactoryInstants {
// System.out.println("Siren's Call - EOT - "+creature.getName()
// +" attacked?: "+creature.getCreatureAttackedThisCombat());
if (creature.getSirenAttackOrDestroy() && !creature.getDamageHistory().getCreatureAttackedThisTurn()) {
if (GameState.isCardInPlay(creature)) {
if (creature.isInPlay()) {
// System.out.println("Siren's Call - destroying "+creature.getName());
// this should probably go on the stack
Singletons.getModel().getGameAction().destroy(creature);
@@ -416,7 +415,7 @@ public class CardFactoryInstants {
@Override
public void resolve() {
final Player you = card.getController();
final List<Card> ens = CardLists.filter(GameState.getCardsIn(ZoneType.Battlefield), Presets.ENCHANTMENTS);
final List<Card> ens = CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), Presets.ENCHANTMENTS);
final List<Card> toReturn = CardLists.filter(ens, new Predicate<Card>() {
@Override
public boolean apply(final Card c) {
@@ -520,7 +519,7 @@ public class CardFactoryInstants {
public void resolve() {
final Card myc = this.getParent().getTargetCard();
final Card tgt = this.getTargetCard();
if (GameState.isCardInPlay(myc) && GameState.isCardInPlay(tgt)) {
if (myc.isInPlay() && tgt.isInPlay()) {
if (myc.canBeTargetedBy(this) && tgt.canBeTargetedBy(this)) {
tgt.addDamage(myc.getNetAttack(), myc);
}

View File

@@ -24,7 +24,6 @@ import javax.swing.JOptionPane;
import com.google.common.base.Predicate;
import forge.AllZone;
import forge.Card;
import forge.CardLists;
@@ -36,7 +35,6 @@ import forge.card.cost.Cost;
import forge.card.spellability.AbilityActivated;
import forge.card.spellability.Target;
import forge.control.input.Input;
import forge.game.GameState;
import forge.game.phase.PhaseType;
import forge.game.player.Player;
import forge.game.zone.PlayerZone;
@@ -97,7 +95,7 @@ class CardFactoryLands {
boolean needsTheMana = false;
final Player ai = card.getController();
if (ai.getLife() > 3) {
final int landsize = GameState.getPlayerLandsInPlay(ai).size();
final int landsize = ai.getLandsInPlay().size();
for (Card c : ai.getCardsIn(ZoneType.Hand)) {
if (landsize == c.getCMC()) {
needsTheMana = true;
@@ -145,7 +143,7 @@ class CardFactoryLands {
@Override
public boolean apply(final Card c) {
return GameState.isCardInPlay(c) && c.isCreature()
return c.isInPlay() && c.isCreature()
&& (c.getTurnInZone() == Singletons.getModel().getGameState().getPhaseHandler().getTurn());
}
};
@@ -181,7 +179,7 @@ class CardFactoryLands {
@Override
public void resolve() {
this.inPlay.clear();
this.inPlay.addAll(GameState.getCardsIn(ZoneType.Battlefield));
this.inPlay.addAll(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield));
for (final Card targ : CardLists.filter(this.inPlay, targets)) {
targ.addCounter(Counters.P1P1, 1);
}
@@ -291,7 +289,7 @@ class CardFactoryLands {
}
public void humanExecute() {
AllZone.getInputControl().setInput(new Input() {
Singletons.getModel().getMatch().getInput().setInput(new Input() {
private static final long serialVersionUID = -2774066137824255680L;
@Override

View File

@@ -31,7 +31,6 @@ import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.Iterables;
import forge.AllZone;
import forge.Card;
import forge.CardLists;
@@ -49,7 +48,6 @@ import forge.card.spellability.Target;
import forge.control.input.Input;
import forge.control.input.InputPayManaCost;
import forge.control.input.InputPayManaCostAbility;
import forge.game.GameState;
import forge.game.player.ComputerUtil;
import forge.game.player.Player;
import forge.game.player.PlayerUtil;
@@ -262,15 +260,15 @@ public class CardFactorySorceries {
public boolean canPlayAI() {
final Player ai = getActivatingPlayer();
final Player opp = ai.getOpponent();
List<Card> humTokenCreats = CardLists.filter(GameState.getCreaturesInPlay(opp), Presets.TOKEN);
List<Card> compTokenCreats = CardLists.filter(GameState.getCreaturesInPlay(ai), Presets.TOKEN);
List<Card> humTokenCreats = CardLists.filter(opp.getCreaturesInPlay(), Presets.TOKEN);
List<Card> compTokenCreats = CardLists.filter(ai.getCreaturesInPlay(), Presets.TOKEN);
return compTokenCreats.size() > humTokenCreats.size();
} // canPlayAI()
@Override
public void resolve() {
List<Card> tokens = GameState.getCreaturesInPlay();
List<Card> tokens = CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), Presets.CREATURES);
tokens = CardLists.filter(tokens, Presets.TOKEN);
CardFactoryUtil.copyTokens(tokens);
@@ -318,7 +316,7 @@ public class CardFactorySorceries {
// Vector<?> computerBasic = new Vector();
// figure out which basic land types the computer has
List<Card> land = GameState.getPlayerLandsInPlay(Singletons.getControl().getPlayer().getOpponent());
List<Card> land = Singletons.getControl().getPlayer().getOpponent().getLandsInPlay();
for (final String element : Constant.Color.BASIC_LANDS) {
final List<Card> cl = CardLists.getType(land, element);
@@ -353,7 +351,7 @@ public class CardFactorySorceries {
// when this spell resolves all basic lands which were not
// selected are sacrificed.
for (int i = 0; i < target.size(); i++) {
if (GameState.isCardInPlay(target.get(i)) && !saveList.contains(target.get(i))) {
if (target.get(i).isInPlay() && !saveList.contains(target.get(i))) {
Singletons.getModel().getGameAction().sacrifice(target.get(i), this);
}
}
@@ -402,7 +400,7 @@ public class CardFactorySorceries {
/* && !saveList.contains(c) */) {
// get all other basic[count] lands human player
// controls and add them to target
List<Card> land = GameState.getPlayerLandsInPlay(c.getController());
List<Card> land = c.getController().getLandsInPlay();
List<Card> cl = CardLists.getType(land, humanBasic.get(this.count));
cl = CardLists.filter(cl, new Predicate<Card>() {
@Override
@@ -576,7 +574,7 @@ public class CardFactorySorceries {
List<List<Card>> lands = new ArrayList<List<Card>>();
for (Player p : Singletons.getModel().getGameState().getPlayers())
{
lands.add(GameState.getPlayerLandsInPlay(p));
lands.add(p.getLandsInPlay());
}
int min = Integer.MAX_VALUE;
@@ -596,7 +594,7 @@ public class CardFactorySorceries {
Singletons.getModel().getGameAction().sacrifice(l.get(i), card);
}
} else {
AllZone.getInputControl().setInput(PlayerUtil.inputSacrificePermanents(sac, "Land"));
Singletons.getModel().getMatch().getInput().setInput(PlayerUtil.inputSacrificePermanents(sac, "Land"));
}
}
}
@@ -626,7 +624,7 @@ public class CardFactorySorceries {
List<List<Card>> creats = new ArrayList<List<Card>>();
for (Player p : Singletons.getModel().getGameState().getPlayers())
{
creats.add(GameState.getCreaturesInPlay(p));
creats.add(p.getCreaturesInPlay());
}
int min = Integer.MAX_VALUE;
for(List<Card> h : creats) {
@@ -647,7 +645,7 @@ public class CardFactorySorceries {
Singletons.getModel().getGameAction().sacrifice(c.get(i), card);
}
} else {
AllZone.getInputControl().setInput(PlayerUtil.inputSacrificePermanents(sac, "Creature"));
Singletons.getModel().getMatch().getInput().setInput(PlayerUtil.inputSacrificePermanents(sac, "Creature"));
}
}
}
@@ -668,12 +666,12 @@ public class CardFactorySorceries {
int diff = 0;
final Player ai = getActivatingPlayer();
final Player opp = ai.getOpponent();
final List<Card> humLand = GameState.getPlayerLandsInPlay(opp);
final List<Card> compLand = GameState.getPlayerLandsInPlay(ai);
final List<Card> humLand = opp.getLandsInPlay();
final List<Card> compLand = ai.getLandsInPlay();
diff += humLand.size() - compLand.size();
final List<Card> humCreats = GameState.getCreaturesInPlay(opp);
List<Card> compCreats = GameState.getCreaturesInPlay(ai);
final List<Card> humCreats = opp.getCreaturesInPlay();
List<Card> compCreats = ai.getCreaturesInPlay();
compCreats = CardLists.filter(compCreats, CardPredicates.Presets.CREATURES);
diff += 1.5 * (humCreats.size() - compCreats.size());
@@ -826,7 +824,7 @@ public class CardFactorySorceries {
}
}
List<Card> bidded = CardLists.filter(GameState.getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.CREATURES);
List<Card> bidded = CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.CREATURES);
for (final Card c : bidded) {
for(int i = 0; i < types.size(); i++) {
if (c.isType(types.get(i))) {
@@ -988,7 +986,7 @@ public class CardFactorySorceries {
if (card.getChoice(i).equals(cardChoice[2])) {
final Card c = ab2card[0];
if (c != null) {
if (GameState.isCardInPlay(c) && c.canBeTargetedBy(this)) {
if (c.isInPlay() && c.canBeTargetedBy(this)) {
final int boost = x[0] * -1;
c.addTempAttackBoost(boost);
c.addTempDefenseBoost(boost);
@@ -997,7 +995,7 @@ public class CardFactorySorceries {
@Override
public void execute() {
if (GameState.isCardInPlay(c)) {
if (c.isInPlay()) {
c.addTempAttackBoost(-1 * boost);
c.addTempDefenseBoost(-1 * boost);
@@ -1015,14 +1013,14 @@ public class CardFactorySorceries {
final ArrayList<Card> cs = new ArrayList<Card>();
cs.addAll(ab3cards);
for (final Card c : cs) {
if (GameState.isCardInPlay(c) && c.canBeTargetedBy(this)) {
if (c.isInPlay() && c.canBeTargetedBy(this)) {
c.addExtrinsicKeyword("Fear");
final Command untilEOT = new Command() {
private static final long serialVersionUID = 986259855862338866L;
@Override
public void execute() {
if (GameState.isCardInPlay(c)) {
if (c.isInPlay()) {
c.removeExtrinsicKeyword("Fear");
}
}
@@ -1302,7 +1300,7 @@ public class CardFactorySorceries {
final ArrayList<String> display = new ArrayList<String>();
// get all
final List<Card> creatures = GameState.getCreaturesInPlay();
final List<Card> creatures = CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), Presets.CREATURES);
List<Card> grave = card.getController().getCardsIn(ZoneType.Graveyard);
grave = CardLists.filter(grave, Presets.CREATURES);
@@ -1415,7 +1413,7 @@ public class CardFactorySorceries {
Singletons.getModel().getGameAction().moveToPlay(newArtifact[0]);
} else {
final String diffCost = String.valueOf(newCMC - baseCMC);
AllZone.getInputControl().setInput(new InputPayManaCostAbility(diffCost, new Command() {
Singletons.getModel().getMatch().getInput().setInput(new InputPayManaCostAbility(diffCost, new Command() {
private static final long serialVersionUID = -8729850321341068049L;
@Override

View File

@@ -31,7 +31,6 @@ import com.google.common.base.Predicates;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import forge.AllZone;
import forge.Card;
import forge.CardCharacteristicName;
@@ -68,7 +67,6 @@ import forge.card.trigger.TriggerType;
import forge.control.input.Input;
import forge.control.input.InputPayManaCost;
import forge.control.input.InputPayManaCostUtil;
import forge.game.GameState;
import forge.game.phase.PhaseHandler;
import forge.game.phase.PhaseType;
import forge.game.player.ComputerUtil;
@@ -864,7 +862,7 @@ public class CardFactoryUtil {
public boolean canPlay() {
//Lands do not have SpellPermanents.
if (sourceCard.isLand()) {
return (GameState.getZoneOf(sourceCard).is(ZoneType.Hand) || sourceCard.hasKeyword("May be played"))
return (Singletons.getModel().getGameState().getZoneOf(sourceCard).is(ZoneType.Hand) || sourceCard.hasKeyword("May be played"))
&& PhaseHandler.canCastSorcery(sourceCard.getController());
}
else {
@@ -917,7 +915,7 @@ public class CardFactoryUtil {
@Override
public boolean canPlay() {
return sourceCard.getController().equals(this.getActivatingPlayer()) && sourceCard.isFaceDown()
&& GameState.isCardInPlay(sourceCard);
&& sourceCard.isInPlay();
}
}; // morph_up
@@ -1271,7 +1269,6 @@ public class CardFactoryUtil {
} else if (choices.contains(card)) {
spell.setTargetCard(card);
if (spell.getManaCost().equals("0") || free) {
this.setFree(false);
Singletons.getModel().getGameState().getStack().add(spell);
this.stop();
} else {
@@ -1571,7 +1568,7 @@ public class CardFactoryUtil {
*/
public static boolean isTargetStillValid(final SpellAbility ability, final Card target) {
if (GameState.getZoneOf(target) == null) {
if (Singletons.getModel().getGameState().getZoneOf(target) == null) {
return false; // for tokens that disappeared
}
@@ -1587,7 +1584,7 @@ public class CardFactoryUtil {
// Check if the target is in the zone it needs to be in to be
// targeted
if (!GameState.getZoneOf(target).is(tgt.getZone())) {
if (!Singletons.getModel().getGameState().getZoneOf(target).is(tgt.getZone())) {
return false;
}
} else {
@@ -1849,7 +1846,7 @@ public class CardFactoryUtil {
if (l[0].contains("Valid")) {
final String restrictions = l[0].replace("Valid ", "");
final String[] rest = restrictions.split(",");
List<Card> cardsonbattlefield = GameState.getCardsIn(ZoneType.Battlefield);
List<Card> cardsonbattlefield = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
cardsonbattlefield = CardLists.getValidCards(cardsonbattlefield, rest, players.get(0), source);
n = cardsonbattlefield.size();
@@ -1899,7 +1896,7 @@ public class CardFactoryUtil {
if (sq[0].contains("CreaturesInPlay")) {
if (players.size() > 0) {
return CardFactoryUtil.doXMath(GameState.getCreaturesInPlay(players.get(0)).size(), m, source);
return CardFactoryUtil.doXMath(players.get(0).getCreaturesInPlay().size(), m, source);
}
}
@@ -2057,7 +2054,7 @@ public class CardFactoryUtil {
String restrictions = l[0].replace("ValidGrave ", "");
restrictions = restrictions.replace("Count$", "");
final String[] rest = restrictions.split(",");
List<Card> cards = GameState.getCardsIn(ZoneType.Graveyard);
List<Card> cards = Singletons.getModel().getGameState().getCardsIn(ZoneType.Graveyard);
cards = CardLists.getValidCards(cards, rest, cardController, c);
n = cards.size();
@@ -2069,7 +2066,7 @@ public class CardFactoryUtil {
String restrictions = l[0].replace("Valid ", "");
restrictions = restrictions.replace("Count$", "");
final String[] rest = restrictions.split(",");
List<Card> cardsonbattlefield = GameState.getCardsIn(ZoneType.Battlefield);
List<Card> cardsonbattlefield = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
cardsonbattlefield = CardLists.getValidCards(cardsonbattlefield, rest, cardController, c);
n = cardsonbattlefield.size();
@@ -2096,7 +2093,7 @@ public class CardFactoryUtil {
}
if (l[0].contains("GreatestPowerYouControl")) {
final List<Card> list = GameState.getCreaturesInPlay(c.getController());
final List<Card> list = c.getController().getCreaturesInPlay();
int highest = 0;
for (final Card crd : list) {
if (crd.getNetAttack() > highest) {
@@ -2107,7 +2104,7 @@ public class CardFactoryUtil {
}
if (l[0].contains("GreatestPowerYouDontControl")) {
final List<Card> list = GameState.getCreaturesInPlay(c.getController().getOpponent());
final List<Card> list = c.getController().getOpponent().getCreaturesInPlay();
int highest = 0;
for (final Card crd : list) {
if (crd.getNetAttack() > highest) {
@@ -2122,7 +2119,7 @@ public class CardFactoryUtil {
int highest = 0;
for (final Object o : c.getRemembered()) {
if (o instanceof Card) {
list.add(GameState.getCardState((Card) o));
list.add(Singletons.getModel().getGameState().getCardState((Card) o));
}
}
for (final Card crd : list) {
@@ -2137,7 +2134,7 @@ public class CardFactoryUtil {
final List<Card> list = new ArrayList<Card>();
for (final Object o : c.getRemembered()) {
if (o instanceof Card) {
list.add(GameState.getCardState((Card) o));
list.add(Singletons.getModel().getGameState().getCardState((Card) o));
}
}
return Aggregates.sum(Iterables.filter(list, CardPredicates.Presets.hasSecondStrike), CardPredicates.Accessors.fnGetAttack);
@@ -2450,7 +2447,7 @@ public class CardFactoryUtil {
if (sq[0].contains("SumPower")) {
final String[] restrictions = l[0].split("_");
final String[] rest = restrictions[1].split(",");
List<Card> cardsonbattlefield = GameState.getCardsIn(ZoneType.Battlefield);
List<Card> cardsonbattlefield = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
List<Card> filteredCards = CardLists.getValidCards(cardsonbattlefield, rest, cardController, c);
int sumPower = 0;
for (int i = 0; i < filteredCards.size(); i++) {
@@ -2470,7 +2467,7 @@ public class CardFactoryUtil {
if (sq[0].contains("SumCMC")) {
final String[] restrictions = l[0].split("_");
final String[] rest = restrictions[1].split(",");
List<Card> cardsonbattlefield = GameState.getCardsIn(ZoneType.Battlefield);
List<Card> cardsonbattlefield = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
List<Card> filteredCards = CardLists.getValidCards(cardsonbattlefield, rest, cardController, c);
return CardLists.sumCMC(filteredCards);
}
@@ -2491,7 +2488,7 @@ public class CardFactoryUtil {
final String[] restrictions = l[0].split("_");
final Counters cType = Counters.getType(restrictions[1]);
final String[] validFilter = restrictions[2].split(",");
List<Card> validCards = GameState.getCardsIn(ZoneType.Battlefield);
List<Card> validCards = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
validCards = CardLists.getValidCards(validCards, validFilter, cardController, c);
int cCount = 0;
for (final Card card : validCards) {
@@ -2520,9 +2517,9 @@ public class CardFactoryUtil {
// Count$M12Empires.<numIf>.<numIfNot>
if (sq[0].contains("AllM12Empires")) {
boolean has = GameState.isCardInPlay("Crown of Empires", c.getController());
has &= GameState.isCardInPlay("Scepter of Empires", c.getController());
has &= GameState.isCardInPlay("Throne of Empires", c.getController());
boolean has = c.getController().isCardInPlay("Crown of Empires");
has &= c.getController().isCardInPlay("Scepter of Empires");
has &= c.getController().isCardInPlay("Throne of Empires");
if (has) {
return CardFactoryUtil.doXMath(Integer.parseInt(sq[1]), m, c);
} else {
@@ -2664,7 +2661,7 @@ public class CardFactoryUtil {
}
if (sq[0].contains("SpellsOnStack")) {
someCards.addAll(GameState.getCardsIn(ZoneType.Stack));
someCards.addAll(Singletons.getModel().getGameState().getCardsIn(ZoneType.Stack));
}
if (sq[0].contains("InAllHands")) {
@@ -3248,7 +3245,7 @@ public class CardFactoryUtil {
c.setBaseAttack(baseAttack);
c.setBaseDefense(baseDefense);
final int multiplier = GameState.getTokenDoublersMagnitude(controller);
final int multiplier = controller.getTokenDoublersMagnitude();
for (int i = 0; i < multiplier; i++) {
Card temp = CardFactoryUtil.copyStats(c);
@@ -3336,7 +3333,7 @@ public class CardFactoryUtil {
@Override
public void execute() {
if (GameState.isCardInPlay(crd)) {
if (crd.isInPlay()) {
crd.addTempAttackBoost(-1 * magnitude);
crd.addTempDefenseBoost(-1 * magnitude);
}
@@ -3400,7 +3397,7 @@ public class CardFactoryUtil {
* @return the worst land found based on the description above
*/
public static Card getWorstLand(final Player player) {
final List<Card> lands = GameState.getPlayerLandsInPlay(player);
final List<Card> lands = player.getLandsInPlay();
return CardFactoryUtil.getWorstLand(lands);
} // end getWorstLand
@@ -4020,7 +4017,7 @@ public class CardFactoryUtil {
final Ability haunterDiesSetup = new Ability(card, "0") {
@Override
public void resolve() {
final List<Card> creats = GameState.getCreaturesInPlay();
final List<Card> creats = CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), Presets.CREATURES);
for (int i = 0; i < creats.size(); i++) {
if (!creats.get(i).canBeTargetedBy(this)) {
creats.remove(i);
@@ -4034,7 +4031,7 @@ public class CardFactoryUtil {
// need to do it this way because I don't know quite how to
// make TriggerHandler respect BeforePayMana.
if (card.getController().isHuman()) {
AllZone.getInputControl().setInput(target);
Singletons.getModel().getMatch().getInput().setInput(target);
} else {
// AI choosing what to haunt
final List<Card> oppCreats = CardLists.filterControlledBy(creats, card.getController().getOpponent());
@@ -4475,7 +4472,7 @@ public class CardFactoryUtil {
@Override
public void execute() {
final List<Card> lands = GameState.getPlayerLandsInPlay(card.getController());
final List<Card> lands = card.getController().getLandsInPlay();
lands.remove(card);
if (!(lands.size() <= 2)) {
// it enters the battlefield this way, and should not
@@ -4560,7 +4557,7 @@ public class CardFactoryUtil {
@Override
public void execute() {
final List<Card> cardsInPlay = CardLists.getType(GameState.getCardsIn(ZoneType.Battlefield), "World");
final List<Card> cardsInPlay = CardLists.getType(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), "World");
cardsInPlay.remove(card);
for (int i = 0; i < cardsInPlay.size(); i++) {
Singletons.getModel().getGameAction().sacrificeDestroy(cardsInPlay.get(i));
@@ -4647,7 +4644,7 @@ public class CardFactoryUtil {
@Override
public void execute() {
final List<Card> creats = GameState.getCreaturesInPlay(card.getController());
final List<Card> creats = card.getController().getCreaturesInPlay();
creats.remove(card);
// System.out.println("Creats size: " + creats.size());
@@ -4732,7 +4729,7 @@ public class CardFactoryUtil {
}
}
} else {
AllZone.getInputControl().setInput(CardFactoryUtil.modularInput(ability, card));
Singletons.getModel().getMatch().getInput().setInput(CardFactoryUtil.modularInput(ability, card));
}
}
});

View File

@@ -28,7 +28,6 @@ import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory;
import forge.card.spellability.SpellAbility;
import forge.control.input.Input;
import forge.game.GameState;
import forge.game.player.ComputerUtil;
import forge.game.player.Player;
import forge.game.zone.PlayerZone;
@@ -116,7 +115,7 @@ public class CostReturn extends CostPartWithList {
if ((amount != null) && (typeList.size() < amount)) {
return false;
}
} else if (!GameState.isCardInPlay(source)) {
} else if (!source.isInPlay()) {
return false;
}
@@ -297,7 +296,7 @@ public class CostReturn extends CostPartWithList {
@Override
public void showMessage() {
final Card card = sa.getSourceCard();
if (card.getController().isHuman() && GameState.isCardInPlay(card)) {
if (card.getController().isHuman() && card.isInPlay()) {
final StringBuilder sb = new StringBuilder();
sb.append(card.getName());
sb.append(" - Return to Hand?");

View File

@@ -28,7 +28,6 @@ import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory;
import forge.card.spellability.SpellAbility;
import forge.control.input.Input;
import forge.game.GameState;
import forge.game.player.ComputerUtil;
import forge.game.player.Player;
import forge.game.zone.PlayerZone;
@@ -120,7 +119,7 @@ public class CostSacrifice extends CostPartWithList {
// choice, it can be Paid even if it's 0
}
else {
if (!GameState.isCardInPlay(source)) {
if (!source.isInPlay()) {
return false;
}
else if (source.isCreature() && activator.hasKeyword("You can't sacrifice creatures to cast spells or activate abilities.")) {
@@ -357,7 +356,7 @@ public class CostSacrifice extends CostPartWithList {
@Override
public void showMessage() {
final Card card = sa.getSourceCard();
if (card.getController().isHuman() && GameState.isCardInPlay(card)) {
if (card.getController().isHuman() && card.isInPlay()) {
final StringBuilder sb = new StringBuilder();
sb.append(card.getName());
sb.append(" - Sacrifice?");

View File

@@ -23,10 +23,10 @@ import forge.Card;
import forge.CardLists;
import forge.CardPredicates.Presets;
import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory;
import forge.card.spellability.SpellAbility;
import forge.control.input.Input;
import forge.game.GameState;
import forge.game.player.ComputerUtil;
import forge.game.player.Player;
import forge.game.zone.PlayerZone;
@@ -120,7 +120,7 @@ public class CostUntapType extends CostPartWithList {
*/
@Override
public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost) {
List<Card> typeList = GameState.getCardsIn(ZoneType.Battlefield);
List<Card> typeList = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
typeList = CardLists.getValidCards(typeList, this.getType().split(";"), activator, source);
@@ -160,7 +160,7 @@ public class CostUntapType extends CostPartWithList {
@Override
public final boolean payHuman(final SpellAbility ability, final Card source, final CostPayment payment) {
final boolean untap = payment.getCost().getUntap();
List<Card> typeList = GameState.getCardsIn(ZoneType.Battlefield);
List<Card> typeList = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
typeList = CardLists.getValidCards(typeList, this.getType().split(";"), ability.getActivatingPlayer(), ability.getSourceCard());
typeList = CardLists.filter(typeList, Presets.TAPPED);
if (untap) {
@@ -197,7 +197,7 @@ public class CostUntapType extends CostPartWithList {
if (c == null) {
final String sVar = ability.getSVar(amount);
if (sVar.equals("XChoice")) {
List<Card> typeList = GameState.getCardsIn(ZoneType.Battlefield);
List<Card> typeList = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
typeList = CardLists.getValidCards(typeList, this.getType().split(";"), ai, ability.getSourceCard());
if (untap) {
typeList.remove(source);

View File

@@ -21,8 +21,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import forge.AllZone;
import forge.Card;
import forge.Singletons;
import forge.CardLists;
import forge.Counters;
@@ -463,7 +463,7 @@ public class CostUtil {
*/
public static void setInput(final Input in) {
// Just a shortcut..
AllZone.getInputControl().setInput(in, true);
Singletons.getModel().getMatch().getInput().setInput(in, true);
}
public static Cost combineCosts(Cost cost1, Cost cost2) {

View File

@@ -26,7 +26,6 @@ import forge.Singletons;
import forge.card.spellability.AbilityMana;
import forge.card.spellability.SpellAbility;
import forge.control.input.InputPayManaCostUtil;
import forge.game.GameState;
import forge.game.player.Player;
import forge.gui.GuiChoose;
@@ -185,7 +184,7 @@ public class ManaPool {
return numRemoved;
}
if (GameState.isCardInPlay("Omnath, Locus of Mana", this.owner)) {
if (this.owner.isCardInPlay("Omnath, Locus of Mana")) {
// Omnath in play, clear all non-green mana
int i = 0;
while (i < this.floatingMana.size()) {

View File

@@ -25,11 +25,11 @@ import forge.Card;
import forge.CardLists;
import forge.CardUtil;
import forge.Singletons;
import forge.card.TriggerReplacementBase;
import forge.card.abilityfactory.AbilityFactory;
import forge.card.cardfactory.CardFactoryUtil;
import forge.card.spellability.SpellAbility;
import forge.game.GameState;
import forge.game.zone.ZoneType;
import forge.util.Expressions;
@@ -321,7 +321,7 @@ public abstract class ReplacementEffect extends TriggerReplacementBase {
}
if (this.getMapParams().containsKey("CheckSVar")) {
final int sVar = AbilityFactory.calculateAmount(GameState.getCardState(this.getHostCard()), this
final int sVar = AbilityFactory.calculateAmount(Singletons.getModel().getGameState().getCardState(this.getHostCard()), this
.getMapParams().get("CheckSVar"), null);
String comparator = "GE1";
if (this.getMapParams().containsKey("SVarCompare")) {
@@ -329,7 +329,7 @@ public abstract class ReplacementEffect extends TriggerReplacementBase {
}
final String svarOperator = comparator.substring(0, 2);
final String svarOperand = comparator.substring(2);
final int operandValue = AbilityFactory.calculateAmount(GameState.getCardState(this.getHostCard()),
final int operandValue = AbilityFactory.calculateAmount(Singletons.getModel().getGameState().getCardState(this.getHostCard()),
svarOperand, null);
if (!Expressions.compare(sVar, svarOperator, operandValue)) {
return false;

View File

@@ -27,7 +27,6 @@ import forge.GameActionUtil;
import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory;
import forge.card.spellability.SpellAbility;
import forge.game.GameState;
import forge.game.player.ComputerUtil;
import forge.game.player.Player;
import forge.game.zone.ZoneType;
@@ -111,7 +110,7 @@ public class ReplacementHandler {
&& replacementEffect.requirementsCheck()
&& replacementEffect.canReplace(runParams)
&& !possibleReplacers.contains(replacementEffect)
&& replacementEffect.zonesCheck(GameState.getZoneOf(crd))) {
&& replacementEffect.zonesCheck(Singletons.getModel().getGameState().getZoneOf(crd))) {
possibleReplacers.add(replacementEffect);
}
}

View File

@@ -21,7 +21,6 @@ import com.esotericsoftware.minlog.Log;
import forge.Card;
import forge.Singletons;
import forge.game.GameState;
/**
* <p>
@@ -73,6 +72,6 @@ public abstract class Ability extends SpellAbility {
return false;
}
return GameState.isCardInPlay(this.getSourceCard()) && !this.getSourceCard().isFaceDown();
return this.getSourceCard().isInPlay() && !this.getSourceCard().isFaceDown();
}
}

View File

@@ -26,7 +26,6 @@ import forge.Singletons;
import forge.card.cost.Cost;
import forge.card.cost.CostPayment;
import forge.card.staticability.StaticAbility;
import forge.game.GameState;
import forge.game.zone.ZoneType;
/**
@@ -94,7 +93,7 @@ public abstract class AbilityActivated extends SpellAbility implements java.io.S
}
// CantBeActivated static abilities
final List<Card> allp = GameState.getCardsIn(ZoneType.Battlefield);
final List<Card> allp = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
for (final Card ca : allp) {
final ArrayList<StaticAbility> staticAbilities = ca.getStaticAbilities();
for (final StaticAbility stAb : staticAbilities) {
@@ -108,7 +107,7 @@ public abstract class AbilityActivated extends SpellAbility implements java.io.S
return false;
}
if (this.isCycling() && GameState.isCardInPlay("Stabilizer")) {
if (this.isCycling() && Singletons.getModel().getGameState().isCardInPlay("Stabilizer")) {
return false;
}

View File

@@ -29,7 +29,6 @@ import forge.card.mana.Mana;
import forge.card.mana.ManaPool;
import forge.card.trigger.TriggerType;
import forge.control.input.InputPayManaCostUtil;
import forge.game.GameState;
import forge.game.player.Player;
/**
@@ -539,7 +538,7 @@ public class AbilityMana extends AbilityActivated implements java.io.Serializabl
* @return a boolean.
*/
public final boolean isUndoable() {
return this.undoable && this.getPayCosts().isUndoable() && GameState.isCardInPlay(this.getSourceCard());
return this.undoable && this.getPayCosts().isUndoable() && this.getSourceCard().isInPlay();
}
/**

View File

@@ -29,7 +29,6 @@ import forge.card.cost.Cost;
import forge.card.cost.CostPayment;
import forge.card.staticability.StaticAbility;
import forge.error.ErrorViewer;
import forge.game.GameState;
import forge.game.phase.PhaseHandler;
import forge.game.player.Player;
import forge.game.zone.ZoneType;
@@ -125,7 +124,7 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable
}
// CantBeCast static abilities
final List<Card> allp = GameState.getCardsIn(ZoneType.Battlefield);
final List<Card> allp = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
allp.add(card);
for (final Card ca : allp) {
final ArrayList<StaticAbility> staticAbilities = ca.getStaticAbilities();
@@ -145,7 +144,7 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable
final Card card = this.getSourceCard();
if (card.getSVar("NeedsToPlay").length() > 0) {
final String needsToPlay = card.getSVar("NeedsToPlay");
List<Card> list = GameState.getCardsIn(ZoneType.Battlefield);
List<Card> list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
list = CardLists.getValidCards(list, needsToPlay.split(","), card.getController(), card);
if (list.isEmpty()) {

View File

@@ -27,7 +27,6 @@ import forge.CardLists;
import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory;
import forge.card.cardfactory.CardFactoryUtil;
import forge.game.GameState;
import forge.game.phase.PhaseHandler;
import forge.game.phase.PhaseType;
import forge.game.player.Player;
@@ -228,18 +227,18 @@ public class SpellAbilityCondition extends SpellAbilityVariables {
if (this.isAllM12Empires()) {
final Player p = sa.getSourceCard().getController();
boolean has = GameState.isCardInPlay("Crown of Empires", p);
has &= GameState.isCardInPlay("Scepter of Empires", p);
has &= GameState.isCardInPlay("Throne of Empires", p);
boolean has = p.isCardInPlay("Crown of Empires");
has &= p.isCardInPlay("Scepter of Empires");
has &= p.isCardInPlay("Throne of Empires");
if (!has) {
return false;
}
}
if (this.isNotAllM12Empires()) {
final Player p = sa.getSourceCard().getController();
boolean has = GameState.isCardInPlay("Crown of Empires", p);
has &= GameState.isCardInPlay("Scepter of Empires", p);
has &= GameState.isCardInPlay("Throne of Empires", p);
boolean has = p.isCardInPlay("Crown of Empires");
has &= p.isCardInPlay("Scepter of Empires");
has &= p.isCardInPlay("Throne of Empires");
if (has) {
return false;
}
@@ -257,7 +256,7 @@ public class SpellAbilityCondition extends SpellAbilityVariables {
if (this.getPresentDefined() != null) {
list.addAll(AbilityFactory.getDefinedCards(sa.getSourceCard(), this.getPresentDefined(), sa));
} else {
list = GameState.getCardsIn(ZoneType.Battlefield);
list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
}
list = CardLists.getValidCards(list, this.getIsPresent().split(","), sa.getActivatingPlayer(), sa.getSourceCard());

View File

@@ -23,7 +23,6 @@ import forge.Card;
import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory;
import forge.card.cost.CostPayment;
import forge.game.GameState;
import forge.game.zone.PlayerZone;
/**
@@ -111,7 +110,7 @@ public class SpellAbilityRequirements {
if (!this.ability.getSourceCard().isCopiedSpell()) {
final Card c = this.ability.getSourceCard();
this.fromZone = GameState.getZoneOf(c);
this.fromZone = Singletons.getModel().getGameState().getZoneOf(c);
this.zonePosition = this.fromZone.getPosition(c);
this.ability.setSourceCard(Singletons.getModel().getGameAction().moveToStack(c));
}

View File

@@ -27,7 +27,6 @@ import forge.CardLists;
import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory;
import forge.card.cardfactory.CardFactoryUtil;
import forge.game.GameState;
import forge.game.phase.PhaseHandler;
import forge.game.phase.PhaseType;
import forge.game.player.Player;
@@ -187,7 +186,7 @@ public class SpellAbilityRestriction extends SpellAbilityVariables {
if (this.getZone() == null) {
return true;
}
PlayerZone cardZone = GameState.getZoneOf(c);
PlayerZone cardZone = Singletons.getModel().getGameState().getZoneOf(c);
Player activator = sa.getActivatingPlayer();
if (cardZone == null || !cardZone.is(this.getZone())) {
// If Card is not in the default activating zone, do some additional checks
@@ -356,7 +355,7 @@ public class SpellAbilityRestriction extends SpellAbilityVariables {
}
}
if (this.getIsPresent() != null) {
List<Card> list = GameState.getCardsIn(this.getPresentZone());
List<Card> list = Singletons.getModel().getGameState().getCardsIn(this.getPresentZone());
list = CardLists.getValidCards(list, this.getIsPresent().split(","), activator, c);

View File

@@ -21,15 +21,14 @@ import java.security.InvalidParameterException;
import java.util.HashMap;
import java.util.List;
import com.google.common.base.Supplier;
import com.google.common.collect.Iterables;
import forge.AllZone;
import forge.Card;
import forge.CardLists;
import forge.CardPredicates;
import forge.Command;
import forge.CommandReturn;
import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory;
import forge.card.cardfactory.CardFactoryUtil;
@@ -40,7 +39,6 @@ import forge.card.replacement.ReplacementEffect;
import forge.card.trigger.Trigger;
import forge.card.trigger.TriggerType;
import forge.control.input.Input;
import forge.game.GameState;
import forge.game.phase.PhaseHandler;
import forge.game.phase.PhaseType;
import forge.game.player.ComputerAIGeneral;
@@ -71,8 +69,7 @@ public class SpellPermanent extends Spell {
@Override
public void showMessage() {
@SuppressWarnings("unchecked")
final List<Card> choice = (List<Card>) SpellPermanent.this.championGetCreature.execute();
final List<Card> choice = SpellPermanent.this.championGetCreature.get();
this.stopSetNext(CardFactoryUtil.inputTargetChampionSac(SpellPermanent.this.getSourceCard(),
SpellPermanent.this.championAbilityComes, choice, "Select another "
@@ -82,9 +79,9 @@ public class SpellPermanent extends Spell {
}
};
private final CommandReturn championGetCreature = new CommandReturn() {
private final Supplier<List<Card>> championGetCreature = new Supplier<List<Card>>() {
@Override
public Object execute() {
public List<Card> get() {
final List<Card> cards = SpellPermanent.this.getSourceCard().getController().getCardsIn(ZoneType.Battlefield);
return CardLists.getValidCards(cards, SpellPermanent.this.championValid, SpellPermanent.this.getSourceCard()
.getController(), SpellPermanent.this.getSourceCard());
@@ -99,13 +96,12 @@ public class SpellPermanent extends Spell {
final Card source = this.getSourceCard();
final Player controller = source.getController();
@SuppressWarnings("unchecked")
final List<Card> creature = (List<Card>) SpellPermanent.this.championGetCreature.execute();
final List<Card> creature = SpellPermanent.this.championGetCreature.get();
if (creature.size() == 0) {
Singletons.getModel().getGameAction().sacrifice(source, null);
return;
} else if (controller.isHuman()) {
AllZone.getInputControl().setInput(SpellPermanent.this.championInputComes);
Singletons.getModel().getMatch().getInput().setInput(SpellPermanent.this.championInputComes);
} else { // Computer
List<Card> computer = controller.getCardsIn(ZoneType.Battlefield);
computer = CardLists.getValidCards(computer, SpellPermanent.this.championValid, controller, source);
@@ -115,7 +111,7 @@ public class SpellPermanent extends Spell {
if (computer.size() != 0) {
final Card c = computer.get(0);
source.setChampionedCard(c);
if (GameState.isCardInPlay(c)) {
if (c.isInPlay()) {
Singletons.getModel().getGameAction().exile(c);
}
@@ -158,7 +154,7 @@ public class SpellPermanent extends Spell {
@Override
public void resolve() {
final Card c = this.getSourceCard().getChampionedCard();
if ((c != null) && !c.isToken() && GameState.isCardExiled(c)) {
if ((c != null) && !c.isToken() && Singletons.getModel().getGameState().isCardExiled(c)) {
Singletons.getModel().getGameAction().moveToPlay(c);
}
} // resolve()
@@ -353,7 +349,7 @@ public class SpellPermanent extends Spell {
}
// check on legendary
if (card.isType("Legendary") && !GameState.isCardInPlay("Mirror Gallery")) {
if (card.isType("Legendary") && !Singletons.getModel().getGameState().isCardInPlay("Mirror Gallery")) {
final List<Card> list = ai.getCardsIn(ZoneType.Battlefield);
if (Iterables.any(list, CardPredicates.nameEquals(card.getName()))) {
return false;
@@ -388,13 +384,12 @@ public class SpellPermanent extends Spell {
}
if (this.willChampion) {
final Object o = this.championGetCreature.execute();
final Object o = this.championGetCreature.get();
if (o == null) {
return false;
}
@SuppressWarnings("unchecked")
final List<Card> cl = (List<Card>) this.championGetCreature.execute();
final List<Card> cl = (List<Card>) this.championGetCreature.get();
if ((o == null) || !(cl.size() > 0) || !this.getSourceCard().isInZone(ZoneType.Hand)) {
return false;
}
@@ -415,7 +410,7 @@ public class SpellPermanent extends Spell {
private static boolean checkETBEffects(final Card card, final SpellAbility sa, final String api, final Player ai) {
if (card.isCreature() && GameState.isCardInPlay("Torpor Orb")) {
if (card.isCreature() && Singletons.getModel().getGameState().isCardInPlay("Torpor Orb")) {
return true;
}

View File

@@ -25,7 +25,6 @@ import forge.Card;
import forge.CardUtil;
import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory;
import forge.game.GameState;
import forge.game.player.Player;
import forge.game.zone.ZoneType;
@@ -714,7 +713,7 @@ public class Target {
if (this.tgtZone.contains(ZoneType.Stack)) {
return true;
} else {
for (final Card c : GameState.getCardsIn(this.tgtZone)) {
for (final Card c : Singletons.getModel().getGameState().getCardsIn(this.tgtZone)) {
if (c.isValid(this.validTgts, this.srcCard.getController(), this.srcCard)
&& (!isTargeted || c.canBeTargetedBy(sa))
&& !this.getTargetCards().contains(c)) {

View File

@@ -23,14 +23,12 @@ import java.util.List;
import com.google.common.base.Predicate;
import forge.AllZone;
import forge.Card;
import forge.Singletons;
import forge.CardLists;
import forge.card.abilityfactory.AbilityFactory;
import forge.control.input.Input;
import forge.game.GameState;
import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
@@ -270,8 +268,7 @@ public class TargetSelection {
return;
}
List<Card> choices = CardLists.getTargetableCards(CardLists.getValidCards(GameState
.getCardsIn(zone), this.target.getValidTgts(), this.ability.getActivatingPlayer(), this.ability.getSourceCard()), this.ability);
List<Card> choices = CardLists.getTargetableCards(CardLists.getValidCards(Singletons.getModel().getGameState().getCardsIn(zone), this.target.getValidTgts(), this.ability.getActivatingPlayer(), this.ability.getSourceCard()), this.ability);
ArrayList<Object> objects = new ArrayList<Object>();
if (tgt.isUniqueTargets()) {
@@ -321,7 +318,7 @@ public class TargetSelection {
}
if (zone.contains(ZoneType.Battlefield) && zone.size() == 1) {
AllZone.getInputControl().setInput(this.inputTargetSpecific(choices, true, mandatory, objects));
Singletons.getModel().getMatch().getInput().setInput(this.inputTargetSpecific(choices, true, mandatory, objects));
} else {
this.chooseCardFromList(choices, true, mandatory);
}
@@ -462,15 +459,15 @@ public class TargetSelection {
final List<Card> crdsLibrary = new ArrayList<Card>();
final List<Card> crdsStack = new ArrayList<Card>();
for (final Card inZone : choicesZoneUnfiltered) {
if (GameState.getCardsIn(ZoneType.Battlefield).contains(inZone)) {
if (Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield).contains(inZone)) {
crdsBattle.add(inZone);
} else if (GameState.getCardsIn(ZoneType.Exile).contains(inZone)) {
} else if (Singletons.getModel().getGameState().getCardsIn(ZoneType.Exile).contains(inZone)) {
crdsExile.add(inZone);
} else if (GameState.getCardsIn(ZoneType.Graveyard).contains(inZone)) {
} else if (Singletons.getModel().getGameState().getCardsIn(ZoneType.Graveyard).contains(inZone)) {
crdsGrave.add(inZone);
} else if (GameState.getCardsIn(ZoneType.Library).contains(inZone)) {
} else if (Singletons.getModel().getGameState().getCardsIn(ZoneType.Library).contains(inZone)) {
crdsLibrary.add(inZone);
} else if (GameState.getCardsIn(ZoneType.Stack).contains(inZone)) {
} else if (Singletons.getModel().getGameState().getCardsIn(ZoneType.Stack).contains(inZone)) {
crdsStack.add(inZone);
}
}

View File

@@ -28,7 +28,6 @@ import forge.card.abilityfactory.AbilityFactory;
import forge.card.cost.Cost;
import forge.card.mana.ManaCost;
import forge.card.spellability.SpellAbility;
import forge.game.GameState;
import forge.game.phase.PhaseType;
import forge.game.player.Player;
import forge.game.zone.ZoneType;
@@ -457,7 +456,7 @@ public class StaticAbility {
if (this.mapParams.containsKey("EffectZone")) {
if (!this.mapParams.get("EffectZone").equals("All")
&& !ZoneType.listValueOf(this.mapParams.get("EffectZone"))
.contains(GameState.getZoneOf(this.hostCard).getZoneType())) {
.contains(Singletons.getModel().getGameState().getZoneOf(this.hostCard).getZoneType())) {
return false;
}
} else {

View File

@@ -21,9 +21,9 @@ import java.util.HashMap;
import java.util.List;
import forge.Card;
import forge.Singletons;
import forge.card.spellability.AbilityMana;
import forge.card.spellability.SpellAbility;
import forge.game.GameState;
import forge.game.phase.PhaseHandler;
import forge.game.player.Player;
import forge.game.zone.ZoneType;
@@ -64,7 +64,7 @@ public class StaticAbilityCantBeCast {
if (params.containsKey("Origin")) {
List<ZoneType> src = ZoneType.listValueOf(params.get("Origin"));
if (!src.contains(GameState.getZoneOf(card).getZoneType())) {
if (!src.contains(Singletons.getModel().getGameState().getZoneOf(card).getZoneType())) {
return false;
}
}

View File

@@ -35,7 +35,6 @@ import forge.card.spellability.AbilityActivated;
import forge.card.spellability.SpellAbility;
import forge.card.trigger.Trigger;
import forge.card.trigger.TriggerHandler;
import forge.game.GameState;
import forge.game.player.Player;
import forge.game.zone.ZoneType;
@@ -232,7 +231,7 @@ public class StaticAbilityContinuous {
}
}
List<Card> cardsIGainedAbilitiesFrom = GameState.getCardsIn(validZones);
List<Card> cardsIGainedAbilitiesFrom = Singletons.getModel().getGameState().getCardsIn(validZones);
cardsIGainedAbilitiesFrom = CardLists.getValidCards(cardsIGainedAbilitiesFrom, valids, hostCard.getController(), hostCard);
if (cardsIGainedAbilitiesFrom.size() > 0) {
@@ -430,9 +429,9 @@ public class StaticAbilityContinuous {
List<Card> affectedCards = new ArrayList<Card>();
if (params.containsKey("AffectedZone")) {
affectedCards.addAll(GameState.getCardsIn(ZoneType.listValueOf(params.get("AffectedZone"))));
affectedCards.addAll(Singletons.getModel().getGameState().getCardsIn(ZoneType.listValueOf(params.get("AffectedZone"))));
} else {
affectedCards = GameState.getCardsIn(ZoneType.Battlefield);
affectedCards = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
}
if (params.containsKey("Affected") && !params.get("Affected").contains(",")) {

View File

@@ -32,7 +32,6 @@ import forge.card.abilityfactory.AbilityFactory;
import forge.card.cardfactory.CardFactoryUtil;
import forge.card.spellability.Ability;
import forge.card.spellability.SpellAbility;
import forge.game.GameState;
import forge.game.phase.PhaseType;
import forge.game.zone.ZoneType;
import forge.util.Expressions;
@@ -411,7 +410,7 @@ public abstract class Trigger extends TriggerReplacementBase {
}
if (this.getMapParams().containsKey("CheckSVar")) {
final int sVar = AbilityFactory.calculateAmount(GameState.getCardState(this.getHostCard()), this
final int sVar = AbilityFactory.calculateAmount(Singletons.getModel().getGameState().getCardState(this.getHostCard()), this
.getMapParams().get("CheckSVar"), null);
String comparator = "GE1";
if (this.getMapParams().containsKey("SVarCompare")) {
@@ -419,7 +418,7 @@ public abstract class Trigger extends TriggerReplacementBase {
}
final String svarOperator = comparator.substring(0, 2);
final String svarOperand = comparator.substring(2);
final int operandValue = AbilityFactory.calculateAmount(GameState.getCardState(this.getHostCard()),
final int operandValue = AbilityFactory.calculateAmount(Singletons.getModel().getGameState().getCardState(this.getHostCard()),
svarOperand, null);
if (!Expressions.compare(sVar, svarOperator, operandValue)) {
return false;

View File

@@ -39,7 +39,6 @@ import forge.card.spellability.SpellAbility;
import forge.card.spellability.SpellAbilityRestriction;
import forge.card.spellability.Target;
import forge.control.input.Input;
import forge.game.GameState;
import forge.game.phase.PhaseType;
//import forge.util.TextUtil;
import forge.game.player.ComputerUtil;
@@ -64,7 +63,7 @@ public class TriggerHandler {
* Clean up temporary triggers.
*/
public final void cleanUpTemporaryTriggers() {
final List<Card> absolutelyAllCards = GameState.getCardsInGame();
final List<Card> absolutelyAllCards = Singletons.getModel().getGameState().getCardsInGame();
for (final Card c : absolutelyAllCards) {
for (int i = 0; i < c.getTriggers().size(); i++) {
if (c.getTriggers().get(i).isTemporary()) {
@@ -286,8 +285,8 @@ public class TriggerHandler {
// This is done to allow the list of triggers to be modified while
// triggers are running.
final ArrayList<Trigger> delayedTriggersWorkingCopy = new ArrayList<Trigger>(this.delayedTriggers);
List<Card> allCards = GameState.getCardsIn(ZoneType.STATIC_ABILITIES_SOURCE_ZONES);
allCards.addAll(GameState.getCardsIn(ZoneType.Stack));
List<Card> allCards = Singletons.getModel().getGameState().getCardsIn(ZoneType.STATIC_ABILITIES_SOURCE_ZONES);
allCards.addAll(Singletons.getModel().getGameState().getCardsIn(ZoneType.Stack));
boolean checkStatics = false;
// Static triggers
@@ -313,12 +312,12 @@ public class TriggerHandler {
// AP
allCards = playerAP.getCardsIn(ZoneType.STATIC_ABILITIES_SOURCE_ZONES);
allCards.addAll(CardLists.filterControlledBy(GameState.getCardsIn(ZoneType.Stack), playerAP));
allCards.addAll(CardLists.filterControlledBy(Singletons.getModel().getGameState().getCardsIn(ZoneType.Stack), playerAP));
// add cards that move to hidden zones
if (runParams.containsKey("Destination") && runParams.containsKey("Card")) {
Card card = (Card) runParams.get("Card");
if (playerAP.equals(card.getController()) && !allCards.contains(card)
&& (GameState.getZoneOf(card) == null || GameState.getZoneOf(card).getZoneType().isHidden())) {
&& (Singletons.getModel().getGameState().getZoneOf(card) == null || Singletons.getModel().getGameState().getZoneOf(card).getZoneType().isHidden())) {
allCards.add(card);
}
}
@@ -339,12 +338,12 @@ public class TriggerHandler {
// NAP
allCards = playerAP.getOpponent().getCardsIn(ZoneType.STATIC_ABILITIES_SOURCE_ZONES);
allCards.addAll(CardLists.filterControlledBy(GameState.getCardsIn(ZoneType.Stack), playerAP.getOpponent()));
allCards.addAll(CardLists.filterControlledBy(Singletons.getModel().getGameState().getCardsIn(ZoneType.Stack), playerAP.getOpponent()));
// add cards that move to hidden zones
if (runParams.containsKey("Destination") && runParams.containsKey("Card")) {
Card card = (Card) runParams.get("Card");
if (!playerAP.equals(card.getController()) && !allCards.contains(card)
&& (GameState.getZoneOf(card) == null || GameState.getZoneOf(card).getZoneType().isHidden())) {
&& (Singletons.getModel().getGameState().getZoneOf(card) == null || Singletons.getModel().getGameState().getZoneOf(card).getZoneType().isHidden())) {
allCards.add(card);
}
}
@@ -410,7 +409,7 @@ public class TriggerHandler {
if (regtrig.isSuppressed()) {
return false; // Trigger removed by effect
}
if (!regtrig.zonesCheck(GameState.getZoneOf(regtrig.getHostCard()))) {
if (!regtrig.zonesCheck(Singletons.getModel().getGameState().getZoneOf(regtrig.getHostCard()))) {
return false; // Host card isn't where it needs to be.
}
@@ -420,7 +419,7 @@ public class TriggerHandler {
String dest = (String) runParams.get("Destination");
if (dest.equals("Battlefield") && runParams.get("Card") instanceof Card) {
Card card = (Card) runParams.get("Card");
if (card.isCreature() && GameState.isCardInPlay("Torpor Orb")) {
if (card.isCreature() && Singletons.getModel().getGameState().isCardInPlay("Torpor Orb")) {
return false;
}
}
@@ -447,7 +446,7 @@ public class TriggerHandler {
final AbilityFactory abilityFactory = new AbilityFactory();
final SpellAbility[] sa = new SpellAbility[1];
Card host = GameState.getCardState(regtrig.getHostCard());
Card host = Singletons.getModel().getGameState().getCardState(regtrig.getHostCard());
if (host == null) {
host = regtrig.getHostCard();

View File

@@ -17,9 +17,9 @@
*/
package forge.control.input;
import forge.AllZone;
import forge.Card;
import forge.Singletons;
import forge.game.phase.PhaseHandler;
import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.gui.match.CMatchUI;
@@ -36,8 +36,6 @@ public abstract class Input implements java.io.Serializable {
/** Constant <code>serialVersionUID=-6539552513871194081L</code>. */
private static final long serialVersionUID = -6539552513871194081L;
private boolean isFree = false;
// showMessage() is always the first method called
/**
* <p>
@@ -99,12 +97,13 @@ public abstract class Input implements java.io.Serializable {
*/
public final void stop() {
// clears a "temp" Input like Input_PayManaCost if there is one
AllZone.getInputControl().resetInput();
Singletons.getModel().getMatch().getInput().resetInput();
if (Singletons.getModel().getGameState().getPhaseHandler().isNeedToNextPhase()) {
PhaseHandler ph = Singletons.getModel().getGameState().getPhaseHandler();
if (ph.isNeedToNextPhase()) {
// mulligan needs this to move onto next phase
Singletons.getModel().getGameState().getPhaseHandler().setNeedToNextPhase(false);
Singletons.getModel().getGameState().getPhaseHandler().nextPhase();
ph.setNeedToNextPhase(false);
ph.nextPhase();
}
}
@@ -119,7 +118,7 @@ public abstract class Input implements java.io.Serializable {
*/
public final void stopSetNext(final Input in) {
this.stop();
AllZone.getInputControl().setInput(in);
Singletons.getModel().getMatch().getInput().setInput(in);
}
/** {@inheritDoc} */
@@ -128,26 +127,5 @@ public abstract class Input implements java.io.Serializable {
return "blank";
} // returns the Input name like "EmptyStack"
/**
* <p>
* setFree.
* </p>
*
* @param isFree
* a boolean.
*/
public void setFree(final boolean isFree) {
this.isFree = isFree;
}
/**
* <p>
* isFree.
* </p>
*
* @return a boolean.
*/
public boolean isFree() {
return this.isFree;
}
}

View File

@@ -21,7 +21,6 @@ import java.util.List;
import com.google.common.collect.Iterables;
import forge.AllZone;
import forge.Card;
import forge.CardPredicates;
@@ -89,7 +88,7 @@ public class InputAttack extends Input {
}
Singletons.getModel().getGameState().getPhaseHandler().setNeedToNextPhase(true);
AllZone.getInputControl().resetInput();
Singletons.getModel().getMatch().getInput().resetInput();
}
/** {@inheritDoc} */

View File

@@ -20,13 +20,13 @@ package forge.control.input;
import java.util.LinkedList;
import java.util.Stack;
import forge.Singletons;
import forge.game.GameState;
import forge.game.phase.PhaseHandler;
import forge.game.phase.PhaseType;
import forge.game.player.ComputerAIInput;
import forge.game.player.Player;
import forge.game.zone.MagicStack;
import forge.gui.match.CMatchUI;
import forge.model.FModel;
import forge.util.MyObservable;
/**
@@ -47,7 +47,7 @@ public class InputControl extends MyObservable implements java.io.Serializable {
private final Stack<Input> resolvingStack = new Stack<Input>();
private final LinkedList<Input> resolvingQueue = new LinkedList<Input>();
private final FModel model;
private final GameState game;
private ComputerAIInput aiInput; // initialized at runtime to be the latest
// object created
@@ -57,8 +57,8 @@ public class InputControl extends MyObservable implements java.io.Serializable {
* @param fModel
* the f model
*/
public InputControl(final FModel fModel) {
this.model = fModel;
public InputControl(final GameState game0) {
this.game = game0;
}
/**
@@ -70,8 +70,10 @@ public class InputControl extends MyObservable implements java.io.Serializable {
* a {@link forge.control.input.Input} object.
*/
public final void setInput(final Input in) {
if (this.model.getGameState().getStack().getResolving()
|| !((this.input == null) || (this.input instanceof InputPassPriority))) {
MagicStack stack = this.game.getStack();
boolean isInputEmpty = this.input == null || this.input instanceof InputPassPriority;
if (stack.isResolving() || !isInputEmpty) {
this.inputStack.add(in);
} else {
this.input = in;
@@ -136,15 +138,6 @@ public class InputControl extends MyObservable implements java.io.Serializable {
this.inputStack.clear();
}
/**
* <p>
* resetInput.
* </p>
*/
public final void resetInput() {
this.input = null;
this.updateObservers();
}
/**
* <p>
@@ -154,6 +147,7 @@ public class InputControl extends MyObservable implements java.io.Serializable {
* @param update
* a boolean.
*/
public final void resetInput() { resetInput(true); }
public final void resetInput(final boolean update) {
this.input = null;
if (update) {
@@ -169,10 +163,11 @@ public class InputControl extends MyObservable implements java.io.Serializable {
* @return a {@link forge.control.input.Input} object.
*/
public final Input updateInput() {
final PhaseHandler handler = this.model.getGameState().getPhaseHandler();
final PhaseHandler handler = game.getPhaseHandler();
final PhaseType phase = handler.getPhase();
final Player playerTurn = handler.getPlayerTurn();
final Player priority = handler.getPriorityPlayer();
final MagicStack stack = game.getStack();
// TODO this resolving portion needs more work, but fixes Death Cloud
// issues
@@ -187,18 +182,20 @@ public class InputControl extends MyObservable implements java.io.Serializable {
return this.input;
}
if (this.model.getGameState().getStack().getResolving()) {
if (stack.isResolving()) {
return null;
}
if (this.input != null) {
return this.input;
} else if (this.inputStack.size() > 0) { // incoming input to Control
}
if (!this.inputStack.isEmpty()) { // incoming input to Control
this.changeInput(this.inputStack.pop());
return this.input;
}
if (Singletons.getModel().getGameState() != null && handler.doPhaseEffects()) {
if (handler.doPhaseEffects()) {
// Handle begin phase stuff, then start back from the top
handler.handleBeginPhase();
return this.updateInput();
@@ -212,19 +209,19 @@ public class InputControl extends MyObservable implements java.io.Serializable {
// Special Inputs needed for the following phases:
if (phase == PhaseType.COMBAT_DECLARE_ATTACKERS) {
this.model.getGameState().getStack().freezeStack();
stack.freezeStack();
if (playerTurn.isHuman() && !handler.getAutoPass()) {
Singletons.getModel().getGameState().getCombat().initiatePossibleDefenders(playerTurn.getOpponent());
game.getCombat().initiatePossibleDefenders(playerTurn.getOpponent());
return new InputAttack();
}
} else if (phase == PhaseType.COMBAT_DECLARE_BLOCKERS) {
this.model.getGameState().getStack().freezeStack();
stack.freezeStack();
if (playerTurn.isHuman()) {
this.aiInput.getComputer().declareBlockers();
return null;
} else {
if (this.model.getGameState().getCombat().getAttackers().isEmpty()) {
if (game.getCombat().getAttackers().isEmpty()) {
// no active attackers, skip the Blocking phase
handler.setNeedToNextPhase(true);
return null;
@@ -235,7 +232,7 @@ public class InputControl extends MyObservable implements java.io.Serializable {
}
} else if (phase == PhaseType.CLEANUP) {
// discard
if (this.model.getGameState().getStack().size() == 0) {
if (stack.isEmpty()) {
// resolve things
// like Madness
return new InputCleanup();
@@ -263,13 +260,13 @@ public class InputControl extends MyObservable implements java.io.Serializable {
} // getInput()
private boolean autoSkipHumanPriority(Player turn, PhaseType phase) {
PhaseHandler handler = this.model.getGameState().getPhaseHandler();
PhaseHandler handler = game.getPhaseHandler();
// Handler tells me if I should skip, and I reset the flag
final boolean skip = handler.doSkipPhase();
handler.setSkipPhase(false);
// If the stack isn't empty, and skip is disallowed, stop auto passing
if (!skip || !this.model.getGameState().getStack().isEmpty()) {
if (!skip || !this.game.getStack().isEmpty()) {
handler.setAutoPass(false);
return false;
}

View File

@@ -23,12 +23,12 @@ import java.util.List;
import forge.Card;
import forge.CardLists;
import forge.CardPredicates;
import forge.GameAction;
import forge.GameActionUtil;
import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory;
import forge.card.spellability.SpellAbility;
import forge.game.GameState;
import forge.game.phase.PhaseUtil;
import forge.game.player.ComputerUtil;
import forge.game.player.Player;
@@ -159,8 +159,7 @@ public class InputMulligan extends Input {
}
}
if (c.getName().startsWith("Leyline")
&& !(c.getName().startsWith("Leyline of Singularity") && (GameState.getCardsIn(ZoneType.Battlefield,
"Leyline of Singularity").size() > 0))) {
&& !(c.getName().startsWith("Leyline of Singularity") && (CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Leyline of Singularity")).size() > 0))) {
ga.moveToPlay(c);
//ga.checkStateEffects();
}

View File

@@ -17,7 +17,6 @@
*/
package forge.control.input;
import forge.AllZone;
import forge.Card;
import forge.Singletons;
import forge.game.phase.PhaseType;
@@ -75,9 +74,9 @@ public class InputPassPriority extends Input implements java.io.Serializable {
public final void selectButtonOK() {
Singletons.getModel().getGameState().getPhaseHandler().passPriority();
//GuiDisplayUtil.updateGUI();
final Input in = AllZone.getInputControl().getInput();
final Input in = Singletons.getModel().getMatch().getInput().getInput();
if ((in == this) || (in == null)) {
AllZone.getInputControl().resetInput();
Singletons.getModel().getMatch().getInput().resetInput();
// Clear out PassPriority after clicking button
}
}

View File

@@ -17,7 +17,6 @@
*/
package forge.control.input;
import forge.AllZone;
import forge.Card;
import forge.Singletons;
import forge.card.mana.ManaCost;
@@ -163,7 +162,7 @@ public class InputPayManaCost extends InputMana {
this.manaCost = InputPayManaCostUtil.activateManaAbility(this.spell, card, this.manaCost);
// only show message if this is the active input
if (AllZone.getInputControl().getInput() == this) {
if (Singletons.getModel().getMatch().getInput().getInput() == this) {
this.showMessage();
}
@@ -200,7 +199,7 @@ public class InputPayManaCost extends InputMana {
if (this.spell.getAfterPayMana() != null) {
this.stopSetNext(this.spell.getAfterPayMana());
} else {
AllZone.getInputControl().resetInput();
Singletons.getModel().getMatch().getInput().resetInput();
}
} else {
Singletons.getControl().getPlayer().getManaPool().clearManaPaid(this.spell, false);
@@ -228,7 +227,7 @@ public class InputPayManaCost extends InputMana {
} else {
Singletons.getModel().getGameState().getStack().add(this.spell);
}
AllZone.getInputControl().resetInput();
Singletons.getModel().getMatch().getInput().resetInput();
}
// If this is a spell with convoke, re-tap all creatures used for
@@ -304,7 +303,7 @@ public class InputPayManaCost extends InputMana {
this.manaCost = InputPayManaCostUtil.activateManaAbility(color, this.spell, this.manaCost);
// only show message if this is the active input
if (AllZone.getInputControl().getInput() == this) {
if (Singletons.getModel().getMatch().getInput().getInput() == this) {
this.showMessage();
}

View File

@@ -22,7 +22,6 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import forge.AllZone;
import forge.Card;
import forge.CardUtil;
import forge.Constant;
@@ -408,7 +407,7 @@ public class InputPayManaCostUtil {
this.xPaid++;
}
if (AllZone.getInputControl().getInput() == this) {
if (Singletons.getModel().getMatch().getInput().getInput() == this) {
this.showMessage();
}
}
@@ -440,7 +439,7 @@ public class InputPayManaCostUtil {
this.xPaid++;
}
if (AllZone.getInputControl().getInput() == this) {
if (Singletons.getModel().getMatch().getInput().getInput() == this) {
this.showMessage();
}
}
@@ -503,7 +502,7 @@ public class InputPayManaCostUtil {
if (this.mana.isPaid()) {
this.done();
} else if (AllZone.getInputControl().getInput() == this) {
} else if (Singletons.getModel().getMatch().getInput().getInput() == this) {
this.showMessage();
}
}
@@ -605,7 +604,7 @@ public class InputPayManaCostUtil {
if (this.mana.isPaid()) {
this.done();
} else if (AllZone.getInputControl().getInput() == this) {
} else if (Singletons.getModel().getMatch().getInput().getInput() == this) {
this.showMessage();
}
}

View File

@@ -97,7 +97,7 @@ public class GameNew {
* their decks and other special starting conditions.
*/
public static void newGame(final Map<Player, PlayerStartConditions> playersConditions, GameType gameType) {
AllZone.getInputControl().clearInput();
Singletons.getModel().getMatch().getInput().clearInput();
AllZone.getColorChanger().reset();
Card.resetUniqueNumber();

View File

@@ -21,17 +21,11 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import forge.Card;
import forge.CardLists;
import forge.CardPredicates;
import forge.CardPredicates.Presets;
import forge.CardUtil;
import forge.Counters;
import forge.GameLog;
import forge.Singletons;
import forge.StaticEffects;
import forge.card.replacement.ReplacementHandler;
import forge.card.trigger.TriggerHandler;
@@ -53,13 +47,6 @@ import forge.game.zone.ZoneType;
* "cleaned up" at each new game.
*/
public class GameState {
/** The Constant HUMAN_PLAYER_NAME. */
public static final String HUMAN_PLAYER_NAME = "Human";
/** The Constant AI_PLAYER_NAME. */
public static final String AI_PLAYER_NAME = "Computer";
private final List<Player> roPlayers;
private final Cleanup cleanup = new Cleanup();
private final EndOfTurn endOfTurn = new EndOfTurn();
@@ -292,26 +279,12 @@ public class GameState {
// THESE WERE MOVED HERE FROM AllZoneUtil
// They must once become non-static members of this class
/**
* <p>
* getZone.
* </p>
*
* @param c
* a {@link forge.Card} object.
* @return a {@link forge.game.zone.PlayerZone} object.
*/
public static PlayerZone getZoneOf(final Card c) {
final GameState gameState = Singletons.getModel().getGameState();
if (gameState == null) {
return null;
public PlayerZone getZoneOf(final Card c) {
if (getStackZone().contains(c)) {
return getStackZone();
}
if (gameState.getStackZone().contains(c)) {
return gameState.getStackZone();
}
for (final Player p : gameState.getPlayers()) {
for (final Player p : getPlayers()) {
for (final ZoneType z : Player.ALL_ZONES) {
final PlayerZone pz = p.getZone(z);
if (pz.contains(c)) {
@@ -323,28 +296,13 @@ public class GameState {
return null;
}
/**
*
* isCardInZone.
*
* @param c
* Card
* @param zone
* Constant.Zone
* @return boolean
*/
public static boolean isCardInZone(final Card c, final ZoneType zone) {
final GameState gameState = Singletons.getModel().getGameState();
if (gameState == null) {
return false;
}
if (zone.equals(ZoneType.Stack)) {
if (gameState.getStackZone().contains(c)) {
public boolean isCardInZone(final Card c, final ZoneType zone) {
if (zone.equals(ZoneType.Stack)) {
if (getStackZone().contains(c)) {
return true;
}
} else {
for (final Player p : gameState.getPlayers()) {
for (final Player p : getPlayers()) {
if (p.getZone(zone).contains(c)) {
return true;
}
@@ -354,37 +312,12 @@ public class GameState {
return false;
}
/**
* <p>
* resetZoneMoveTracking.
* </p>
*/
public static void resetZoneMoveTracking() {
final GameState gameState = Singletons.getModel().getGameState();
if (gameState == null) {
return;
}
for (final Player p : gameState.getPlayers()) {
for (final ZoneType z : Player.ALL_ZONES) {
p.getZone(z).resetCardsAddedThisTurn();
}
}
}
/**
* gets a list of all cards owned by both players that have are currently in
* the given zone.
*
* @param zone
* Constant.Zone
* @return a List<Card> with all cards currently in a graveyard
*/
public static List<Card> getCardsIn(final ZoneType zone) {
public List<Card> getCardsIn(final ZoneType zone) {
if (zone == ZoneType.Stack) {
return Singletons.getModel().getGameState().getStackZone().getCards();
return getStackZone().getCards();
} else {
List<Card> cards = null;
for (final Player p : Singletons.getModel().getGameState().getPlayers()) {
for (final Player p : getPlayers()) {
if ( cards == null )
cards = p.getZone(zone).getCards();
else
@@ -394,7 +327,7 @@ public class GameState {
}
}
public static List<Card> getCardsIn(final Iterable<ZoneType> zones) {
public List<Card> getCardsIn(final Iterable<ZoneType> zones) {
final List<Card> cards = new ArrayList<Card>();
for (final ZoneType z : zones) {
cards.addAll(getCardsIn(z));
@@ -402,168 +335,33 @@ public class GameState {
return cards;
}
/**
* gets a list of all cards owned by both players that have are currently in
* the given zone.
*
* @param zone
* a Constant.Zone
* @param cardName
* a String
* @return a List<Card> with all cards currently in a graveyard
*/
public static List<Card> getCardsIn(final ZoneType zone, final String cardName) {
return CardLists.filter(GameState.getCardsIn(zone), CardPredicates.nameEquals(cardName));
public List<Card> getLandsInPlay() {
return CardLists.filter(getCardsIn(ZoneType.Battlefield), Presets.LANDS);
}
/**
* use to get a List<Card> of all creatures on the battlefield for both.
* players
*
* @return a List<Card> of all creatures on the battlefield on both sides
*/
public static List<Card> getCreaturesInPlay() {
final List<Card> creats = GameState.getCardsIn(ZoneType.Battlefield);
return CardLists.filter(creats, Presets.CREATURES);
public boolean isCardExiled(final Card c) {
return getCardsIn(ZoneType.Exile).contains(c);
}
/**
* use to get a list of creatures in play for a given player.
*
* @param player
* the player to get creatures for
* @return a List<Card> containing all creatures a given player has in play
*/
public static List<Card> getCreaturesInPlay(final Player player) {
final List<Card> creats = player.getCardsIn(ZoneType.Battlefield);
return CardLists.filter(creats, Presets.CREATURES);
}
/**
* use to get a list of all lands a given player has on the battlefield.
*
* @param player
* the player whose lands we want to get
* @return a List<Card> containing all lands the given player has in play
*/
public static List<Card> getPlayerLandsInPlay(final Player player) {
return CardLists.filter(player.getCardsIn(ZoneType.Battlefield), Presets.LANDS);
}
/**
* gets a list of all lands in play.
*
* @return a List<Card> of all lands on the battlefield
*/
public static List<Card> getLandsInPlay() {
return CardLists.filter(GameState.getCardsIn(ZoneType.Battlefield), Presets.LANDS);
}
/**
* answers the question "is the given card in any exile zone?".
*
* @param c
* the card to look for in Exile
* @return true is the card is in Human or Computer's Exile zone
*/
public static boolean isCardExiled(final Card c) {
return GameState.getCardsIn(ZoneType.Exile).contains(c);
}
// /Check if a certain card is in play
/**
* <p>
* isCardInPlay.
* </p>
*
* @param card
* a {@link forge.Card} object.
* @return a boolean.
*/
public static boolean isCardInPlay(final Card card) {
if (card.getController() == null) {
return false;
}
return card.getController().getCardsIn(ZoneType.Battlefield).contains(card);
}
/**
* Answers the question: "Is <card name> in play?".
*
* @param cardName
* the name of the card to look for
* @return true is the card is in play, false otherwise
*/
public static boolean isCardInPlay(final String cardName) {
for (final Player p : Singletons.getModel().getGameState().getPlayers()) {
if (isCardInPlay(cardName, p))
public boolean isCardInPlay(final String cardName) {
for (final Player p : getPlayers()) {
if (p.isCardInPlay(cardName))
return true;
}
return false;
}
/**
* Answers the question: "Does <player> have <card name> in play?".
*
* @param cardName
* the name of the card to look for
* @param player
* the player whose battlefield we want to check
* @return true if that player has that card in play, false otherwise
*/
public static boolean isCardInPlay(final String cardName, final Player player) {
return Iterables.any(player.getZone(ZoneType.Battlefield), CardPredicates.nameEquals(cardName));
}
/**
* gets a list of all Cards of a given color on the battlefield.
*
* @param color
* the color of cards to get
* @return a List<Card> of all cards in play of a given color
*/
public static List<Card> getColorInPlay(final String color) {
public List<Card> getColoredCardsInPlay(final String color) {
final List<Card> cards = new ArrayList<Card>();
for(Player p : Singletons.getModel().getGameState().getPlayers()) {
cards.addAll(getPlayerColorInPlay(p, color));
for(Player p : getPlayers()) {
cards.addAll(p.getColoredCardsInPlay(color));
}
return cards;
}
/**
* gets a list of all Cards of a given color a given player has on the
* battlefield.
*
* @param player
* the player's cards to get
* @param color
* the color of cards to get
* @return a List<Card> of all cards in play of a given color
*/
public static List<Card> getPlayerColorInPlay(final Player player, final String color) {
List<Card> cards = player.getCardsIn(ZoneType.Battlefield);
cards = CardLists.filter(cards, new Predicate<Card>() {
@Override
public boolean apply(final Card c) {
final List<String> colorList = CardUtil.getColors(c);
return colorList.contains(color);
}
});
return cards;
}
/**
* <p>
* getCardState.
* </p>
*
* @param card
* a {@link forge.Card} object.
* @return a {@link forge.Card} object.
*/
public static Card getCardState(final Card card) {
for (final Card c : GameState.getCardsInGame()) {
public Card getCardState(final Card card) {
for (final Card c : getCardsInGame()) {
if (card.equals(c)) {
return c;
}
@@ -610,45 +408,19 @@ public class GameState {
return (playerList.size() - opponentList.size());
}
/**
* a CardListFilter to get all cards that are a part of this game.
*
* @return a {@link forge.CardList} with all cards in all Battlefields,
* Hands, Graveyards, Libraries, and Exiles.
*/
public static List<Card> getCardsInGame() {
public List<Card> getCardsInGame() {
final List<Card> all = new ArrayList<Card>();
for (final Player player : Singletons.getModel().getGameState().getPlayers()) {
for (final Player player : getPlayers()) {
all.addAll(player.getZone(ZoneType.Graveyard).getCards());
all.addAll(player.getZone(ZoneType.Hand).getCards());
all.addAll(player.getZone(ZoneType.Library).getCards());
all.addAll(player.getZone(ZoneType.Battlefield).getCards(false));
all.addAll(player.getZone(ZoneType.Exile).getCards());
}
all.addAll(Singletons.getModel().getGameState().getStackZone().getCards());
all.addAll(getStackZone().getCards());
return all;
}
/**
* <p>
* getDoublingSeasonMagnitude.
* </p>
*
* @param player
* the {@link forge.game.player.Player} player to determine if is affected by
* Doubling Season
* @return a int.
*/
public static int getCounterDoublersMagnitude(final Player player, Counters type) {
int counterDoublers = player.getCardsIn(ZoneType.Battlefield, "Doubling Season").size();
if(type == Counters.P1P1) {
counterDoublers += player.getCardsIn(ZoneType.Battlefield, "Corpsejack Menace").size();
}
return (int) Math.pow(2, counterDoublers); // pow(a,0) = 1; pow(a,1) = a
// ... no worries about size
// = 0
}
/**
* <p>
* getTokenDoublersMagnitude.
@@ -659,11 +431,5 @@ public class GameState {
* Doubling Season
* @return a int.
*/
public static int getTokenDoublersMagnitude(final Player player) {
final int tokenDoublers = player.getCardsIn(ZoneType.Battlefield, "Parallel Lives").size()
+ player.getCardsIn(ZoneType.Battlefield, "Doubling Season").size();
return (int) Math.pow(2, tokenDoublers); // pow(a,0) = 1; pow(a,1) = a
// ... no worries about size =
// 0
}
}

View File

@@ -6,10 +6,10 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import forge.AllZone;
import forge.Singletons;
import forge.Constant.Preferences;
import forge.control.FControl;
import forge.control.input.InputControl;
import forge.control.input.InputMulligan;
import forge.deck.Deck;
import forge.error.ErrorViewer;
@@ -19,6 +19,7 @@ import forge.game.player.LobbyPlayer;
import forge.game.player.Player;
import forge.game.player.PlayerType;
import forge.game.zone.ZoneType;
import forge.gui.GuiInput;
import forge.gui.framework.EDocID;
import forge.gui.framework.SDisplayUtil;
import forge.gui.match.CMatchUI;
@@ -49,6 +50,8 @@ public class MatchController {
private final List<GameOutcome> gamesPlayed = new ArrayList<GameOutcome>();
private final List<GameOutcome> gamesPlayedRo;
private InputControl input;
public MatchController() {
gamesPlayedRo = Collections.unmodifiableList(gamesPlayed);
}
@@ -95,6 +98,10 @@ public class MatchController {
// Will this lose all the ordering?
currentGame = Singletons.getModel().newGame(players.keySet());
// Instantiate AI
input = new InputControl(currentGame);
Map<Player, PlayerStartConditions> startConditions = new HashMap<Player, PlayerStartConditions>();
for (Player p : currentGame.getPlayers())
startConditions.put(p, players.get(p.getLobbyPlayer()));
@@ -106,15 +113,19 @@ public class MatchController {
SDisplayUtil.showTab(EDocID.REPORT_LOG.getDoc());
// set all observers
CMessage.SINGLETON_INSTANCE.subscribe(currentGame);
CLog.SINGLETON_INSTANCE.subscribe(currentGame);
CStack.SINGLETON_INSTANCE.subscribe(currentGame);
GuiInput inputControl = CMessage.SINGLETON_INSTANCE.getInputControl();
input.addObserver(inputControl);
currentGame.getStack().addObserver(inputControl);
currentGame.getPhaseHandler().addObserver(inputControl);
currentGame.getGameLog().addObserver(CLog.SINGLETON_INSTANCE);
currentGame.getStack().addObserver(CStack.SINGLETON_INSTANCE);
// some observers are set in CMatchUI.initMatch
GameNew.newGame(startConditions, gameType);
Player computerPlayer = Aggregates.firstFieldEquals(currentGame.getPlayers(), Player.Accessors.FN_GET_TYPE, PlayerType.COMPUTER);
AllZone.getInputControl().setComputer(new ComputerAIInput(new ComputerAIGeneral(computerPlayer)));
input.setComputer(new ComputerAIInput(new ComputerAIGeneral(computerPlayer)));
if (this.getPlayedGames().isEmpty()) {
@@ -127,16 +138,16 @@ public class MatchController {
}
VAntes.SINGLETON_INSTANCE.clearAnteCards();
AllZone.getInputControl().resetInput();
Singletons.getModel().getMatch().getInput().resetInput();
}
// per player observers were set in CMatchUI.SINGLETON_INSTANCE.initMatch
CMessage.SINGLETON_INSTANCE.updateGameInfo(this);
// Update observers
Singletons.getModel().getGameState().getStack().updateObservers();
AllZone.getInputControl().updateObservers();
Singletons.getModel().getGameState().getGameLog().updateObservers();
currentGame.getStack().updateObservers();
input.updateObservers();
currentGame.getGameLog().updateObservers();
for( Player p : currentGame.getPlayers() ) {
@@ -145,7 +156,7 @@ public class MatchController {
}
CMatchUI.SINGLETON_INSTANCE.setCard(Singletons.getControl().getPlayer().getCardsIn(ZoneType.Hand).get(0));
AllZone.getInputControl().setInput(new InputMulligan());
input.setInput(new InputMulligan());
} catch (Exception e) {
ErrorViewer.showError(e);
@@ -257,4 +268,8 @@ public class MatchController {
PlayerStartConditions cond = players.get(lobbyPlayer);
return cond == null ? null : cond.getDeck();
}
public final InputControl getInput() {
return input;
}
}

View File

@@ -34,7 +34,6 @@ import forge.GameActionUtil;
import forge.GameEntity;
import forge.Singletons;
import forge.card.trigger.TriggerType;
import forge.game.GameState;
import forge.game.player.Player;
import forge.game.zone.ZoneType;
import forge.gui.match.CMatchUI;
@@ -625,7 +624,7 @@ public class Combat {
all.addAll(this.getAllBlockers());
for (int i = 0; i < all.size(); i++) {
if (!GameState.isCardInPlay(all.get(i))) {
if (!all.get(i).isInPlay()) {
this.removeFromCombat(all.get(i));
}
}

View File

@@ -35,7 +35,6 @@ import forge.CardPredicates;
import forge.Command;
import forge.Constant;
import forge.Counters;
import forge.GameAction;
import forge.GameActionUtil;
import forge.GameEntity;
import forge.Singletons;
@@ -53,7 +52,6 @@ import forge.card.staticability.StaticAbility;
import forge.card.trigger.Trigger;
import forge.card.trigger.TriggerHandler;
import forge.card.trigger.TriggerType;
import forge.game.GameState;
import forge.game.player.ComputerUtil;
import forge.game.player.ComputerUtilBlock;
import forge.game.player.Player;
@@ -100,7 +98,7 @@ public class CombatUtil {
return false;
}
for (final Card c : GameState.getCardsIn(ZoneType.Battlefield)) {
for (final Card c : Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield)) {
for (final String keyword : c.getKeyword()) {
if (keyword.equals("No more than one creature can block each combat.")
&& (combat.getAllBlockers().size() > 0)) {
@@ -113,7 +111,7 @@ public class CombatUtil {
}
}
if (combat.getAllBlockers().size() > 0 && GameState.isCardInPlay("Dueling Grounds")) {
if (combat.getAllBlockers().size() > 0 && Singletons.getModel().getGameState().isCardInPlay("Dueling Grounds")) {
return false;
}
@@ -159,7 +157,7 @@ public class CombatUtil {
return false;
}
final List<Card> list = GameState.getCreaturesInPlay(blocker.getController());
final List<Card> list = blocker.getController().getCreaturesInPlay();
if (list.size() < 2 && blocker.hasKeyword("CARDNAME can't attack or block alone.")) {
return false;
}
@@ -381,7 +379,7 @@ public class CombatUtil {
*/
public static boolean finishedMandatoryBlocks(final Combat combat) {
final List<Card> blockers = GameState.getCreaturesInPlay(Singletons.getControl().getPlayer());
final List<Card> blockers = Singletons.getControl().getPlayer().getCreaturesInPlay();
final List<Card> attackers = combat.getAttackerList();
// if a creature does not block but should, return false
@@ -760,7 +758,7 @@ public class CombatUtil {
return false;
}
if (GameState.isCardInPlay("Shifting Sliver")) {
if (Singletons.getModel().getGameState().isCardInPlay("Shifting Sliver")) {
if (attacker.isType("Sliver") && !blocker.isType("Sliver")) {
return false;
}
@@ -784,7 +782,7 @@ public class CombatUtil {
public static boolean canAttack(final Card c, final Combat combat) {
int cntAttackers = combat.getAttackers().size();
for (final Card card : GameState.getCardsIn(ZoneType.Battlefield)) {
for (final Card card : Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield)) {
for (final String keyword : card.getKeyword()) {
if (keyword.equals("No more than one creature can attack each combat.") && cntAttackers > 0) {
return false;
@@ -802,7 +800,7 @@ public class CombatUtil {
}
}
final List<Card> list = GameState.getCreaturesInPlay(c.getController());
final List<Card> list = c.getController().getCreaturesInPlay();
if (list.size() < 2 && c.hasKeyword("CARDNAME can't attack or block alone.")) {
return false;
}
@@ -811,7 +809,7 @@ public class CombatUtil {
return false;
}
if (cntAttackers > 0 && GameState.isCardInPlay("Dueling Grounds")) {
if (cntAttackers > 0 && Singletons.getModel().getGameState().isCardInPlay("Dueling Grounds")) {
return false;
}
@@ -879,7 +877,7 @@ public class CombatUtil {
if (asSeparateWords[12].matches("[0-9][0-9]?")) {
powerLimit[0] = Integer.parseInt((asSeparateWords[12]).trim());
List<Card> list = GameState.getCreaturesInPlay(c.getController().getOpponent());
List<Card> list = c.getController().getOpponent().getCreaturesInPlay();
list = CardLists.filter(list, new Predicate<Card>() {
@Override
public boolean apply(final Card ct) {
@@ -958,7 +956,7 @@ public class CombatUtil {
public static int getTotalFirstStrikeBlockPower(final Card attacker, final Player player) {
final Card att = attacker;
List<Card> list = GameState.getCreaturesInPlay(player);
List<Card> list = player.getCreaturesInPlay();
list = CardLists.filter(list, new Predicate<Card>() {
@Override
public boolean apply(final Card c) {
@@ -1321,7 +1319,7 @@ public class CombatUtil {
}
int defenderDamage = defender.getNetAttack() + CombatUtil.predictPowerBonusOfBlocker(attacker, defender, true);
if (GameState.isCardInPlay("Doran, the Siege Tower")) {
if (Singletons.getModel().getGameState().isCardInPlay("Doran, the Siege Tower")) {
defenderDamage = defender.getNetDefense() + CombatUtil.predictToughnessBonusOfBlocker(attacker, defender, true);
}
@@ -1465,7 +1463,7 @@ public class CombatUtil {
combat = Singletons.getModel().getGameState().getCombat();
}
if (!trigger.zonesCheck(GameState.getZoneOf(trigger.getHostCard()))) {
if (!trigger.zonesCheck(Singletons.getModel().getGameState().getZoneOf(trigger.getHostCard()))) {
return false;
}
if (!trigger.requirementsCheck()) {
@@ -1581,7 +1579,7 @@ public class CombatUtil {
// look out for continuous static abilities that only care for blocking
// creatures
final List<Card> cardList = GameState.getCardsIn(ZoneType.Battlefield);
final List<Card> cardList = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
for (final Card card : cardList) {
for (final StaticAbility stAb : card.getStaticAbilities()) {
final HashMap<String, String> params = stAb.getMapParams();
@@ -1608,7 +1606,7 @@ public class CombatUtil {
}
final ArrayList<Trigger> theTriggers = new ArrayList<Trigger>();
for (Card card : GameState.getCardsIn(ZoneType.Battlefield)) {
for (Card card : Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield)) {
theTriggers.addAll(card.getTriggers());
}
theTriggers.addAll(attacker.getTriggers());
@@ -1707,7 +1705,7 @@ public class CombatUtil {
toughness += defender.getKeywordMagnitude("Bushido");
final ArrayList<Trigger> theTriggers = new ArrayList<Trigger>();
for (Card card : GameState.getCardsIn(ZoneType.Battlefield)) {
for (Card card : Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield)) {
theTriggers.addAll(card.getTriggers());
}
theTriggers.addAll(attacker.getTriggers());
@@ -1829,7 +1827,7 @@ public class CombatUtil {
}
final ArrayList<Trigger> theTriggers = new ArrayList<Trigger>();
for (Card card : GameState.getCardsIn(ZoneType.Battlefield)) {
for (Card card : Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield)) {
theTriggers.addAll(card.getTriggers());
}
// if the defender has first strike and wither the attacker will deal
@@ -1846,7 +1844,7 @@ public class CombatUtil {
// look out for continuous static abilities that only care for attacking
// creatures
final List<Card> cardList = GameState.getCardsIn(ZoneType.Battlefield);
final List<Card> cardList = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
for (final Card card : cardList) {
for (final StaticAbility stAb : card.getStaticAbilities()) {
final HashMap<String, String> params = stAb.getMapParams();
@@ -1961,7 +1959,7 @@ public class CombatUtil {
}
final ArrayList<Trigger> theTriggers = new ArrayList<Trigger>();
for (Card card : GameState.getCardsIn(ZoneType.Battlefield)) {
for (Card card : Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield)) {
theTriggers.addAll(card.getTriggers());
}
if (defender != null) {
@@ -1971,7 +1969,7 @@ public class CombatUtil {
// look out for continuous static abilities that only care for attacking
// creatures
final List<Card> cardList = GameState.getCardsIn(ZoneType.Battlefield);
final List<Card> cardList = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
for (final Card card : cardList) {
for (final StaticAbility stAb : card.getStaticAbilities()) {
final HashMap<String, String> params = stAb.getMapParams();
@@ -2092,7 +2090,7 @@ public class CombatUtil {
*/
public static boolean checkDestroyBlockerTrigger(final Card attacker, final Card defender) {
final ArrayList<Trigger> theTriggers = new ArrayList<Trigger>();
for (Card card : GameState.getCardsIn(ZoneType.Battlefield)) {
for (Card card : Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield)) {
theTriggers.addAll(card.getTriggers());
}
for (Trigger trigger : theTriggers) {
@@ -2147,7 +2145,7 @@ public class CombatUtil {
*/
public static boolean checkDestroyAttackerTrigger(final Card attacker, final Card defender) {
final ArrayList<Trigger> theTriggers = new ArrayList<Trigger>();
for (Card card : GameState.getCardsIn(ZoneType.Battlefield)) {
for (Card card : Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield)) {
theTriggers.addAll(card.getTriggers());
}
for (Trigger trigger : theTriggers) {
@@ -2241,7 +2239,7 @@ public class CombatUtil {
+ CombatUtil.predictPowerBonusOfBlocker(attacker, defender, withoutAbilities);
int attackerDamage = attacker.getNetAttack()
+ CombatUtil.predictPowerBonusOfAttacker(attacker, defender, combat);
if (GameState.isCardInPlay("Doran, the Siege Tower")) {
if (Singletons.getModel().getGameState().isCardInPlay("Doran, the Siege Tower")) {
defenderDamage = defender.getNetDefense()
+ CombatUtil.predictToughnessBonusOfBlocker(attacker, defender, withoutAbilities);
attackerDamage = attacker.getNetDefense()
@@ -2389,7 +2387,7 @@ public class CombatUtil {
+ CombatUtil.predictPowerBonusOfBlocker(attacker, defender, withoutAbilities);
int attackerDamage = attacker.getNetAttack()
+ CombatUtil.predictPowerBonusOfAttacker(attacker, defender, combat);
if (GameState.isCardInPlay("Doran, the Siege Tower")) {
if (Singletons.getModel().getGameState().isCardInPlay("Doran, the Siege Tower")) {
defenderDamage = defender.getNetDefense()
+ CombatUtil.predictToughnessBonusOfBlocker(attacker, defender, withoutAbilities);
attackerDamage = attacker.getNetDefense()
@@ -2478,7 +2476,7 @@ public class CombatUtil {
* </p>
*/
public static void removeAllDamage() {
final List<Card> cl = GameState.getCardsIn(ZoneType.Battlefield);
final List<Card> cl = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
for (final Card c : cl) {
c.setDamage(0);
}
@@ -2644,7 +2642,7 @@ public class CombatUtil {
public static void checkPropagandaEffects(final Card c, final boolean bLast) {
Cost attackCost = new Cost(c, "0", true);
// Sort abilities to apply them in proper order
for (Card card : GameState.getCardsIn(ZoneType.Battlefield)) {
for (Card card : Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield)) {
final ArrayList<StaticAbility> staticAbilities = card.getStaticAbilities();
for (final StaticAbility stAb : staticAbilities) {
Cost additionalCost = stAb.getCostAbility("CantAttackUnless", c, Singletons.getModel().getGameState().getCombat().getDefenderByAttacker(c));
@@ -2800,13 +2798,13 @@ public class CombatUtil {
@Override
public void execute() {
if (GameState.isCardInPlay(charger)) {
if (charger.isInPlay()) {
charger.removeIntrinsicKeyword("Trample");
}
}
}; // Command
if (GameState.isCardInPlay(charger)) {
if (charger.isInPlay()) {
charger.addIntrinsicKeyword("Trample");
Singletons.getModel().getGameState().getEndOfTurn().addUntil(untilEOT);
@@ -2952,14 +2950,14 @@ public class CombatUtil {
@Override
public void execute() {
if (GameState.isCardInPlay(blocker)) {
if (blocker.isInPlay()) {
blocker.addTempAttackBoost(mag);
blocker.addTempDefenseBoost(mag);
}
}
}; // Command
if (GameState.isCardInPlay(blocker)) {
if (blocker.isInPlay()) {
blocker.addTempAttackBoost(-mag);
blocker.addTempDefenseBoost(-mag);
@@ -3008,14 +3006,14 @@ public class CombatUtil {
@Override
public void execute() {
if (GameState.isCardInPlay(crd)) {
if (crd.isInPlay()) {
crd.addTempAttackBoost(-1);
crd.addTempDefenseBoost(-1);
}
}
}; // Command
if (GameState.isCardInPlay(crd)) {
if (crd.isInPlay()) {
crd.addTempAttackBoost(1);
crd.addTempDefenseBoost(1);
@@ -3105,8 +3103,8 @@ public class CombatUtil {
} else {
enchantment = CardFactoryUtil.getBestEnchantmentAI(enchantments, this, false);
}
if ((enchantment != null) && GameState.isCardInPlay(attacker)) {
GameAction.changeZone(GameState.getZoneOf(enchantment),
if ((enchantment != null) && attacker.isInPlay()) {
Singletons.getModel().getGameAction().changeZone(Singletons.getModel().getGameState().getZoneOf(enchantment),
enchantment.getOwner().getZone(ZoneType.Battlefield), enchantment, null);
enchantment.enchantEntity(attacker);
}
@@ -3152,14 +3150,14 @@ public class CombatUtil {
@Override
public void execute() {
if (GameState.isCardInPlay(crd)) {
if (crd.isInPlay()) {
crd.addTempAttackBoost(-pump);
crd.addTempDefenseBoost(-pump);
}
}
}; // Command
if (GameState.isCardInPlay(crd)) {
if (crd.isInPlay()) {
crd.addTempAttackBoost(pump);
crd.addTempDefenseBoost(pump);

View File

@@ -29,7 +29,6 @@ import forge.Singletons;
import forge.card.spellability.Ability;
import forge.card.spellability.SpellAbility;
import forge.game.GameLossReason;
import forge.game.GameState;
import forge.game.player.Player;
import forge.game.zone.ZoneType;
@@ -56,7 +55,7 @@ public class EndOfTurn extends Phase implements java.io.Serializable {
// TODO - should this freeze the Stack?
final List<Card> all = GameState.getCardsIn(ZoneType.Battlefield);
final List<Card> all = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
//EndOfTurn.endOfTurnWallOfReverence();
EndOfTurn.endOfTurnLighthouseChronologist();
@@ -72,7 +71,7 @@ public class EndOfTurn extends Phase implements java.io.Serializable {
final SpellAbility sac = new Ability(card, "0") {
@Override
public void resolve() {
if (GameState.isCardInPlay(card)) {
if (card.isInPlay()) {
Singletons.getModel().getGameAction().sacrifice(card, null);
}
}
@@ -90,7 +89,7 @@ public class EndOfTurn extends Phase implements java.io.Serializable {
final SpellAbility exile = new Ability(card, "0") {
@Override
public void resolve() {
if (GameState.isCardInPlay(card)) {
if (card.isInPlay()) {
Singletons.getModel().getGameAction().exile(card);
}
}
@@ -108,7 +107,7 @@ public class EndOfTurn extends Phase implements java.io.Serializable {
final SpellAbility destroy = new Ability(card, "0") {
@Override
public void resolve() {
if (GameState.isCardInPlay(card)) {
if (card.isInPlay()) {
Singletons.getModel().getGameAction().destroy(card);
}
}
@@ -128,7 +127,7 @@ public class EndOfTurn extends Phase implements java.io.Serializable {
final SpellAbility sac = new Ability(card, "0") {
@Override
public void resolve() {
if (GameState.isCardInPlay(card)) {
if (card.isInPlay()) {
Singletons.getModel().getGameAction().destroy(card);
}
}
@@ -150,7 +149,7 @@ public class EndOfTurn extends Phase implements java.io.Serializable {
final SpellAbility change = new Ability(vale, "0") {
@Override
public void resolve() {
if (GameState.isCardInPlay(vale)) {
if (vale.isInPlay()) {
vale.addController(vale.getController().getOpponent());
// Singletons.getModel().getGameAction().changeController(
// new ArrayList<Card>(vale), vale.getController(),
@@ -175,7 +174,7 @@ public class EndOfTurn extends Phase implements java.io.Serializable {
final SpellAbility change = new Ability(raider, "0") {
@Override
public void resolve() {
if (GameState.isCardInPlay(raider)) {
if (raider.isInPlay()) {
raider.getController().addDamage(2, raider);
}
}
@@ -194,7 +193,7 @@ public class EndOfTurn extends Phase implements java.io.Serializable {
final SpellAbility change = new Ability(source, "0") {
@Override
public void resolve() {
if (GameState.isCardInPlay(source)) {
if (source.isInPlay()) {
Singletons.getModel().getGameAction().moveToHand(source);
}
}

View File

@@ -22,7 +22,6 @@ import java.util.List;
import java.util.Stack;
import com.esotericsoftware.minlog.Log;
import forge.AllZone;
import forge.Card;
import forge.CardLists;
@@ -31,7 +30,6 @@ import forge.GameActionUtil;
import forge.Singletons;
import forge.card.spellability.SpellAbility;
import forge.card.trigger.TriggerType;
import forge.game.GameState;
import forge.game.player.Player;
import forge.game.player.PlayerType;
import forge.game.zone.ZoneType;
@@ -394,7 +392,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
case CLEANUP:
// Reset Damage received map
final List<Card> list = GameState.getCardsIn(ZoneType.Battlefield);
final List<Card> list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
for (final Card c : list) {
c.resetPreventNextDamage();
c.resetReceivedDamageFromThisTurn();
@@ -474,7 +472,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
return;
}
this.bPhaseEffects = true;
if (!GameState.isCardInPlay("Upwelling")) {
if (!Singletons.getModel().getGameState().isCardInPlay("Upwelling")) {
for (Player p : Singletons.getModel().getGameState().getPlayers()) {
int burn = p.getManaPool().clearPool();
if (Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_MANABURN)) {
@@ -563,7 +561,12 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
Singletons.getModel().getGameState().getStack().setCardsCastLastTurn();
Singletons.getModel().getGameState().getStack().clearCardsCastThisTurn();
GameState.resetZoneMoveTracking();
for (final Player p1 : Singletons.getModel().getGameState().getPlayers()) {
for (final ZoneType z : Player.ALL_ZONES) {
p1.getZone(z).resetCardsAddedThisTurn();
}
}
for( Player p : Singletons.getModel().getGameState().getPlayers() )
{
p.resetProwl();
@@ -822,7 +825,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
if (firstAction.equals(actingPlayer)) {
// pass the priority to other player
this.setPriorityPlayer(actingPlayer.getOpponent());
AllZone.getInputControl().resetInput();
Singletons.getModel().getMatch().getInput().resetInput();
Singletons.getModel().getGameState().getStack().chooseOrderOfSimultaneousStackEntryAll();
} else {
if (Singletons.getModel().getGameState().getStack().size() == 0) {
@@ -865,7 +868,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
if (this.getPriorityPlayer().isHuman()) {
// TODO This doesn't work quite 100% but pretty close
this.passPriority();
AllZone.getInputControl().resetInput();
Singletons.getModel().getMatch().getInput().resetInput();
}
}
@@ -938,7 +941,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
final Card source = sa.getRootSpellAbility().getSourceCard();
boolean onlyThis = true;
if (Singletons.getModel().getGameState().getStack().size() != 0) {
for (final Card card : GameState.getCardsIn(ZoneType.Stack)) {
for (final Card card : Singletons.getModel().getGameState().getCardsIn(ZoneType.Stack)) {
if (card != source) {
onlyThis = false;
//System.out.println("StackCard: " + card + " vs SourceCard: " + source);

View File

@@ -28,7 +28,6 @@ import forge.CardLists;
import forge.CardPredicates.Presets;
import forge.Singletons;
import forge.card.trigger.TriggerType;
import forge.game.GameState;
import forge.game.player.Player;
import forge.game.zone.ZoneType;
import forge.gui.match.CMatchUI;
@@ -65,7 +64,7 @@ public class PhaseUtil {
return true;
}
if (GameState.isCardInPlay("Sands of Time") || GameState.isCardInPlay("Stasis")) {
if (Singletons.getModel().getGameState().isCardInPlay("Sands of Time") || Singletons.getModel().getGameState().isCardInPlay("Stasis")) {
return true;
}
@@ -104,7 +103,7 @@ public class PhaseUtil {
Singletons.getModel().getGameAction().resetActivationsPerTurn();
final List<Card> lands = CardLists.filter(GameState.getPlayerLandsInPlay(turn), Presets.UNTAPPED);
final List<Card> lands = CardLists.filter(turn.getLandsInPlay(), Presets.UNTAPPED);
turn.setNumPowerSurgeLands(lands.size());
// anything before this point happens regardless of whether the Untap
@@ -154,13 +153,13 @@ public class PhaseUtil {
* @return a boolean.
*/
public static boolean skipUpkeep() {
if (GameState.isCardInPlay("Eon Hub")) {
if (Singletons.getModel().getGameState().isCardInPlay("Eon Hub")) {
return true;
}
final Player turn = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn();
if ((turn.getCardsIn(ZoneType.Hand).size() == 0) && GameState.isCardInPlay("Gibbering Descent", turn)) {
if ((turn.getCardsIn(ZoneType.Hand).size() == 0) && turn.isCardInPlay("Gibbering Descent")) {
return true;
}

View File

@@ -22,10 +22,10 @@ import java.util.List;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import forge.AllZone;
import forge.Card;
import forge.CardLists;
import forge.CardPredicates;
import forge.CardPredicates.Presets;
import forge.Counters;
import forge.GameActionUtil;
@@ -33,7 +33,6 @@ import forge.GameEntity;
import forge.Singletons;
import forge.card.cardfactory.CardFactoryUtil;
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 @@ public class Untap extends Phase implements java.io.Serializable {
return false;
}
final List<Card> allp = GameState.getCardsIn(ZoneType.Battlefield);
final List<Card> allp = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
for (final Card ca : allp) {
if (ca.hasStartOfKeyword("Permanents don't untap during their controllers' untap steps")) {
final int keywordPosition = ca
@@ -131,12 +130,11 @@ public class Untap extends Phase implements java.io.Serializable {
if (Untap.canOnlyUntapOneLand() && c.isLand()) {
return false;
}
if ((GameState.isCardInPlay("Damping Field") || GameState.isCardInPlay("Imi Statue"))
if ((Singletons.getModel().getGameState().isCardInPlay("Damping Field") || Singletons.getModel().getGameState().isCardInPlay("Imi Statue"))
&& c.isArtifact()) {
return false;
}
if ((GameState.isCardInPlay("Smoke") || GameState.isCardInPlay("Stoic Angel") || GameState
.isCardInPlay("Intruder Alarm")) && c.isCreature()) {
if ((Singletons.getModel().getGameState().isCardInPlay("Smoke") || Singletons.getModel().getGameState().isCardInPlay("Stoic Angel") || Singletons.getModel().getGameState().isCardInPlay("Intruder Alarm")) && c.isCreature()) {
return false;
}
return true;
@@ -154,7 +152,7 @@ public class Untap extends Phase implements java.io.Serializable {
prompt += "\r\n" + c + " is controlling: ";
for (final Card target : targets) {
prompt += target;
if (GameState.isCardInPlay(target)) {
if (target.isInPlay()) {
defaultChoice = false;
}
}
@@ -170,7 +168,7 @@ public class Untap extends Phase implements java.io.Serializable {
final ArrayList<Card> targets = c.getGainControlTargets();
boolean untap = true;
for (final Card target : targets) {
if (GameState.isCardInPlay(target)) {
if (target.isInPlay()) {
untap |= true;
}
}
@@ -180,7 +178,7 @@ public class Untap extends Phase implements java.io.Serializable {
}
}
}
} else if ((c.getCounters(Counters.WIND) > 0) && GameState.isCardInPlay("Freyalise's Winds")) {
} else if ((c.getCounters(Counters.WIND) > 0) && Singletons.getModel().getGameState().isCardInPlay("Freyalise's Winds")) {
// remove a WIND counter instead of untapping
c.subtractCounter(Counters.WIND, 1);
} else {
@@ -200,7 +198,7 @@ public class Untap extends Phase implements java.io.Serializable {
if (Untap.canOnlyUntapOneLand()) {
if (player.isComputer()) {
// search for lands the computer has and only untap 1
List<Card> landList = GameState.getPlayerLandsInPlay(player);
List<Card> landList = player.getLandsInPlay();
landList = CardLists.filter(landList, tappedCanUntap);
if (landList.size() > 0) {
@@ -229,14 +227,14 @@ public class Untap extends Phase implements java.io.Serializable {
}
} // selectCard()
}; // Input
List<Card> landList = GameState.getPlayerLandsInPlay(player);
List<Card> landList = player.getLandsInPlay();
landList = CardLists.filter(landList, tappedCanUntap);
if (landList.size() > 0) {
AllZone.getInputControl().setInput(target);
Singletons.getModel().getMatch().getInput().setInput(target);
}
}
}
if (GameState.isCardInPlay("Damping Field") || GameState.isCardInPlay("Imi Statue")) {
if (Singletons.getModel().getGameState().isCardInPlay("Damping Field") || Singletons.getModel().getGameState().isCardInPlay("Imi Statue")) {
final Player turnOwner = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn();
if (turnOwner.isComputer()) {
List<Card> artList = turnOwner.getCardsIn(ZoneType.Battlefield);
@@ -273,13 +271,13 @@ public class Untap extends Phase implements java.io.Serializable {
artList = CardLists.filter(artList, Presets.ARTIFACTS);
artList = CardLists.filter(artList, tappedCanUntap);
if (artList.size() > 0) {
AllZone.getInputControl().setInput(target);
Singletons.getModel().getMatch().getInput().setInput(target);
}
}
}
if ((GameState.isCardInPlay("Smoke") || GameState.isCardInPlay("Stoic Angel"))) {
if ((Singletons.getModel().getGameState().isCardInPlay("Smoke") || Singletons.getModel().getGameState().isCardInPlay("Stoic Angel"))) {
if (player.isComputer()) {
List<Card> creatures = GameState.getCreaturesInPlay(player);
List<Card> creatures = player.getCreaturesInPlay();
creatures = CardLists.filter(creatures, tappedCanUntap);
if (creatures.size() > 0) {
creatures.get(0).untap();
@@ -308,10 +306,10 @@ public class Untap extends Phase implements java.io.Serializable {
}
} // selectCard()
}; // Input
List<Card> creatures = GameState.getCreaturesInPlay(player);
List<Card> creatures = player.getCreaturesInPlay();
creatures = CardLists.filter(creatures, tappedCanUntap);
if (creatures.size() > 0) {
AllZone.getInputControl().setInput(target);
Singletons.getModel().getMatch().getInput().setInput(target);
}
}
}
@@ -331,7 +329,7 @@ public class Untap extends Phase implements java.io.Serializable {
private static boolean canOnlyUntapOneLand() {
// Winter Orb was given errata so it no longer matters if it's tapped or
// not
if (GameState.getCardsIn(ZoneType.Battlefield, "Winter Orb").size() > 0) {
if (CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Winter Orb")).size() > 0) {
return true;
}

View File

@@ -23,7 +23,6 @@ import java.util.List;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import forge.AllZone;
import forge.Card;
import forge.CardLists;
@@ -31,7 +30,6 @@ import forge.CardPredicates;
import forge.CardPredicates.Presets;
import forge.Command;
import forge.Counters;
import forge.GameAction;
import forge.GameActionUtil;
import forge.Singletons;
import forge.card.cardfactory.CardFactoryUtil;
@@ -476,8 +474,8 @@ public class Upkeep extends Phase implements java.io.Serializable {
* regenerated.
*/
final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn();
final List<Card> the = GameState.getCardsIn(ZoneType.Battlefield, "The Abyss");
final List<Card> magus = GameState.getCardsIn(ZoneType.Battlefield, "Magus of the Abyss");
final List<Card> the = CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("The Abyss"));
final List<Card> magus = CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Magus of the Abyss"));
final List<Card> cards = new ArrayList<Card>();
cards.addAll(the);
@@ -486,7 +484,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
for (final Card c : cards) {
final Card abyss = c;
final List<Card> abyssGetTargets = CardLists.filter(GameState.getCreaturesInPlay(player), Presets.NON_ARTIFACTS);
final List<Card> abyssGetTargets = CardLists.filter(player.getCreaturesInPlay(), Presets.NON_ARTIFACTS);
final Ability sacrificeCreature = new Ability(abyss, "") {
@Override
@@ -494,7 +492,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
final List<Card> targets = CardLists.getTargetableCards(abyssGetTargets, this);
if (player.isHuman()) {
if (targets.size() > 0) {
AllZone.getInputControl().setInput(new Input() {
Singletons.getModel().getMatch().getInput().setInput(new Input() {
private static final long serialVersionUID = 4820011040853968644L;
@Override
@@ -562,12 +560,12 @@ public class Upkeep extends Phase implements java.io.Serializable {
final Ability ability = new Ability(c, "") {
@Override
public void resolve() {
final List<Card> creatures = GameState.getCreaturesInPlay();
final List<Card> creatures = CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), Presets.CREATURES);
if (creatures.size() > 0) {
CardLists.sortAttackLowFirst(creatures);
final int power = creatures.get(0).getNetAttack();
if (player.isHuman()) {
AllZone.getInputControl().setInput(
Singletons.getModel().getMatch().getInput().setInput(
CardFactoryUtil.inputDestroyNoRegeneration(this.getLowestPowerList(creatures),
"Select creature with power: " + power + " to sacrifice."));
} else { // computer
@@ -637,12 +635,12 @@ public class Upkeep extends Phase implements java.io.Serializable {
final Ability noPay = new Ability(c, "B B B") {
@Override
public void resolve() {
final List<Card> playerLand = GameState.getPlayerLandsInPlay(player);
final List<Card> playerLand = player.getLandsInPlay();
c.tap();
if (c.getController().isComputer()) {
if (playerLand.size() > 0) {
AllZone.getInputControl().setInput(
Singletons.getModel().getMatch().getInput().setInput(
PlayerUtil.inputSacrificePermanent(playerLand, c.getName()
+ " - Select a land to sacrifice."));
}
@@ -661,7 +659,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
final Ability pay = new Ability(c, "0") {
@Override
public void resolve() {
if (GameState.getZoneOf(c).is(ZoneType.Battlefield)) {
if (Singletons.getModel().getGameState().getZoneOf(c).is(ZoneType.Battlefield)) {
final StringBuilder cost = new StringBuilder();
cost.append("Pay cost for ").append(c).append("\r\n");
GameActionUtil.payManaDuringAbilityResolve(cost.toString(), noPay.getManaCost(),
@@ -1235,11 +1233,11 @@ public class Upkeep extends Phase implements java.io.Serializable {
}
// player isComputer()
else {
List<Card> humanCreatures = GameState.getCreaturesInPlay(player.getOpponent());
List<Card> humanCreatures = player.getOpponent().getCreaturesInPlay();
humanCreatures = CardLists.getValidCards(humanCreatures, smallCreatures, k.getController(), k);
humanCreatures = CardLists.getNotKeyword(humanCreatures, "Indestructible");
List<Card> computerCreatures = GameState.getCreaturesInPlay(player);
List<Card> computerCreatures = player.getCreaturesInPlay();
computerCreatures = CardLists.getValidCards(computerCreatures, smallCreatures, k.getController(), k);
computerCreatures = CardLists.getNotKeyword(computerCreatures, "Indestructible");
@@ -1256,7 +1254,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
}
if (wantDamageCreatures) {
final List<Card> allCreatures = GameState.getCreaturesInPlay();
final List<Card> allCreatures = CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), Presets.CREATURES);
for (final Card crd : allCreatures) {
crd.addDamage(2, k);
}
@@ -1607,7 +1605,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
}
if (wantMerfolkBuff) {
final List<Card> creatures = GameState.getCreaturesInPlay(player);
final List<Card> creatures = player.getCreaturesInPlay();
for (int i = 0; i < creatures.size(); i++) {
if (!creatures.get(i).hasKeyword("Flying")) {
creatures.get(i).addExtrinsicKeyword("Flying");
@@ -1618,7 +1616,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
@Override
public void execute() {
final List<Card> creatures = GameState.getCreaturesInPlay(player);
final List<Card> creatures = player.getCreaturesInPlay();
for (int i = 0; i < creatures.size(); i++) {
if (creatures.get(i).hasKeyword("Flying")) {
creatures.get(i).removeExtrinsicKeyword("Flying");
@@ -1937,7 +1935,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
* </p>
*/
private static void upkeepOathOfDruids() {
final List<Card> oathList = GameState.getCardsIn(ZoneType.Battlefield, "Oath of Druids");
final List<Card> oathList = CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Oath of Druids"));
if (oathList.isEmpty()) {
return;
}
@@ -2018,7 +2016,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
* </p>
*/
private static void upkeepOathOfGhouls() {
final List<Card> oathList = GameState.getCardsIn(ZoneType.Battlefield, "Oath of Ghouls");
final List<Card> oathList = CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Oath of Ghouls"));
if (oathList.isEmpty()) {
return;
}
@@ -2068,7 +2066,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
*/
private static void upkeepKarma() {
final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn();
final List<Card> karmas = GameState.getCardsIn(ZoneType.Battlefield, "Karma");
final List<Card> karmas = CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Karma"));
final List<Card> swamps = CardLists.getType(player.getCardsIn(ZoneType.Battlefield), "Swamp");
// determine how much damage to deal the current player
@@ -2113,7 +2111,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
* controlled at the beginning of this turn.
*/
final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn();
final List<Card> list = GameState.getCardsIn(ZoneType.Battlefield, "Power Surge");
final List<Card> list = CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Power Surge"));
final int damage = player.getNumPowerSurgeLands();
for (final Card surge : list) {
@@ -2143,7 +2141,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
*/
private static void upkeepTangleWire() {
final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn();
final List<Card> wires = GameState.getCardsIn(ZoneType.Battlefield, "Tangle Wire");
final List<Card> wires = CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Tangle Wire"));
for (final Card source : wires) {
final SpellAbility ability = new Ability(source, "0") {
@@ -2185,7 +2183,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
list.remove(toTap);
}
} else {
AllZone.getInputControl().setInput(new Input() {
Singletons.getModel().getMatch().getInput().setInput(new Input() {
private static final long serialVersionUID = 5313424586016061612L;
@Override
@@ -2304,7 +2302,8 @@ public class Upkeep extends Phase implements java.io.Serializable {
enchantment = CardFactoryUtil.getBestEnchantmentAI(enchantmentsInLibrary, this, false);
}
if (enchantment != null) {
GameAction.changeZone(GameState.getZoneOf(enchantment),
Singletons.getModel().getGameAction().changeZone(
Singletons.getModel().getGameState().getZoneOf(enchantment),
enchantment.getOwner().getZone(ZoneType.Battlefield), enchantment, null);
enchantment.enchantEntity(source.getEnchantingPlayer());
}

View File

@@ -34,7 +34,6 @@ import forge.card.spellability.SpellAbility;
import forge.card.spellability.SpellPermanent;
import forge.card.trigger.Trigger;
import forge.card.trigger.TriggerType;
import forge.game.GameState;
import forge.game.phase.CombatUtil;
import forge.game.zone.ZoneType;
@@ -311,7 +310,7 @@ public class ComputerAIGeneral implements Computer {
*/
@Override
public final void declareBlockers() {
final List<Card> blockers = GameState.getCreaturesInPlay(player);
final List<Card> blockers = player.getCreaturesInPlay();
Singletons.getModel().getGameState().setCombat(ComputerUtilBlock.getBlockers(player, Singletons.getModel().getGameState().getCombat(), blockers));

View File

@@ -52,7 +52,6 @@ import forge.card.spellability.SpellAbility;
import forge.card.spellability.Target;
import forge.control.input.InputPayManaCostUtil;
import forge.error.ErrorViewer;
import forge.game.GameState;
import forge.game.phase.Combat;
import forge.game.phase.CombatUtil;
import forge.game.phase.PhaseType;
@@ -1279,7 +1278,7 @@ public class ComputerUtil {
public boolean apply(final Card c) {
if (c.getSVar("NeedsToPlay").length() > 0) {
final String needsToPlay = c.getSVar("NeedsToPlay");
List<Card> list = GameState.getCardsIn(ZoneType.Battlefield);
List<Card> list = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
list = CardLists.getValidCards(list, needsToPlay.split(","), c.getController(), c);
if (list.isEmpty()) {
@@ -1963,7 +1962,7 @@ public class ComputerUtil {
final Target tgt = sa.getTarget();
if (tgt != null) {
if (CardLists.getValidCards(GameState.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), controller, sa.getSourceCard()).contains(card)) {
if (CardLists.getValidCards(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), controller, sa.getSourceCard()).contains(card)) {
return true;
}
} else if (AbilityFactory.getDefinedCards(sa.getSourceCard(), mapParams.get("Defined"), sa)
@@ -2012,7 +2011,7 @@ public class ComputerUtil {
}
final Target tgt = sa.getTarget();
if (tgt != null) {
if (CardLists.getValidCards(GameState.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), controller, af.getHostCard()).contains(card)) {
if (CardLists.getValidCards(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), controller, af.getHostCard()).contains(card)) {
prevented += AbilityFactory.calculateAmount(af.getHostCard(),
mapParams.get("Amount"), sa);
}
@@ -2112,13 +2111,13 @@ public class ComputerUtil {
// Otherwise, if life is possibly in danger, then this is fine.
Combat combat = new Combat();
combat.initiatePossibleDefenders(ai);
List<Card> attackers = GameState.getCreaturesInPlay(ai.getOpponent());
List<Card> attackers = ai.getOpponent().getCreaturesInPlay();
for (Card att : attackers) {
if (CombatUtil.canAttackNextTurn(att)) {
combat.addAttacker(att);
}
}
combat = ComputerUtilBlock.getBlockers(ai, combat, GameState.getCreaturesInPlay(ai));
combat = ComputerUtilBlock.getBlockers(ai, combat, ai.getCreaturesInPlay());
if (!CombatUtil.lifeInDanger(ai, combat)) {
// Otherwise, return false. Do not play now.
ret = false;

View File

@@ -33,7 +33,6 @@ import forge.Singletons;
import forge.card.cardfactory.CardFactoryUtil;
import forge.card.trigger.Trigger;
import forge.card.trigger.TriggerType;
import forge.game.GameState;
import forge.game.phase.Combat;
import forge.game.phase.CombatUtil;
import forge.game.zone.ZoneType;
@@ -313,7 +312,7 @@ public class ComputerUtilAttack {
// bonus TWICE
humanBaseAttack = humanBaseAttack + humanExaltedBonus;
}
final int totalExaltedAttack = GameState.isCardInPlay("Rafiq of the Many", opp) ? 2 * humanBaseAttack
final int totalExaltedAttack = opp.isCardInPlay("Rafiq of the Many") ? 2 * humanBaseAttack
: humanBaseAttack;
if (ai.getLife() - 3 <= totalExaltedAttack) {
// We will lose if there is an Exalted attack -- keep one
@@ -381,7 +380,7 @@ public class ComputerUtilAttack {
*/
private boolean doAssault(final Player ai) {
// Beastmaster Ascension
if (GameState.isCardInPlay("Beastmaster Ascension", ai)
if (ai.isCardInPlay("Beastmaster Ascension")
&& (this.attackers.size() > 1)) {
final List<Card> beastions = ai.getCardsIn(ZoneType.Battlefield, "Beastmaster Ascension");
int minCreatures = 7;

View File

@@ -20,7 +20,6 @@ package forge.game.player;
import java.util.ArrayList;
import java.util.List;
import forge.AllZone;
import forge.Card;
import forge.Singletons;
@@ -126,7 +125,7 @@ public class HumanPlayer extends Player {
/** {@inheritDoc} */
@Override
public final List<Card> discard(final int num, final SpellAbility sa, final boolean duringResolution) {
AllZone.getInputControl().setInput(PlayerUtil.inputDiscard(num, sa), duringResolution);
Singletons.getModel().getMatch().getInput().setInput(PlayerUtil.inputDiscard(num, sa), duringResolution);
// why is List<Card> returned?
return new ArrayList<Card>();
@@ -136,7 +135,7 @@ public class HumanPlayer extends Player {
@Override
public final void discardUnless(final int num, final String uType, final SpellAbility sa) {
if (this.getCardsIn(ZoneType.Hand).size() > 0) {
AllZone.getInputControl().setInput(PlayerUtil.inputDiscardNumUnless(num, uType, sa));
Singletons.getModel().getMatch().getInput().setInput(PlayerUtil.inputDiscardNumUnless(num, uType, sa));
}
}
@@ -150,7 +149,7 @@ public class HumanPlayer extends Player {
*/
@Override
protected final void discardChainsOfMephistopheles() {
AllZone.getInputControl().setInput(PlayerUtil.inputChainsDiscard(), true);
Singletons.getModel().getMatch().getInput().setInput(PlayerUtil.inputChainsDiscard(), true);
}
/** {@inheritDoc} */
@@ -182,7 +181,7 @@ public class HumanPlayer extends Player {
@Override
public final void sacrificePermanent(final String prompt, final List<Card> choices) {
final Input in = PlayerUtil.inputSacrificePermanent(choices, prompt);
AllZone.getInputControl().setInput(in);
Singletons.getModel().getMatch().getInput().setInput(in);
}
/** {@inheritDoc} */

View File

@@ -37,9 +37,11 @@ import forge.Card;
import forge.CardLists;
import forge.CardPredicates;
import forge.CardPredicates.Presets;
import forge.CardUtil;
import forge.Constant;
import forge.Constant.Preferences;
import forge.Counters;
import forge.GameActionUtil;
import forge.GameEntity;
import forge.Singletons;
@@ -50,7 +52,6 @@ import forge.card.spellability.SpellAbility;
import forge.card.staticability.StaticAbility;
import forge.card.trigger.TriggerType;
import forge.game.GameLossReason;
import forge.game.GameState;
import forge.game.phase.PhaseHandler;
import forge.game.zone.PlayerZone;
import forge.game.zone.PlayerZoneBattlefield;
@@ -583,7 +584,7 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
@Override
public final int staticDamagePrevention(final int damage, final Card source, final boolean isCombat) {
if (GameState.isCardInPlay("Leyline of Punishment")) {
if (Singletons.getModel().getGameState().isCardInPlay("Leyline of Punishment")) {
return damage;
}
@@ -615,7 +616,7 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
}
// Prevent Damage static abilities
final List<Card> allp = GameState.getCardsIn(ZoneType.Battlefield);
final List<Card> allp = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
for (final Card ca : allp) {
final ArrayList<StaticAbility> staticAbilities = ca.getStaticAbilities();
for (final StaticAbility stAb : staticAbilities) {
@@ -624,12 +625,12 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
}
// specific cards
if (GameState.isCardInPlay("Spirit of Resistance", this)) {
if ((GameState.getPlayerColorInPlay(this, Constant.Color.BLACK).size() > 0)
&& (GameState.getPlayerColorInPlay(this, Constant.Color.BLUE).size() > 0)
&& (GameState.getPlayerColorInPlay(this, Constant.Color.GREEN).size() > 0)
&& (GameState.getPlayerColorInPlay(this, Constant.Color.RED).size() > 0)
&& (GameState.getPlayerColorInPlay(this, Constant.Color.WHITE).size() > 0)) {
if (this.isCardInPlay("Spirit of Resistance")) {
if ((this.getColoredCardsInPlay(Constant.Color.BLACK).size() > 0)
&& (this.getColoredCardsInPlay(Constant.Color.BLUE).size() > 0)
&& (this.getColoredCardsInPlay(Constant.Color.GREEN).size() > 0)
&& (this.getColoredCardsInPlay(Constant.Color.RED).size() > 0)
&& (this.getColoredCardsInPlay(Constant.Color.WHITE).size() > 0)) {
return 0;
}
}
@@ -662,7 +663,7 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
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;
@@ -750,7 +751,7 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
return 0;
}
if (GameState.isCardInPlay("Crumbling Sanctuary")) {
if (Singletons.getModel().getGameState().isCardInPlay("Crumbling Sanctuary")) {
for (int i = 0; i < damage; i++) {
final List<Card> lib = this.getCardsIn(ZoneType.Library);
if (lib.size() > 0) {
@@ -781,7 +782,7 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
@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;
}
@@ -1194,7 +1195,7 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
}
}
if (!firstFromDraw && GameState.isCardInPlay("Chains of Mephistopheles")) {
if (!firstFromDraw && Singletons.getModel().getGameState().isCardInPlay("Chains of Mephistopheles")) {
if (!this.getZone(ZoneType.Hand).isEmpty()) {
if (this.isHuman()) {
this.discardChainsOfMephistopheles();
@@ -1827,7 +1828,7 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
}
// CantBeCast static abilities
final List<Card> allp = GameState.getCardsIn(ZoneType.Battlefield);
final List<Card> allp = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
for (final Card ca : allp) {
final ArrayList<StaticAbility> staticAbilities = ca.getStaticAbilities();
for (final StaticAbility stAb : staticAbilities) {
@@ -2724,4 +2725,59 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
if ( null == stats.getOutcome() ) // not lost?
setOutcome(PlayerOutcome.win()); // then won!
}
/**
* use to get a list of creatures in play for a given player.
*
* @param player
* the player to get creatures for
* @return a List<Card> containing all creatures a given player has in play
*/
public List<Card> getCreaturesInPlay() {
return CardLists.filter(getCardsIn(ZoneType.Battlefield), Presets.CREATURES);
}
/**
* use to get a list of all lands a given player has on the battlefield.
*
* @param player
* the player whose lands we want to get
* @return a List<Card> containing all lands the given player has in play
*/
public List<Card> getLandsInPlay() {
return CardLists.filter(getCardsIn(ZoneType.Battlefield), Presets.LANDS);
}
public boolean isCardInPlay(final String cardName) {
return Iterables.any(getZone(ZoneType.Battlefield), CardPredicates.nameEquals(cardName));
}
public List<Card> getColoredCardsInPlay(final String color) {
return CardLists.filter(getCardsIn(ZoneType.Battlefield), new Predicate<Card>() {
@Override
public boolean apply(final Card c) {
final List<String> colorList = CardUtil.getColors(c);
return colorList.contains(color);
}
});
}
public int getCounterDoublersMagnitude(final Counters type) {
int counterDoublers = getCardsIn(ZoneType.Battlefield, "Doubling Season").size();
if(type == Counters.P1P1) {
counterDoublers += getCardsIn(ZoneType.Battlefield, "Corpsejack Menace").size();
}
return (int) Math.pow(2, counterDoublers); // pow(a,0) = 1; pow(a,1) = a
// ... no worries about size
// = 0
}
public int getTokenDoublersMagnitude() {
final int tokenDoublers = getCardsIn(ZoneType.Battlefield, "Parallel Lives").size()
+ getCardsIn(ZoneType.Battlefield, "Doubling Season").size();
return (int) Math.pow(2, tokenDoublers); // pow(a,0) = 1; pow(a,1) = a
// ... no worries about size =
// 0
}
}

View File

@@ -28,6 +28,7 @@ import forge.AllZone;
import forge.Card;
import forge.CardLists;
import forge.CardPredicates;
import forge.CardPredicates.Presets;
import forge.Command;
import forge.GameActionUtil;
@@ -49,7 +50,6 @@ import forge.card.trigger.Trigger;
import forge.card.trigger.TriggerType;
import forge.control.input.Input;
import forge.control.input.InputPayManaCostAbility;
import forge.game.GameState;
import forge.game.phase.PhaseType;
import forge.game.player.ComputerUtil;
import forge.game.player.Player;
@@ -276,7 +276,7 @@ public class MagicStack extends MyObservable {
*
* @return a boolean.
*/
public final boolean getResolving() {
public final boolean isResolving() {
return this.bResolving;
}
@@ -514,7 +514,7 @@ public class MagicStack extends MyObservable {
public void execute() {
ability.resolve();
final Card crd = sa.getSourceCard();
AllZone.getInputControl().setInput(
Singletons.getModel().getMatch().getInput().setInput(
new InputPayManaCostAbility("Pay X cost for " + crd.getName() + " (X="
+ crd.getXManaCostPaid() + ")\r\n", ability.getManaCost(), this, unpaidCommand,
true));
@@ -524,7 +524,7 @@ public class MagicStack extends MyObservable {
final Card crd = sa.getSourceCard();
Player player = sp.getSourceCard().getController();
if (player.isHuman()) {
AllZone.getInputControl().setInput(
Singletons.getModel().getMatch().getInput().setInput(
new InputPayManaCostAbility("Pay X cost for " + sp.getSourceCard().getName() + " (X="
+ crd.getXManaCostPaid() + ")\r\n", ability.getManaCost(), paidCommand,
unpaidCommand, true));
@@ -573,12 +573,12 @@ public class MagicStack extends MyObservable {
&& Singletons.getModel().getGameAction().getCostCuttingGetMultiKickerManaCostPaidColored()
.equals("")) {
AllZone.getInputControl().setInput(
Singletons.getModel().getMatch().getInput().setInput(
new InputPayManaCostAbility("Multikicker for " + sa.getSourceCard() + "\r\n"
+ "Times Kicked: " + sa.getSourceCard().getMultiKickerMagnitude()
+ "\r\n", manaCost.toString(), this, unpaidCommand));
} else {
AllZone.getInputControl()
Singletons.getModel().getMatch().getInput()
.setInput(
new InputPayManaCostAbility(
"Multikicker for "
@@ -609,12 +609,12 @@ public class MagicStack extends MyObservable {
} else {
if ((Singletons.getModel().getGameAction().getCostCuttingGetMultiKickerManaCostPaid() == 0)
&& Singletons.getModel().getGameAction().getCostCuttingGetMultiKickerManaCostPaidColored().equals("")) {
AllZone.getInputControl().setInput(
Singletons.getModel().getMatch().getInput().setInput(
new InputPayManaCostAbility("Multikicker for " + sa.getSourceCard() + "\r\n"
+ "Times Kicked: " + sa.getSourceCard().getMultiKickerMagnitude() + "\r\n",
manaCost.toString(), paidCommand, unpaidCommand));
} else {
AllZone.getInputControl().setInput(
Singletons.getModel().getMatch().getInput().setInput(
new InputPayManaCostAbility(
"Multikicker for "
+ sa.getSourceCard()
@@ -675,7 +675,7 @@ public class MagicStack extends MyObservable {
this.execute();
} else {
AllZone.getInputControl().setInput(
Singletons.getModel().getMatch().getInput().setInput(
new InputPayManaCostAbility("Replicate for " + sa.getSourceCard() + "\r\n"
+ "Times Replicated: " + sa.getSourceCard().getReplicateMagnitude()
+ "\r\n", manaCost.toString(), this, unpaidCommand));
@@ -690,7 +690,7 @@ public class MagicStack extends MyObservable {
if (manaCost.isPaid()) {
paidCommand.execute();
} else {
AllZone.getInputControl().setInput(
Singletons.getModel().getMatch().getInput().setInput(
new InputPayManaCostAbility("Replicate for " + sa.getSourceCard() + "\r\n"
+ "Times Replicated: " + sa.getSourceCard().getReplicateMagnitude() + "\r\n",
manaCost.toString(), paidCommand, unpaidCommand));
@@ -775,11 +775,11 @@ public class MagicStack extends MyObservable {
* name is in a graveyard or a nontoken permanent with the same name is
* on the battlefield.
*/
if (sp.isSpell() && GameState.isCardInPlay("Bazaar of Wonders")) {
if (sp.isSpell() && Singletons.getModel().getGameState().isCardInPlay("Bazaar of Wonders")) {
boolean found = false;
List<Card> all = GameState.getCardsIn(ZoneType.Battlefield);
List<Card> all = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
all = CardLists.filter(all, Presets.NON_TOKEN);
final List<Card> graves = GameState.getCardsIn(ZoneType.Graveyard);
final List<Card> graves = Singletons.getModel().getGameState().getCardsIn(ZoneType.Graveyard);
all.addAll(graves);
for (final Card c : all) {
@@ -789,7 +789,7 @@ public class MagicStack extends MyObservable {
}
if (found) {
final List<Card> bazaars = GameState.getCardsIn(ZoneType.Battlefield, "Bazaar of Wonders"); // should
final List<Card> bazaars = CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Bazaar of Wonders")); // should
// only
// be
// 1...
@@ -911,8 +911,8 @@ public class MagicStack extends MyObservable {
sa.getSourceCard().setXManaCostPaid(0);
if (source.hasStartOfKeyword("Haunt") && !source.isCreature()
&& GameState.getZoneOf(source).is(ZoneType.Graveyard)) {
final List<Card> creats = GameState.getCreaturesInPlay();
&& Singletons.getModel().getGameState().getZoneOf(source).is(ZoneType.Graveyard)) {
final List<Card> creats = CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), Presets.CREATURES);
final Ability haunterDiesWork = new Ability(source, "0") {
@Override
public void resolve() {
@@ -954,7 +954,7 @@ public class MagicStack extends MyObservable {
};
if (source.getController().isHuman()) {
AllZone.getInputControl().setInput(target);
Singletons.getModel().getMatch().getInput().setInput(target);
} else {
// AI choosing what to haunt
final List<Card> oppCreats = CardLists.filterControlledBy(creats, source.getController().getOpponent());
@@ -994,7 +994,7 @@ public class MagicStack extends MyObservable {
sa.setFlashBackAbility(false);
} else if (source.hasKeyword("Rebound")
&& source.getCastFrom() == ZoneType.Hand
&& GameState.getZoneOf(source).is(ZoneType.Stack)
&& Singletons.getModel().getGameState().getZoneOf(source).is(ZoneType.Stack)
&& source.getOwner().equals(source.getController())) //"If you cast this spell from your hand"
{
@@ -1058,7 +1058,7 @@ public class MagicStack extends MyObservable {
final Card tmp = sa.getSourceCard();
tmp.setCanCounter(true); // reset mana pumped counter magic flag
if (tmp.getClones().size() > 0) {
for (final Card c : GameState.getCardsIn(ZoneType.Battlefield)) {
for (final Card c : Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield)) {
if (c.equals(tmp)) {
c.setClones(tmp.getClones());
}
@@ -1106,7 +1106,7 @@ public class MagicStack extends MyObservable {
}
else if (o instanceof Card) {
final Card card = (Card) o;
Card current = GameState.getCardState(card);
Card current = Singletons.getModel().getGameState().getCardState(card);
invalidTarget = current.getTimestamp() != card.getTimestamp();
@@ -1471,7 +1471,7 @@ public class MagicStack extends MyObservable {
* @return true, if is resolving
*/
public final boolean isResolving(Card c) {
if (!this.getResolving() || this.curResolvingCard == null) {
if (!this.isResolving() || this.curResolvingCard == null) {
return false;
}

View File

@@ -29,7 +29,6 @@ import forge.Card;
import forge.Singletons;
import forge.card.trigger.TriggerType;
import forge.game.GameState;
import forge.game.player.Player;
import forge.util.MyObservable;
@@ -83,7 +82,7 @@ public class PlayerZone extends MyObservable implements IPlayerZone, Observer, j
// don't want to log those.
if (!c.isImmutable()) {
this.cardsAddedThisTurn.add(c);
final PlayerZone zone = GameState.getZoneOf(c);
final PlayerZone zone = Singletons.getModel().getGameState().getZoneOf(c);
if (zone != null) {
this.cardsAddedThisTurnSource.add(zone.getZoneType());
} else {
@@ -163,7 +162,7 @@ public class PlayerZone extends MyObservable implements IPlayerZone, Observer, j
// don't want to log those.
if (!c.isImmutable()) {
this.cardsAddedThisTurn.add(c);
final PlayerZone zone = GameState.getZoneOf(c);
final PlayerZone zone = Singletons.getModel().getGameState().getZoneOf(c);
if (zone != null) {
this.cardsAddedThisTurnSource.add(zone.getZoneType());
} else {

View File

@@ -27,6 +27,7 @@ import com.google.common.collect.Lists;
import forge.Card;
import forge.CardLists;
import forge.CardPredicates;
import forge.CardPredicates.Presets;
import forge.Command;
import forge.GameActionUtil;
@@ -34,7 +35,6 @@ import forge.Singletons;
import forge.card.spellability.Ability;
import forge.card.spellability.SpellAbility;
import forge.card.staticability.StaticAbility;
import forge.game.GameState;
import forge.game.player.Player;
/**
@@ -84,7 +84,7 @@ public class PlayerZoneBattlefield extends PlayerZone {
c.setTapped(true);
} else {
// ETBTapped static abilities
final List<Card> allp = GameState.getCardsIn(ZoneType.Battlefield);
final List<Card> allp = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
for (final Card ca : allp) {
final ArrayList<StaticAbility> staticAbilities = ca.getStaticAbilities();
for (final StaticAbility stAb : staticAbilities) {
@@ -123,7 +123,7 @@ public class PlayerZoneBattlefield extends PlayerZone {
if (c.isLand()) {
// Tectonic Instability
final List<Card> tis = GameState.getCardsIn(ZoneType.Battlefield, "Tectonic Instability");
final List<Card> tis = CardLists.filter(Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Tectonic Instability"));
final Card tisLand = c;
for (final Card ti : tis) {
final Card source = ti;
@@ -152,7 +152,7 @@ public class PlayerZoneBattlefield extends PlayerZone {
final SpellAbility ability = new Ability(source, "") {
@Override
public void resolve() {
final List<Card> lands = GameState.getPlayerLandsInPlay(lesLand.getOwner());
final List<Card> lands = lesLand.getOwner().getLandsInPlay();
lesLand.getOwner().sacrificePermanent(source.getName() + " - Select a land to sacrifice",
lands);
}
@@ -161,8 +161,8 @@ public class PlayerZoneBattlefield extends PlayerZone {
sb.append(source).append(" - ");
sb.append(tisLand.getController()).append(" sacrifices a land.");
ability.setStackDescription(sb.toString());
final List<Card> pLands = GameState.getPlayerLandsInPlay(lesLand.getOwner());
final List<Card> oLands = GameState.getPlayerLandsInPlay(lesLand.getOwner().getOpponent());
final List<Card> pLands = lesLand.getOwner().getLandsInPlay();
final List<Card> oLands = lesLand.getOwner().getOpponent().getLandsInPlay();
// (pLands - 1) because this land is in play, and the
// ability is before it is in play
if (oLands.size() <= (pLands.size() - 1)) {

View File

@@ -42,7 +42,6 @@ import forge.Counters;
import forge.Singletons;
import forge.card.spellability.AbilityMana;
import forge.card.trigger.TriggerType;
import forge.game.GameState;
import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
@@ -681,7 +680,7 @@ public final class GuiDisplayUtil {
* @since 1.0.15
*/
public static void devModeAddCounter() {
final Card o = GuiChoose.oneOrNone("Add counters to which card?", GameState.getCardsIn(ZoneType.Battlefield));
final Card o = GuiChoose.oneOrNone("Add counters to which card?", Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield));
if (null == o) {
return;
} else {
@@ -712,7 +711,7 @@ public final class GuiDisplayUtil {
* @since 1.0.15
*/
public static void devModeTapPerm() {
final List<Card> play = GameState.getCardsIn(ZoneType.Battlefield);
final List<Card> play = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
final Object o = GuiChoose.oneOrNone("Choose a permanent", play);
if (null == o) {
return;
@@ -730,7 +729,7 @@ public final class GuiDisplayUtil {
* @since 1.0.15
*/
public static void devModeUntapPerm() {
final List<Card> play = GameState.getCardsIn(ZoneType.Battlefield);
final List<Card> play = Singletons.getModel().getGameState().getCardsIn(ZoneType.Battlefield);
final Object o = GuiChoose.oneOrNone("Choose a permanent", play);
if (null == o) {
return;

View File

@@ -20,10 +20,9 @@ package forge.gui;
import java.util.Observable;
import java.util.Observer;
import forge.AllZone;
import forge.Card;
import forge.Singletons;
import forge.control.input.Input;
import forge.game.GameState;
import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.util.MyObservable;
@@ -45,7 +44,7 @@ public class GuiInput extends MyObservable implements Observer {
/** {@inheritDoc} */
@Override
public final void update(final Observable observable, final Object obj) {
final Input tmp = AllZone.getInputControl().updateInput();
final Input tmp = Singletons.getModel().getMatch().getInput().updateInput();
if (tmp != null) {
this.setInput(tmp);
}
@@ -64,15 +63,6 @@ public class GuiInput extends MyObservable implements Observer {
this.input.showMessage();
}
/**
* <p>
* showMessage.
* </p>
*/
public final void showMessage() {
this.getInput().showMessage();
}
/**
* <p>
* selectButtonOK.
@@ -128,12 +118,5 @@ public class GuiInput extends MyObservable implements Observer {
return this.input;
}
/**
* TODO: Write javadoc for this method.
*/
public void subscribe(GameState game) {
AllZone.getInputControl().addObserver(this);
game.getStack().addObserver(this);
game.getPhaseHandler().addObserver(this);
}
}

View File

@@ -4,7 +4,6 @@ import java.util.Observable;
import java.util.Observer;
import forge.Command;
import forge.game.GameState;
import forge.gui.framework.ICDoc;
import forge.gui.match.views.VLog;
@@ -34,10 +33,6 @@ public enum CLog implements ICDoc, Observer {
}
public void subscribe(GameState currentGame) {
currentGame.getGameLog().addObserver(this);
}
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#update()
*/

View File

@@ -22,7 +22,6 @@ import java.awt.event.ActionListener;
import forge.Command;
import forge.Singletons;
import forge.game.GameState;
import forge.game.MatchController;
import forge.gui.GuiInput;
import forge.gui.framework.ICDoc;
@@ -61,10 +60,6 @@ public enum CMessage implements ICDoc {
}
};
public void subscribe(GameState game) {
inputControl.subscribe(game);
}
@Override
public void initialize() {
VMessage.SINGLETON_INSTANCE.getBtnCancel().removeActionListener(actCancel);

View File

@@ -4,7 +4,6 @@ import java.util.Observable;
import java.util.Observer;
import forge.Command;
import forge.game.GameState;
import forge.gui.framework.EDocID;
import forge.gui.framework.ICDoc;
import forge.gui.framework.SDisplayUtil;
@@ -35,10 +34,6 @@ public enum CStack implements ICDoc, Observer {
public void initialize() {
}
public void subscribe(GameState currentGame) {
currentGame.getStack().addObserver(this);
}
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#update()
*/

View File

@@ -485,7 +485,7 @@ public class CField implements ICDoc {
System.out.println("Stop trying to spend the AI's mana");
// TODO: Mindslaver might need to add changes here
} else {
final Input in = AllZone.getInputControl().getInput();
final Input in = Singletons.getModel().getMatch().getInput().getInput();
if (in instanceof InputMana) {
// Do something
((InputMana) in).selectManaPool(Constant.Color.BLACK);
@@ -499,7 +499,7 @@ public class CField implements ICDoc {
System.out.println("Stop trying to spend the AI's mana");
// TODO: Mindslaver might need to add changes here
} else {
final Input in = AllZone.getInputControl().getInput();
final Input in = Singletons.getModel().getMatch().getInput().getInput();
if (in instanceof InputMana) {
// Do something
((InputMana) in).selectManaPool(Constant.Color.BLUE);
@@ -513,7 +513,7 @@ public class CField implements ICDoc {
System.out.println("Stop trying to spend the AI's mana");
// TODO: Mindslaver might need to add changes here
} else {
final Input in = AllZone.getInputControl().getInput();
final Input in = Singletons.getModel().getMatch().getInput().getInput();
if (in instanceof InputMana) {
// Do something
((InputMana) in).selectManaPool(Constant.Color.GREEN);
@@ -527,7 +527,7 @@ public class CField implements ICDoc {
System.out.println("Stop trying to spend the AI's mana");
// TODO: Mindslaver might need to add changes here
} else {
final Input in = AllZone.getInputControl().getInput();
final Input in = Singletons.getModel().getMatch().getInput().getInput();
if (in instanceof InputMana) {
// Do something
((InputMana) in).selectManaPool(Constant.Color.RED);
@@ -541,7 +541,7 @@ public class CField implements ICDoc {
System.out.println("Stop trying to spend the AI's mana");
// TODO: Mindslaver might need to add changes here
} else {
final Input in = AllZone.getInputControl().getInput();
final Input in = Singletons.getModel().getMatch().getInput().getInput();
if (in instanceof InputMana) {
// Do something
((InputMana) in).selectManaPool(Constant.Color.WHITE);
@@ -555,7 +555,7 @@ public class CField implements ICDoc {
System.out.println("Stop trying to spend the AI's mana");
// TODO: Mindslaver might need to add changes here
} else {
final Input in = AllZone.getInputControl().getInput();
final Input in = Singletons.getModel().getMatch().getInput().getInput();
if (in instanceof InputMana) {
// Do something
((InputMana) in).selectManaPool(Constant.Color.COLORLESS);

View File

@@ -25,7 +25,6 @@ import java.io.OutputStream;
import java.io.PrintStream;
import java.util.List;
import forge.AllZone;
import forge.Constant;
import forge.Constant.Preferences;
import forge.GameAction;
@@ -34,7 +33,6 @@ import forge.card.CardBlock;
import forge.card.EditionCollection;
import forge.card.FatPackData;
import forge.card.FormatCollection;
import forge.control.input.InputControl;
import forge.deck.CardCollections;
import forge.error.ExceptionHandler;
import forge.game.GameState;
@@ -73,10 +71,11 @@ public enum FModel {
private BuildInfo buildInfo;
private OutputStream logFileStream;
private final GameAction gameAction;
private final QuestPreferences questPreferences;
private final ForgePreferences preferences;
private GameState gameState;
private GameAction gameAction;
private GauntletData gauntletData;
private QuestController quest = null;
@@ -128,7 +127,6 @@ public enum FModel {
throw new RuntimeException(exn);
}
this.gameAction = new GameAction();
this.questPreferences = new QuestPreferences();
this.gauntletData = new GauntletData();
@@ -144,9 +142,6 @@ public enum FModel {
// TODO - there's got to be a better place for this...oblivion?
Preferences.DEV_MODE = this.preferences.getPrefBoolean(FPref.DEV_MODE_ENABLED);
// Instantiate AI
AllZone.setInputControl(new InputControl(FModel.this));
/// Wrong direction here. It is computer that lives inside player, not a player in computer
testNetworkConnection();
@@ -429,6 +424,7 @@ public enum FModel {
*/
public GameState newGame(Iterable<LobbyPlayer> players) {
gameState = new GameState(players);
gameAction = new GameAction(gameState);
return gameState;
}
}

View File

@@ -40,7 +40,6 @@ import forge.Card;
import forge.Counters;
import forge.ImageCache;
import forge.Singletons;
import forge.game.GameState;
import forge.gui.CardContainer;
import forge.gui.toolbox.CardFaceSymbols;
import forge.properties.ForgePreferences.FPref;
@@ -414,7 +413,7 @@ public class CardPanel extends JPanel implements CardContainer {
(this.cardYOffset + this.cardHeight) - (this.cardHeight / 8) - 16);
}
if (this.getCard().isSick() && GameState.isCardInPlay(this.getCard())) {
if (this.getCard().isSick() && this.getCard().isInPlay()) {
CardFaceSymbols.drawSymbol("summonsick", g, (this.cardXOffset + (this.cardWidth / 2)) - 16,
(this.cardYOffset + this.cardHeight) - (this.cardHeight / 8) - 16);
}