mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
removed FModel.getGame method.
please retrieve the GameState instance from nearby players
This commit is contained in:
@@ -61,6 +61,7 @@ import forge.card.trigger.Trigger;
|
||||
import forge.card.trigger.TriggerType;
|
||||
import forge.card.trigger.ZCTrigger;
|
||||
import forge.game.GameActionUtil;
|
||||
import forge.game.GameState;
|
||||
import forge.game.GlobalRuleChange;
|
||||
import forge.game.event.CardEquippedEvent;
|
||||
import forge.game.event.CounterAddedEvent;
|
||||
@@ -264,7 +265,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
|| (cur == CardCharacteristicName.Transformed && state == CardCharacteristicName.Original)) {
|
||||
HashMap<String, Object> runParams = new HashMap<String, Object>();
|
||||
runParams.put("Transformer", this);
|
||||
Singletons.getModel().getGame().getTriggerHandler().runTrigger(TriggerType.Transformed, runParams, false);
|
||||
getGame().getTriggerHandler().runTrigger(TriggerType.Transformed, runParams, false);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -369,12 +370,12 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
HashMap<String, Object> repParams = new HashMap<String, Object>();
|
||||
repParams.put("Event", "TurnFaceUp");
|
||||
repParams.put("Affected", this);
|
||||
Singletons.getModel().getGame().getReplacementHandler().run(repParams);
|
||||
getGame().getReplacementHandler().run(repParams);
|
||||
|
||||
// Run triggers
|
||||
final Map<String, Object> runParams = new TreeMap<String, Object>();
|
||||
runParams.put("Card", this);
|
||||
Singletons.getModel().getGame().getTriggerHandler().runTrigger(TriggerType.TurnFaceUp, runParams, false);
|
||||
getGame().getTriggerHandler().runTrigger(TriggerType.TurnFaceUp, runParams, false);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -1193,11 +1194,11 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
runParams.put("Card", this);
|
||||
runParams.put("CounterType", counterType);
|
||||
for (int i = 0; i < addAmount; i++) {
|
||||
Singletons.getModel().getGame().getTriggerHandler().runTrigger(TriggerType.CounterAdded, runParams, false);
|
||||
getGame().getTriggerHandler().runTrigger(TriggerType.CounterAdded, runParams, false);
|
||||
}
|
||||
|
||||
// play the Add Counter sound
|
||||
Singletons.getModel().getGame().getEvents().post(new CounterAddedEvent(addAmount));
|
||||
getGame().getEvents().post(new CounterAddedEvent(addAmount));
|
||||
|
||||
this.updateObservers();
|
||||
}
|
||||
@@ -1264,23 +1265,23 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
runParams.put("Card", this);
|
||||
runParams.put("CounterType", counterName);
|
||||
for (int i = 0; i < delta; i++) {
|
||||
Singletons.getModel().getGame().getTriggerHandler().runTrigger(TriggerType.CounterRemoved, runParams, false);
|
||||
getGame().getTriggerHandler().runTrigger(TriggerType.CounterRemoved, runParams, false);
|
||||
}
|
||||
|
||||
if (counterName.equals(CounterType.TIME) && (newValue == 0)) {
|
||||
final boolean hasVanish = CardFactoryUtil.hasKeyword(this, "Vanishing") != -1;
|
||||
|
||||
if (hasVanish && this.isInPlay()) {
|
||||
Singletons.getModel().getGame().getAction().sacrifice(this, null);
|
||||
getGame().getAction().sacrifice(this, null);
|
||||
}
|
||||
|
||||
if (this.hasSuspend() && Singletons.getModel().getGame().isCardExiled(this)) {
|
||||
if (this.hasSuspend() && getGame().isCardExiled(this)) {
|
||||
getOwner().getController().playFromSuspend(this);
|
||||
}
|
||||
}
|
||||
|
||||
// Play the Subtract Counter sound
|
||||
Singletons.getModel().getGame().getEvents().post(new CounterRemovedEvent(delta));
|
||||
getGame().getEvents().post(new CounterRemovedEvent(delta));
|
||||
|
||||
this.updateObservers();
|
||||
}
|
||||
@@ -3171,7 +3172,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
*/
|
||||
public final void addEquipping(final Card c) {
|
||||
this.equipping.add(c);
|
||||
this.setTimestamp(Singletons.getModel().getGame().getNextTimestamp());
|
||||
this.setTimestamp(getGame().getNextTimestamp());
|
||||
this.updateObservers();
|
||||
}
|
||||
|
||||
@@ -3199,7 +3200,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
*/
|
||||
public final void equipCard(final Card c) {
|
||||
if (c.hasKeyword("CARDNAME can't be equipped.")) {
|
||||
Singletons.getModel().getGame().getGameLog().add("ResolveStack", "Trying to equip " + c.getName()
|
||||
getGame().getGameLog().add("ResolveStack", "Trying to equip " + c.getName()
|
||||
+ " but it can't be equipped.", 2);
|
||||
return;
|
||||
}
|
||||
@@ -3209,7 +3210,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
final String[] k = parse.split(" ", 2);
|
||||
final String[] restrictions = k[1].split(",");
|
||||
if (c.isValid(restrictions, this.getController(), this)) {
|
||||
Singletons.getModel().getGame().getGameLog().add("ResolveStack", "Trying to equip " + c.getName()
|
||||
getGame().getGameLog().add("ResolveStack", "Trying to equip " + c.getName()
|
||||
+ " but it can't be equipped.", 2);
|
||||
return;
|
||||
}
|
||||
@@ -3221,7 +3222,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
c.addEquippedBy(this);
|
||||
|
||||
// Play the Equip sound
|
||||
Singletons.getModel().getGame().getEvents().post(new CardEquippedEvent());
|
||||
getGame().getEvents().post(new CardEquippedEvent());
|
||||
// run trigger
|
||||
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
||||
runParams.put("AttachSource", this);
|
||||
@@ -3246,7 +3247,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
final Map<String, Object> runParams = new TreeMap<String, Object>();
|
||||
runParams.put("Equipment", this);
|
||||
runParams.put("Card", c);
|
||||
Singletons.getModel().getGame().getTriggerHandler().runTrigger(TriggerType.Unequip, runParams, false);
|
||||
getGame().getTriggerHandler().runTrigger(TriggerType.Unequip, runParams, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3373,7 +3374,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
*/
|
||||
public final void addEnchanting(final GameEntity e) {
|
||||
this.enchanting = e;
|
||||
this.setTimestamp(Singletons.getModel().getGame().getNextTimestamp());
|
||||
this.setTimestamp(getGame().getNextTimestamp());
|
||||
this.updateObservers();
|
||||
}
|
||||
|
||||
@@ -3402,7 +3403,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
*/
|
||||
public final void enchantEntity(final GameEntity entity) {
|
||||
if (entity.hasKeyword("CARDNAME can't be enchanted.")) {
|
||||
Singletons.getModel().getGame().getGameLog().add("ResolveStack", "Trying to enchant " + entity.getName()
|
||||
getGame().getGameLog().add("ResolveStack", "Trying to enchant " + entity.getName()
|
||||
+ " but it can't be enchanted.", 2);
|
||||
return;
|
||||
}
|
||||
@@ -3895,7 +3896,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (Singletons.getModel().getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.toughnessAssignsDamage)) {
|
||||
if (getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.toughnessAssignsDamage)) {
|
||||
return this.getNetDefense();
|
||||
}
|
||||
return this.getNetAttack();
|
||||
@@ -4133,12 +4134,12 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
// Run triggers
|
||||
final Map<String, Object> runParams = new TreeMap<String, Object>();
|
||||
runParams.put("Card", this);
|
||||
Singletons.getModel().getGame().getTriggerHandler().runTrigger(TriggerType.Taps, runParams, false);
|
||||
getGame().getTriggerHandler().runTrigger(TriggerType.Taps, runParams, false);
|
||||
}
|
||||
this.setTapped(true);
|
||||
|
||||
// Play the Tap sound
|
||||
Singletons.getModel().getGame().getEvents().post(new SetTappedEvent(true));
|
||||
getGame().getEvents().post(new SetTappedEvent(true));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4151,10 +4152,10 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
// Run triggers
|
||||
final Map<String, Object> runParams = new TreeMap<String, Object>();
|
||||
runParams.put("Card", this);
|
||||
Singletons.getModel().getGame().getTriggerHandler().runTrigger(TriggerType.Untaps, runParams, false);
|
||||
getGame().getTriggerHandler().runTrigger(TriggerType.Untaps, runParams, false);
|
||||
|
||||
// Play the Untap sound
|
||||
Singletons.getModel().getGame().getEvents().post(new SetTappedEvent(false));
|
||||
getGame().getEvents().post(new SetTappedEvent(false));
|
||||
}
|
||||
|
||||
for (final Command var : this.untapCommandList) {
|
||||
@@ -4884,9 +4885,9 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
|
||||
// Suppressed Exiling is as close as we can get to
|
||||
// "ceasing to exist"
|
||||
Singletons.getModel().getGame().getTriggerHandler().suppressMode(TriggerType.ChangesZone);
|
||||
Singletons.getModel().getGame().getAction().exile(this);
|
||||
Singletons.getModel().getGame().getTriggerHandler().clearSuppression(TriggerType.ChangesZone);
|
||||
getGame().getTriggerHandler().suppressMode(TriggerType.ChangesZone);
|
||||
getGame().getAction().exile(this);
|
||||
getGame().getTriggerHandler().clearSuppression(TriggerType.ChangesZone);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -5278,10 +5279,10 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
return false;
|
||||
}
|
||||
} else if (property.startsWith("DefenderCtrl")) {
|
||||
if (!Singletons.getModel().getGame().getPhaseHandler().inCombat()) {
|
||||
if (!getGame().getPhaseHandler().inCombat()) {
|
||||
return false;
|
||||
}
|
||||
if (!Singletons.getModel().getGame().getCombat().getDefendingPlayerRelatedTo(source).contains(this.getController())) {
|
||||
if (!getGame().getCombat().getDefendingPlayerRelatedTo(source).contains(this.getController())) {
|
||||
return false;
|
||||
}
|
||||
} else if (property.startsWith("EnchantedPlayerCtrl")) {
|
||||
@@ -5295,7 +5296,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
}
|
||||
} else if (property.startsWith("RememberedPlayerCtrl")) {
|
||||
if (source.getRemembered().isEmpty()) {
|
||||
final Card newCard = Singletons.getModel().getGame().getCardState(source);
|
||||
final Card newCard = getGame().getCardState(source);
|
||||
for (final Object o : newCard.getRemembered()) {
|
||||
if (o instanceof Player) {
|
||||
if (!this.getController().equals(o)) {
|
||||
@@ -5341,11 +5342,11 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
}
|
||||
}
|
||||
} else if (property.startsWith("ActivePlayerCtrl")) {
|
||||
if (!Singletons.getModel().getGame().getPhaseHandler().isPlayerTurn(this.getController())) {
|
||||
if (!getGame().getPhaseHandler().isPlayerTurn(this.getController())) {
|
||||
return false;
|
||||
}
|
||||
} else if (property.startsWith("NonActivePlayerCtrl")) {
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().isPlayerTurn(this.getController())) {
|
||||
if (getGame().getPhaseHandler().isPlayerTurn(this.getController())) {
|
||||
return false;
|
||||
}
|
||||
} else if (property.startsWith("YouOwn")) {
|
||||
@@ -5655,7 +5656,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
}
|
||||
} else if (restriction.equals("MostProminentColor")) {
|
||||
for (final String color : CardUtil.getColors(this)) {
|
||||
if (CardFactoryUtil.isMostProminentColor(Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield), color)) {
|
||||
if (CardFactoryUtil.isMostProminentColor(getGame().getCardsIn(ZoneType.Battlefield), color)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -5679,7 +5680,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
}
|
||||
String color = props[1];
|
||||
|
||||
return CardFactoryUtil.isMostProminentColor(Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield), color);
|
||||
return CardFactoryUtil.isMostProminentColor(getGame().getCardsIn(ZoneType.Battlefield), color);
|
||||
} else if (property.startsWith("notSharesColorWith")) {
|
||||
if (property.equals("notSharesColorWith")) {
|
||||
if (this.sharesColorWith(source)) {
|
||||
@@ -5777,7 +5778,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
return false;
|
||||
} else if (restriction.equals("EachTopLibrary")) {
|
||||
final List<Card> list = new ArrayList<Card>();
|
||||
for (Player p : Singletons.getModel().getGame().getPlayers()) {
|
||||
for (Player p : getGame().getPlayers()) {
|
||||
final Card top = p.getCardsIn(ZoneType.Library).get(0);
|
||||
list.add(top);
|
||||
}
|
||||
@@ -5804,14 +5805,14 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
}
|
||||
return false;
|
||||
} else if (restriction.equals(ZoneType.Graveyard.toString())) {
|
||||
for (final Card card : Singletons.getModel().getGame().getCardsIn(ZoneType.Graveyard)) {
|
||||
for (final Card card : getGame().getCardsIn(ZoneType.Graveyard)) {
|
||||
if (this.getName().equals(card.getName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else if (restriction.equals(ZoneType.Battlefield.toString())) {
|
||||
for (final Card card : Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield)) {
|
||||
for (final Card card : getGame().getCardsIn(ZoneType.Battlefield)) {
|
||||
if (this.getName().equals(card.getName())) {
|
||||
return true;
|
||||
}
|
||||
@@ -5842,7 +5843,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
}
|
||||
return false;
|
||||
} else if (restriction.equals("NonToken")) {
|
||||
final List<Card> list = CardLists.filter(Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield),
|
||||
final List<Card> list = CardLists.filter(getGame().getCardsIn(ZoneType.Battlefield),
|
||||
Presets.NON_TOKEN);
|
||||
for (final Card card : list) {
|
||||
if (this.getName().equals(card.getName())) {
|
||||
@@ -5959,11 +5960,11 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
return false;
|
||||
}
|
||||
} else if (property.startsWith("enteredBattlefieldThisTurn")) {
|
||||
if (!(this.getTurnInZone() == Singletons.getModel().getGame().getPhaseHandler().getTurn())) {
|
||||
if (!(this.getTurnInZone() == getGame().getPhaseHandler().getTurn())) {
|
||||
return false;
|
||||
}
|
||||
} else if (property.startsWith("notEnteredBattlefieldThisTurn")) {
|
||||
if (this.getTurnInZone() == Singletons.getModel().getGame().getPhaseHandler().getTurn()) {
|
||||
if (this.getTurnInZone() == getGame().getPhaseHandler().getTurn()) {
|
||||
return false;
|
||||
}
|
||||
} else if (property.startsWith("firstTurnControlled")) {
|
||||
@@ -6039,7 +6040,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
return false;
|
||||
}
|
||||
} else if (property.startsWith("greatestPower")) {
|
||||
final List<Card> list = CardLists.filter(Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield), Presets.CREATURES);
|
||||
final List<Card> list = CardLists.filter(getGame().getCardsIn(ZoneType.Battlefield), Presets.CREATURES);
|
||||
for (final Card crd : list) {
|
||||
if (crd.getNetAttack() > this.getNetAttack()) {
|
||||
return false;
|
||||
@@ -6053,21 +6054,21 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
}
|
||||
}
|
||||
} else if (property.startsWith("leastPower")) {
|
||||
final List<Card> list = CardLists.filter(Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield), Presets.CREATURES);
|
||||
final List<Card> list = CardLists.filter(getGame().getCardsIn(ZoneType.Battlefield), Presets.CREATURES);
|
||||
for (final Card crd : list) {
|
||||
if (crd.getNetAttack() < this.getNetAttack()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else if (property.startsWith("leastToughness")) {
|
||||
final List<Card> list = CardLists.filter(Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield), Presets.CREATURES);
|
||||
final List<Card> list = CardLists.filter(getGame().getCardsIn(ZoneType.Battlefield), Presets.CREATURES);
|
||||
for (final Card crd : list) {
|
||||
if (crd.getNetDefense() < this.getNetDefense()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else if (property.startsWith("greatestCMC")) {
|
||||
final List<Card> list = CardLists.filter(Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield), Presets.CREATURES);
|
||||
final List<Card> list = CardLists.filter(getGame().getCardsIn(ZoneType.Battlefield), Presets.CREATURES);
|
||||
for (final Card crd : list) {
|
||||
if (crd.isSplitCard()) {
|
||||
if (crd.getCMC(Card.SplitCMCMode.LeftSplitCMC) > this.getCMC() || crd.getCMC(Card.SplitCMCMode.RightSplitCMC) > this.getCMC()) {
|
||||
@@ -6083,7 +6084,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
List<Card> list = new ArrayList<Card>();
|
||||
for (final Object o : source.getRemembered()) {
|
||||
if (o instanceof Card) {
|
||||
list.add(Singletons.getModel().getGame().getCardState((Card) o));
|
||||
list.add(getGame().getCardState((Card) o));
|
||||
}
|
||||
}
|
||||
if (!list.contains(this)) {
|
||||
@@ -6094,7 +6095,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
return false;
|
||||
}
|
||||
} else if (property.startsWith("lowestCMC")) {
|
||||
final List<Card> list = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
final List<Card> list = getGame().getCardsIn(ZoneType.Battlefield);
|
||||
for (final Card crd : list) {
|
||||
if (!crd.isLand() && !crd.isImmutable()) {
|
||||
if (crd.isSplitCard()) {
|
||||
@@ -6146,7 +6147,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
return false;
|
||||
}
|
||||
} else if (property.startsWith("suspended")) {
|
||||
if (!this.hasSuspend() || !Singletons.getModel().getGame().isCardExiled(this)
|
||||
if (!this.hasSuspend() || !getGame().isCardExiled(this)
|
||||
|| !(this.getCounters(CounterType.getType("TIME")) >= 1)) {
|
||||
return false;
|
||||
}
|
||||
@@ -6244,7 +6245,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
return false;
|
||||
}
|
||||
} else if (property.equals("attackedBySourceThisCombat")) {
|
||||
final GameEntity defender = Singletons.getModel().getGame().getCombat().getDefenderByAttacker(source);
|
||||
final GameEntity defender = getGame().getCombat().getDefenderByAttacker(source);
|
||||
if (defender instanceof Card) {
|
||||
if (!this.equals((Card) defender)) {
|
||||
return false;
|
||||
@@ -6319,7 +6320,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
return false;
|
||||
}
|
||||
} else if (property.startsWith("unblocked")) {
|
||||
if (!Singletons.getModel().getGame().getCombat().isUnblocked(this)) {
|
||||
if (!getGame().getCombat().isUnblocked(this)) {
|
||||
return false;
|
||||
}
|
||||
} else if (property.startsWith("kicked")) {
|
||||
@@ -6704,7 +6705,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean isAttacking() {
|
||||
return Singletons.getModel().getGame().getCombat().isAttacking(this);
|
||||
return getGame().getCombat().isAttacking(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -6715,7 +6716,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean isAttacking(GameEntity ge) {
|
||||
Combat combat = Singletons.getModel().getGame().getCombat();
|
||||
Combat combat = getGame().getCombat();
|
||||
if (!combat.isAttacking(this)) {
|
||||
return false;
|
||||
}
|
||||
@@ -6730,7 +6731,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean isBlocking() {
|
||||
final List<Card> blockers = Singletons.getModel().getGame().getCombat().getAllBlockers();
|
||||
final List<Card> blockers = getGame().getCombat().getAllBlockers();
|
||||
return blockers.contains(this);
|
||||
}
|
||||
|
||||
@@ -6742,7 +6743,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean isBlocked() {
|
||||
return Singletons.getModel().getGame().getCombat().isBlocked(this);
|
||||
return getGame().getCombat().isBlocked(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -6755,7 +6756,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean isBlocking(final Card attacker) {
|
||||
return Singletons.getModel().getGame().getCombat().getAttackersBlockedBy(this).contains(attacker);
|
||||
return getGame().getCombat().getAttackersBlockedBy(this).contains(attacker);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -6768,7 +6769,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean isBlockedBy(final Card blocker) {
|
||||
return Singletons.getModel().getGame().getCombat().getAttackersBlockedBy(blocker).contains(this);
|
||||
return getGame().getCombat().getAttackersBlockedBy(blocker).contains(this);
|
||||
}
|
||||
|
||||
// /////////////////////////
|
||||
@@ -6778,7 +6779,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
// ////////////////////////
|
||||
|
||||
// all damage to cards is now handled in Card.java, no longer
|
||||
// Singletons.getModel().getGameAction()...
|
||||
// getGameAction()...
|
||||
/**
|
||||
* <p>
|
||||
* addReceivedDamageFromThisTurn.
|
||||
@@ -7089,11 +7090,11 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
public final int staticDamagePrevention(final int damage, final int possiblePrevention, final Card source,
|
||||
final boolean isCombat) {
|
||||
|
||||
if (Singletons.getModel().getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noPrevention)) {
|
||||
if (getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noPrevention)) {
|
||||
return damage;
|
||||
}
|
||||
|
||||
for (final Card ca : Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield)) {
|
||||
for (final Card ca : getGame().getCardsIn(ZoneType.Battlefield)) {
|
||||
for (final ReplacementEffect re : ca.getReplacementEffects()) {
|
||||
Map<String, String> params = re.getMapParams();
|
||||
if (!"DamageDone".equals(params.get("Event")) || !params.containsKey("PreventionEffect")) {
|
||||
@@ -7148,11 +7149,11 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
@Override
|
||||
public final int staticDamagePrevention(final int damageIn, final Card source, final boolean isCombat, final boolean isTest) {
|
||||
|
||||
if (Singletons.getModel().getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noPrevention)) {
|
||||
if (getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noPrevention)) {
|
||||
return damageIn;
|
||||
}
|
||||
|
||||
if (isCombat && Singletons.getModel().getGame().getPhaseHandler().isPreventCombatDamageThisTurn()) {
|
||||
if (isCombat && getGame().getPhaseHandler().isPreventCombatDamageThisTurn()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -7211,7 +7212,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
}
|
||||
|
||||
// Prevent Damage static abilities
|
||||
for (final Card ca : Singletons.getModel().getGame().getCardsIn(ZoneType.listValueOf("Battlefield,Command"))) {
|
||||
for (final Card ca : getGame().getCardsIn(ZoneType.listValueOf("Battlefield,Command"))) {
|
||||
final ArrayList<StaticAbility> staticAbilities = ca.getStaticAbilities();
|
||||
for (final StaticAbility stAb : staticAbilities) {
|
||||
restDamage = stAb.applyAbility("PreventDamage", source, this, restDamage, isCombat, isTest);
|
||||
@@ -7224,7 +7225,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (source.isCreature() && Singletons.getModel().getGame().isCardInPlay("Well-Laid Plans")
|
||||
if (source.isCreature() && getGame().isCardInPlay("Well-Laid Plans")
|
||||
&& source.sharesColorWith(this)) {
|
||||
return 0;
|
||||
}
|
||||
@@ -7250,7 +7251,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
@Override
|
||||
public final int preventDamage(final int damage, final Card source, final boolean isCombat) {
|
||||
|
||||
if (Singletons.getModel().getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noPrevention)
|
||||
if (getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noPrevention)
|
||||
|| source.hasKeyword("Damage that would be dealt by CARDNAME can't be prevented.")) {
|
||||
return damage;
|
||||
}
|
||||
@@ -7270,7 +7271,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
repParams.put("IsCombat", isCombat);
|
||||
repParams.put("Prevention", true);
|
||||
|
||||
if (Singletons.getModel().getGame().getReplacementHandler().run(repParams) != ReplacementResult.NotReplaced) {
|
||||
if (getGame().getReplacementHandler().run(repParams) != ReplacementResult.NotReplaced) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -7316,7 +7317,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 : Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield)) {
|
||||
for (Card c : getGame().getCardsIn(ZoneType.Battlefield)) {
|
||||
if (c.getName().equals("Sulfuric Vapors")) {
|
||||
if (source.isSpell() && source.isRed()) {
|
||||
restDamage += 1;
|
||||
@@ -7397,7 +7398,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
repParams.put("DamageAmount", damageIn);
|
||||
repParams.put("IsCombat", isCombat);
|
||||
|
||||
if (Singletons.getModel().getGame().getReplacementHandler().run(repParams) != ReplacementResult.NotReplaced) {
|
||||
if (getGame().getReplacementHandler().run(repParams) != ReplacementResult.NotReplaced) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -7460,14 +7461,14 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
runParams.put("DamageTarget", this);
|
||||
runParams.put("DamageAmount", damageToAdd);
|
||||
runParams.put("IsCombatDamage", isCombat);
|
||||
Singletons.getModel().getGame().getTriggerHandler().runTrigger(TriggerType.DamageDone, runParams, false);
|
||||
getGame().getTriggerHandler().runTrigger(TriggerType.DamageDone, runParams, false);
|
||||
|
||||
String additionalLog = "";
|
||||
if (this.isPlaneswalker()) {
|
||||
this.subtractCounter(CounterType.LOYALTY, damageToAdd);
|
||||
additionalLog = String.format("(Removing %d Loyalty Counters)", damageToAdd);
|
||||
} else {
|
||||
boolean wither = (Singletons.getModel().getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.alwaysWither)
|
||||
boolean wither = (getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.alwaysWither)
|
||||
|| source.hasKeyword("Wither") || source.hasKeyword("Infect"));
|
||||
|
||||
GameActionUtil.executeDamageToCreatureEffects(source, this, damageToAdd);
|
||||
@@ -7477,14 +7478,14 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
additionalLog = "(As -1/-1 Counters)";
|
||||
}
|
||||
if (source.hasKeyword("Deathtouch") && this.isCreature()) {
|
||||
Singletons.getModel().getGame().getAction().destroy(this, null);
|
||||
getGame().getAction().destroy(this, null);
|
||||
additionalLog = "(Deathtouch)";
|
||||
} else if (this.isInPlay() && !wither) {
|
||||
this.damage += damageToAdd;
|
||||
}
|
||||
}
|
||||
|
||||
Singletons.getModel().getGame().getGameLog().add("Damage", String.format("Dealing %d damage to %s. %s",
|
||||
getGame().getGameLog().add("Damage", String.format("Dealing %d damage to %s. %s",
|
||||
damageToAdd, this.getName(), additionalLog), 3);
|
||||
return true;
|
||||
}
|
||||
@@ -7859,7 +7860,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isInZone(final ZoneType zone) {
|
||||
return Singletons.getModel().getGame().isCardInZone(this, zone);
|
||||
return getGame().isCardInZone(this, zone);
|
||||
}
|
||||
|
||||
public final boolean canBeDestroyed() {
|
||||
@@ -7881,7 +7882,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
}
|
||||
|
||||
// CantTarget static abilities
|
||||
for (final Card ca : Singletons.getModel().getGame().getCardsIn(ZoneType.listValueOf("Battlefield,Command"))) {
|
||||
for (final Card ca : getGame().getCardsIn(ZoneType.listValueOf("Battlefield,Command"))) {
|
||||
final ArrayList<StaticAbility> staticAbilities = ca.getStaticAbilities();
|
||||
for (final StaticAbility stAb : staticAbilities) {
|
||||
if (stAb.applyAbility("CantTarget", this, sa)) {
|
||||
@@ -8203,7 +8204,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
int xPaid = 0;
|
||||
|
||||
// 2012-07-22 - If a card is on the stack, count the xManaCost in with it's CMC
|
||||
if (Singletons.getModel().getGame().getCardsIn(ZoneType.Stack).contains(this) && getManaCost() != null) {
|
||||
if (getGame().getCardsIn(ZoneType.Stack).contains(this) && getManaCost() != null) {
|
||||
xPaid = getXManaCostPaid() * getManaCost().countX();
|
||||
}
|
||||
|
||||
@@ -8296,4 +8297,20 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
public Iterable<OptionalCost> getOptionalCostsPaid() { return costsPaid; }
|
||||
public boolean isOptionalCostPaid(OptionalCost cost) { return costsPaid.contains(cost); }
|
||||
|
||||
/**
|
||||
* Fetch GameState for this card from references to players who may own or control this card.
|
||||
*/
|
||||
public GameState getGame() {
|
||||
|
||||
Player controller = getController();
|
||||
if (null != controller)
|
||||
return controller.getGame();
|
||||
|
||||
Player owner = getOwner();
|
||||
if (null != owner)
|
||||
return owner.getGame();
|
||||
|
||||
throw new IllegalStateException("Card " + toString() + " has no means to determine the game it belongs to!");
|
||||
}
|
||||
|
||||
} // end Card class
|
||||
|
||||
@@ -30,6 +30,7 @@ import forge.card.ability.ApiType;
|
||||
import forge.card.spellability.AbilityManaPart;
|
||||
import forge.card.spellability.AbilitySub;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.GameState;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.properties.NewConstants;
|
||||
@@ -88,15 +89,15 @@ public final class CardUtil {
|
||||
* @param src a Card object
|
||||
* @return a List<Card> that matches the given criteria
|
||||
*/
|
||||
public static List<Card> getThisTurnEntered(final ZoneType to, final ZoneType from, final String valid,
|
||||
final Card src) {
|
||||
public static List<Card> getThisTurnEntered(final ZoneType to, final ZoneType from, final String valid, final Card src) {
|
||||
List<Card> res = new ArrayList<Card>();
|
||||
final GameState game = src.getGame();
|
||||
if (to != ZoneType.Stack) {
|
||||
for (Player p : Singletons.getModel().getGame().getPlayers()) {
|
||||
for (Player p : game.getPlayers()) {
|
||||
res.addAll(p.getZone(to).getCardsAddedThisTurn(from));
|
||||
}
|
||||
} else {
|
||||
res.addAll(Singletons.getModel().getGame().getStackZone().getCardsAddedThisTurn(from));
|
||||
res.addAll(game.getStackZone().getCardsAddedThisTurn(from));
|
||||
}
|
||||
|
||||
res = CardLists.getValidCards(res, valid, src.getController(), src);
|
||||
@@ -106,8 +107,8 @@ public final class CardUtil {
|
||||
|
||||
public static List<Card> getThisTurnCast(final String valid, final Card src) {
|
||||
List<Card> res = new ArrayList<Card>();
|
||||
|
||||
res.addAll(Singletons.getModel().getGame().getStack().getCardsCastThisTurn());
|
||||
final GameState game = src.getGame();
|
||||
res.addAll(game.getStack().getCardsCastThisTurn());
|
||||
|
||||
res = CardLists.getValidCards(res, valid, src.getController(), src);
|
||||
|
||||
@@ -116,8 +117,8 @@ public final class CardUtil {
|
||||
|
||||
public static List<Card> getLastTurnCast(final String valid, final Card src) {
|
||||
List<Card> res = new ArrayList<Card>();
|
||||
|
||||
res.addAll(Singletons.getModel().getGame().getStack().getCardsCastLastTurn());
|
||||
final GameState game = src.getGame();
|
||||
res.addAll(game.getStack().getCardsCastLastTurn());
|
||||
|
||||
res = CardLists.getValidCards(res, valid, src.getController(), src);
|
||||
|
||||
@@ -181,12 +182,13 @@ public final class CardUtil {
|
||||
public static List<Card> getRadiance(final Card source, final Card origin, final String[] valid) {
|
||||
final List<Card> res = new ArrayList<Card>();
|
||||
|
||||
final GameState game = source.getGame();
|
||||
for (final CardColor col : origin.getColor()) {
|
||||
for (final String strCol : col.toStringList()) {
|
||||
if (strCol.equalsIgnoreCase("Colorless")) {
|
||||
continue;
|
||||
}
|
||||
for (final Card c : Singletons.getModel().getGame().getColoredCardsInPlay(strCol)) {
|
||||
for (final Card c : game.getColoredCardsInPlay(strCol)) {
|
||||
if (!res.contains(c) && c.isValid(valid, source.getController(), source) && !c.equals(origin)) {
|
||||
res.add(c);
|
||||
}
|
||||
@@ -248,7 +250,8 @@ public final class CardUtil {
|
||||
if (validCard.startsWith("Defined.")) {
|
||||
cards = AbilityUtils.getDefinedCards(card, validCard.replace("Defined.", ""), abMana);
|
||||
} else {
|
||||
cards = CardLists.getValidCards(Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield), validCard, abMana.getActivatingPlayer(), card);
|
||||
final GameState game = sa.getActivatingPlayer().getGame();
|
||||
cards = CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), validCard, abMana.getActivatingPlayer(), card);
|
||||
}
|
||||
|
||||
// remove anything cards that is already in parents
|
||||
|
||||
@@ -289,4 +289,12 @@ public enum CounterType {
|
||||
final String replacedName = name.replace("/", "").replaceAll("\\+", "p").replaceAll("\\-", "m").toUpperCase();
|
||||
return Enum.valueOf(CounterType.class, replacedName);
|
||||
}
|
||||
|
||||
// although this should be in AI's code
|
||||
public boolean isNegativeCounter() {
|
||||
CounterType c = this;
|
||||
return (c == CounterType.AGE) || (c == CounterType.BLAZE) || (c == CounterType.BRIBERY) || (c == CounterType.DOOM)
|
||||
|| (c == CounterType.ICE) || (c == CounterType.M1M1) || (c == CounterType.M0M2) || (c == CounterType.M0M1)
|
||||
|| (c == CounterType.TIME);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import forge.card.TriggerReplacementBase;
|
||||
import forge.card.replacement.ReplacementEffect;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.staticability.StaticAbility;
|
||||
import forge.game.GameState;
|
||||
import forge.game.GlobalRuleChange;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
@@ -63,8 +64,6 @@ public class StaticEffects {
|
||||
this.removeStaticEffect(this.staticEffects.get(i));
|
||||
}
|
||||
this.staticEffects = new ArrayList<StaticEffect>();
|
||||
|
||||
Singletons.getModel().getGame().getTriggerHandler().cleanUpTemporaryTriggers();
|
||||
}
|
||||
|
||||
public void setGlobalRuleChange(GlobalRuleChange change) {
|
||||
@@ -374,11 +373,12 @@ public class StaticEffects {
|
||||
* <p>
|
||||
* rePopulateStateBasedList.
|
||||
* </p>
|
||||
* @param game
|
||||
*/
|
||||
public final void rePopulateStateBasedList() {
|
||||
public final void rePopulateStateBasedList(GameState game) {
|
||||
this.reset();
|
||||
|
||||
final List<Card> cards = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
final List<Card> cards = game.getCardsIn(ZoneType.Battlefield);
|
||||
|
||||
Log.debug("== Start add state effects ==");
|
||||
for (Card c : cards) {
|
||||
|
||||
@@ -9,10 +9,10 @@ import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardUtil;
|
||||
import forge.GameEntity;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.GameState;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.Zone;
|
||||
import forge.game.zone.ZoneType;
|
||||
@@ -155,8 +155,8 @@ public abstract class TriggerReplacementBase {
|
||||
}
|
||||
|
||||
protected boolean meetsCommonRequirements(Map<String, String> params) {
|
||||
|
||||
Player hostController = this.getHostCard().getController();
|
||||
final Player hostController = this.getHostCard().getController();
|
||||
final GameState game = hostController.getGame();
|
||||
|
||||
if ("True".equalsIgnoreCase(params.get("Metalcraft")) && !hostController.hasMetalcraft()) return false;
|
||||
if ("True".equalsIgnoreCase(params.get("Threshold")) && !hostController.hasThreshold()) return false;
|
||||
@@ -167,7 +167,7 @@ public abstract class TriggerReplacementBase {
|
||||
if ("You".equalsIgnoreCase(params.get("PlayersPoisoned")) && hostController.getPoisonCounters() == 0) return false;
|
||||
if ("Opponent".equalsIgnoreCase(params.get("PlayersPoisoned")) && hostController.getOpponent().getPoisonCounters() == 0) return false;
|
||||
if ("Each".equalsIgnoreCase(params.get("PlayersPoisoned"))) {
|
||||
for( Player p : Singletons.getModel().getGame().getPlayers())
|
||||
for( Player p : game.getPlayers())
|
||||
if( p.getPoisonCounters() == 0 )
|
||||
return false;
|
||||
}
|
||||
@@ -281,14 +281,14 @@ public abstract class TriggerReplacementBase {
|
||||
}
|
||||
|
||||
if (params.containsKey("CheckSVar")) {
|
||||
final int sVar = AbilityUtils.calculateAmount(Singletons.getModel().getGame().getCardState(this.getHostCard()), params.get("CheckSVar"), null);
|
||||
final int sVar = AbilityUtils.calculateAmount(game.getCardState(this.getHostCard()), params.get("CheckSVar"), null);
|
||||
String comparator = "GE1";
|
||||
if (params.containsKey("SVarCompare")) {
|
||||
comparator = params.get("SVarCompare");
|
||||
}
|
||||
final String svarOperator = comparator.substring(0, 2);
|
||||
final String svarOperand = comparator.substring(2);
|
||||
final int operandValue = AbilityUtils.calculateAmount(Singletons.getModel().getGame().getCardState(this.getHostCard()),
|
||||
final int operandValue = AbilityUtils.calculateAmount(game.getCardState(this.getHostCard()),
|
||||
svarOperand, null);
|
||||
if (!Expressions.compare(sVar, svarOperator, operandValue)) {
|
||||
return false;
|
||||
|
||||
@@ -12,7 +12,6 @@ import forge.CardLists;
|
||||
import forge.CardUtil;
|
||||
import forge.Constant;
|
||||
import forge.CounterType;
|
||||
import forge.Singletons;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.mana.ManaCostBeingPaid;
|
||||
@@ -79,7 +78,8 @@ public class AbilityUtils {
|
||||
public static List<Card> getDefinedCards(final Card hostCard, final String def, final SpellAbility sa) {
|
||||
final List<Card> cards = new ArrayList<Card>();
|
||||
final String defined = (def == null) ? "Self" : def; // default to Self
|
||||
|
||||
final GameState game = sa.getActivatingPlayer().getGame();
|
||||
|
||||
Card c = null;
|
||||
|
||||
if (defined.equals("Self")) {
|
||||
@@ -142,7 +142,7 @@ public class AbilityUtils {
|
||||
else {
|
||||
final Object crd = root.getTriggeringObject(defined.substring(9));
|
||||
if (crd instanceof Card) {
|
||||
c = Singletons.getModel().getGame().getCardState((Card) crd);
|
||||
c = game.getCardState((Card) crd);
|
||||
} else if (crd instanceof List<?>) {
|
||||
for (final Card cardItem : (List<Card>) crd) {
|
||||
cards.add(cardItem);
|
||||
@@ -153,7 +153,7 @@ public class AbilityUtils {
|
||||
final SpellAbility root = sa.getRootAbility();
|
||||
final Object crd = root.getReplacingObject(defined.substring(8));
|
||||
if (crd instanceof Card) {
|
||||
c = Singletons.getModel().getGame().getCardState((Card) crd);
|
||||
c = game.getCardState((Card) crd);
|
||||
} else if (crd instanceof List<?>) {
|
||||
for (final Card cardItem : (List<Card>) crd) {
|
||||
cards.add(cardItem);
|
||||
@@ -161,26 +161,26 @@ public class AbilityUtils {
|
||||
}
|
||||
} else if (defined.equals("Remembered")) {
|
||||
if (hostCard.getRemembered().isEmpty()) {
|
||||
final Card newCard = Singletons.getModel().getGame().getCardState(hostCard);
|
||||
final Card newCard = game.getCardState(hostCard);
|
||||
for (final Object o : newCard.getRemembered()) {
|
||||
if (o instanceof Card) {
|
||||
cards.add(Singletons.getModel().getGame().getCardState((Card) o));
|
||||
cards.add(game.getCardState((Card) o));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (final Object o : hostCard.getRemembered()) {
|
||||
if (o instanceof Card) {
|
||||
cards.add(Singletons.getModel().getGame().getCardState((Card) o));
|
||||
cards.add(game.getCardState((Card) o));
|
||||
}
|
||||
}
|
||||
} else if (defined.equals("Clones")) {
|
||||
for (final Card clone : hostCard.getClones()) {
|
||||
cards.add(Singletons.getModel().getGame().getCardState(clone));
|
||||
cards.add(game.getCardState(clone));
|
||||
}
|
||||
} else if (defined.equals("Imprinted")) {
|
||||
for (final Card imprint : hostCard.getImprinted()) {
|
||||
cards.add(Singletons.getModel().getGame().getCardState(imprint));
|
||||
cards.add(game.getCardState(imprint));
|
||||
}
|
||||
} else if (defined.startsWith("ThisTurnEntered")) {
|
||||
final String[] workingCopy = defined.split("_");
|
||||
@@ -196,11 +196,11 @@ public class AbilityUtils {
|
||||
validFilter = workingCopy[2];
|
||||
}
|
||||
for (final Card cl : CardUtil.getThisTurnEntered(destination, origin, validFilter, hostCard)) {
|
||||
cards.add(Singletons.getModel().getGame().getCardState(cl));
|
||||
cards.add(game.getCardState(cl));
|
||||
}
|
||||
} else if (defined.equals("ChosenCard")) {
|
||||
for (final Card chosen : hostCard.getChosenCard()) {
|
||||
cards.add(Singletons.getModel().getGame().getCardState(chosen));
|
||||
cards.add(game.getCardState(chosen));
|
||||
}
|
||||
} else {
|
||||
List<Card> list = null;
|
||||
@@ -226,22 +226,16 @@ public class AbilityUtils {
|
||||
|
||||
else if (defined.startsWith("Valid ")) {
|
||||
String validDefined = defined.substring("Valid ".length());
|
||||
GameState game = Singletons.getModel().getGame();
|
||||
|
||||
list = CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), validDefined.split(","), hostCard.getController(), hostCard);
|
||||
}
|
||||
|
||||
else if (defined.startsWith("ValidHand ")) {
|
||||
String validDefined = defined.substring("ValidHand ".length());
|
||||
GameState game = Singletons.getModel().getGame();
|
||||
|
||||
list = CardLists.getValidCards(game.getCardsIn(ZoneType.Hand), validDefined.split(","), hostCard.getController(), hostCard);
|
||||
}
|
||||
|
||||
else if (defined.startsWith("ValidAll ")) {
|
||||
String validDefined = defined.substring("ValidAll ".length());
|
||||
GameState game = Singletons.getModel().getGame();
|
||||
|
||||
list = CardLists.getValidCards(game.getCardsInGame(), validDefined.split(","), hostCard.getController(), hostCard);
|
||||
}
|
||||
|
||||
@@ -292,6 +286,7 @@ public class AbilityUtils {
|
||||
public static int calculateAmount(final Card card, String amount, final SpellAbility ability) {
|
||||
// return empty strings and constants
|
||||
if (StringUtils.isBlank(amount)) { return 0; }
|
||||
final GameState game = card.getController().getGame();
|
||||
|
||||
// Strip and save sign for calculations
|
||||
final boolean startsWithPlus = amount.charAt(0) == '+';
|
||||
@@ -366,7 +361,7 @@ public class AbilityUtils {
|
||||
final String hType = calcX[0].substring(11);
|
||||
final ArrayList<Player> players = new ArrayList<Player>();
|
||||
if (hType.equals("Players") || hType.equals("")) {
|
||||
players.addAll(Singletons.getModel().getGame().getPlayers());
|
||||
players.addAll(game.getPlayers());
|
||||
return CardFactoryUtil.playerXCount(players, calcX[1], card) * multiplier;
|
||||
} else if (hType.equals("Opponents")) {
|
||||
players.addAll(card.getController().getOpponents());
|
||||
@@ -382,8 +377,8 @@ public class AbilityUtils {
|
||||
}
|
||||
return CardFactoryUtil.playerXCount(players, calcX[1], card) * multiplier;
|
||||
} else if (hType.equals("NonActive")) {
|
||||
players.addAll(Singletons.getModel().getGame().getPlayers());
|
||||
players.remove(Singletons.getModel().getGame().getPhaseHandler().getPlayerTurn());
|
||||
players.addAll(game.getPlayers());
|
||||
players.remove(game.getPhaseHandler().getPlayerTurn());
|
||||
return CardFactoryUtil.playerXCount(players, calcX[1], card) * multiplier;
|
||||
}
|
||||
return 0;
|
||||
@@ -393,10 +388,10 @@ public class AbilityUtils {
|
||||
// Add whole Remembered list to handlePaid
|
||||
final List<Card> list = new ArrayList<Card>();
|
||||
if (card.getRemembered().isEmpty()) {
|
||||
final Card newCard = Singletons.getModel().getGame().getCardState(card);
|
||||
final Card newCard = game.getCardState(card);
|
||||
for (final Object o : newCard.getRemembered()) {
|
||||
if (o instanceof Card) {
|
||||
list.add(Singletons.getModel().getGame().getCardState((Card) o));
|
||||
list.add(game.getCardState((Card) o));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -410,7 +405,7 @@ public class AbilityUtils {
|
||||
} else {
|
||||
for (final Object o : card.getRemembered()) {
|
||||
if (o instanceof Card) {
|
||||
list.add(Singletons.getModel().getGame().getCardState((Card) o));
|
||||
list.add(game.getCardState((Card) o));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -422,7 +417,7 @@ public class AbilityUtils {
|
||||
// Add whole Imprinted list to handlePaid
|
||||
final List<Card> list = new ArrayList<Card>();
|
||||
for (final Card c : card.getImprinted()) {
|
||||
list.add(Singletons.getModel().getGame().getCardState(c));
|
||||
list.add(game.getCardState(c));
|
||||
}
|
||||
|
||||
return CardFactoryUtil.handlePaid(list, calcX[1], card) * multiplier;
|
||||
@@ -434,7 +429,7 @@ public class AbilityUtils {
|
||||
if (card.isEnchanting()) {
|
||||
Object o = card.getEnchanting();
|
||||
if (o instanceof Card) {
|
||||
list.add(Singletons.getModel().getGame().getCardState((Card) o));
|
||||
list.add(game.getCardState((Card) o));
|
||||
}
|
||||
}
|
||||
return CardFactoryUtil.handlePaid(list, calcX[1], card) * multiplier;
|
||||
@@ -704,6 +699,7 @@ public class AbilityUtils {
|
||||
public static List<Player> getDefinedPlayers(final Card card, final String def, final SpellAbility sa) {
|
||||
final List<Player> players = new ArrayList<Player>();
|
||||
final String defined = (def == null) ? "You" : def;
|
||||
final GameState game = sa.getActivatingPlayer().getGame();
|
||||
|
||||
if (defined.equals("Targeted")) {
|
||||
final SpellAbility saTargeting = sa.getSATargetingPlayer();
|
||||
@@ -893,12 +889,12 @@ public class AbilityUtils {
|
||||
}
|
||||
}
|
||||
} else if (defined.equals("AttackingPlayer")) {
|
||||
final Player p = Singletons.getModel().getGame().getCombat().getAttackingPlayer();
|
||||
final Player p = game.getCombat().getAttackingPlayer();
|
||||
if (!players.contains(p)) {
|
||||
players.add(p);
|
||||
}
|
||||
} else if (defined.equals("DefendingPlayer")) {
|
||||
players.addAll(Singletons.getModel().getGame().getCombat().getDefendingPlayerRelatedTo(card));
|
||||
players.addAll(game.getCombat().getDefendingPlayerRelatedTo(card));
|
||||
} else if (defined.equals("ChosenPlayer")) {
|
||||
final Player p = card.getChosenPlayer();
|
||||
if (!players.contains(p)) {
|
||||
@@ -910,7 +906,7 @@ public class AbilityUtils {
|
||||
players.add(p);
|
||||
}
|
||||
} else if (defined.startsWith("Flipped")) {
|
||||
for (Player p : Singletons.getModel().getGame().getPlayers()) {
|
||||
for (Player p : game.getPlayers()) {
|
||||
if (null != sa.getSourceCard().getFlipResult(p)) {
|
||||
if (sa.getSourceCard().getFlipResult(p).equals(defined.substring(7))) {
|
||||
players.add(p);
|
||||
@@ -920,11 +916,11 @@ public class AbilityUtils {
|
||||
} else if (defined.equals("You")) {
|
||||
players.add(sa.getActivatingPlayer());
|
||||
} else if (defined.equals("Each")) {
|
||||
players.addAll(Singletons.getModel().getGame().getPlayers());
|
||||
players.addAll(game.getPlayers());
|
||||
} else if (defined.equals("Opponent")) {
|
||||
players.add(sa.getActivatingPlayer().getOpponent());
|
||||
} else {
|
||||
for (Player p : Singletons.getModel().getGame().getPlayers()) {
|
||||
for (Player p : game.getPlayers()) {
|
||||
if (p.isValid(defined, sa.getActivatingPlayer(), sa.getSourceCard())) {
|
||||
players.add(p);
|
||||
}
|
||||
@@ -950,7 +946,8 @@ public class AbilityUtils {
|
||||
final SpellAbility sa) {
|
||||
final ArrayList<SpellAbility> sas = new ArrayList<SpellAbility>();
|
||||
final String defined = (def == null) ? "Self" : def; // default to Self
|
||||
|
||||
final GameState game = sa.getActivatingPlayer().getGame();
|
||||
|
||||
SpellAbility s = null;
|
||||
|
||||
// TODO - this probably needs to be fleshed out a bit, but the basics
|
||||
@@ -974,7 +971,7 @@ public class AbilityUtils {
|
||||
for (final Object o : card.getRemembered()) {
|
||||
if (o instanceof Card) {
|
||||
final Card rem = (Card) o;
|
||||
sas.addAll(Singletons.getModel().getGame().getCardState(rem).getSpellAbilities());
|
||||
sas.addAll(game.getCardState(rem).getSpellAbilities());
|
||||
}
|
||||
}
|
||||
} else if (defined.equals("Imprinted")) {
|
||||
@@ -995,7 +992,7 @@ public class AbilityUtils {
|
||||
final SpellAbility root = sa.getRootAbility();
|
||||
final Object crd = root.getTriggeringObject("Card");
|
||||
if (crd instanceof Card) {
|
||||
triggeredCard = Singletons.getModel().getGame().getCardState((Card) crd);
|
||||
triggeredCard = game.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())) {
|
||||
@@ -1057,8 +1054,7 @@ public class AbilityUtils {
|
||||
return;
|
||||
}
|
||||
|
||||
final GameState game = Singletons.getModel().getGame();
|
||||
AbilityUtils.resolveApiAbility(sa, usedStack, game);
|
||||
AbilityUtils.resolveApiAbility(sa, usedStack, sa.getActivatingPlayer().getGame());
|
||||
}
|
||||
|
||||
private static void resolveSubAbilities(final SpellAbility sa, boolean usedStack, final GameState game) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package forge.card.ability;
|
||||
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.card.spellability.AbilitySub;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.ai.ComputerUtilCost;
|
||||
@@ -81,7 +80,7 @@ public abstract class SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sa.getRestrictions().getPlaneswalker() && Singletons.getModel().getGame().getPhaseHandler().is(PhaseType.MAIN2)) {
|
||||
if (sa.getRestrictions().getPlaneswalker() && ai.getGame().getPhaseHandler().is(PhaseType.MAIN2)) {
|
||||
return true;
|
||||
}
|
||||
if (sa.isTrigger()) {
|
||||
@@ -91,7 +90,7 @@ public abstract class SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
|
||||
PhaseHandler phase = Singletons.getModel().getGame().getPhaseHandler();
|
||||
PhaseHandler phase = ai.getGame().getPhaseHandler();
|
||||
return phase.is(PhaseType.END_OF_TURN) && phase.getNextTurn().equals(ai);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,11 +6,11 @@ import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardPredicates;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.game.GameState;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.AIPlayer;
|
||||
import forge.game.player.Player;
|
||||
@@ -34,7 +34,8 @@ public class AnimateAi extends SpellAbilityAi {
|
||||
protected boolean canPlayAI(AIPlayer aiPlayer, SpellAbility sa) {
|
||||
final Target tgt = sa.getTarget();
|
||||
final Card source = sa.getSourceCard();
|
||||
|
||||
final GameState game = aiPlayer.getGame();
|
||||
|
||||
// TODO - add some kind of check to answer
|
||||
// "Am I going to attack with this?"
|
||||
// TODO - add some kind of check for during human turn to answer
|
||||
@@ -42,8 +43,8 @@ public class AnimateAi extends SpellAbilityAi {
|
||||
|
||||
// don't use instant speed animate abilities outside computers
|
||||
// Combat_Begin step
|
||||
if (!Singletons.getModel().getGame().getPhaseHandler().is(PhaseType.COMBAT_BEGIN)
|
||||
&& Singletons.getModel().getGame().getPhaseHandler().isPlayerTurn(aiPlayer)
|
||||
if (!game.getPhaseHandler().is(PhaseType.COMBAT_BEGIN)
|
||||
&& game.getPhaseHandler().isPlayerTurn(aiPlayer)
|
||||
&& !SpellAbilityAi.isSorcerySpeed(sa)
|
||||
&& !sa.hasParam("ActivationPhases") && !sa.hasParam("Permanent")) {
|
||||
return false;
|
||||
@@ -51,7 +52,7 @@ public class AnimateAi extends SpellAbilityAi {
|
||||
|
||||
Player opponent = aiPlayer.getWeakestOpponent();
|
||||
// don't animate if the AI won't attack anyway
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().isPlayerTurn(aiPlayer)
|
||||
if (game.getPhaseHandler().isPlayerTurn(aiPlayer)
|
||||
&& aiPlayer.getLife() < 6
|
||||
&& opponent.getLife() > 6
|
||||
&& Iterables.any(opponent.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES)) {
|
||||
@@ -60,14 +61,14 @@ public class AnimateAi extends SpellAbilityAi {
|
||||
|
||||
// don't use instant speed animate abilities outside humans
|
||||
// Combat_Declare_Attackers_InstantAbility step
|
||||
if ((!Singletons.getModel().getGame().getPhaseHandler().is(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)
|
||||
|| (Singletons.getModel().getGame().getCombat().getAttackers().isEmpty()))
|
||||
&& Singletons.getModel().getGame().getPhaseHandler().isPlayerTurn(opponent)) {
|
||||
if ((!game.getPhaseHandler().is(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)
|
||||
|| (game.getCombat().getAttackers().isEmpty()))
|
||||
&& game.getPhaseHandler().isPlayerTurn(opponent)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// don't activate during main2 unless this effect is permanent
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().is(PhaseType.MAIN2) && !sa.hasParam("Permanent")) {
|
||||
if (game.getPhaseHandler().is(PhaseType.MAIN2) && !sa.hasParam("Permanent")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -77,7 +78,7 @@ public class AnimateAi extends SpellAbilityAi {
|
||||
boolean bFlag = false;
|
||||
for (final Card c : defined) {
|
||||
bFlag |= (!c.isCreature() && !c.isTapped()
|
||||
&& !(c.getTurnInZone() == Singletons.getModel().getGame().getPhaseHandler().getTurn())
|
||||
&& !(c.getTurnInZone() == game.getPhaseHandler().getTurn())
|
||||
&& !c.isEquipping());
|
||||
|
||||
// for creatures that could be improved (like Figure of Destiny)
|
||||
|
||||
@@ -14,7 +14,6 @@ import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates;
|
||||
import forge.CardUtil;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.ApiType;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
@@ -79,7 +78,7 @@ public class AttachAi extends SpellAbilityAi {
|
||||
source.setSVar("PayX", Integer.toString(xPay));
|
||||
}
|
||||
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)
|
||||
if (ai.getGame().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)
|
||||
&& !"Curse".equals(sa.getParam("AILogic"))) {
|
||||
return false;
|
||||
}
|
||||
@@ -264,7 +263,7 @@ public class AttachAi extends SpellAbilityAi {
|
||||
private static Player attachToPlayerAIPreferences(final Player aiPlayer, final SpellAbility sa,
|
||||
final boolean mandatory) {
|
||||
List<Player> targetable = new ArrayList<Player>();
|
||||
for (final Player player : Singletons.getModel().getGame().getPlayers()) {
|
||||
for (final Player player : aiPlayer.getGame().getPlayers()) {
|
||||
if (sa.canTarget(player)) {
|
||||
targetable.add(player);
|
||||
}
|
||||
@@ -880,7 +879,7 @@ public class AttachAi extends SpellAbilityAi {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<Card> list = Singletons.getModel().getGame().getCardsIn(tgt.getZone());
|
||||
List<Card> list = aiPlayer.getGame().getCardsIn(tgt.getZone());
|
||||
list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), attachSource);
|
||||
|
||||
// TODO If Attaching without casting, don't need to actually target.
|
||||
@@ -1023,7 +1022,7 @@ public class AttachAi extends SpellAbilityAi {
|
||||
* @return true, if is useful keyword
|
||||
*/
|
||||
private static boolean isUsefulAttachKeyword(final String keyword, final Card card, final SpellAbility sa, final int powerBonus) {
|
||||
final PhaseHandler ph = Singletons.getModel().getGame().getPhaseHandler();
|
||||
final PhaseHandler ph = sa.getActivatingPlayer().getGame().getPhaseHandler();
|
||||
if (!CardUtil.isStackingKeyword(keyword) && card.hasKeyword(keyword)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import java.util.List;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
@@ -20,7 +19,7 @@ public class BecomesBlockedAi extends SpellAbilityAi {
|
||||
final Card source = sa.getSourceCard();
|
||||
final Target tgt = sa.getTarget();
|
||||
|
||||
List<Card> list = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
List<Card> list = aiPlayer.getGame().getCardsIn(ZoneType.Battlefield);
|
||||
list = CardLists.getValidCards(list, tgt.getValidTgts(), source.getController(), source);
|
||||
list = CardLists.getTargetableCards(list, sa);
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
@@ -101,7 +100,7 @@ public class ChangeZoneAllAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// Don't cast during main1?
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().is(PhaseType.MAIN1, ai)) {
|
||||
if (ai.getGame().getPhaseHandler().is(PhaseType.MAIN1, ai)) {
|
||||
return false;
|
||||
}
|
||||
} else if (origin.equals(ZoneType.Graveyard)) {
|
||||
|
||||
@@ -4,7 +4,6 @@ import java.util.List;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
@@ -34,7 +33,7 @@ public class ChooseCardAi extends SpellAbilityAi {
|
||||
if (sa.hasParam("ChoiceZone")) {
|
||||
choiceZone = ZoneType.smartValueOf(sa.getParam("ChoiceZone"));
|
||||
}
|
||||
List<Card> choices = Singletons.getModel().getGame().getCardsIn(choiceZone);
|
||||
List<Card> choices = ai.getGame().getCardsIn(choiceZone);
|
||||
if (sa.hasParam("Choices")) {
|
||||
choices = CardLists.getValidCards(choices, sa.getParam("Choices"), host.getController(), host);
|
||||
}
|
||||
|
||||
@@ -7,13 +7,13 @@ import com.google.common.base.Predicate;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.ApiType;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.game.GameState;
|
||||
import forge.game.ai.ComputerUtilCombat;
|
||||
import forge.game.ai.ComputerUtilCost;
|
||||
import forge.game.phase.PhaseType;
|
||||
@@ -65,9 +65,10 @@ public class ChooseSourceAi extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
if (sa.hasParam("AILogic")) {
|
||||
final GameState game = ai.getGame();
|
||||
if (sa.getParam("AILogic").equals("NeedsPrevention")) {
|
||||
if (!Singletons.getModel().getGame().getStack().isEmpty()) {
|
||||
final SpellAbility topStack = Singletons.getModel().getGame().getStack().peekAbility();
|
||||
if (!game.getStack().isEmpty()) {
|
||||
final SpellAbility topStack = game.getStack().peekAbility();
|
||||
if (sa.hasParam("Choices") && !topStack.getSourceCard().isValid(sa.getParam("Choices"), ai, source)) {
|
||||
return false;
|
||||
}
|
||||
@@ -98,21 +99,21 @@ public class ChooseSourceAi extends SpellAbilityAi {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (!Singletons.getModel().getGame().getPhaseHandler().getPhase()
|
||||
if (!game.getPhaseHandler().getPhase()
|
||||
.equals(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
return false;
|
||||
}
|
||||
List<Card> choices = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
List<Card> choices = game.getCardsIn(ZoneType.Battlefield);
|
||||
if (sa.hasParam("Choices")) {
|
||||
choices = CardLists.getValidCards(choices, sa.getParam("Choices"), host.getController(), host);
|
||||
}
|
||||
choices = CardLists.filter(choices, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
if (!c.isAttacking(ai) || !Singletons.getModel().getGame().getCombat().isUnblocked(c)) {
|
||||
if (!c.isAttacking(ai) || !game.getCombat().isUnblocked(c)) {
|
||||
return false;
|
||||
}
|
||||
return ComputerUtilCombat.damageIfUnblocked(c, ai, Singletons.getModel().getGame().getCombat()) > 0;
|
||||
return ComputerUtilCombat.damageIfUnblocked(c, ai, game.getCombat()) > 0;
|
||||
}
|
||||
});
|
||||
if (choices.isEmpty()) {
|
||||
|
||||
@@ -3,11 +3,11 @@ package forge.card.ability.ai;
|
||||
import java.util.List;
|
||||
|
||||
import forge.Card;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
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.AIPlayer;
|
||||
@@ -18,6 +18,7 @@ public class CloneAi extends SpellAbilityAi {
|
||||
protected boolean canPlayAI(AIPlayer ai, SpellAbility sa) {
|
||||
final Target tgt = sa.getTarget();
|
||||
final Card source = sa.getSourceCard();
|
||||
final GameState game = source.getGame();
|
||||
|
||||
boolean useAbility = true;
|
||||
|
||||
@@ -33,7 +34,7 @@ public class CloneAi extends SpellAbilityAi {
|
||||
// TODO - add some kind of check for during human turn to answer
|
||||
// "Can I use this to block something?"
|
||||
|
||||
PhaseHandler phase = Singletons.getModel().getGame().getPhaseHandler();
|
||||
PhaseHandler phase = game.getPhaseHandler();
|
||||
// don't use instant speed clone abilities outside computers
|
||||
// Combat_Begin step
|
||||
if (!phase.is(PhaseType.COMBAT_BEGIN)
|
||||
@@ -45,7 +46,7 @@ public class CloneAi extends SpellAbilityAi {
|
||||
// don't use instant speed clone abilities outside humans
|
||||
// Combat_Declare_Attackers_InstantAbility step
|
||||
if ((!phase.is(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)
|
||||
|| Singletons.getModel().getGame().getCombat().getAttackers().isEmpty())
|
||||
|| game.getCombat().getAttackers().isEmpty())
|
||||
&& !phase.isPlayerTurn(ai)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -25,11 +25,11 @@ import com.google.common.base.Predicate;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.game.GameState;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.AIPlayer;
|
||||
@@ -113,7 +113,7 @@ public class ControlGainAi extends SpellAbilityAi {
|
||||
// Don't steal something if I can't Attack without, or prevent it from
|
||||
// blocking at least
|
||||
if ((lose != null) && lose.contains("EOT")
|
||||
&& Singletons.getModel().getGame().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS)) {
|
||||
&& ai.getGame().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -184,9 +184,10 @@ public class ControlGainAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(SpellAbility sa, final AIPlayer ai) {
|
||||
final GameState game = ai.getGame();
|
||||
if ((sa.getTarget() == null) || !sa.getTarget().doesTarget()) {
|
||||
if (sa.hasParam("AllValid")) {
|
||||
List<Card> tgtCards = CardLists.filterControlledBy(Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield), ai.getOpponent());
|
||||
List<Card> tgtCards = CardLists.filterControlledBy(game.getCardsIn(ZoneType.Battlefield), ai.getOpponent());
|
||||
tgtCards = AbilityUtils.filterListByType(tgtCards, sa.getParam("AllValid"), sa);
|
||||
if (tgtCards.isEmpty()) {
|
||||
return false;
|
||||
@@ -195,7 +196,7 @@ public class ControlGainAi extends SpellAbilityAi {
|
||||
|
||||
final List<String> lose = sa.hasParam("LoseControl") ? Arrays.asList(sa.getParam("LoseControl").split(",")) : null;
|
||||
if ((lose != null) && lose.contains("EOT")
|
||||
&& Singletons.getModel().getGame().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)) {
|
||||
&& game.getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.google.common.base.Predicate;
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates.Presets;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
@@ -29,7 +28,7 @@ public class CopyPermanentAi extends SpellAbilityAi {
|
||||
// Card source = sa.getSourceCard();
|
||||
// TODO - I'm sure someone can do this AI better
|
||||
|
||||
if (sa.hasParam("AtEOT") && !Singletons.getModel().getGame().getPhaseHandler().is(PhaseType.MAIN1)) {
|
||||
if (sa.hasParam("AtEOT") && !aiPlayer.getGame().getPhaseHandler().is(PhaseType.MAIN1)) {
|
||||
return false;
|
||||
} else {
|
||||
double chance = .4; // 40 percent chance with instant speed stuff
|
||||
@@ -56,7 +55,7 @@ public class CopyPermanentAi extends SpellAbilityAi {
|
||||
final Target abTgt = sa.getTarget();
|
||||
|
||||
if (abTgt != null) {
|
||||
List<Card> list = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
List<Card> list = aiPlayer.getGame().getCardsIn(ZoneType.Battlefield);
|
||||
list = CardLists.getValidCards(list, abTgt.getValidTgts(), source.getController(), source);
|
||||
list = CardLists.getTargetableCards(list, sa);
|
||||
list = CardLists.filter(list, new Predicate<Card>() {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package forge.card.ability.ai;
|
||||
|
||||
import forge.Card;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.game.GameState;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.game.ai.ComputerUtilCost;
|
||||
import forge.game.ai.ComputerUtilMana;
|
||||
@@ -21,7 +21,8 @@ public class CounterAi extends SpellAbilityAi {
|
||||
boolean toReturn = true;
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
if (Singletons.getModel().getGame().getStack().isEmpty()) {
|
||||
final GameState game = ai.getGame();
|
||||
if (game.getStack().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -38,7 +39,7 @@ public class CounterAi extends SpellAbilityAi {
|
||||
final Target tgt = sa.getTarget();
|
||||
if (tgt != null) {
|
||||
|
||||
final SpellAbility topSA = Singletons.getModel().getGame().getStack().peekAbility();
|
||||
final SpellAbility topSA = game.getStack().peekAbility();
|
||||
if (!CardFactoryUtil.isCounterableBy(topSA.getSourceCard(), sa) || topSA.getActivatingPlayer() == ai) {
|
||||
// might as well check for player's friendliness
|
||||
return false;
|
||||
@@ -110,10 +111,11 @@ public class CounterAi extends SpellAbilityAi {
|
||||
|
||||
final Target tgt = sa.getTarget();
|
||||
if (tgt != null) {
|
||||
if (Singletons.getModel().getGame().getStack().isEmpty()) {
|
||||
final GameState game = ai.getGame();
|
||||
if (game.getStack().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
final SpellAbility topSA = Singletons.getModel().getGame().getStack().peekAbility();
|
||||
final SpellAbility topSA = game.getStack().peekAbility();
|
||||
if (!CardFactoryUtil.isCounterableBy(topSA.getSourceCard(), sa) || topSA.getActivatingPlayer() == ai) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CounterType;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.player.AIPlayer;
|
||||
import forge.game.zone.ZoneType;
|
||||
@@ -23,7 +22,7 @@ public class CountersProliferateAi extends SpellAbilityAi {
|
||||
@Override
|
||||
public boolean apply(final Card crd) {
|
||||
for (final CounterType c1 : CounterType.values()) {
|
||||
if (crd.getCounters(c1) != 0 && !CardFactoryUtil.isNegativeCounter(c1)) {
|
||||
if (crd.getCounters(c1) != 0 && !c1.isNegativeCounter()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -35,7 +34,7 @@ public class CountersProliferateAi extends SpellAbilityAi {
|
||||
@Override
|
||||
public boolean apply(final Card crd) {
|
||||
for (final CounterType c1 : CounterType.values()) {
|
||||
if (crd.getCounters(c1) != 0 && CardFactoryUtil.isNegativeCounter(c1)) {
|
||||
if (crd.getCounters(c1) != 0 && c1.isNegativeCounter()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.google.common.base.Predicate;
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CounterType;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
@@ -151,7 +150,7 @@ public class CountersPutAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// Don't use non P1P1/M1M1 counters before main 2 if possible
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)
|
||||
if (ai.getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)
|
||||
&& !sa.hasParam("ActivationPhases")
|
||||
&& !(type.equals("P1P1") || type.equals("M1M1"))) {
|
||||
return false;
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.google.common.base.Predicate;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
@@ -105,7 +104,7 @@ public class CountersPutAllAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
//Check for cards that could profit from the ability
|
||||
PhaseHandler phase = Singletons.getModel().getGame().getPhaseHandler();
|
||||
PhaseHandler phase = ai.getGame().getPhaseHandler();
|
||||
if (type.equals("P1P1") && sa.isAbility() && source.isCreature()
|
||||
&& sa.getPayCosts() != null && sa.getPayCosts().hasTapCost()
|
||||
&& sa instanceof AbilitySub
|
||||
|
||||
@@ -4,7 +4,6 @@ import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CounterType;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
@@ -66,7 +65,7 @@ public class CountersRemoveAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)
|
||||
if (ai.getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)
|
||||
&& !sa.hasParam("ActivationPhases")
|
||||
&& !type.equals("M1M1")) {
|
||||
return false;
|
||||
|
||||
@@ -6,9 +6,9 @@ import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardPredicates;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.GameState;
|
||||
import forge.game.ai.ComputerUtilCombat;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
@@ -17,6 +17,7 @@ import forge.game.zone.ZoneType;
|
||||
public abstract class DamageAiBase extends SpellAbilityAi {
|
||||
protected boolean shouldTgtP(final Player comp, final SpellAbility sa, final int d, final boolean noPrevention) {
|
||||
int restDamage = d;
|
||||
final GameState game = comp.getGame();
|
||||
final Player enemy = comp.getOpponent();
|
||||
if (!sa.canTarget(enemy)) {
|
||||
return false;
|
||||
@@ -44,8 +45,8 @@ public abstract class DamageAiBase extends SpellAbilityAi {
|
||||
|
||||
if (sa.isSpell()) {
|
||||
// If this is a spell, cast it instead of discarding
|
||||
if ((Singletons.getModel().getGame().getPhaseHandler().is(PhaseType.END_OF_TURN) || Singletons.getModel().getGame().getPhaseHandler().is(PhaseType.MAIN2))
|
||||
&& Singletons.getModel().getGame().getPhaseHandler().isPlayerTurn(comp) && (hand.size() > comp.getMaxHandSize())) {
|
||||
if ((game.getPhaseHandler().is(PhaseType.END_OF_TURN) || game.getPhaseHandler().is(PhaseType.MAIN2))
|
||||
&& game.getPhaseHandler().isPlayerTurn(comp) && (hand.size() > comp.getMaxHandSize())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.google.common.base.Predicate;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
@@ -86,7 +85,7 @@ public class DamageAllAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// wait until stack is empty (prevents duplicate kills)
|
||||
if (!Singletons.getModel().getGame().getStack().isEmpty()) {
|
||||
if (!ai.getGame().getStack().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,13 +8,13 @@ import com.google.common.base.Predicate;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.spellability.AbilitySub;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.game.GameState;
|
||||
import forge.game.ai.ComputerUtil;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.game.ai.ComputerUtilCombat;
|
||||
@@ -81,7 +81,7 @@ public class DamageDealAi extends DamageAiBase {
|
||||
if (source.getName().equals("Stuffy Doll")) {
|
||||
// Now stuffy sits around for blocking
|
||||
// TODO(sol): this should also happen if Stuffy is going to die
|
||||
return Singletons.getModel().getGame().getPhaseHandler().is(PhaseType.END_OF_TURN, ai.getOpponent());
|
||||
return ai.getGame().getPhaseHandler().is(PhaseType.END_OF_TURN, ai.getOpponent());
|
||||
}
|
||||
|
||||
if (sa.isAbility()) {
|
||||
@@ -133,7 +133,7 @@ public class DamageDealAi extends DamageAiBase {
|
||||
final Player pl, final boolean mandatory) {
|
||||
|
||||
// wait until stack is empty (prevents duplicate kills)
|
||||
if (!saMe.isTrigger() && !Singletons.getModel().getGame().getStack().isEmpty()) {
|
||||
if (!saMe.isTrigger() && !ai.getGame().getStack().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
final Target tgt = saMe.getTarget();
|
||||
@@ -226,7 +226,8 @@ public class DamageDealAi extends DamageAiBase {
|
||||
final boolean isTrigger, final boolean mandatory) {
|
||||
final Card source = saMe.getSourceCard();
|
||||
final boolean noPrevention = saMe.hasParam("NoPrevention");
|
||||
final PhaseHandler phase = Singletons.getModel().getGame().getPhaseHandler();
|
||||
final GameState game = source.getGame();
|
||||
final PhaseHandler phase = game.getPhaseHandler();
|
||||
final boolean divided = saMe.hasParam("DividedAsYouChoose");
|
||||
|
||||
// target loop
|
||||
|
||||
@@ -6,12 +6,12 @@ import java.util.List;
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.game.GameState;
|
||||
import forge.game.ai.ComputerUtil;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.game.ai.ComputerUtilCombat;
|
||||
@@ -27,6 +27,7 @@ public class DamagePreventAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean canPlayAI(AIPlayer ai, SpellAbility sa) {
|
||||
final Card hostCard = sa.getSourceCard();
|
||||
final GameState game = ai.getGame();
|
||||
boolean chance = false;
|
||||
|
||||
final Cost cost = sa.getPayCosts();
|
||||
@@ -56,7 +57,7 @@ public class DamagePreventAi extends SpellAbilityAi {
|
||||
sa.getParam("Defined"), sa);
|
||||
|
||||
// react to threats on the stack
|
||||
if (Singletons.getModel().getGame().getStack().size() > 0) {
|
||||
if (game.getStack().size() > 0) {
|
||||
final ArrayList<Object> threatenedObjects = ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa);
|
||||
for (final Object o : objects) {
|
||||
if (threatenedObjects.contains(o)) {
|
||||
@@ -64,7 +65,7 @@ public class DamagePreventAi extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
PhaseHandler handler = Singletons.getModel().getGame().getPhaseHandler();
|
||||
PhaseHandler handler = game.getPhaseHandler();
|
||||
if (handler.is(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
boolean flag = false;
|
||||
for (final Object o : objects) {
|
||||
@@ -75,8 +76,8 @@ public class DamagePreventAi extends SpellAbilityAi {
|
||||
// Don't need to worry about Combat Damage during AI's turn
|
||||
final Player p = (Player) o;
|
||||
if (!handler.isPlayerTurn(p)) {
|
||||
flag |= (p == ai && ((ComputerUtilCombat.wouldLoseLife(ai, Singletons.getModel().getGame().getCombat()) && sa
|
||||
.isAbility()) || ComputerUtilCombat.lifeInDanger(ai, Singletons.getModel().getGame().getCombat())));
|
||||
flag |= (p == ai && ((ComputerUtilCombat.wouldLoseLife(ai, game.getCombat()) && sa
|
||||
.isAbility()) || ComputerUtilCombat.lifeInDanger(ai, game.getCombat())));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,7 +91,7 @@ public class DamagePreventAi extends SpellAbilityAi {
|
||||
} // targeted
|
||||
|
||||
// react to threats on the stack
|
||||
else if (Singletons.getModel().getGame().getStack().size() > 0) {
|
||||
else if (game.getStack().size() > 0) {
|
||||
tgt.resetTargets();
|
||||
// check stack for something on the stack will kill anything i
|
||||
// control
|
||||
@@ -118,10 +119,10 @@ public class DamagePreventAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
} // Protect combatants
|
||||
else if (Singletons.getModel().getGame().getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
if (sa.canTarget(ai) && ComputerUtilCombat.wouldLoseLife(ai, Singletons.getModel().getGame().getCombat())
|
||||
&& (ComputerUtilCombat.lifeInDanger(ai, Singletons.getModel().getGame().getCombat()) || sa.isAbility())
|
||||
&& Singletons.getModel().getGame().getPhaseHandler().isPlayerTurn(ai.getOpponent())) {
|
||||
else if (game.getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
if (sa.canTarget(ai) && ComputerUtilCombat.wouldLoseLife(ai, game.getCombat())
|
||||
&& (ComputerUtilCombat.lifeInDanger(ai, game.getCombat()) || sa.isAbility())
|
||||
&& game.getPhaseHandler().isPlayerTurn(ai.getOpponent())) {
|
||||
tgt.addTarget(ai);
|
||||
chance = true;
|
||||
} else {
|
||||
@@ -180,7 +181,8 @@ public class DamagePreventAi extends SpellAbilityAi {
|
||||
final Target tgt = sa.getTarget();
|
||||
tgt.resetTargets();
|
||||
// filter AIs battlefield by what I can target
|
||||
List<Card> targetables = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
final GameState game = ai.getGame();
|
||||
List<Card> targetables = game.getCardsIn(ZoneType.Battlefield);
|
||||
targetables = CardLists.getValidCards(targetables, tgt.getValidTgts(), ai, sa.getSourceCard());
|
||||
final List<Card> compTargetables = CardLists.filterControlledBy(targetables, ai);
|
||||
|
||||
@@ -195,7 +197,7 @@ public class DamagePreventAi extends SpellAbilityAi {
|
||||
if (compTargetables.size() > 0) {
|
||||
final List<Card> combatants = CardLists.filter(compTargetables, CardPredicates.Presets.CREATURES);
|
||||
CardLists.sortByEvaluateCreature(combatants);
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
if (game.getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
for (final Card c : combatants) {
|
||||
if (ComputerUtilCombat.combatantWouldBeDestroyed(ai, c)) {
|
||||
tgt.addTarget(c);
|
||||
|
||||
@@ -2,7 +2,6 @@ package forge.card.ability.ai;
|
||||
|
||||
|
||||
import forge.Card;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
@@ -39,12 +38,12 @@ public class DamagePreventAllAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Singletons.getModel().getGame().getStack().size() > 0) {
|
||||
if (ai.getGame().getStack().size() > 0) {
|
||||
// TODO check stack for something on the stack will kill anything i
|
||||
// control
|
||||
|
||||
} // Protect combatants
|
||||
else if (Singletons.getModel().getGame().getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
else if (ai.getGame().getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.google.common.base.Predicate;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
@@ -52,12 +51,12 @@ public class DebuffAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
final SpellAbilityRestriction restrict = sa.getRestrictions();
|
||||
final PhaseHandler ph = Singletons.getModel().getGame().getPhaseHandler();
|
||||
final PhaseHandler ph = ai.getGame().getPhaseHandler();
|
||||
|
||||
// Phase Restrictions
|
||||
if (ph.getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)
|
||||
|| !Singletons.getModel().getGame().getStack().isEmpty()) {
|
||||
|| !ai.getGame().getStack().isEmpty()) {
|
||||
// Instant-speed pumps should not be cast outside of combat when the
|
||||
// stack is empty
|
||||
if (!SpellAbilityAi.isSorcerySpeed(sa)) {
|
||||
@@ -126,7 +125,7 @@ public class DebuffAi extends SpellAbilityAi {
|
||||
*/
|
||||
private boolean debuffTgtAI(final Player ai, final SpellAbility sa, final List<String> kws, final boolean mandatory) {
|
||||
// this would be for evasive things like Flying, Unblockable, etc
|
||||
if (!mandatory && Singletons.getModel().getGame().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
if (!mandatory && ai.getGame().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -217,7 +216,7 @@ public class DebuffAi extends SpellAbilityAi {
|
||||
* @return a boolean.
|
||||
*/
|
||||
private boolean debuffMandatoryTarget(final Player ai, final SpellAbility sa, final boolean mandatory) {
|
||||
List<Card> list = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
List<Card> list = ai.getGame().getCardsIn(ZoneType.Battlefield);
|
||||
final Target tgt = sa.getTarget();
|
||||
list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard());
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.google.common.base.Predicate;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.phase.CombatUtil;
|
||||
@@ -49,7 +48,7 @@ public class DebuffAllAi extends SpellAbilityAi {
|
||||
});
|
||||
|
||||
// don't use DebuffAll after Combat_Begin until AI is improved
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_BEGIN)) {
|
||||
if (ai.getGame().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_BEGIN)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.google.common.base.Predicate;
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CounterType;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
@@ -172,7 +171,7 @@ public class DestroyAi extends SpellAbilityAi {
|
||||
final Player opp = ai.getOpponent();
|
||||
if (tgt != null) {
|
||||
List<Card> list;
|
||||
list = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
list = ai.getGame().getCardsIn(ZoneType.Battlefield);
|
||||
list = CardLists.getTargetableCards(list, sa);
|
||||
list = CardLists.getValidCards(list, tgt.getValidTgts(), source.getController(), source);
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package forge.card.ability.ai;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
@@ -47,7 +46,7 @@ public class DigAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// Don't use draw abilities before main 2 if possible
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2) && !sa.hasParam("ActivationPhases")
|
||||
if (ai.getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2) && !sa.hasParam("ActivationPhases")
|
||||
&& !sa.hasParam("DestinationZone")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
@@ -95,7 +94,7 @@ public class DiscardAi extends SpellAbilityAi {
|
||||
// TODO: Implement support for Discard AI for cards with AnyNumber set to true.
|
||||
|
||||
// Don't use draw abilities before main 2 if possible
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)
|
||||
if (ai.getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)
|
||||
&& !sa.hasParam("ActivationPhases")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
@@ -32,6 +31,7 @@ import forge.card.cost.PaymentDecision;
|
||||
import forge.card.spellability.AbilitySub;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.game.GameState;
|
||||
import forge.game.ai.ComputerUtil;
|
||||
import forge.game.ai.ComputerUtilCost;
|
||||
import forge.game.ai.ComputerUtilMana;
|
||||
@@ -56,6 +56,7 @@ public class DrawAi extends SpellAbilityAi {
|
||||
final Target tgt = sa.getTarget();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final GameState game = ai.getGame();
|
||||
|
||||
if (abCost != null) {
|
||||
// AI currently disabled for these costs
|
||||
@@ -103,12 +104,12 @@ public class DrawAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// Don't use draw abilities before main 2 if possible
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)
|
||||
if (game.getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)
|
||||
&& !sa.hasParam("ActivationPhases")) {
|
||||
return false;
|
||||
}
|
||||
if ((!Singletons.getModel().getGame().getPhaseHandler().getNextTurn().equals(ai)
|
||||
|| Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.END_OF_TURN))
|
||||
if ((!game.getPhaseHandler().getNextTurn().equals(ai)
|
||||
|| game.getPhaseHandler().getPhase().isBefore(PhaseType.END_OF_TURN))
|
||||
&& !sa.hasParam("PlayerTurn") && !SpellAbilityAi.isSorcerySpeed(sa)
|
||||
&& ai.getCardsIn(ZoneType.Hand).size() > 1) {
|
||||
return false;
|
||||
@@ -126,8 +127,8 @@ public class DrawAi extends SpellAbilityAi {
|
||||
if (SpellAbilityAi.isSorcerySpeed(sa)) {
|
||||
randomReturn = true;
|
||||
}
|
||||
if ((Singletons.getModel().getGame().getPhaseHandler().is(PhaseType.END_OF_TURN)
|
||||
&& Singletons.getModel().getGame().getPhaseHandler().getNextTurn().equals(ai))) {
|
||||
if ((game.getPhaseHandler().is(PhaseType.END_OF_TURN)
|
||||
&& game.getPhaseHandler().getNextTurn().equals(ai))) {
|
||||
randomReturn = true;
|
||||
}
|
||||
|
||||
@@ -142,6 +143,7 @@ public class DrawAi extends SpellAbilityAi {
|
||||
final Target tgt = sa.getTarget();
|
||||
final Card source = sa.getSourceCard();
|
||||
final boolean drawback = (sa instanceof AbilitySub);
|
||||
final GameState game = ai.getGame();
|
||||
Player opp = ai.getOpponent();
|
||||
|
||||
int computerHandSize = ai.getCardsIn(ZoneType.Hand).size();
|
||||
@@ -209,7 +211,7 @@ public class DrawAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
if (((computerHandSize + numCards) > computerMaxHandSize)
|
||||
&& Singletons.getModel().getGame().getPhaseHandler().isPlayerTurn(ai)) {
|
||||
&& game.getPhaseHandler().isPlayerTurn(ai)) {
|
||||
if (xPaid) {
|
||||
numCards = computerMaxHandSize - computerHandSize;
|
||||
source.setSVar("PayX", Integer.toString(numCards));
|
||||
@@ -247,7 +249,7 @@ public class DrawAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
if ((computerHandSize + numCards > computerMaxHandSize)
|
||||
&& Singletons.getModel().getGame().getPhaseHandler().isPlayerTurn(ai)
|
||||
&& game.getPhaseHandler().isPlayerTurn(ai)
|
||||
&& !sa.isTrigger()) {
|
||||
// Don't draw too many cards and then risk discarding cards at
|
||||
// EOT
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.google.common.base.Predicate;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
@@ -25,7 +24,7 @@ import forge.util.MyRandom;
|
||||
public class EffectAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean canPlayAI(AIPlayer ai, SpellAbility sa) {
|
||||
final GameState game = Singletons.getModel().getGame();
|
||||
final GameState game = ai.getGame();
|
||||
final Random r = MyRandom.getRandom();
|
||||
boolean randomReturn = r.nextFloat() <= .6667;
|
||||
final Player opp = ai.getOpponent();
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package forge.card.ability.ai;
|
||||
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.GameState;
|
||||
import forge.game.ai.ComputerUtilCombat;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.AIPlayer;
|
||||
@@ -15,38 +15,40 @@ public class FogAi extends SpellAbilityAi {
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(AIPlayer ai, SpellAbility sa) {
|
||||
final GameState game = ai.getGame();
|
||||
// AI should only activate this during Human's Declare Blockers phase
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().isPlayerTurn(sa.getActivatingPlayer())) {
|
||||
if (game.getPhaseHandler().isPlayerTurn(sa.getActivatingPlayer())) {
|
||||
return false;
|
||||
}
|
||||
if (!Singletons.getModel().getGame().getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
if (!game.getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only cast when Stack is empty, so Human uses spells/abilities first
|
||||
if (!Singletons.getModel().getGame().getStack().isEmpty()) {
|
||||
if (!game.getStack().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Don't cast it, if the effect is already in place
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().isPreventCombatDamageThisTurn()) {
|
||||
if (game.getPhaseHandler().isPreventCombatDamageThisTurn()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Cast it if life is in danger
|
||||
return ComputerUtilCombat.lifeInDanger(ai, Singletons.getModel().getGame().getCombat());
|
||||
return ComputerUtilCombat.lifeInDanger(ai, game.getCombat());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(SpellAbility sa, AIPlayer ai) {
|
||||
// AI should only activate this during Human's turn
|
||||
boolean chance;
|
||||
final GameState game = ai.getGame();
|
||||
|
||||
// should really check if other player is attacking this player
|
||||
if (ai.isOpponentOf(Singletons.getModel().getGame().getPhaseHandler().getPlayerTurn())) {
|
||||
chance = Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_FIRST_STRIKE_DAMAGE);
|
||||
if (ai.isOpponentOf(game.getPhaseHandler().getPlayerTurn())) {
|
||||
chance = game.getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_FIRST_STRIKE_DAMAGE);
|
||||
} else {
|
||||
chance = Singletons.getModel().getGame().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DAMAGE);
|
||||
chance = game.getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DAMAGE);
|
||||
}
|
||||
|
||||
return chance;
|
||||
@@ -54,11 +56,12 @@ public class FogAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(AIPlayer aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
final GameState game = aiPlayer.getGame();
|
||||
boolean chance;
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().isPlayerTurn(sa.getActivatingPlayer().getOpponent())) {
|
||||
chance = Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_FIRST_STRIKE_DAMAGE);
|
||||
if (game.getPhaseHandler().isPlayerTurn(sa.getActivatingPlayer().getOpponent())) {
|
||||
chance = game.getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_FIRST_STRIKE_DAMAGE);
|
||||
} else {
|
||||
chance = Singletons.getModel().getGame().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DAMAGE);
|
||||
chance = game.getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DAMAGE);
|
||||
}
|
||||
|
||||
return chance;
|
||||
|
||||
@@ -3,13 +3,13 @@ package forge.card.ability.ai;
|
||||
import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.spellability.AbilitySub;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.game.GameState;
|
||||
import forge.game.ai.ComputerUtil;
|
||||
import forge.game.ai.ComputerUtilCombat;
|
||||
import forge.game.ai.ComputerUtilCost;
|
||||
@@ -34,6 +34,7 @@ public class LifeGainAi extends SpellAbilityAi {
|
||||
final Random r = MyRandom.getRandom();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
final GameState game = source.getGame();
|
||||
final int life = ai.getLife();
|
||||
final String amountStr = sa.getParam("LifeAmount");
|
||||
int lifeAmount = 0;
|
||||
@@ -62,13 +63,13 @@ public class LifeGainAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS)
|
||||
if (game.getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS)
|
||||
&& !sa.hasParam("ActivationPhases")) {
|
||||
return false;
|
||||
}
|
||||
boolean lifeCritical = life <= 5;
|
||||
lifeCritical |= (Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DAMAGE) && ComputerUtilCombat
|
||||
.lifeInDanger(ai, Singletons.getModel().getGame().getCombat()));
|
||||
lifeCritical |= (game.getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DAMAGE) && ComputerUtilCombat
|
||||
.lifeInDanger(ai, game.getCombat()));
|
||||
|
||||
if (abCost != null && !lifeCritical) {
|
||||
if (!ComputerUtilCost.checkSacrificeCost(ai, abCost, source, false)) {
|
||||
@@ -93,13 +94,13 @@ public class LifeGainAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// Don't use lifegain before main 2 if possible
|
||||
if (!lifeCritical && Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)
|
||||
if (!lifeCritical && game.getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)
|
||||
&& !sa.hasParam("ActivationPhases")) {
|
||||
return false;
|
||||
}
|
||||
// Don't use lifegain before main 2 if possible
|
||||
if (!lifeCritical && (!Singletons.getModel().getGame().getPhaseHandler().getNextTurn().equals(ai)
|
||||
|| Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.END_OF_TURN))
|
||||
if (!lifeCritical && (!game.getPhaseHandler().getNextTurn().equals(ai)
|
||||
|| game.getPhaseHandler().getPhase().isBefore(PhaseType.END_OF_TURN))
|
||||
&& !sa.hasParam("PlayerTurn") && !SpellAbilityAi.isSorcerySpeed(sa)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
@@ -110,7 +109,7 @@ public class LifeLoseAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// Don't use loselife before main 2 if possible
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)
|
||||
if (ai.getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)
|
||||
&& !sa.hasParam("ActivationPhases") && !priority) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CounterType;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
@@ -32,7 +31,7 @@ public class LifeSetAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// Don't use setLife before main 2 if possible
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)
|
||||
if (ai.getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)
|
||||
&& !sa.hasParam("ActivationPhases")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
@@ -53,7 +52,7 @@ public class MillAi extends SpellAbilityAi {
|
||||
final Random r = MyRandom.getRandom();
|
||||
|
||||
// Don't use draw abilities before main 2 if possible
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2) && !sa.hasParam("ActivationPhases")) {
|
||||
if (ai.getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2) && !sa.hasParam("ActivationPhases")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -68,8 +67,7 @@ public class MillAi extends SpellAbilityAi {
|
||||
chance = .667; // 66.7% chance for sorcery speed
|
||||
}
|
||||
|
||||
if ((Singletons.getModel().getGame().getPhaseHandler().is(PhaseType.END_OF_TURN)
|
||||
&& Singletons.getModel().getGame().getPhaseHandler().getNextTurn().equals(ai))) {
|
||||
if ((ai.getGame().getPhaseHandler().is(PhaseType.END_OF_TURN) && ai.getGame().getPhaseHandler().getNextTurn().equals(ai))) {
|
||||
chance = .9; // 90% for end of opponents turn
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.google.common.base.Predicate;
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
@@ -39,7 +38,7 @@ public class MustBlockAi extends SpellAbilityAi {
|
||||
final Target abTgt = sa.getTarget();
|
||||
|
||||
// only use on creatures that can attack
|
||||
if (!Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)) {
|
||||
if (!ai.getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardPredicates;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.GameState;
|
||||
@@ -28,7 +27,7 @@ public class PermanentCreatureAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean canPlayAI(AIPlayer aiPlayer, SpellAbility sa) {
|
||||
String logic = sa.getParam("AILogic");
|
||||
GameState game = Singletons.getModel().getGame();
|
||||
GameState game = aiPlayer.getGame();
|
||||
|
||||
if ("ZeroToughness".equals(logic)) {
|
||||
// If Creature has Zero Toughness, make sure some static ability is in play
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package forge.card.ability.ai;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.GameState;
|
||||
import forge.game.ai.ComputerUtil;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.AIPlayer;
|
||||
@@ -20,7 +18,6 @@ public class PermanentNoncreatureAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean canPlayAI(AIPlayer aiPlayer, SpellAbility sa) {
|
||||
String logic = sa.getParam("AILogic");
|
||||
GameState game = Singletons.getModel().getGame();
|
||||
|
||||
if ("DontCast".equals(logic)) {
|
||||
return false;
|
||||
@@ -29,7 +26,7 @@ public class PermanentNoncreatureAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// Wait for Main2 if possible
|
||||
if (game.getPhaseHandler().is(PhaseType.MAIN1)
|
||||
if (aiPlayer.getGame().getPhaseHandler().is(PhaseType.MAIN1)
|
||||
&& !ComputerUtil.castPermanentInMain1(aiPlayer, sa)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -5,11 +5,11 @@ import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.game.GameState;
|
||||
import forge.game.player.AIPlayer;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.MyRandom;
|
||||
@@ -61,7 +61,7 @@ public class PhasesAi extends SpellAbilityAi {
|
||||
return true;
|
||||
} else if (mandatory) {
|
||||
// not enough preferred targets, but mandatory so keep going:
|
||||
return phasesUnpreferredTargeting(sa, mandatory);
|
||||
return phasesUnpreferredTargeting(aiPlayer.getGame(), sa, mandatory);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -133,12 +133,11 @@ public class PhasesAi extends SpellAbilityAi {
|
||||
* a boolean.
|
||||
* @return a boolean.
|
||||
*/
|
||||
private boolean phasesUnpreferredTargeting(final SpellAbility sa,
|
||||
final boolean mandatory) {
|
||||
private boolean phasesUnpreferredTargeting(final GameState game, final SpellAbility sa, final boolean mandatory) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final Target tgt = sa.getTarget();
|
||||
|
||||
List<Card> list = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
List<Card> list = game.getCardsIn(ZoneType.Battlefield);
|
||||
list = CardLists.getTargetableCards(CardLists.getValidCards(list, tgt.getValidTgts(), source.getController(), source), sa);
|
||||
|
||||
return false;
|
||||
|
||||
@@ -6,7 +6,6 @@ import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
@@ -47,7 +46,7 @@ public class PlayAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// don't use this as a response
|
||||
if (!Singletons.getModel().getGame().getStack().isEmpty()) {
|
||||
if (!ai.getGame().getStack().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -58,7 +57,7 @@ public class PlayAi extends SpellAbilityAi {
|
||||
final Target tgt = sa.getTarget();
|
||||
if (tgt != null) {
|
||||
ZoneType zone = tgt.getZone().get(0);
|
||||
cards = CardLists.getValidCards(Singletons.getModel().getGame().getCardsIn(zone), tgt.getValidTgts(), ai, source);
|
||||
cards = CardLists.getValidCards(ai.getGame().getCardsIn(zone), tgt.getValidTgts(), ai, source);
|
||||
if (cards.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package forge.card.ability.ai;
|
||||
import java.util.List;
|
||||
|
||||
import forge.Card;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
@@ -51,7 +50,7 @@ public class PoisonAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// Don't use poison before main 2 if possible
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)
|
||||
if (ai.getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)
|
||||
&& !sa.hasParam("ActivationPhases")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.google.common.base.Predicate;
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.Constant;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
@@ -68,7 +67,7 @@ public class ProtectAi extends SpellAbilityAi {
|
||||
*/
|
||||
private static List<Card> getProtectCreatures(final Player ai, final SpellAbility sa) {
|
||||
final ArrayList<String> gains = AbilityUtils.getProtectionList(sa);
|
||||
final GameState game = Singletons.getModel().getGame();
|
||||
final GameState game = ai.getGame();
|
||||
|
||||
List<Card> list = ai.getCreaturesInPlay();
|
||||
list = CardLists.filter(list, new Predicate<Card>() {
|
||||
@@ -113,6 +112,7 @@ public class ProtectAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean canPlayAI(AIPlayer ai, SpellAbility sa) {
|
||||
final Card hostCard = sa.getSourceCard();
|
||||
final GameState game = ai.getGame();
|
||||
// if there is no target and host card isn't in play, don't activate
|
||||
if ((sa.getTarget() == null) && !hostCard.isInPlay()) {
|
||||
return false;
|
||||
@@ -138,13 +138,13 @@ public class ProtectAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// Phase Restrictions
|
||||
if ((Singletons.getModel().getGame().getStack().size() == 0) && Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_FIRST_STRIKE_DAMAGE)) {
|
||||
if ((game.getStack().size() == 0) && game.getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_FIRST_STRIKE_DAMAGE)) {
|
||||
// Instant-speed protections should not be cast outside of combat
|
||||
// when the stack is empty
|
||||
if (!SpellAbilityAi.isSorcerySpeed(sa)) {
|
||||
return false;
|
||||
}
|
||||
} else if (Singletons.getModel().getGame().getStack().size() > 0) {
|
||||
} else if (game.getStack().size() > 0) {
|
||||
// TODO protection something only if the top thing on the stack will
|
||||
// kill it via damage or destroy
|
||||
return false;
|
||||
@@ -172,7 +172,8 @@ public class ProtectAi extends SpellAbilityAi {
|
||||
} // protectPlayAI()
|
||||
|
||||
private boolean protectTgtAI(final Player ai, final SpellAbility sa, final boolean mandatory) {
|
||||
if (!mandatory && Singletons.getModel().getGame().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
final GameState game = ai.getGame();
|
||||
if (!mandatory && game.getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -195,16 +196,16 @@ public class ProtectAi extends SpellAbilityAi {
|
||||
* Or, add protection (to make it unblockable) when Compy is attacking.
|
||||
*/
|
||||
|
||||
if (Singletons.getModel().getGame().getStack().isEmpty()) {
|
||||
if (game.getStack().isEmpty()) {
|
||||
// If the cost is tapping, don't activate before declare
|
||||
// attack/block
|
||||
if ((sa.getPayCosts() != null) && sa.getPayCosts().hasTapCost()) {
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
&& Singletons.getModel().getGame().getPhaseHandler().isPlayerTurn(ai)) {
|
||||
if (game.getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
&& game.getPhaseHandler().isPlayerTurn(ai)) {
|
||||
list.remove(sa.getSourceCard());
|
||||
}
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS)
|
||||
&& Singletons.getModel().getGame().getPhaseHandler().isPlayerTurn(ai)) {
|
||||
if (game.getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS)
|
||||
&& game.getPhaseHandler().isPlayerTurn(ai)) {
|
||||
list.remove(sa.getSourceCard());
|
||||
}
|
||||
}
|
||||
@@ -250,9 +251,9 @@ public class ProtectAi extends SpellAbilityAi {
|
||||
} // protectTgtAI()
|
||||
|
||||
private static boolean protectMandatoryTarget(final Player ai, final SpellAbility sa, final boolean mandatory) {
|
||||
final GameState game = ai.getGame();
|
||||
|
||||
|
||||
List<Card> list = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
List<Card> list = game.getCardsIn(ZoneType.Battlefield);
|
||||
final Target tgt = sa.getTarget();
|
||||
list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard());
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.google.common.base.Predicate;
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates.Presets;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
@@ -18,6 +17,7 @@ import forge.card.cost.CostTapType;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.SpellAbilityRestriction;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.game.GameState;
|
||||
import forge.game.ai.ComputerUtil;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.game.ai.ComputerUtilCost;
|
||||
@@ -49,7 +49,8 @@ public class PumpAi extends PumpAiBase {
|
||||
@Override
|
||||
protected boolean canPlayAI(AIPlayer ai, SpellAbility sa) {
|
||||
final Cost cost = sa.getPayCosts();
|
||||
final PhaseHandler ph = Singletons.getModel().getGame().getPhaseHandler();
|
||||
final GameState game = ai.getGame();
|
||||
final PhaseHandler ph = game.getPhaseHandler();
|
||||
final List<String> keywords = sa.hasParam("KW") ? Arrays.asList(sa.getParam("KW").split(" & ")) : new ArrayList<String>();
|
||||
final String numDefense = sa.hasParam("NumDef") ? sa.getParam("NumDef") : "";
|
||||
final String numAttack = sa.hasParam("NumAtt") ? sa.getParam("NumAtt") : "";
|
||||
@@ -70,7 +71,7 @@ public class PumpAi extends PumpAiBase {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Singletons.getModel().getGame().getStack().isEmpty() && hasTapCost(cost, sa.getSourceCard())) {
|
||||
if (game.getStack().isEmpty() && hasTapCost(cost, sa.getSourceCard())) {
|
||||
if (ph.getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS) && ph.isPlayerTurn(ai)) {
|
||||
return false;
|
||||
}
|
||||
@@ -83,13 +84,13 @@ public class PumpAi extends PumpAiBase {
|
||||
}
|
||||
|
||||
// Phase Restrictions
|
||||
if ((Singletons.getModel().getGame().getStack().size() == 0) && ph.getPhase().isBefore(PhaseType.COMBAT_BEGIN)) {
|
||||
if ((game.getStack().size() == 0) && ph.getPhase().isBefore(PhaseType.COMBAT_BEGIN)) {
|
||||
// Instant-speed pumps should not be cast outside of combat when the
|
||||
// stack is empty
|
||||
if (!sa.isCurse() && !SpellAbilityAi.isSorcerySpeed(sa)) {
|
||||
return false;
|
||||
}
|
||||
} else if (Singletons.getModel().getGame().getStack().size() > 0) {
|
||||
} else if (game.getStack().size() > 0) {
|
||||
if (!keywords.contains("Shroud") && !keywords.contains("Hexproof")) {
|
||||
return false;
|
||||
}
|
||||
@@ -181,10 +182,11 @@ public class PumpAi extends PumpAiBase {
|
||||
|
||||
private boolean pumpTgtAI(final Player ai, final SpellAbility sa, final int defense, final int attack, final boolean mandatory) {
|
||||
final List<String> keywords = sa.hasParam("KW") ? Arrays.asList(sa.getParam("KW").split(" & ")) : new ArrayList<String>();
|
||||
final GameState game = ai.getGame();
|
||||
|
||||
if (!mandatory
|
||||
&& !sa.isTrigger()
|
||||
&& Singletons.getModel().getGame().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)
|
||||
&& game.getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)
|
||||
&& !(sa.isCurse() && (defense < 0))
|
||||
&& !this.containsNonCombatKeyword(keywords)
|
||||
&& !sa.hasParam("UntilYourNextTurn")) {
|
||||
@@ -197,7 +199,7 @@ public class PumpAi extends PumpAiBase {
|
||||
List<Card> list = new ArrayList<Card>();
|
||||
if (sa.hasParam("AILogic")) {
|
||||
if (sa.getParam("AILogic").equals("HighestPower")) {
|
||||
list = CardLists.getValidCards(CardLists.filter(Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield), Presets.CREATURES), tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard());
|
||||
list = CardLists.getValidCards(CardLists.filter(game.getCardsIn(ZoneType.Battlefield), Presets.CREATURES), tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard());
|
||||
list = CardLists.getTargetableCards(list, sa);
|
||||
CardLists.sortByPowerDesc(list);
|
||||
if (!list.isEmpty()) {
|
||||
@@ -216,7 +218,7 @@ public class PumpAi extends PumpAiBase {
|
||||
} else {
|
||||
if (!tgt.canTgtCreature()) {
|
||||
ZoneType zone = tgt.getZone().get(0);
|
||||
list = Singletons.getModel().getGame().getCardsIn(zone);
|
||||
list = game.getCardsIn(zone);
|
||||
} else {
|
||||
list = this.getPumpCreatures(ai, sa, defense, attack, keywords);
|
||||
}
|
||||
@@ -227,16 +229,16 @@ public class PumpAi extends PumpAiBase {
|
||||
}
|
||||
|
||||
list = CardLists.getValidCards(list, tgt.getValidTgts(), ai, sa.getSourceCard());
|
||||
if (Singletons.getModel().getGame().getStack().size() == 0) {
|
||||
if (game.getStack().size() == 0) {
|
||||
// If the cost is tapping, don't activate before declare
|
||||
// attack/block
|
||||
if ((sa.getPayCosts() != null) && sa.getPayCosts().hasTapCost()) {
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
&& Singletons.getModel().getGame().getPhaseHandler().isPlayerTurn(ai)) {
|
||||
if (game.getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
&& game.getPhaseHandler().isPlayerTurn(ai)) {
|
||||
list.remove(sa.getSourceCard());
|
||||
}
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS)
|
||||
&& Singletons.getModel().getGame().getPhaseHandler().isPlayerTurn(opp)) {
|
||||
if (game.getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS)
|
||||
&& game.getPhaseHandler().isPlayerTurn(opp)) {
|
||||
list.remove(sa.getSourceCard());
|
||||
}
|
||||
}
|
||||
@@ -283,7 +285,8 @@ public class PumpAi extends PumpAiBase {
|
||||
} // pumpTgtAI()
|
||||
|
||||
private boolean pumpMandatoryTarget(final Player ai, final SpellAbility sa, final boolean mandatory) {
|
||||
List<Card> list = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
final GameState game = ai.getGame();
|
||||
List<Card> list = game.getCardsIn(ZoneType.Battlefield);
|
||||
final Target tgt = sa.getTarget();
|
||||
final Player opp = ai.getOpponent();
|
||||
list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard());
|
||||
|
||||
@@ -11,7 +11,6 @@ import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates;
|
||||
import forge.CardUtil;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.GameState;
|
||||
@@ -52,7 +51,8 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
||||
* @return true, if is useful keyword
|
||||
*/
|
||||
public boolean isUsefulCurseKeyword(final Player ai, final String keyword, final Card card, final SpellAbility sa) {
|
||||
final PhaseHandler ph = Singletons.getModel().getGame().getPhaseHandler();
|
||||
final GameState game = ai.getGame();
|
||||
final PhaseHandler ph = game.getPhaseHandler();
|
||||
final Player human = ai.getOpponent();
|
||||
//int attack = getNumAttack(sa);
|
||||
//int defense = getNumDefense(sa);
|
||||
@@ -157,7 +157,8 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
||||
* @return true, if is useful keyword
|
||||
*/
|
||||
public boolean isUsefulPumpKeyword(final Player ai, final String keyword, final Card card, final SpellAbility sa, final int attack) {
|
||||
final PhaseHandler ph = Singletons.getModel().getGame().getPhaseHandler();
|
||||
final GameState game = ai.getGame();
|
||||
final PhaseHandler ph = game.getPhaseHandler();
|
||||
final Player opp = ai.getOpponent();
|
||||
//int defense = getNumDefense(sa);
|
||||
if (!CardUtil.isStackingKeyword(keyword) && card.hasKeyword(keyword)) {
|
||||
@@ -179,10 +180,10 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
||||
} else if (keyword.endsWith("Flying")) {
|
||||
if (ph.isPlayerTurn(opp)
|
||||
&& ph.getPhase().equals(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)
|
||||
&& !CardLists.getKeyword(Singletons.getModel().getGame().getCombat().getAttackers(), "Flying").isEmpty()
|
||||
&& !CardLists.getKeyword(game.getCombat().getAttackers(), "Flying").isEmpty()
|
||||
&& !card.hasKeyword("Reach")
|
||||
&& CombatUtil.canBlock(card)
|
||||
&& ComputerUtilCombat.lifeInDanger(ai, Singletons.getModel().getGame().getCombat())) {
|
||||
&& ComputerUtilCombat.lifeInDanger(ai, game.getCombat())) {
|
||||
return true;
|
||||
}
|
||||
Predicate<Card> flyingOrReach = Predicates.or(CardPredicates.hasKeyword("Flying"), CardPredicates.hasKeyword("Reach"));
|
||||
@@ -196,9 +197,9 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
||||
} else if (keyword.endsWith("Horsemanship")) {
|
||||
if (ph.isPlayerTurn(opp)
|
||||
&& ph.getPhase().equals(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)
|
||||
&& !CardLists.getKeyword(Singletons.getModel().getGame().getCombat().getAttackers(), "Horsemanship").isEmpty()
|
||||
&& !CardLists.getKeyword(game.getCombat().getAttackers(), "Horsemanship").isEmpty()
|
||||
&& CombatUtil.canBlock(card)
|
||||
&& ComputerUtilCombat.lifeInDanger(ai, Singletons.getModel().getGame().getCombat())) {
|
||||
&& ComputerUtilCombat.lifeInDanger(ai, game.getCombat())) {
|
||||
return true;
|
||||
}
|
||||
if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card, opp) || card.isAttacking())
|
||||
@@ -219,7 +220,7 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
||||
} else if (keyword.endsWith("Indestructible")) {
|
||||
return true;
|
||||
} else if (keyword.endsWith("Deathtouch")) {
|
||||
Combat combat = Singletons.getModel().getGame().getCombat();
|
||||
Combat combat = game.getCombat();
|
||||
if (ph.isPlayerTurn(opp) && ph.getPhase().equals(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)) {
|
||||
List<Card> attackers = combat.getAttackers();
|
||||
for (Card attacker : attackers) {
|
||||
@@ -312,7 +313,7 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
||||
} else if (keyword.equals("Reach")) {
|
||||
if (ph.isPlayerTurn(ai)
|
||||
|| !ph.getPhase().equals(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)
|
||||
|| CardLists.getKeyword(Singletons.getModel().getGame().getCombat().getAttackers(), "Flying").isEmpty()
|
||||
|| CardLists.getKeyword(game.getCombat().getAttackers(), "Flying").isEmpty()
|
||||
|| card.hasKeyword("Flying")
|
||||
|| !CombatUtil.canBlock(card)) {
|
||||
return false;
|
||||
@@ -324,7 +325,7 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
||||
}
|
||||
int canBlockNum = 1 + card.getKeywordAmount("CARDNAME can block an additional creature.");
|
||||
int possibleBlockNum = 0;
|
||||
for (Card attacker : Singletons.getModel().getGame().getCombat().getAttackers()) {
|
||||
for (Card attacker : game.getCombat().getAttackers()) {
|
||||
if (CombatUtil.canBlock(attacker, card)) {
|
||||
possibleBlockNum++;
|
||||
if (possibleBlockNum > canBlockNum) {
|
||||
@@ -383,7 +384,7 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
||||
|
||||
protected boolean shouldPumpCard(final Player ai, final SpellAbility sa, final Card c, final int defense, final int attack,
|
||||
final List<String> keywords) {
|
||||
final GameState game = Singletons.getModel().getGame();
|
||||
final GameState game = ai.getGame();
|
||||
PhaseHandler phase = game.getPhaseHandler();
|
||||
|
||||
if (!c.canBeTargetedBy(sa)) {
|
||||
@@ -413,7 +414,7 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
||||
if (defense > 0 && ComputerUtilCombat.blockerWouldBeDestroyed(ai, c)) {
|
||||
return true;
|
||||
}
|
||||
List<Card> blockedBy = Singletons.getModel().getGame().getCombat().getAttackersBlockedBy(c);
|
||||
List<Card> blockedBy = game.getCombat().getAttackersBlockedBy(c);
|
||||
// For now, Only care the first creature blocked by a card.
|
||||
// TODO Add in better BlockAdditional support
|
||||
if (!blockedBy.isEmpty() && attack > 0 && !ComputerUtilCombat.attackerWouldBeDestroyed(ai, blockedBy.get(0))) {
|
||||
@@ -490,6 +491,7 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
||||
*/
|
||||
protected List<Card> getCurseCreatures(final Player ai, final SpellAbility sa, final int defense, final int attack, final List<String> keywords) {
|
||||
List<Card> list = ai.getOpponent().getCreaturesInPlay();
|
||||
final GameState game = ai.getGame();
|
||||
list = CardLists.getTargetableCards(list, sa);
|
||||
|
||||
if (list.isEmpty()) {
|
||||
@@ -507,11 +509,11 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
||||
}
|
||||
}); // leaves all creatures that will be destroyed
|
||||
} // -X/-X end
|
||||
else if (attack < 0 && !Singletons.getModel().getGame().getPhaseHandler().isPreventCombatDamageThisTurn()) {
|
||||
else if (attack < 0 && !game.getPhaseHandler().isPreventCombatDamageThisTurn()) {
|
||||
// spells that give -X/0
|
||||
boolean isMyTurn = Singletons.getModel().getGame().getPhaseHandler().isPlayerTurn(ai);
|
||||
boolean isMyTurn = game.getPhaseHandler().isPlayerTurn(ai);
|
||||
if (isMyTurn) {
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_BEGIN)) {
|
||||
if (game.getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_BEGIN)) {
|
||||
// TODO: Curse creatures that will block AI's creatures, if AI is going to attack.
|
||||
list = new ArrayList<Card>();
|
||||
} else {
|
||||
@@ -519,7 +521,7 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
||||
}
|
||||
} else {
|
||||
// Human active, only curse attacking creatures
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS)) {
|
||||
if (game.getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS)) {
|
||||
list = CardLists.filter(list, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
|
||||
@@ -8,10 +8,10 @@ import com.google.common.base.Predicate;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.game.GameState;
|
||||
import forge.game.ai.ComputerUtil;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.game.ai.ComputerUtilCombat;
|
||||
@@ -30,12 +30,13 @@ public class PumpAllAi extends PumpAiBase {
|
||||
protected boolean canPlayAI(final AIPlayer ai, final SpellAbility sa) {
|
||||
String valid = "";
|
||||
final Card source = sa.getSourceCard();
|
||||
final GameState game = ai.getGame();
|
||||
|
||||
final int power = AbilityUtils.calculateAmount(sa.getSourceCard(), sa.getParam("NumAtt"), sa);
|
||||
final int defense = AbilityUtils.calculateAmount(sa.getSourceCard(), sa.getParam("NumDef"), sa);
|
||||
final List<String> keywords = sa.hasParam("KW") ? Arrays.asList(sa.getParam("KW").split(" & ")) : new ArrayList<String>();
|
||||
|
||||
final PhaseType phase = Singletons.getModel().getGame().getPhaseHandler().getPhase();
|
||||
final PhaseType phase = game.getPhaseHandler().getPhase();
|
||||
|
||||
if (ComputerUtil.preventRunAwayActivations(sa)) {
|
||||
return false;
|
||||
@@ -80,8 +81,8 @@ public class PumpAllAi extends PumpAiBase {
|
||||
else if (power < 0) { // -X/-0
|
||||
if (phase.isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)
|
||||
|| phase.isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)
|
||||
|| Singletons.getModel().getGame().getPhaseHandler().isPlayerTurn(sa.getActivatingPlayer())
|
||||
|| Singletons.getModel().getGame().getPhaseHandler().isPreventCombatDamageThisTurn()) {
|
||||
|| game.getPhaseHandler().isPlayerTurn(sa.getActivatingPlayer())
|
||||
|| game.getPhaseHandler().isPreventCombatDamageThisTurn()) {
|
||||
return false;
|
||||
}
|
||||
int totalPower = 0;
|
||||
@@ -91,8 +92,8 @@ public class PumpAllAi extends PumpAiBase {
|
||||
}
|
||||
totalPower += Math.min(c.getNetAttack(), power * -1);
|
||||
if (phase == PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY
|
||||
&& Singletons.getModel().getGame().getCombat().getUnblockedAttackers().contains(c)) {
|
||||
if (ComputerUtilCombat.lifeInDanger(sa.getActivatingPlayer(), Singletons.getModel().getGame().getCombat())) {
|
||||
&& game.getCombat().getUnblockedAttackers().contains(c)) {
|
||||
if (ComputerUtilCombat.lifeInDanger(sa.getActivatingPlayer(), game.getCombat())) {
|
||||
return true;
|
||||
}
|
||||
totalPower += Math.min(c.getNetAttack(), power * -1);
|
||||
|
||||
@@ -23,12 +23,12 @@ import java.util.List;
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.game.GameState;
|
||||
import forge.game.ai.ComputerUtil;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.game.ai.ComputerUtilCombat;
|
||||
@@ -59,8 +59,10 @@ public class RegenerateAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean canPlayAI(AIPlayer ai, SpellAbility sa) {
|
||||
final Card hostCard = sa.getSourceCard();
|
||||
boolean chance = false;
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final GameState game = ai.getGame();
|
||||
|
||||
boolean chance = false;
|
||||
if (abCost != null) {
|
||||
// AI currently disabled for these costs
|
||||
if (!ComputerUtilCost.checkLifeCost(ai, abCost, hostCard, 4, null)) {
|
||||
@@ -82,7 +84,7 @@ public class RegenerateAi extends SpellAbilityAi {
|
||||
// them
|
||||
final List<Card> list = AbilityUtils.getDefinedCards(hostCard, sa.getParam("Defined"), sa);
|
||||
|
||||
if (Singletons.getModel().getGame().getStack().size() > 0) {
|
||||
if (game.getStack().size() > 0) {
|
||||
final List<Object> objects = ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa);
|
||||
|
||||
for (final Card c : list) {
|
||||
@@ -91,7 +93,7 @@ public class RegenerateAi extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
if (game.getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
boolean flag = false;
|
||||
|
||||
for (final Card c : list) {
|
||||
@@ -116,7 +118,7 @@ public class RegenerateAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Singletons.getModel().getGame().getStack().size() > 0) {
|
||||
if (game.getStack().size() > 0) {
|
||||
// check stack for something on the stack will kill anything i
|
||||
// control
|
||||
final ArrayList<Object> objects = ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa);
|
||||
@@ -135,7 +137,7 @@ public class RegenerateAi extends SpellAbilityAi {
|
||||
chance = true;
|
||||
}
|
||||
} else {
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
if (game.getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
final List<Card> combatants = CardLists.filter(targetables, CardPredicates.Presets.CREATURES);
|
||||
CardLists.sortByEvaluateCreature(combatants);
|
||||
|
||||
@@ -173,10 +175,11 @@ public class RegenerateAi extends SpellAbilityAi {
|
||||
|
||||
private static boolean regenMandatoryTarget(final Player ai, final SpellAbility sa, final boolean mandatory) {
|
||||
final Card hostCard = sa.getSourceCard();
|
||||
final GameState game = ai.getGame();
|
||||
final Target tgt = sa.getTarget();
|
||||
tgt.resetTargets();
|
||||
// filter AIs battlefield by what I can target
|
||||
List<Card> targetables = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
List<Card> targetables = game.getCardsIn(ZoneType.Battlefield);
|
||||
targetables = CardLists.getValidCards(targetables, tgt.getValidTgts(), ai, hostCard);
|
||||
targetables = CardLists.getTargetableCards(targetables, sa);
|
||||
final List<Card> compTargetables = CardLists.filterControlledBy(targetables, ai);
|
||||
@@ -192,7 +195,7 @@ public class RegenerateAi extends SpellAbilityAi {
|
||||
if (compTargetables.size() > 0) {
|
||||
final List<Card> combatants = CardLists.filter(compTargetables, CardPredicates.Presets.CREATURES);
|
||||
CardLists.sortByEvaluateCreature(combatants);
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
if (game.getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
for (final Card c : combatants) {
|
||||
if ((c.getShield() == 0) && ComputerUtilCombat.combatantWouldBeDestroyed(ai, c)) {
|
||||
tgt.addTarget(c);
|
||||
|
||||
@@ -6,10 +6,10 @@ import java.util.List;
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.GameState;
|
||||
import forge.game.ai.ComputerUtil;
|
||||
import forge.game.ai.ComputerUtilCombat;
|
||||
import forge.game.ai.ComputerUtilCost;
|
||||
@@ -24,6 +24,7 @@ public class RegenerateAllAi extends SpellAbilityAi {
|
||||
final Card hostCard = sa.getSourceCard();
|
||||
boolean chance = false;
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final GameState game = ai.getGame();
|
||||
if (abCost != null) {
|
||||
// AI currently disabled for these costs
|
||||
if (!ComputerUtilCost.checkSacrificeCost(ai, abCost, hostCard)) {
|
||||
@@ -46,7 +47,7 @@ public class RegenerateAllAi extends SpellAbilityAi {
|
||||
valid = sa.getParam("ValidCards");
|
||||
}
|
||||
|
||||
List<Card> list = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
List<Card> list = game.getCardsIn(ZoneType.Battlefield);
|
||||
list = CardLists.getValidCards(list, valid.split(","), hostCard.getController(), hostCard);
|
||||
list = CardLists.filter(list, CardPredicates.isController(ai));
|
||||
|
||||
@@ -55,7 +56,7 @@ public class RegenerateAllAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
int numSaved = 0;
|
||||
if (Singletons.getModel().getGame().getStack().size() > 0) {
|
||||
if (game.getStack().size() > 0) {
|
||||
final ArrayList<Object> objects = ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa);
|
||||
|
||||
for (final Card c : list) {
|
||||
@@ -64,7 +65,7 @@ public class RegenerateAllAi extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
if (game.getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
final List<Card> combatants = CardLists.filter(list, CardPredicates.Presets.CREATURES);
|
||||
|
||||
for (final Card c : combatants) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package forge.card.ability.ai;
|
||||
|
||||
import forge.Card;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.ai.ComputerUtil;
|
||||
@@ -16,7 +15,7 @@ public class StoreSVarAi extends SpellAbilityAi {
|
||||
|
||||
final Card source = sa.getSourceCard();
|
||||
if (ComputerUtil.waitForBlocking(sa) || ai.getLife() + 1 >= source.getNetDefense()
|
||||
|| (ai.getLife() > 5 && !ComputerUtilCombat.lifeInSeriousDanger(ai, Singletons.getModel().getGame().getCombat()))) {
|
||||
|| (ai.getLife() > 5 && !ComputerUtilCombat.lifeInSeriousDanger(ai, ai.getGame().getCombat()))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
@@ -19,7 +18,7 @@ public class TapAi extends TapAiBase {
|
||||
@Override
|
||||
protected boolean canPlayAI(AIPlayer ai, SpellAbility sa) {
|
||||
|
||||
final PhaseHandler phase = Singletons.getModel().getGame().getPhaseHandler();
|
||||
final PhaseHandler phase = ai.getGame().getPhaseHandler();
|
||||
final Player turn = phase.getPlayerTurn();
|
||||
|
||||
if (turn.isOpponentOf(ai) && phase.getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS)) {
|
||||
|
||||
@@ -9,10 +9,10 @@ import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates;
|
||||
import forge.CardPredicates.Presets;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.game.GameState;
|
||||
import forge.game.ai.ComputerUtil;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.game.phase.CombatUtil;
|
||||
@@ -115,6 +115,7 @@ public abstract class TapAiBase extends SpellAbilityAi {
|
||||
*/
|
||||
protected boolean tapPrefTargeting(final Player ai, final Card source, final Target tgt, final SpellAbility sa, final boolean mandatory) {
|
||||
final Player opp = ai.getOpponent();
|
||||
final GameState game = ai.getGame();
|
||||
List<Card> tapList = opp.getCardsIn(ZoneType.Battlefield);
|
||||
tapList = CardLists.filter(tapList, Presets.UNTAPPED);
|
||||
tapList = CardLists.getValidCards(tapList, tgt.getValidTgts(), source.getController(), source);
|
||||
@@ -159,7 +160,7 @@ public abstract class TapAiBase extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
|
||||
PhaseHandler phase = Singletons.getModel().getGame().getPhaseHandler();
|
||||
PhaseHandler phase = game.getPhaseHandler();
|
||||
if (phase.isPlayerTurn(ai)
|
||||
&& phase.getPhase().isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS)) {
|
||||
// Tap creatures possible blockers before combat during AI's turn.
|
||||
@@ -167,7 +168,7 @@ public abstract class TapAiBase extends SpellAbilityAi {
|
||||
List<Card> attackers;
|
||||
if (phase.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)) {
|
||||
//Combat has already started
|
||||
attackers = Singletons.getModel().getGame().getCombat().getAttackers();
|
||||
attackers = game.getCombat().getAttackers();
|
||||
} else {
|
||||
attackers = CardLists.filter(ai.getCreaturesInPlay(), new Predicate<Card>() {
|
||||
@Override
|
||||
@@ -240,8 +241,9 @@ public abstract class TapAiBase extends SpellAbilityAi {
|
||||
protected boolean tapUnpreferredTargeting(final Player ai, final SpellAbility sa, final boolean mandatory) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final Target tgt = sa.getTarget();
|
||||
final GameState game = ai.getGame();
|
||||
|
||||
List<Card> list = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
List<Card> list = game.getCardsIn(ZoneType.Battlefield);
|
||||
list = CardLists.getValidCards(list, tgt.getValidTgts(), source.getController(), source);
|
||||
list = CardLists.getTargetableCards(list, sa);
|
||||
|
||||
|
||||
@@ -9,10 +9,10 @@ import com.google.common.collect.Iterables;
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates.Presets;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
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.AIPlayer;
|
||||
@@ -33,8 +33,9 @@ public class TapAllAi extends SpellAbilityAi {
|
||||
|
||||
final Card source = sa.getSourceCard();
|
||||
final Player opp = ai.getOpponent();
|
||||
final GameState game = ai.getGame();
|
||||
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_BEGIN)) {
|
||||
if (game.getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_BEGIN)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -43,7 +44,7 @@ public class TapAllAi extends SpellAbilityAi {
|
||||
valid = sa.getParam("ValidCards");
|
||||
}
|
||||
|
||||
List<Card> validTappables = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
List<Card> validTappables = game.getCardsIn(ZoneType.Battlefield);
|
||||
|
||||
final Target tgt = sa.getTarget();
|
||||
|
||||
@@ -81,7 +82,7 @@ public class TapAllAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
// in AI's turn, check if there are possible attackers, before tapping blockers
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().isPlayerTurn(ai) && !SpellAbilityAi.isSorcerySpeed(sa)) {
|
||||
if (game.getPhaseHandler().isPlayerTurn(ai) && !SpellAbilityAi.isSorcerySpeed(sa)) {
|
||||
validTappables = ai.getCardsIn(ZoneType.Battlefield);
|
||||
final boolean any = Iterables.any(validTappables, new Predicate<Card>() {
|
||||
@Override
|
||||
@@ -108,7 +109,8 @@ public class TapAllAi extends SpellAbilityAi {
|
||||
* @return a {@link forge.CardList} object.
|
||||
*/
|
||||
private List<Card> getTapAllTargets(final String valid, final Card source) {
|
||||
List<Card> tmpList = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
final GameState game = source.getGame();
|
||||
List<Card> tmpList = game.getCardsIn(ZoneType.Battlefield);
|
||||
tmpList = CardLists.getValidCards(tmpList, valid, source.getController(), source);
|
||||
tmpList = CardLists.filter(tmpList, Presets.UNTAPPED);
|
||||
return tmpList;
|
||||
|
||||
@@ -3,12 +3,12 @@ package forge.card.ability.ai;
|
||||
import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.game.GameState;
|
||||
import forge.game.ai.ComputerUtil;
|
||||
import forge.game.ai.ComputerUtilCost;
|
||||
import forge.game.ai.ComputerUtilMana;
|
||||
@@ -67,6 +67,7 @@ public class TokenAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean canPlayAI(AIPlayer ai, SpellAbility sa) {
|
||||
final Cost cost = sa.getPayCosts();
|
||||
final GameState game = ai.getGame();
|
||||
readParameters(sa);
|
||||
|
||||
if (ComputerUtil.preventRunAwayActivations(sa)) {
|
||||
@@ -95,7 +96,7 @@ public class TokenAi extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
|
||||
PhaseHandler ph = Singletons.getModel().getGame().getPhaseHandler();
|
||||
PhaseHandler ph = game.getPhaseHandler();
|
||||
// Don't generate tokens without haste before main 2 if possible
|
||||
if (ph.getPhase().isBefore(PhaseType.MAIN2)
|
||||
&& ph.isPlayerTurn(ai) && !haste
|
||||
@@ -109,7 +110,7 @@ public class TokenAi extends SpellAbilityAi {
|
||||
&& !SpellAbilityAi.isSorcerySpeed(sa) && !haste) {
|
||||
return false;
|
||||
}
|
||||
if ((ph.getPhase().isAfter(PhaseType.COMBAT_BEGIN) || Singletons.getModel().getGame().getPhaseHandler().isPlayerTurn(
|
||||
if ((ph.getPhase().isAfter(PhaseType.COMBAT_BEGIN) || game.getPhaseHandler().isPlayerTurn(
|
||||
opp))
|
||||
&& oneShot) {
|
||||
return false;
|
||||
@@ -163,7 +164,7 @@ public class TokenAi extends SpellAbilityAi {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().is(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)) {
|
||||
if (game.getPhaseHandler().is(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)) {
|
||||
return true;
|
||||
}
|
||||
if (sa.isAbility()) {
|
||||
|
||||
@@ -4,7 +4,6 @@ import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
@@ -51,7 +50,7 @@ public class UnattachAllAi extends SpellAbilityAi {
|
||||
source.setSVar("PayX", Integer.toString(xPay));
|
||||
}
|
||||
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)
|
||||
if (ai.getGame().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)
|
||||
&& !"Curse".equals(sa.getParam("AILogic"))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import java.util.Random;
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates.Presets;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
@@ -187,12 +186,11 @@ public class UntapAi extends SpellAbilityAi {
|
||||
* a boolean.
|
||||
* @return a boolean.
|
||||
*/
|
||||
private boolean untapUnpreferredTargeting(final SpellAbility sa,
|
||||
final boolean mandatory) {
|
||||
private boolean untapUnpreferredTargeting(final SpellAbility sa, final boolean mandatory) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final Target tgt = sa.getTarget();
|
||||
|
||||
List<Card> list = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
List<Card> list = sa.getActivatingPlayer().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
|
||||
list = CardLists.getValidCards(list, tgt.getValidTgts(), source.getController(), source);
|
||||
list = CardLists.getTargetableCards(list, sa);
|
||||
|
||||
@@ -4,7 +4,6 @@ import java.util.List;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.AbilitySub;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
@@ -20,7 +19,7 @@ public class UntapAllAi extends SpellAbilityAi {
|
||||
final AbilitySub abSub = sa.getSubAbility();
|
||||
if (abSub != null) {
|
||||
String valid = "";
|
||||
List<Card> list = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
List<Card> list = aiPlayer.getGame().getCardsIn(ZoneType.Battlefield);
|
||||
if (sa.hasParam("ValidCards")) {
|
||||
valid = sa.getParam("ValidCards");
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package forge.card.ability.effects;
|
||||
|
||||
|
||||
import forge.Card;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.trigger.TriggerType;
|
||||
@@ -12,7 +10,6 @@ import forge.game.zone.ZoneType;
|
||||
|
||||
public class AbandonEffect extends SpellAbilityEffect {
|
||||
|
||||
private GameState game = Singletons.getModel().getGame();
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.card.abilityfactory.SpellEffect#resolve(java.util.Map, forge.card.spellability.SpellAbility)
|
||||
@@ -22,6 +19,8 @@ public class AbandonEffect extends SpellAbilityEffect {
|
||||
Card source = sa.getSourceCard();
|
||||
Player controller = source.getController();
|
||||
|
||||
final GameState game = controller.getGame();
|
||||
|
||||
game.getTriggerHandler().suppressMode(TriggerType.ChangesZone);
|
||||
controller.getZone(ZoneType.Command).remove(source);
|
||||
game.getTriggerHandler().clearSuppression(TriggerType.ChangesZone);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.card.ability.effects;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.phase.PhaseHandler;
|
||||
@@ -14,7 +13,7 @@ public class AddPhaseEffect extends SpellAbilityEffect {
|
||||
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
PhaseHandler phaseHandler = Singletons.getModel().getGame().getPhaseHandler();
|
||||
PhaseHandler phaseHandler = sa.getActivatingPlayer().getGame().getPhaseHandler();
|
||||
PhaseType extra = PhaseType.smartValueOf(sa.getParam("ExtraPhase"));
|
||||
|
||||
PhaseType after;
|
||||
|
||||
@@ -2,7 +2,6 @@ package forge.card.ability.effects;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
@@ -52,7 +51,7 @@ public class AddTurnEffect extends SpellAbilityEffect {
|
||||
for (final Player p : tgtPlayers) {
|
||||
if ((tgt == null) || p.canBeTargetedBy(sa)) {
|
||||
for (int i = 0; i < numTurns; i++) {
|
||||
ExtraTurn extra = Singletons.getModel().getGame().getPhaseHandler().addExtraTurn(p);
|
||||
ExtraTurn extra = p.getGame().getPhaseHandler().addExtraTurn(p);
|
||||
if (sa.hasParam("LoseAtEndStep")) {
|
||||
extra.setLoseAtEndStep(true);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardUtil;
|
||||
import forge.Command;
|
||||
import forge.Singletons;
|
||||
import forge.card.TriggerReplacementBase;
|
||||
import forge.card.ability.AbilityFactory;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
@@ -19,6 +18,7 @@ import forge.card.spellability.Target;
|
||||
import forge.card.staticability.StaticAbility;
|
||||
import forge.card.trigger.Trigger;
|
||||
import forge.card.trigger.TriggerHandler;
|
||||
import forge.game.GameState;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
@@ -33,7 +33,6 @@ public class AnimateAllEffect extends AnimateEffectBase {
|
||||
public void resolve(final SpellAbility sa) {
|
||||
final Card host = sa.getSourceCard();
|
||||
final Map<String, String> svars = host.getSVars();
|
||||
long timest = -1;
|
||||
|
||||
// AF specific sa
|
||||
int power = -1;
|
||||
@@ -44,11 +43,10 @@ public class AnimateAllEffect extends AnimateEffectBase {
|
||||
if (sa.hasParam("Toughness")) {
|
||||
toughness = AbilityUtils.calculateAmount(host, sa.getParam("Toughness"), sa);
|
||||
}
|
||||
final GameState game = sa.getActivatingPlayer().getGame();
|
||||
|
||||
// Every Animate event needs a unique time stamp
|
||||
timest = Singletons.getModel().getGame().getNextTimestamp();
|
||||
|
||||
final long timestamp = timest;
|
||||
final long timestamp = game.getNextTimestamp();
|
||||
|
||||
final boolean permanent = sa.hasParam("Permanent");
|
||||
|
||||
@@ -134,7 +132,7 @@ public class AnimateAllEffect extends AnimateEffectBase {
|
||||
}
|
||||
|
||||
if ((tgtPlayers == null) || tgtPlayers.isEmpty()) {
|
||||
list = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
list = game.getCardsIn(ZoneType.Battlefield);
|
||||
} else {
|
||||
list = new ArrayList<Card>(tgtPlayers.get(0).getCardsIn(ZoneType.Battlefield));
|
||||
}
|
||||
@@ -243,9 +241,9 @@ public class AnimateAllEffect extends AnimateEffectBase {
|
||||
|
||||
if (!permanent) {
|
||||
if (sa.hasParam("UntilEndOfCombat")) {
|
||||
Singletons.getModel().getGame().getEndOfCombat().addUntil(unanimate);
|
||||
game.getEndOfCombat().addUntil(unanimate);
|
||||
} else {
|
||||
Singletons.getModel().getGame().getEndOfTurn().addUntil(unanimate);
|
||||
game.getEndOfTurn().addUntil(unanimate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import java.util.Map;
|
||||
import forge.Card;
|
||||
import forge.CardUtil;
|
||||
import forge.Command;
|
||||
import forge.Singletons;
|
||||
import forge.card.TriggerReplacementBase;
|
||||
import forge.card.ability.AbilityFactory;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
@@ -18,6 +17,7 @@ import forge.card.spellability.Target;
|
||||
import forge.card.staticability.StaticAbility;
|
||||
import forge.card.trigger.Trigger;
|
||||
import forge.card.trigger.TriggerHandler;
|
||||
import forge.game.GameState;
|
||||
|
||||
public class AnimateEffect extends AnimateEffectBase {
|
||||
|
||||
@@ -29,7 +29,7 @@ public class AnimateEffect extends AnimateEffectBase {
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card host = sa.getSourceCard();
|
||||
final Map<String, String> svars = host.getSVars();
|
||||
long timest = -1;
|
||||
|
||||
String animateRemembered = null;
|
||||
|
||||
//if host is not on the battlefield don't apply
|
||||
@@ -53,10 +53,11 @@ public class AnimateEffect extends AnimateEffectBase {
|
||||
toughness = AbilityUtils.calculateAmount(host, sa.getParam("Toughness"), sa);
|
||||
}
|
||||
|
||||
final GameState game = sa.getActivatingPlayer().getGame();
|
||||
// Every Animate event needs a unique time stamp
|
||||
timest = Singletons.getModel().getGame().getNextTimestamp();
|
||||
final long timestamp = game.getNextTimestamp();
|
||||
|
||||
|
||||
final long timestamp = timest;
|
||||
|
||||
final boolean permanent = sa.hasParam("Permanent");
|
||||
|
||||
@@ -264,17 +265,17 @@ public class AnimateEffect extends AnimateEffectBase {
|
||||
|
||||
if (!permanent) {
|
||||
if (sa.hasParam("UntilEndOfCombat")) {
|
||||
Singletons.getModel().getGame().getEndOfCombat().addUntil(unanimate);
|
||||
game.getEndOfCombat().addUntil(unanimate);
|
||||
} else if (sa.hasParam("UntilHostLeavesPlay")) {
|
||||
host.addLeavesPlayCommand(unanimate);
|
||||
} else if (sa.hasParam("UntilYourNextUpkeep")) {
|
||||
Singletons.getModel().getGame().getUpkeep().addUntil(host.getController(), unanimate);
|
||||
game.getUpkeep().addUntil(host.getController(), unanimate);
|
||||
} else if (sa.hasParam("UntilControllerNextUntap")) {
|
||||
Singletons.getModel().getGame().getUntap().addUntil(c.getController(), unanimate);
|
||||
game.getUntap().addUntil(c.getController(), unanimate);
|
||||
} else if (sa.hasParam("UntilYourNextTurn")) {
|
||||
Singletons.getModel().getGame().getCleanup().addUntil(host.getController(), unanimate);
|
||||
game.getCleanup().addUntil(host.getController(), unanimate);
|
||||
} else {
|
||||
Singletons.getModel().getGame().getEndOfTurn().addUntil(unanimate);
|
||||
game.getEndOfTurn().addUntil(unanimate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,13 +7,13 @@ import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.Command;
|
||||
import forge.GameEntity;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.ApiType;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
import forge.card.ability.ai.AttachAi;
|
||||
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.gui.GuiChoose;
|
||||
@@ -28,10 +28,12 @@ public class AttachEffect extends SpellAbilityEffect {
|
||||
public void resolve(SpellAbility sa) {
|
||||
if (sa.getSourceCard().isAura() && sa.isSpell()) {
|
||||
|
||||
final Player ap = sa.getActivatingPlayer();
|
||||
// The Spell_Permanent (Auras) version of this AF needs to
|
||||
// move the card into play before Attaching
|
||||
sa.getSourceCard().setController(sa.getActivatingPlayer(), 0);
|
||||
final Card c = Singletons.getModel().getGame().getAction().moveTo(sa.getActivatingPlayer().getZone(ZoneType.Battlefield), sa.getSourceCard());
|
||||
|
||||
sa.getSourceCard().setController(ap, 0);
|
||||
final Card c = ap.getGame().getAction().moveTo(ap.getZone(ZoneType.Battlefield), sa.getSourceCard());
|
||||
sa.setSourceCard(c);
|
||||
}
|
||||
|
||||
@@ -182,13 +184,14 @@ public class AttachEffect extends SpellAbilityEffect {
|
||||
return false;
|
||||
}
|
||||
aura.setActivatingPlayer(source.getController());
|
||||
final GameState game = source.getGame();
|
||||
final Target tgt = aura.getTarget();
|
||||
|
||||
if (source.getController().isHuman()) {
|
||||
if (tgt.canTgtPlayer()) {
|
||||
final ArrayList<Player> players = new ArrayList<Player>();
|
||||
|
||||
for (Player player : Singletons.getModel().getGame().getPlayers()) {
|
||||
for (Player player : game.getPlayers()) {
|
||||
if (player.isValid(tgt.getValidTgts(), aura.getActivatingPlayer(), source)) {
|
||||
players.add(player);
|
||||
}
|
||||
@@ -200,7 +203,7 @@ public class AttachEffect extends SpellAbilityEffect {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
List<Card> list = Singletons.getModel().getGame().getCardsIn(tgt.getZone());
|
||||
List<Card> list = game.getCardsIn(tgt.getZone());
|
||||
list = CardLists.getValidCards(list, tgt.getValidTgts(), aura.getActivatingPlayer(), source);
|
||||
if (list.isEmpty()) {
|
||||
return false;
|
||||
|
||||
@@ -6,13 +6,13 @@ import java.util.List;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.Card;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.spellability.Ability;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.card.trigger.TriggerType;
|
||||
import forge.game.GameState;
|
||||
|
||||
public class BecomesBlockedEffect extends SpellAbilityEffect {
|
||||
|
||||
@@ -31,20 +31,21 @@ public class BecomesBlockedEffect extends SpellAbilityEffect {
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
|
||||
final GameState game = sa.getActivatingPlayer().getGame();
|
||||
final Target tgt = sa.getTarget();
|
||||
for (final Card c : getTargetCards(sa)) {
|
||||
if ((tgt == null) || c.canBeTargetedBy(sa)) {
|
||||
Singletons.getModel().getGame().getCombat().setBlocked(c);
|
||||
game.getCombat().setBlocked(c);
|
||||
if (!c.getDamageHistory().getCreatureGotBlockedThisCombat()) {
|
||||
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
||||
runParams.put("Attacker", c);
|
||||
runParams.put("Blocker", null);
|
||||
runParams.put("NumBlockers", 0);
|
||||
Singletons.getModel().getGame().getTriggerHandler().runTrigger(TriggerType.AttackerBlocked, runParams, false);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.AttackerBlocked, runParams, false);
|
||||
|
||||
// Bushido
|
||||
for (final Ability ab : CardFactoryUtil.getBushidoEffects(c)) {
|
||||
Singletons.getModel().getGame().getStack().add(ab);
|
||||
game.getStack().add(ab);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package forge.card.ability.effects;
|
||||
import java.util.List;
|
||||
|
||||
import forge.Card;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
@@ -21,7 +20,7 @@ public class BondEffect extends SpellAbilityEffect {
|
||||
}
|
||||
|
||||
// find list of valid cards to pair with
|
||||
List<Card> cards = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
List<Card> cards = sa.getActivatingPlayer().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
cards = AbilityUtils.filterListByType(cards, sa.getParam("ValidCards"), sa);
|
||||
if (cards.isEmpty()) {
|
||||
return;
|
||||
|
||||
@@ -8,10 +8,10 @@ import com.google.common.collect.Iterables;
|
||||
import forge.Card;
|
||||
import forge.CardCharacteristicName;
|
||||
import forge.CardPredicates;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.GameState;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.gui.GuiChoose;
|
||||
@@ -40,9 +40,10 @@ public class ChangeZoneAllEffect extends SpellAbilityEffect {
|
||||
List<Card> cards = new ArrayList<Card>();
|
||||
|
||||
List<Player> tgtPlayers = getTargetPlayersEmptyAsDefault(sa);
|
||||
final GameState game = sa.getActivatingPlayer().getGame();
|
||||
|
||||
if ((tgtPlayers == null) || tgtPlayers.isEmpty() || sa.hasParam("UseAllOriginZones")) {
|
||||
cards = Singletons.getModel().getGame().getCardsIn(origin);
|
||||
cards = game.getCardsIn(origin);
|
||||
} else {
|
||||
for (final Player p : tgtPlayers) {
|
||||
cards.addAll(p.getCardsIn(origin));
|
||||
@@ -81,10 +82,10 @@ public class ChangeZoneAllEffect extends SpellAbilityEffect {
|
||||
}
|
||||
|
||||
if (sa.hasParam("GainControl")) {
|
||||
c.setController(sa.getActivatingPlayer(), Singletons.getModel().getGame().getNextTimestamp());
|
||||
Singletons.getModel().getGame().getAction().moveToPlay(c, sa.getActivatingPlayer());
|
||||
c.setController(sa.getActivatingPlayer(), game.getNextTimestamp());
|
||||
game.getAction().moveToPlay(c, sa.getActivatingPlayer());
|
||||
} else {
|
||||
final Card movedCard = Singletons.getModel().getGame().getAction().moveTo(destination, c, libraryPos);
|
||||
final Card movedCard = game.getAction().moveTo(destination, c, libraryPos);
|
||||
if (sa.hasParam("ExileFaceDown")) {
|
||||
movedCard.setState(CardCharacteristicName.FaceDown);
|
||||
}
|
||||
@@ -94,20 +95,20 @@ public class ChangeZoneAllEffect extends SpellAbilityEffect {
|
||||
}
|
||||
|
||||
if (remember != null) {
|
||||
Singletons.getModel().getGame().getCardState(sa.getSourceCard()).addRemembered(c);
|
||||
game.getCardState(sa.getSourceCard()).addRemembered(c);
|
||||
}
|
||||
if (forget != null) {
|
||||
Singletons.getModel().getGame().getCardState(sa.getSourceCard()).removeRemembered(c);
|
||||
game.getCardState(sa.getSourceCard()).removeRemembered(c);
|
||||
}
|
||||
if (imprint != null) {
|
||||
Singletons.getModel().getGame().getCardState(sa.getSourceCard()).addImprinted(c);
|
||||
game.getCardState(sa.getSourceCard()).addImprinted(c);
|
||||
}
|
||||
}
|
||||
|
||||
// if Shuffle parameter exists, and any amount of cards were owned by
|
||||
// that player, then shuffle that library
|
||||
if (sa.hasParam("Shuffle")) {
|
||||
for (Player p : Singletons.getModel().getGame().getPlayers()) {
|
||||
for (Player p : game.getPlayers()) {
|
||||
if (Iterables.any(cards, CardPredicates.isOwner(p))) {
|
||||
p.shuffle();
|
||||
}
|
||||
|
||||
@@ -8,12 +8,12 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates.Presets;
|
||||
import forge.Singletons;
|
||||
import forge.card.CardType;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
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.Aggregates;
|
||||
@@ -34,6 +34,7 @@ public class ChooseCardEffect extends SpellAbilityEffect {
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
final Card host = sa.getSourceCard();
|
||||
final GameState game = sa.getActivatingPlayer().getGame();
|
||||
final ArrayList<Card> chosen = new ArrayList<Card>();
|
||||
|
||||
final Target tgt = sa.getTarget();
|
||||
@@ -43,7 +44,7 @@ public class ChooseCardEffect extends SpellAbilityEffect {
|
||||
if (sa.hasParam("ChoiceZone")) {
|
||||
choiceZone = ZoneType.smartValueOf(sa.getParam("ChoiceZone"));
|
||||
}
|
||||
List<Card> choices = Singletons.getModel().getGame().getCardsIn(choiceZone);
|
||||
List<Card> choices = game.getCardsIn(choiceZone);
|
||||
if (sa.hasParam("Choices")) {
|
||||
choices = CardLists.getValidCards(choices, sa.getParam("Choices"), host.getController(), host);
|
||||
}
|
||||
@@ -57,7 +58,7 @@ public class ChooseCardEffect extends SpellAbilityEffect {
|
||||
for (final Player p : tgtPlayers) {
|
||||
if (sa.hasParam("EachBasicType")) {
|
||||
// Get all lands,
|
||||
List<Card> land = CardLists.filter(Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield), Presets.LANDS);
|
||||
List<Card> land = CardLists.filter(game.getCardsIn(ZoneType.Battlefield), Presets.LANDS);
|
||||
String eachBasic = sa.getParam("EachBasicType");
|
||||
if (eachBasic.equals("Controlled")) {
|
||||
land = CardLists.filterControlledBy(land, p);
|
||||
|
||||
@@ -13,7 +13,6 @@ import com.google.common.collect.Lists;
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates.Presets;
|
||||
import forge.Singletons;
|
||||
import forge.card.CardRulesPredicates;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
@@ -100,7 +99,7 @@ public class ChooseCardNameEffect extends SpellAbilityEffect {
|
||||
chosen = ComputerUtilCard.getMostProminentCardName(p.getOpponent().getCardsIn(ZoneType.Library));
|
||||
}
|
||||
} else {
|
||||
List<Card> list = CardLists.filterControlledBy(Singletons.getModel().getGame().getCardsInGame(), p.getOpponent());
|
||||
List<Card> list = CardLists.filterControlledBy(p.getGame().getCardsInGame(), p.getOpponent());
|
||||
list = CardLists.filter(list, Predicates.not(Presets.LANDS));
|
||||
if (!list.isEmpty()) {
|
||||
chosen = list.get(0).getName();
|
||||
|
||||
@@ -9,10 +9,10 @@ import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates;
|
||||
import forge.Constant;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.game.GameState;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
@@ -67,25 +67,26 @@ public class ChooseColorEffect extends SpellAbilityEffect {
|
||||
} else {
|
||||
List<String> chosen = new ArrayList<String>();
|
||||
Player ai = sa.getActivatingPlayer();
|
||||
final GameState game = ai.getGame();
|
||||
Player opp = ai.getOpponent();
|
||||
if (sa.hasParam("AILogic")) {
|
||||
final String logic = sa.getParam("AILogic");
|
||||
if (logic.equals("MostProminentInHumanDeck")) {
|
||||
chosen.add(ComputerUtilCard.getMostProminentColor(CardLists.filterControlledBy(Singletons.getModel().getGame().getCardsInGame(), opp)));
|
||||
chosen.add(ComputerUtilCard.getMostProminentColor(CardLists.filterControlledBy(game.getCardsInGame(), opp)));
|
||||
} else if (logic.equals("MostProminentInComputerDeck")) {
|
||||
chosen.add(ComputerUtilCard.getMostProminentColor(CardLists.filterControlledBy(Singletons.getModel().getGame().getCardsInGame(), ai)));
|
||||
chosen.add(ComputerUtilCard.getMostProminentColor(CardLists.filterControlledBy(game.getCardsInGame(), ai)));
|
||||
} else if (logic.equals("MostProminentDualInComputerDeck")) {
|
||||
List<String> prominence = ComputerUtilCard.getColorByProminence(CardLists.filterControlledBy(Singletons.getModel().getGame().getCardsInGame(), ai));
|
||||
List<String> prominence = ComputerUtilCard.getColorByProminence(CardLists.filterControlledBy(game.getCardsInGame(), ai));
|
||||
chosen.add(prominence.get(0));
|
||||
chosen.add(prominence.get(1));
|
||||
}
|
||||
else if (logic.equals("MostProminentInGame")) {
|
||||
chosen.add(ComputerUtilCard.getMostProminentColor(Singletons.getModel().getGame().getCardsInGame()));
|
||||
chosen.add(ComputerUtilCard.getMostProminentColor(game.getCardsInGame()));
|
||||
}
|
||||
else if (logic.equals("MostProminentHumanCreatures")) {
|
||||
List<Card> list = opp.getCreaturesInPlay();
|
||||
if (list.isEmpty()) {
|
||||
list = CardLists.filter(CardLists.filterControlledBy(Singletons.getModel().getGame().getCardsInGame(), opp), CardPredicates.Presets.CREATURES);
|
||||
list = CardLists.filter(CardLists.filterControlledBy(game.getCardsInGame(), opp), CardPredicates.Presets.CREATURES);
|
||||
}
|
||||
chosen.add(ComputerUtilCard.getMostProminentColor(list));
|
||||
}
|
||||
@@ -96,11 +97,11 @@ public class ChooseColorEffect extends SpellAbilityEffect {
|
||||
chosen.add(ComputerUtilCard.getMostProminentColor(ai.getOpponent().getCardsIn(ZoneType.Battlefield)));
|
||||
}
|
||||
else if (logic.equals("MostProminentPermanent")) {
|
||||
final List<Card> list = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
final List<Card> list = game.getCardsIn(ZoneType.Battlefield);
|
||||
chosen.add(ComputerUtilCard.getMostProminentColor(list));
|
||||
}
|
||||
else if (logic.equals("MostProminentAttackers")) {
|
||||
chosen.add(ComputerUtilCard.getMostProminentColor(Singletons.getModel().getGame().getCombat().getAttackers()));
|
||||
chosen.add(ComputerUtilCard.getMostProminentColor(game.getCombat().getAttackers()));
|
||||
}
|
||||
else if (logic.equals("MostProminentKeywordInComputerDeck")) {
|
||||
List<Card> list = ai.getAllCards();
|
||||
|
||||
@@ -3,7 +3,6 @@ package forge.card.ability.effects;
|
||||
import java.util.List;
|
||||
|
||||
import forge.Card;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
@@ -34,7 +33,7 @@ public class ChoosePlayerEffect extends SpellAbilityEffect {
|
||||
final Target tgt = sa.getTarget();
|
||||
|
||||
final List<Player> choices = sa.hasParam("Choices") ? AbilityUtils.getDefinedPlayers(
|
||||
sa.getSourceCard(), sa.getParam("Choices"), sa) : Singletons.getModel().getGame().getPlayers();
|
||||
sa.getSourceCard(), sa.getParam("Choices"), sa) : sa.getActivatingPlayer().getGame().getPlayers();
|
||||
|
||||
final String choiceDesc = sa.hasParam("ChoiceTitle") ? sa.getParam("ChoiceTitle") : "Choose a player";
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ import com.google.common.base.Predicate;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.ApiType;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
@@ -18,6 +17,7 @@ import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.SpellAbilityStackInstance;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.game.GameState;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.game.ai.ComputerUtilCombat;
|
||||
import forge.game.player.Player;
|
||||
@@ -41,11 +41,12 @@ public class ChooseSourceEffect extends SpellAbilityEffect {
|
||||
public void resolve(SpellAbility sa) {
|
||||
final Card host = sa.getSourceCard();
|
||||
final ArrayList<Card> chosen = new ArrayList<Card>();
|
||||
final GameState game = sa.getActivatingPlayer().getGame();
|
||||
|
||||
final Target tgt = sa.getTarget();
|
||||
final List<Player> tgtPlayers = getTargetPlayers(sa);
|
||||
|
||||
Stack<SpellAbilityStackInstance> stack = Singletons.getModel().getGame().getStack().getStack();
|
||||
Stack<SpellAbilityStackInstance> stack = game.getStack().getStack();
|
||||
|
||||
List<Card> permanentSources = new ArrayList<Card>();
|
||||
List<Card> stackSources = new ArrayList<Card>();
|
||||
@@ -54,7 +55,7 @@ public class ChooseSourceEffect extends SpellAbilityEffect {
|
||||
List<Card> sourcesToChooseFrom = new ArrayList<Card>();
|
||||
|
||||
// Get the list of permanent cards
|
||||
permanentSources = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
permanentSources = game.getCardsIn(ZoneType.Battlefield);
|
||||
|
||||
// Get the list of cards that produce effects on the stack
|
||||
if (stack != null) {
|
||||
@@ -142,8 +143,8 @@ public class ChooseSourceEffect extends SpellAbilityEffect {
|
||||
} else {
|
||||
if (sa.hasParam("AILogic") && sa.getParam("AILogic").equals("NeedsPrevention")) {
|
||||
final Player ai = sa.getActivatingPlayer();
|
||||
if (!Singletons.getModel().getGame().getStack().isEmpty()) {
|
||||
final SpellAbility topStack = Singletons.getModel().getGame().getStack().peekAbility();
|
||||
if (!game.getStack().isEmpty()) {
|
||||
final SpellAbility topStack = game.getStack().peekAbility();
|
||||
if (sa.hasParam("Choices") && !topStack.getSourceCard().isValid(sa.getParam("Choices"), ai, host)) {
|
||||
break;
|
||||
}
|
||||
@@ -177,10 +178,10 @@ public class ChooseSourceEffect extends SpellAbilityEffect {
|
||||
sourcesToChooseFrom = CardLists.filter(sourcesToChooseFrom, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
if (!c.isAttacking(ai) || !Singletons.getModel().getGame().getCombat().isUnblocked(c)) {
|
||||
if (!c.isAttacking(ai) || !game.getCombat().isUnblocked(c)) {
|
||||
return false;
|
||||
}
|
||||
return ComputerUtilCombat.damageIfUnblocked(c, ai, Singletons.getModel().getGame().getCombat()) > 0;
|
||||
return ComputerUtilCombat.damageIfUnblocked(c, ai, game.getCombat()) > 0;
|
||||
}
|
||||
});
|
||||
chosen.add(ComputerUtilCard.getBestCreatureAI(sourcesToChooseFrom));
|
||||
|
||||
@@ -10,11 +10,11 @@ import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates;
|
||||
import forge.Constant;
|
||||
import forge.Singletons;
|
||||
import forge.card.CardType;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.game.GameState;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
@@ -52,6 +52,7 @@ public class ChooseTypeEffect extends SpellAbilityEffect {
|
||||
final List<Player> tgtPlayers = getTargetPlayers(sa);
|
||||
|
||||
for (final Player p : tgtPlayers) {
|
||||
final GameState game = p.getGame();
|
||||
if ((tgt == null) || p.canBeTargetedBy(sa)) {
|
||||
|
||||
if (type.equals("Card")) {
|
||||
@@ -95,7 +96,7 @@ public class ChooseTypeEffect extends SpellAbilityEffect {
|
||||
if (sa.hasParam("AILogic")) {
|
||||
final String logic = sa.getParam("AILogic");
|
||||
if (logic.equals("MostProminentOnBattlefield")) {
|
||||
chosen = ComputerUtilCard.getMostProminentCreatureType(Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield));
|
||||
chosen = ComputerUtilCard.getMostProminentCreatureType(game.getCardsIn(ZoneType.Battlefield));
|
||||
}
|
||||
else if (logic.equals("MostProminentComputerControls")) {
|
||||
chosen = ComputerUtilCard.getMostProminentCreatureType(ai.getCardsIn(ZoneType.Battlefield));
|
||||
@@ -103,11 +104,11 @@ public class ChooseTypeEffect extends SpellAbilityEffect {
|
||||
else if (logic.equals("MostProminentHumanControls")) {
|
||||
chosen = ComputerUtilCard.getMostProminentCreatureType(opp.getCardsIn(ZoneType.Battlefield));
|
||||
if (!CardType.isACreatureType(chosen) || invalidTypes.contains(chosen)) {
|
||||
chosen = ComputerUtilCard.getMostProminentCreatureType(CardLists.filterControlledBy(Singletons.getModel().getGame().getCardsInGame(), opp));
|
||||
chosen = ComputerUtilCard.getMostProminentCreatureType(CardLists.filterControlledBy(game.getCardsInGame(), opp));
|
||||
}
|
||||
}
|
||||
else if (logic.equals("MostProminentInComputerDeck")) {
|
||||
chosen = ComputerUtilCard.getMostProminentCreatureType(CardLists.filterControlledBy(Singletons.getModel().getGame().getCardsInGame(), ai));
|
||||
chosen = ComputerUtilCard.getMostProminentCreatureType(CardLists.filterControlledBy(game.getCardsInGame(), ai));
|
||||
}
|
||||
else if (logic.equals("MostProminentInComputerGraveyard")) {
|
||||
chosen = ComputerUtilCard.getMostProminentCreatureType(ai.getCardsIn(ZoneType.Graveyard));
|
||||
|
||||
@@ -3,7 +3,6 @@ package forge.card.ability.effects;
|
||||
import java.util.HashMap;
|
||||
|
||||
import forge.Card;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityFactory;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
@@ -59,7 +58,8 @@ public class ClashEffect extends SpellAbilityEffect {
|
||||
runParams.put("Won", "False");
|
||||
}
|
||||
|
||||
Singletons.getModel().getGame().getTriggerHandler().runTrigger(TriggerType.Clashed, runParams, false);
|
||||
|
||||
sa.getSourceCard().getGame().getTriggerHandler().runTrigger(TriggerType.Clashed, runParams, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,10 +2,10 @@ package forge.card.ability.effects;
|
||||
|
||||
|
||||
import forge.Card;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.GameState;
|
||||
|
||||
public class CleanUpEffect extends SpellAbilityEffect {
|
||||
|
||||
@@ -15,10 +15,11 @@ public class CleanUpEffect extends SpellAbilityEffect {
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
Card source = sa.getSourceCard();
|
||||
final GameState game = source.getGame();
|
||||
|
||||
if (sa.hasParam("ClearRemembered")) {
|
||||
source.clearRemembered();
|
||||
Singletons.getModel().getGame().getCardState(source).clearRemembered();
|
||||
game.getCardState(source).clearRemembered();
|
||||
}
|
||||
if (sa.hasParam("ForgetDefined")) {
|
||||
for (final Card card : AbilityUtils.getDefinedCards(source, sa.getParam("ForgetDefined"), sa)) {
|
||||
@@ -32,7 +33,7 @@ public class CleanUpEffect extends SpellAbilityEffect {
|
||||
source.setSVar("ChosenX", "");
|
||||
}
|
||||
if (sa.hasParam("ClearTriggered")) {
|
||||
Singletons.getModel().getGame().getTriggerHandler().clearDelayedTrigger(source);
|
||||
game.getTriggerHandler().clearDelayedTrigger(source);
|
||||
}
|
||||
if (sa.hasParam("ClearCoinFlips")) {
|
||||
source.clearFlipResult();
|
||||
|
||||
@@ -18,6 +18,7 @@ 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.gui.GuiDialog;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
|
||||
@@ -199,11 +200,12 @@ public class CloneEffect extends SpellAbilityEffect {
|
||||
}
|
||||
};
|
||||
|
||||
final GameState game = sa.getActivatingPlayer().getGame();
|
||||
String duration = sa.getParam("Duration");
|
||||
if (duration.equals("UntilEndOfTurn")) {
|
||||
Singletons.getModel().getGame().getEndOfTurn().addUntil(unclone);
|
||||
game.getEndOfTurn().addUntil(unclone);
|
||||
} else if (duration.equals("UntilYourNextTurn")) {
|
||||
Singletons.getModel().getGame().getCleanup().addUntil(host.getController(), unclone);
|
||||
game.getCleanup().addUntil(host.getController(), unclone);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import forge.Card;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
@@ -67,7 +66,7 @@ public class ControlExchangeEffect extends SpellAbilityEffect {
|
||||
}
|
||||
|
||||
final Player player2 = object2.getController();
|
||||
final long tStamp = Singletons.getModel().getGame().getNextTimestamp();
|
||||
final long tStamp = sa.getActivatingPlayer().getGame().getNextTimestamp();
|
||||
object2.setController(object1.getController(), tStamp);
|
||||
object1.setController(player2, tStamp);
|
||||
}
|
||||
|
||||
@@ -6,13 +6,13 @@ import java.util.List;
|
||||
|
||||
import forge.Card;
|
||||
import forge.Command;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.card.spellability.Ability;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.game.GameState;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
@@ -85,8 +85,20 @@ public class ControlGainEffect extends SpellAbilityEffect {
|
||||
final List<String> lose = sa.hasParam("LoseControl") ? Arrays.asList(sa.getParam("LoseControl").split(",")) : null;
|
||||
|
||||
final Target tgt = sa.getTarget();
|
||||
final List<Player> controllers;
|
||||
|
||||
if (sa.hasParam("NewController")) {
|
||||
controllers = AbilityUtils.getDefinedPlayers(sa.getSourceCard(), sa.getParam("NewController"), sa);
|
||||
} else if (tgt != null && tgt.getTargetPlayers() != null && tgt.canTgtPlayer()) {
|
||||
controllers = tgt.getTargetPlayers();
|
||||
} else
|
||||
controllers = new ArrayList<Player>();
|
||||
|
||||
final Player newController = controllers.isEmpty() ? sa.getActivatingPlayer() : controllers.get(0);
|
||||
final GameState game = newController.getGame();
|
||||
|
||||
if (sa.hasParam("AllValid")) {
|
||||
tgtCards = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
tgtCards = game.getCardsIn(ZoneType.Battlefield);
|
||||
tgtCards = AbilityUtils.filterListByType(tgtCards, sa.getParam("AllValid"), sa);
|
||||
} else if (sa.hasParam("Defined")) {
|
||||
tgtCards = AbilityUtils.getDefinedCards(source, sa.getParam("Defined"), sa);
|
||||
@@ -94,21 +106,7 @@ public class ControlGainEffect extends SpellAbilityEffect {
|
||||
tgtCards = getTargetCards(sa);
|
||||
}
|
||||
|
||||
List<Player> controllers = new ArrayList<Player>();
|
||||
|
||||
if (sa.hasParam("NewController")) {
|
||||
controllers = AbilityUtils.getDefinedPlayers(sa.getSourceCard(), sa.getParam("NewController"), sa);
|
||||
} else if (tgt != null && tgt.getTargetPlayers() != null && tgt.canTgtPlayer()) {
|
||||
controllers = tgt.getTargetPlayers();
|
||||
}
|
||||
|
||||
Player newController;
|
||||
|
||||
if (controllers.size() == 0) {
|
||||
newController = sa.getActivatingPlayer();
|
||||
} else {
|
||||
newController = controllers.get(0);
|
||||
}
|
||||
// check for lose control criteria right away
|
||||
if (lose != null && lose.contains("LeavesPlay") && !source.isInZone(ZoneType.Battlefield)) {
|
||||
return;
|
||||
@@ -127,7 +125,7 @@ public class ControlGainEffect extends SpellAbilityEffect {
|
||||
return;
|
||||
}
|
||||
|
||||
long tStamp = Singletons.getModel().getGame().getNextTimestamp();
|
||||
long tStamp = game.getNextTimestamp();
|
||||
if (lose != null) {
|
||||
tgtC.addTempController(newController, tStamp);
|
||||
} else {
|
||||
@@ -155,7 +153,7 @@ public class ControlGainEffect extends SpellAbilityEffect {
|
||||
sa.getSourceCard().addChangeControllerCommand(this.getLoseControlCommand(tgtC, tStamp, bTapOnLose, source, kws));
|
||||
}
|
||||
if (lose.contains("EOT")) {
|
||||
Singletons.getModel().getGame().getEndOfTurn().addAt(this.getLoseControlCommand(tgtC, tStamp, bTapOnLose, source, kws));
|
||||
game.getEndOfTurn().addAt(this.getLoseControlCommand(tgtC, tStamp, bTapOnLose, source, kws));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,14 +190,15 @@ public class ControlGainEffect extends SpellAbilityEffect {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
final GameState game = hostCard.getGame();
|
||||
final Ability ability = new Ability(hostCard, ManaCost.ZERO) {
|
||||
@Override
|
||||
public void resolve() {
|
||||
|
||||
if (bNoRegen) {
|
||||
Singletons.getModel().getGame().getAction().destroyNoRegeneration(c, null);
|
||||
game.getAction().destroyNoRegeneration(c, null);
|
||||
} else {
|
||||
Singletons.getModel().getGame().getAction().destroy(c, null);
|
||||
game.getAction().destroy(c, null);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -210,7 +209,7 @@ public class ControlGainEffect extends SpellAbilityEffect {
|
||||
}
|
||||
ability.setStackDescription(sb.toString());
|
||||
|
||||
Singletons.getModel().getGame().getStack().addSimultaneousStackEntry(ability);
|
||||
game.getStack().addSimultaneousStackEntry(ability);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -15,7 +15,6 @@ import forge.Card;
|
||||
import forge.CardCharacteristicName;
|
||||
import forge.CardLists;
|
||||
import forge.Command;
|
||||
import forge.Singletons;
|
||||
import forge.card.CardRulesPredicates;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
@@ -25,6 +24,7 @@ import forge.card.mana.ManaCost;
|
||||
import forge.card.spellability.Ability;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.game.GameState;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.game.player.HumanPlayer;
|
||||
import forge.game.player.Player;
|
||||
@@ -56,6 +56,7 @@ public class CopyPermanentEffect extends SpellAbilityEffect {
|
||||
@Override
|
||||
public void resolve(final SpellAbility sa) {
|
||||
final Card hostCard = sa.getSourceCard();
|
||||
final GameState game = hostCard.getGame();
|
||||
final ArrayList<String> keywords = new ArrayList<String>();
|
||||
if (sa.hasParam("Keywords")) {
|
||||
keywords.addAll(Arrays.asList(sa.getParam("Keywords").split(" & ")));
|
||||
@@ -224,7 +225,7 @@ public class CopyPermanentEffect extends SpellAbilityEffect {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
copy = Singletons.getModel().getGame().getAction().moveToPlay(copy);
|
||||
copy = game.getAction().moveToPlay(copy);
|
||||
|
||||
copy.setCloneOrigin(hostCard);
|
||||
sa.getSourceCard().addClone(copy);
|
||||
@@ -255,9 +256,9 @@ public class CopyPermanentEffect extends SpellAbilityEffect {
|
||||
if (sa.getParam("AtEOT").equals("Sacrifice")) {
|
||||
// maybe do a setSacrificeAtEOT, but
|
||||
// probably not.
|
||||
Singletons.getModel().getGame().getAction().sacrifice(target[index], sa);
|
||||
game.getAction().sacrifice(target[index], sa);
|
||||
} else if (sa.getParam("AtEOT").equals("Exile")) {
|
||||
Singletons.getModel().getGame().getAction().exile(target[index]);
|
||||
game.getAction().exile(target[index]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -270,11 +271,11 @@ public class CopyPermanentEffect extends SpellAbilityEffect {
|
||||
@Override
|
||||
public void run() {
|
||||
sac.setStackDescription(sa.getParam("AtEOT") + " " + target[index] + ".");
|
||||
Singletons.getModel().getGame().getStack().addSimultaneousStackEntry(sac);
|
||||
game.getStack().addSimultaneousStackEntry(sac);
|
||||
}
|
||||
}; // Command
|
||||
if (sa.hasParam("AtEOT")) {
|
||||
Singletons.getModel().getGame().getEndOfTurn().addAt(atEOT);
|
||||
game.getEndOfTurn().addAt(atEOT);
|
||||
}
|
||||
// end copied Kiki code
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import forge.Card;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.game.GameState;
|
||||
import forge.game.player.AIPlayer;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.SpellAbilityStackInstance;
|
||||
@@ -18,14 +18,15 @@ import forge.gui.GuiChoose;
|
||||
public class CounterEffect extends SpellAbilityEffect {
|
||||
@Override
|
||||
protected String getStackDescription(SpellAbility sa) {
|
||||
final GameState game = sa.getActivatingPlayer().getGame();
|
||||
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
final List<SpellAbility> sas;
|
||||
|
||||
if (sa.hasParam("AllType")) {
|
||||
sas = new ArrayList<SpellAbility>();
|
||||
for (int i = 0; i < Singletons.getModel().getGame().getStack().size(); i++) {
|
||||
SpellAbility spell = Singletons.getModel().getGame().getStack().peekAbility(i);
|
||||
for (int i = 0; i < game.getStack().size(); i++) {
|
||||
SpellAbility spell = game.getStack().peekAbility(i);
|
||||
if (sa.getParam("AllType").equals("Spell") && !spell.isSpell()) {
|
||||
continue;
|
||||
}
|
||||
@@ -62,14 +63,15 @@ public class CounterEffect extends SpellAbilityEffect {
|
||||
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
final GameState game = sa.getActivatingPlayer().getGame();
|
||||
// TODO Before this resolves we should see if any of our targets are
|
||||
// still on the stack
|
||||
final List<SpellAbility> sas;
|
||||
|
||||
if (sa.hasParam("AllType")) {
|
||||
sas = new ArrayList<SpellAbility>();
|
||||
for (int i = 0; i < Singletons.getModel().getGame().getStack().size(); i++) {
|
||||
SpellAbility spell = Singletons.getModel().getGame().getStack().peekAbility(i);
|
||||
for (int i = 0; i < game.getStack().size(); i++) {
|
||||
SpellAbility spell = game.getStack().peekAbility(i);
|
||||
if (sa.getParam("AllType").equals("Spell") && !spell.isSpell()) {
|
||||
continue;
|
||||
}
|
||||
@@ -97,7 +99,7 @@ public class CounterEffect extends SpellAbilityEffect {
|
||||
continue;
|
||||
}
|
||||
|
||||
final SpellAbilityStackInstance si = Singletons.getModel().getGame().getStack().getInstanceFromSpellAbility(tgtSA);
|
||||
final SpellAbilityStackInstance si = game.getStack().getInstanceFromSpellAbility(tgtSA);
|
||||
if (si == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -106,7 +108,7 @@ public class CounterEffect extends SpellAbilityEffect {
|
||||
|
||||
// Destroy Permanent may be able to be turned into a SubAbility
|
||||
if (tgtSA.isAbility() && sa.hasParam("DestroyPermanent")) {
|
||||
Singletons.getModel().getGame().getAction().destroy(tgtSACard, sa);
|
||||
game.getAction().destroy(tgtSACard, sa);
|
||||
}
|
||||
|
||||
if (sa.hasParam("RememberCountered")) {
|
||||
@@ -132,7 +134,8 @@ public class CounterEffect extends SpellAbilityEffect {
|
||||
* @param sa
|
||||
*/
|
||||
private void removeFromStack(final SpellAbility tgtSA, final SpellAbility srcSA, final SpellAbilityStackInstance si) {
|
||||
Singletons.getModel().getGame().getStack().remove(si);
|
||||
final GameState game = tgtSA.getActivatingPlayer().getGame();
|
||||
game.getStack().remove(si);
|
||||
|
||||
String destination = srcSA.hasParam("Destination") ? srcSA.getParam("Destination") : "Graveyard";
|
||||
if (srcSA.hasParam("DestinationChoice")) {//Hinder
|
||||
@@ -148,29 +151,29 @@ public class CounterEffect extends SpellAbilityEffect {
|
||||
// For Ability-targeted counterspells - do not move it anywhere,
|
||||
// even if Destination$ is specified.
|
||||
} else if (tgtSA.isFlashBackAbility()) {
|
||||
Singletons.getModel().getGame().getAction().exile(tgtSA.getSourceCard());
|
||||
game.getAction().exile(tgtSA.getSourceCard());
|
||||
} else if (destination.equals("Graveyard")) {
|
||||
Singletons.getModel().getGame().getAction().moveToGraveyard(tgtSA.getSourceCard());
|
||||
game.getAction().moveToGraveyard(tgtSA.getSourceCard());
|
||||
} else if (destination.equals("Exile")) {
|
||||
Singletons.getModel().getGame().getAction().exile(tgtSA.getSourceCard());
|
||||
game.getAction().exile(tgtSA.getSourceCard());
|
||||
} else if (destination.equals("TopOfLibrary")) {
|
||||
Singletons.getModel().getGame().getAction().moveToLibrary(tgtSA.getSourceCard());
|
||||
game.getAction().moveToLibrary(tgtSA.getSourceCard());
|
||||
} else if (destination.equals("Hand")) {
|
||||
Singletons.getModel().getGame().getAction().moveToHand(tgtSA.getSourceCard());
|
||||
game.getAction().moveToHand(tgtSA.getSourceCard());
|
||||
} else if (destination.equals("Battlefield")) {
|
||||
if (tgtSA instanceof SpellPermanent) {
|
||||
Card c = tgtSA.getSourceCard();
|
||||
System.out.println(c + " is SpellPermanent");
|
||||
c.setController(srcSA.getActivatingPlayer(), 0);
|
||||
Singletons.getModel().getGame().getAction().moveToPlay(c, srcSA.getActivatingPlayer());
|
||||
game.getAction().moveToPlay(c, srcSA.getActivatingPlayer());
|
||||
} else {
|
||||
Card c = Singletons.getModel().getGame().getAction().moveToPlay(tgtSA.getSourceCard(), srcSA.getActivatingPlayer());
|
||||
Card c = game.getAction().moveToPlay(tgtSA.getSourceCard(), srcSA.getActivatingPlayer());
|
||||
c.setController(srcSA.getActivatingPlayer(), 0);
|
||||
}
|
||||
} else if (destination.equals("BottomOfLibrary")) {
|
||||
Singletons.getModel().getGame().getAction().moveToBottomOfLibrary(tgtSA.getSourceCard());
|
||||
game.getAction().moveToBottomOfLibrary(tgtSA.getSourceCard());
|
||||
} else if (destination.equals("ShuffleIntoLibrary")) {
|
||||
Singletons.getModel().getGame().getAction().moveToBottomOfLibrary(tgtSA.getSourceCard());
|
||||
game.getAction().moveToBottomOfLibrary(tgtSA.getSourceCard());
|
||||
tgtSA.getSourceCard().getController().shuffle();
|
||||
} else {
|
||||
throw new IllegalArgumentException("AbilityFactory_CounterMagic: Invalid Destination argument for card "
|
||||
|
||||
@@ -10,9 +10,7 @@ import forge.CardLists;
|
||||
import forge.CounterType;
|
||||
import forge.FThreads;
|
||||
import forge.GameEntity;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.control.input.InputProliferate;
|
||||
import forge.game.player.Player;
|
||||
@@ -58,10 +56,10 @@ public class CountersProliferateEffect extends SpellAbilityEffect {
|
||||
@Override
|
||||
public boolean apply(Card crd) {
|
||||
for (final Entry<CounterType, Integer> c1 : crd.getCounters().entrySet()) {
|
||||
if (CardFactoryUtil.isNegativeCounter(c1.getKey()) && enemies.contains(crd.getController())) {
|
||||
if (c1.getKey().isNegativeCounter() && enemies.contains(crd.getController())) {
|
||||
return true;
|
||||
}
|
||||
if (!CardFactoryUtil.isNegativeCounter(c1.getKey()) && allies.contains(crd.getController())) {
|
||||
if (!c1.getKey().isNegativeCounter() && allies.contains(crd.getController())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -69,7 +67,7 @@ public class CountersProliferateEffect extends SpellAbilityEffect {
|
||||
}
|
||||
};
|
||||
|
||||
List<Card> cardsToProliferate = CardLists.filter(Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield), predProliferate);
|
||||
List<Card> cardsToProliferate = CardLists.filter(ai.getGame().getCardsIn(ZoneType.Battlefield), predProliferate);
|
||||
List<Player> playersToPoison = new ArrayList<Player>();
|
||||
for (Player e : enemies) {
|
||||
if (e.getPoisonCounters() > 0) {
|
||||
@@ -104,12 +102,12 @@ public class CountersProliferateEffect extends SpellAbilityEffect {
|
||||
// computer
|
||||
for (final Card c : cardsToProliferate) {
|
||||
for (final Entry<CounterType, Integer> c1 : c.getCounters().entrySet()) {
|
||||
if (CardFactoryUtil.isNegativeCounter(c1.getKey()) && enemies.contains(c.getController()))
|
||||
if (c1.getKey().isNegativeCounter() && enemies.contains(c.getController()))
|
||||
{
|
||||
c.addCounter(c1.getKey(), 1, true);
|
||||
break;
|
||||
}
|
||||
if (!CardFactoryUtil.isNegativeCounter(c1.getKey()) && allies.contains(c.getController()))
|
||||
if (!c1.getKey().isNegativeCounter() && allies.contains(c.getController()))
|
||||
{
|
||||
c.addCounter(c1.getKey(), 1, true);
|
||||
break;
|
||||
|
||||
@@ -5,11 +5,11 @@ import java.util.List;
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CounterType;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.game.GameState;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
@@ -43,8 +43,9 @@ public class CountersPutAllEffect extends SpellAbilityEffect {
|
||||
final int counterAmount = AbilityUtils.calculateAmount(sa.getSourceCard(), sa.getParam("CounterNum"), sa);
|
||||
final String valid = sa.getParam("ValidCards");
|
||||
final ZoneType zone = sa.hasParam("ValidZone") ? ZoneType.smartValueOf(sa.getParam("ValidZone")) : ZoneType.Battlefield;
|
||||
final GameState game = sa.getActivatingPlayer().getGame();
|
||||
|
||||
List<Card> cards = Singletons.getModel().getGame().getCardsIn(zone);
|
||||
List<Card> cards = game.getCardsIn(zone);
|
||||
cards = CardLists.getValidCards(cards, valid, sa.getSourceCard().getController(), sa.getSourceCard());
|
||||
|
||||
final Target tgt = sa.getTarget();
|
||||
@@ -54,7 +55,7 @@ public class CountersPutAllEffect extends SpellAbilityEffect {
|
||||
}
|
||||
|
||||
for (final Card tgtCard : cards) {
|
||||
if (Singletons.getModel().getGame().getZoneOf(tgtCard).is(ZoneType.Battlefield)) {
|
||||
if (game.getZoneOf(tgtCard).is(ZoneType.Battlefield)) {
|
||||
tgtCard.addCounter(CounterType.valueOf(type), counterAmount, true);
|
||||
} else {
|
||||
// adding counters to something like re-suspend cards
|
||||
|
||||
@@ -6,7 +6,6 @@ import java.util.List;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CounterType;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
@@ -108,7 +107,7 @@ public class CountersPutEffect extends SpellAbilityEffect {
|
||||
if (max != -1) {
|
||||
counterAmount = max - tgtCard.getCounters(counterType);
|
||||
}
|
||||
final Zone zone = Singletons.getModel().getGame().getZoneOf(tgtCard);
|
||||
final Zone zone = tgtCard.getGame().getZoneOf(tgtCard);
|
||||
if (zone == null || zone.is(ZoneType.Battlefield) || zone.is(ZoneType.Stack)) {
|
||||
if (remember) {
|
||||
final int value = tgtCard.getTotalCountersToAdd(counterType, counterAmount, true);
|
||||
|
||||
@@ -5,11 +5,11 @@ import java.util.List;
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CounterType;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.game.GameState;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
@@ -47,8 +47,9 @@ public class CountersRemoveAllEffect extends SpellAbilityEffect {
|
||||
int counterAmount = AbilityUtils.calculateAmount(sa.getSourceCard(), sa.getParam("CounterNum"), sa);
|
||||
final String valid = sa.getParam("ValidCards");
|
||||
final ZoneType zone = sa.hasParam("ValidZone") ? ZoneType.smartValueOf(sa.getParam("ValidZone")) : ZoneType.Battlefield;
|
||||
|
||||
List<Card> cards = Singletons.getModel().getGame().getCardsIn(zone);
|
||||
final GameState game = sa.getActivatingPlayer().getGame();
|
||||
|
||||
List<Card> cards = game.getCardsIn(zone);
|
||||
cards = CardLists.getValidCards(cards, valid, sa.getSourceCard().getController(), sa.getSourceCard());
|
||||
|
||||
final Target tgt = sa.getTarget();
|
||||
|
||||
@@ -6,11 +6,11 @@ import java.util.Map;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CounterType;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.game.GameState;
|
||||
import forge.game.zone.Zone;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.gui.GuiChoose;
|
||||
@@ -55,6 +55,7 @@ public class CountersRemoveEffect extends SpellAbilityEffect {
|
||||
public void resolve(SpellAbility sa) {
|
||||
|
||||
final Card card = sa.getSourceCard();
|
||||
final GameState game = card.getGame();
|
||||
final String type = sa.getParam("CounterType");
|
||||
int counterAmount = 0;
|
||||
if (!sa.getParam("CounterNum").equals("All") && !sa.getParam("CounterNum").equals("Remembered")) {
|
||||
@@ -80,7 +81,7 @@ public class CountersRemoveEffect extends SpellAbilityEffect {
|
||||
}
|
||||
for (final Card tgtCard : getTargetCards(sa)) {
|
||||
if ((tgt == null) || tgtCard.canBeTargetedBy(sa)) {
|
||||
final Zone zone = Singletons.getModel().getGame().getZoneOf(tgtCard);
|
||||
final Zone zone = game.getZoneOf(tgtCard);
|
||||
if (sa.getParam("CounterNum").equals("All")) {
|
||||
counterAmount = tgtCard.getCounters(counterType);
|
||||
} else if (sa.getParam("CounterNum").equals("Remembered")) {
|
||||
|
||||
@@ -5,11 +5,11 @@ import java.util.List;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.game.GameState;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
@@ -46,6 +46,7 @@ public class DamageAllEffect extends SpellAbilityEffect {
|
||||
final List<Card> definedSources = AbilityUtils.getDefinedCards(sa.getSourceCard(), sa.getParam("DamageSource"), sa);
|
||||
final Card card = definedSources.get(0);
|
||||
final Card source = sa.getSourceCard();
|
||||
final GameState game = sa.getActivatingPlayer().getGame();
|
||||
|
||||
final String damage = sa.getParam("NumDmg");
|
||||
final int dmg = AbilityUtils.calculateAmount(sa.getSourceCard(), damage, sa);
|
||||
@@ -64,7 +65,7 @@ public class DamageAllEffect extends SpellAbilityEffect {
|
||||
}
|
||||
|
||||
if (sa.hasParam("ValidCards")) {
|
||||
list = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
list = game.getCardsIn(ZoneType.Battlefield);
|
||||
}
|
||||
|
||||
if (targetPlayer != null) {
|
||||
|
||||
@@ -5,7 +5,6 @@ import java.util.List;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
@@ -61,7 +60,7 @@ public class DamageEachEffect extends SpellAbilityEffect {
|
||||
public void resolve(SpellAbility sa) {
|
||||
final Card card = sa.getSourceCard();
|
||||
|
||||
List<Card> sources = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
List<Card> sources = card.getGame().getCardsIn(ZoneType.Battlefield);
|
||||
if (sa.hasParam("ValidCards")) {
|
||||
sources = CardLists.getValidCards(sources, sa.getParam("ValidCards"), card.getController(), card);
|
||||
}
|
||||
|
||||
@@ -4,10 +4,10 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import forge.Card;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.GameState;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
@@ -19,6 +19,7 @@ public class DamagePreventAllEffect extends SpellAbilityEffect {
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final GameState game = sa.getActivatingPlayer().getGame();
|
||||
final int numDam = AbilityUtils.calculateAmount(sa.getSourceCard(), sa.getParam("Amount"), sa);
|
||||
|
||||
String players = "";
|
||||
@@ -29,7 +30,7 @@ public class DamagePreventAllEffect extends SpellAbilityEffect {
|
||||
}
|
||||
|
||||
if (sa.hasParam("ValidCards")) {
|
||||
list = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
list = game.getCardsIn(ZoneType.Battlefield);
|
||||
}
|
||||
|
||||
list = AbilityUtils.filterListByType(list, sa.getParam("ValidCards"), sa);
|
||||
@@ -39,7 +40,7 @@ public class DamagePreventAllEffect extends SpellAbilityEffect {
|
||||
}
|
||||
|
||||
if (!players.equals("")) {
|
||||
final ArrayList<Player> playerList = new ArrayList<Player>(Singletons.getModel().getGame().getPlayers());
|
||||
final ArrayList<Player> playerList = new ArrayList<Player>(game.getPlayers());
|
||||
for (final Player p : playerList) {
|
||||
if (p.isValid(players, source.getController(), source)) {
|
||||
p.addPreventNextDamage(numDam);
|
||||
|
||||
@@ -7,9 +7,9 @@ import java.util.List;
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.Command;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.GameState;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
public class DebuffAllEffect extends SpellAbilityEffect {
|
||||
@@ -40,6 +40,7 @@ public class DebuffAllEffect extends SpellAbilityEffect {
|
||||
public void resolve(SpellAbility sa) {
|
||||
final Card hostCard = sa.getSourceCard();
|
||||
final List<String> kws = sa.hasParam("Keywords") ? Arrays.asList(sa.getParam("Keywords").split(" & ")) : new ArrayList<String>();
|
||||
final GameState game = sa.getActivatingPlayer().getGame();
|
||||
|
||||
String valid = "";
|
||||
|
||||
@@ -47,7 +48,7 @@ public class DebuffAllEffect extends SpellAbilityEffect {
|
||||
valid = sa.getParam("ValidCards");
|
||||
}
|
||||
|
||||
List<Card> list = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
List<Card> list = game.getCardsIn(ZoneType.Battlefield);
|
||||
list = CardLists.getValidCards(list, valid.split(","), hostCard.getController(), hostCard);
|
||||
|
||||
for (final Card tgtC : list) {
|
||||
@@ -62,7 +63,7 @@ public class DebuffAllEffect extends SpellAbilityEffect {
|
||||
}
|
||||
}
|
||||
if (!sa.hasParam("Permanent")) {
|
||||
Singletons.getModel().getGame().getEndOfTurn().addUntil(new Command() {
|
||||
game.getEndOfTurn().addUntil(new Command() {
|
||||
private static final long serialVersionUID = 7486231071095628674L;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,9 +7,9 @@ import java.util.List;
|
||||
|
||||
import forge.Card;
|
||||
import forge.Command;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.GameState;
|
||||
|
||||
public class DebuffEffect extends SpellAbilityEffect {
|
||||
|
||||
@@ -56,6 +56,7 @@ public class DebuffEffect extends SpellAbilityEffect {
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
final List<String> kws = sa.hasParam("Keywords") ? Arrays.asList(sa.getParam("Keywords").split(" & ")) : new ArrayList<String>();
|
||||
final GameState game = sa.getActivatingPlayer().getGame();
|
||||
|
||||
for (final Card tgtC : getTargetCards(sa)) {
|
||||
final ArrayList<String> hadIntrinsic = new ArrayList<String>();
|
||||
@@ -69,7 +70,7 @@ public class DebuffEffect extends SpellAbilityEffect {
|
||||
}
|
||||
}
|
||||
if (!sa.hasParam("Permanent")) {
|
||||
Singletons.getModel().getGame().getEndOfTurn().addUntil(new Command() {
|
||||
game.getEndOfTurn().addUntil(new Command() {
|
||||
private static final long serialVersionUID = 5387486776282932314L;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,7 +3,6 @@ package forge.card.ability.effects;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.trigger.Trigger;
|
||||
@@ -40,6 +39,6 @@ public class DelayedTriggerEffect extends SpellAbilityEffect {
|
||||
|
||||
final Trigger delTrig = TriggerHandler.parseTrigger(mapParams, sa.getSourceCard(), true);
|
||||
|
||||
Singletons.getModel().getGame().getTriggerHandler().registerDelayedTrigger(delTrig);
|
||||
sa.getActivatingPlayer().getGame().getTriggerHandler().registerDelayedTrigger(delTrig);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,11 +5,11 @@ import java.util.List;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.game.GameState;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
@@ -48,6 +48,7 @@ public class DestroyAllEffect extends SpellAbilityEffect {
|
||||
|
||||
final boolean noRegen = sa.hasParam("NoRegen");
|
||||
final Card card = sa.getSourceCard();
|
||||
final GameState game = sa.getActivatingPlayer().getGame();
|
||||
|
||||
final Target tgt = sa.getTarget();
|
||||
Player targetPlayer = null;
|
||||
@@ -72,7 +73,7 @@ public class DestroyAllEffect extends SpellAbilityEffect {
|
||||
valid = valid.replace("X", Integer.toString(AbilityUtils.calculateAmount(card, "X", sa)));
|
||||
}
|
||||
|
||||
List<Card> list = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
List<Card> list = game.getCardsIn(ZoneType.Battlefield);
|
||||
|
||||
if (targetPlayer != null) {
|
||||
list = CardLists.filterControlledBy(list, targetPlayer);
|
||||
@@ -87,13 +88,13 @@ public class DestroyAllEffect extends SpellAbilityEffect {
|
||||
|
||||
if (noRegen) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
if (Singletons.getModel().getGame().getAction().destroyNoRegeneration(list.get(i), sa) && remDestroyed) {
|
||||
if (game.getAction().destroyNoRegeneration(list.get(i), sa) && remDestroyed) {
|
||||
card.addRemembered(list.get(i));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
if (Singletons.getModel().getGame().getAction().destroy(list.get(i), sa) && remDestroyed) {
|
||||
if (game.getAction().destroy(list.get(i), sa) && remDestroyed) {
|
||||
card.addRemembered(list.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@ import java.util.List;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardUtil;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.game.GameState;
|
||||
|
||||
public class DestroyEffect extends SpellAbilityEffect {
|
||||
/* (non-Javadoc)
|
||||
@@ -69,6 +69,7 @@ public class DestroyEffect extends SpellAbilityEffect {
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
final Card card = sa.getSourceCard();
|
||||
final GameState game = card.getGame();
|
||||
|
||||
final boolean remDestroyed = sa.hasParam("RememberDestroyed");
|
||||
if (remDestroyed) {
|
||||
@@ -94,11 +95,11 @@ public class DestroyEffect extends SpellAbilityEffect {
|
||||
if (tgtC.isInPlay() && ((tgt == null) || tgtC.canBeTargetedBy(sa))) {
|
||||
boolean destroyed = false;
|
||||
if (sac) {
|
||||
destroyed = Singletons.getModel().getGame().getAction().sacrifice(tgtC, sa);
|
||||
destroyed = game.getAction().sacrifice(tgtC, sa);
|
||||
} else if (noRegen) {
|
||||
destroyed = Singletons.getModel().getGame().getAction().destroyNoRegeneration(tgtC, sa);
|
||||
destroyed = game.getAction().destroyNoRegeneration(tgtC, sa);
|
||||
} else {
|
||||
destroyed = Singletons.getModel().getGame().getAction().destroy(tgtC, sa);
|
||||
destroyed = game.getAction().destroy(tgtC, sa);
|
||||
} if (destroyed && remDestroyed) {
|
||||
card.addRemembered(tgtC);
|
||||
}
|
||||
@@ -109,11 +110,11 @@ public class DestroyEffect extends SpellAbilityEffect {
|
||||
if (unTgtC.isInPlay()) {
|
||||
boolean destroyed = false;
|
||||
if (sac) {
|
||||
destroyed = Singletons.getModel().getGame().getAction().sacrifice(unTgtC, sa);
|
||||
destroyed = game.getAction().sacrifice(unTgtC, sa);
|
||||
} else if (noRegen) {
|
||||
destroyed = Singletons.getModel().getGame().getAction().destroyNoRegeneration(unTgtC, sa);
|
||||
destroyed = game.getAction().destroyNoRegeneration(unTgtC, sa);
|
||||
} else {
|
||||
destroyed = Singletons.getModel().getGame().getAction().destroy(unTgtC, sa);
|
||||
destroyed = game.getAction().destroy(unTgtC, sa);
|
||||
} if (destroyed && remDestroyed) {
|
||||
card.addRemembered(unTgtC);
|
||||
}
|
||||
|
||||
@@ -9,11 +9,11 @@ import java.util.Random;
|
||||
import forge.Card;
|
||||
import forge.CardCharacteristicName;
|
||||
import forge.CardLists;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.game.GameState;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.PlayerZone;
|
||||
@@ -52,6 +52,7 @@ public class DigEffect extends SpellAbilityEffect {
|
||||
public void resolve(SpellAbility sa) {
|
||||
final Card host = sa.getSourceCard();
|
||||
final Player player = sa.getActivatingPlayer();
|
||||
final GameState game = player.getGame();
|
||||
Player choser = player;
|
||||
int numToDig = AbilityUtils.calculateAmount(host, sa.getParam("DigNum"), sa);
|
||||
final ZoneType destZone1 = sa.hasParam("DestinationZone") ? ZoneType.smartValueOf(sa.getParam("DestinationZone"))
|
||||
@@ -161,7 +162,7 @@ public class DigEffect extends SpellAbilityEffect {
|
||||
rest.add(c);
|
||||
}
|
||||
if (mitosis) {
|
||||
valid = sharesNameWithCardOnBattlefield(top);
|
||||
valid = sharesNameWithCardOnBattlefield(game, top);
|
||||
} else if (!changeValid.equals("")) {
|
||||
if (changeValid.contains("ChosenType")) {
|
||||
changeValid = changeValid.replace("ChosenType", host.getChosenType());
|
||||
@@ -283,9 +284,9 @@ public class DigEffect extends SpellAbilityEffect {
|
||||
}
|
||||
final PlayerZone zone = c.getOwner().getZone(destZone1);
|
||||
if (zone.is(ZoneType.Library)) {
|
||||
Singletons.getModel().getGame().getAction().moveToLibrary(c, libraryPosition);
|
||||
game.getAction().moveToLibrary(c, libraryPosition);
|
||||
} else {
|
||||
c = Singletons.getModel().getGame().getAction().moveTo(zone, c);
|
||||
c = game.getAction().moveTo(zone, c);
|
||||
if (destZone1.equals(ZoneType.Battlefield)) {
|
||||
for (final String kw : keywords) {
|
||||
c.addExtrinsicKeyword(kw);
|
||||
@@ -328,12 +329,12 @@ public class DigEffect extends SpellAbilityEffect {
|
||||
} else {
|
||||
chosen = rest.get(0);
|
||||
}
|
||||
Singletons.getModel().getGame().getAction().moveToLibrary(chosen, libraryPosition2);
|
||||
game.getAction().moveToLibrary(chosen, libraryPosition2);
|
||||
rest.remove(chosen);
|
||||
}
|
||||
} else { // Computer
|
||||
for (int i = 0; i < rest.size(); i++) {
|
||||
Singletons.getModel().getGame().getAction().moveToLibrary(rest.get(i), libraryPosition2);
|
||||
game.getAction().moveToLibrary(rest.get(i), libraryPosition2);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -341,7 +342,7 @@ public class DigEffect extends SpellAbilityEffect {
|
||||
for (int i = 0; i < rest.size(); i++) {
|
||||
Card c = rest.get(i);
|
||||
final PlayerZone toZone = c.getOwner().getZone(destZone2);
|
||||
c = Singletons.getModel().getGame().getAction().moveTo(toZone, c);
|
||||
c = game.getAction().moveTo(toZone, c);
|
||||
if (destZone2.equals(ZoneType.Battlefield) && !keywords.isEmpty()) {
|
||||
for (final String kw : keywords) {
|
||||
c.addExtrinsicKeyword(kw);
|
||||
@@ -366,9 +367,9 @@ public class DigEffect extends SpellAbilityEffect {
|
||||
* a {@link forge.CardList} object.
|
||||
* @return a {@link forge.CardList} object.
|
||||
*/
|
||||
private List<Card> sharesNameWithCardOnBattlefield(final List<Card> list) {
|
||||
private List<Card> sharesNameWithCardOnBattlefield(final GameState game, final List<Card> list) {
|
||||
final List<Card> toReturn = new ArrayList<Card>();
|
||||
final List<Card> play = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
final List<Card> play = game.getCardsIn(ZoneType.Battlefield);
|
||||
for (final Card c : list) {
|
||||
for (final Card p : play) {
|
||||
if (p.getName().equals(c.getName()) && !toReturn.contains(c)) {
|
||||
|
||||
@@ -5,11 +5,11 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import forge.Card;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.game.GameState;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.PlayerZone;
|
||||
import forge.game.zone.ZoneType;
|
||||
@@ -124,6 +124,7 @@ public class DigUntilEffect extends SpellAbilityEffect {
|
||||
if (revealed.size() > 0) {
|
||||
GuiChoose.one(p + " revealed: ", revealed);
|
||||
}
|
||||
final GameState game = p.getGame();
|
||||
|
||||
// TODO Allow Human to choose the order
|
||||
if (foundDest != null) {
|
||||
@@ -131,12 +132,12 @@ public class DigUntilEffect extends SpellAbilityEffect {
|
||||
while (itr.hasNext()) {
|
||||
final Card c = itr.next();
|
||||
if (sa.hasParam("GainControl") && foundDest.equals(ZoneType.Battlefield)) {
|
||||
c.setController(sa.getActivatingPlayer(), Singletons.getModel().getGame().getNextTimestamp());
|
||||
Singletons.getModel().getGame().getAction().moveTo(c.getController().getZone(foundDest), c);
|
||||
c.setController(sa.getActivatingPlayer(), game.getNextTimestamp());
|
||||
game.getAction().moveTo(c.getController().getZone(foundDest), c);
|
||||
} else if (sa.hasParam("NoMoveFound") && foundDest.equals(ZoneType.Library)) {
|
||||
//Don't do anything
|
||||
} else {
|
||||
Singletons.getModel().getGame().getAction().moveTo(foundDest, c, foundLibPos);
|
||||
game.getAction().moveTo(foundDest, c, foundLibPos);
|
||||
}
|
||||
revealed.remove(c);
|
||||
}
|
||||
@@ -152,7 +153,7 @@ public class DigUntilEffect extends SpellAbilityEffect {
|
||||
final Iterator<Card> itr = revealed.iterator();
|
||||
while (itr.hasNext()) {
|
||||
final Card c = itr.next();
|
||||
Singletons.getModel().getGame().getAction().moveTo(revealedDest, c, revealedLibPos);
|
||||
game.getAction().moveTo(revealedDest, c, revealedLibPos);
|
||||
}
|
||||
|
||||
if (sa.hasParam("Shuffle")) {
|
||||
|
||||
@@ -11,6 +11,6 @@ import forge.card.spellability.SpellAbility;
|
||||
public class ETBReplacementEffect extends SpellAbilityEffect {
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
forge.Singletons.getModel().getGame().getAction().moveToPlay(((Card) sa.getReplacingObject("Card")));
|
||||
sa.getActivatingPlayer().getGame().getAction().moveToPlay(((Card) sa.getReplacingObject("Card")));
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import java.util.List;
|
||||
|
||||
import forge.Card;
|
||||
import forge.Command;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityFactory;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
@@ -14,6 +13,7 @@ import forge.card.spellability.SpellAbility;
|
||||
import forge.card.trigger.Trigger;
|
||||
import forge.card.trigger.TriggerHandler;
|
||||
import forge.card.trigger.TriggerType;
|
||||
import forge.game.GameState;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
@@ -37,6 +37,7 @@ public class EffectEffect extends SpellAbilityEffect {
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
final Card hostCard = sa.getSourceCard();
|
||||
final GameState game = hostCard.getGame();
|
||||
|
||||
String[] effectAbilities = null;
|
||||
String[] effectTriggers = null;
|
||||
@@ -87,7 +88,7 @@ public class EffectEffect extends SpellAbilityEffect {
|
||||
}
|
||||
|
||||
// Unique Effects shouldn't be duplicated
|
||||
if (sa.hasParam("Unique") && Singletons.getModel().getGame().isCardInCommand(name)) {
|
||||
if (sa.hasParam("Unique") && game.isCardInCommand(name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -186,7 +187,7 @@ public class EffectEffect extends SpellAbilityEffect {
|
||||
|
||||
// Remember created effect
|
||||
if (sa.hasParam("RememberEffect")) {
|
||||
Singletons.getModel().getGame().getCardState(hostCard).addRemembered(eff);
|
||||
game.getCardState(hostCard).addRemembered(eff);
|
||||
}
|
||||
|
||||
// Duration
|
||||
@@ -197,29 +198,29 @@ public class EffectEffect extends SpellAbilityEffect {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Singletons.getModel().getGame().getAction().exile(e);
|
||||
game.getAction().exile(e);
|
||||
}
|
||||
};
|
||||
|
||||
if ((duration == null) || duration.equals("EndOfTurn")) {
|
||||
Singletons.getModel().getGame().getEndOfTurn().addUntil(endEffect);
|
||||
game.getEndOfTurn().addUntil(endEffect);
|
||||
}
|
||||
else if (duration.equals("UntilHostLeavesPlay")) {
|
||||
hostCard.addLeavesPlayCommand(endEffect);
|
||||
}
|
||||
else if (duration.equals("HostLeavesOrEOT")) {
|
||||
Singletons.getModel().getGame().getEndOfTurn().addUntil(endEffect);
|
||||
game.getEndOfTurn().addUntil(endEffect);
|
||||
hostCard.addLeavesPlayCommand(endEffect);
|
||||
}
|
||||
else if (duration.equals("UntilYourNextTurn")) {
|
||||
Singletons.getModel().getGame().getCleanup().addUntil(controller, endEffect);
|
||||
game.getCleanup().addUntil(controller, endEffect);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Add targeting to the effect so it knows who it's dealing with
|
||||
Singletons.getModel().getGame().getTriggerHandler().suppressMode(TriggerType.ChangesZone);
|
||||
Singletons.getModel().getGame().getAction().moveTo(ZoneType.Command, eff);
|
||||
Singletons.getModel().getGame().getTriggerHandler().clearSuppression(TriggerType.ChangesZone);
|
||||
game.getTriggerHandler().suppressMode(TriggerType.ChangesZone);
|
||||
game.getAction().moveTo(ZoneType.Command, eff);
|
||||
game.getTriggerHandler().clearSuppression(TriggerType.ChangesZone);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@ import java.util.List;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
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;
|
||||
|
||||
@@ -29,9 +29,10 @@ public class EncodeEffect extends SpellAbilityEffect {
|
||||
public void resolve(SpellAbility sa) {
|
||||
final Card host = sa.getSourceCard();
|
||||
final Player player = sa.getActivatingPlayer();
|
||||
final GameState game = player.getGame();
|
||||
|
||||
// make list of creatures that controller has on Battlefield
|
||||
List<Card> choices = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
List<Card> choices = game.getCardsIn(ZoneType.Battlefield);
|
||||
choices = CardLists.getValidCards(choices, "Creature.YouCtrl", host.getController(), host);
|
||||
|
||||
// if no creatures on battlefield, cannot encoded
|
||||
@@ -48,7 +49,7 @@ public class EncodeEffect extends SpellAbilityEffect {
|
||||
}
|
||||
|
||||
// move host card to exile
|
||||
Card movedCard = Singletons.getModel().getGame().getAction().moveTo(ZoneType.Exile, host);
|
||||
Card movedCard = game.getAction().moveTo(ZoneType.Exile, host);
|
||||
|
||||
// choose a creature
|
||||
Card choice = player.getController().chooseSingleCardForEffect(choices, sa, "Choose a creature you control to encode ", true);
|
||||
|
||||
@@ -2,7 +2,6 @@ package forge.card.ability.effects;
|
||||
|
||||
|
||||
import forge.Card;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.GameState;
|
||||
@@ -21,7 +20,7 @@ public class EndTurnEffect extends SpellAbilityEffect {
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
|
||||
GameState game = Singletons.getModel().getGame();
|
||||
GameState game = sa.getActivatingPlayer().getGame();
|
||||
// Steps taken from gatherer's rulings on Time Stop.
|
||||
// 1) All spells and abilities on the stack are exiled. This includes
|
||||
// Time Stop, though it will continue to resolve. It also includes
|
||||
@@ -32,7 +31,7 @@ public class EndTurnEffect extends SpellAbilityEffect {
|
||||
game.getStack().getStack().clear();
|
||||
|
||||
// 2) All attacking and blocking creatures are removed from combat.
|
||||
game.getCombat().reset();
|
||||
game.getCombat().reset(game.getPhaseHandler().getPlayerTurn());
|
||||
|
||||
// 3) State-based actions are checked. No player gets priority, and no
|
||||
// triggered abilities are put onto the stack.
|
||||
|
||||
@@ -4,7 +4,6 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import forge.Card;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityFactory;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
@@ -132,7 +131,7 @@ public class FlipCoinEffect extends SpellAbilityEffect {
|
||||
public static boolean flipCoinNoCall(final Card source, final Player flipper) {
|
||||
final boolean resultIsHeads = MyRandom.getRandom().nextBoolean();
|
||||
|
||||
Singletons.getModel().getGame().getEvents().post(new FlipCoinEvent());
|
||||
flipper.getGame().getEvents().post(new FlipCoinEvent());
|
||||
final StringBuilder result = new StringBuilder();
|
||||
result.append(flipper.getName());
|
||||
result.append("'s flip comes up");
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user