*Reintroduced TriggerReplacementBase as a specialized subclass of CardTraitBase

This commit is contained in:
Hellfish
2014-02-09 16:03:27 +00:00
parent d331c87ab5
commit 50c40311a7
264 changed files with 1010 additions and 1101 deletions

View File

@@ -498,9 +498,9 @@ public class AiController {
int b1 = b.getPayCosts() == null ? 0 : b.getPayCosts().getTotalMana().getCMC(); int b1 = b.getPayCosts() == null ? 0 : b.getPayCosts().getTotalMana().getCMC();
// deprioritize planar die roll marked with AIRollPlanarDieParams:LowPriority$ True // deprioritize planar die roll marked with AIRollPlanarDieParams:LowPriority$ True
if (ApiType.RollPlanarDice == a.getApi() && a.getSourceCard().hasSVar("AIRollPlanarDieParams") && a.getSourceCard().getSVar("AIRollPlanarDieParams").toLowerCase().matches(".*lowpriority\\$\\s*true.*")) { if (ApiType.RollPlanarDice == a.getApi() && a.getHostCard().hasSVar("AIRollPlanarDieParams") && a.getHostCard().getSVar("AIRollPlanarDieParams").toLowerCase().matches(".*lowpriority\\$\\s*true.*")) {
return 1; return 1;
} else if (ApiType.RollPlanarDice == b.getApi() && b.getSourceCard().hasSVar("AIRollPlanarDieParams") && b.getSourceCard().getSVar("AIRollPlanarDieParams").toLowerCase().matches(".*lowpriority\\$\\s*true.*")) { } else if (ApiType.RollPlanarDice == b.getApi() && b.getHostCard().hasSVar("AIRollPlanarDieParams") && b.getHostCard().getSVar("AIRollPlanarDieParams").toLowerCase().matches(".*lowpriority\\$\\s*true.*")) {
return -1; return -1;
} }
@@ -519,13 +519,13 @@ public class AiController {
private int getSpellAbilityPriority(SpellAbility sa) { private int getSpellAbilityPriority(SpellAbility sa) {
int p = 0; int p = 0;
Card source = sa.getSourceCard(); Card source = sa.getHostCard();
// puts creatures in front of spells // puts creatures in front of spells
if (source.isCreature()) { if (source.isCreature()) {
p += 1; p += 1;
} }
// don't play equipments before having any creatures // don't play equipments before having any creatures
if (source.isEquipment() && sa.getSourceCard().getController().getCreaturesInPlay().isEmpty()) { if (source.isEquipment() && sa.getHostCard().getController().getCreaturesInPlay().isEmpty()) {
p -= 9; p -= 9;
} }
// artifacts and enchantments with effects that do not stack // artifacts and enchantments with effects that do not stack
@@ -566,7 +566,7 @@ public class AiController {
if ((uTypes != null) && (sa != null)) { if ((uTypes != null) && (sa != null)) {
hand = CardLists.getValidCards(hand, uTypes, sa.getActivatingPlayer(), sa.getSourceCard()); hand = CardLists.getValidCards(hand, uTypes, sa.getActivatingPlayer(), sa.getHostCard());
} }
return getCardsToDiscard(numDiscard, numDiscard, hand, sa); return getCardsToDiscard(numDiscard, numDiscard, hand, sa);
} }
@@ -581,7 +581,7 @@ public class AiController {
final List<Card> discardList = new ArrayList<Card>(); final List<Card> discardList = new ArrayList<Card>();
int count = 0; int count = 0;
if (sa != null) { if (sa != null) {
sourceCard = sa.getSourceCard(); sourceCard = sa.getHostCard();
} }
// look for good discards // look for good discards
@@ -729,7 +729,7 @@ public class AiController {
if(landsWannaPlay != null && !landsWannaPlay.isEmpty() && player.canPlayLand(null)) { if(landsWannaPlay != null && !landsWannaPlay.isEmpty() && player.canPlayLand(null)) {
Card land = chooseBestLandToPlay(landsWannaPlay); Card land = chooseBestLandToPlay(landsWannaPlay);
if (ComputerUtil.damageFromETB(player, land) < player.getLife() || !player.canLoseLife()) { if (ComputerUtil.damageFromETB(player, land) < player.getLife() || !player.canLoseLife()) {
Ability.PLAY_LAND_SURROGATE.setSourceCard(land); Ability.PLAY_LAND_SURROGATE.setHostCard(land);
return Ability.PLAY_LAND_SURROGATE; return Ability.PLAY_LAND_SURROGATE;
} }
} }
@@ -835,7 +835,7 @@ public class AiController {
for(int i = 0; i < result.size(); i++) { for(int i = 0; i < result.size(); i++) {
SpellAbility sa = result.get(i); SpellAbility sa = result.get(i);
String srcName = sa.getSourceCard().getName(); String srcName = sa.getHostCard().getName();
if("Gemstone Caverns".equals(srcName)) { if("Gemstone Caverns".equals(srcName)) {
if(saGemstones == null) if(saGemstones == null)
saGemstones = sa; saGemstones = sa;
@@ -1042,9 +1042,9 @@ public class AiController {
switch(sa.getApi()) switch(sa.getApi())
{ {
case SetLife: case SetLife:
if (relatedPlayer.equals(sa.getSourceCard().getController())) { if (relatedPlayer.equals(sa.getHostCard().getController())) {
return Collections.max(options); return Collections.max(options);
} else if (relatedPlayer.isOpponentOf(sa.getSourceCard().getController())) { } else if (relatedPlayer.isOpponentOf(sa.getHostCard().getController())) {
return Collections.min(options); return Collections.min(options);
} else { } else {
return options.get(0); return options.get(0);

View File

@@ -29,7 +29,7 @@ public class AiCostDecision extends CostDecisionMakerBase implements ICostVisito
public AiCostDecision(Player ai0, SpellAbility sa) { public AiCostDecision(Player ai0, SpellAbility sa) {
super(ai0); super(ai0);
ability = sa; ability = sa;
source = ability.getSourceCard(); source = ability.getHostCard();
} }
@Override @Override
@@ -362,7 +362,7 @@ public class AiCostDecision extends CostDecisionMakerBase implements ICostVisito
final String sVar = ability.getSVar(amount); final String sVar = ability.getSVar(amount);
if (sVar.equals("XChoice")) { if (sVar.equals("XChoice")) {
List<Card> typeList = List<Card> typeList =
CardLists.getValidCards(player.getCardsIn(ZoneType.Battlefield), cost.getType().split(";"), ability.getActivatingPlayer(), ability.getSourceCard()); CardLists.getValidCards(player.getCardsIn(ZoneType.Battlefield), cost.getType().split(";"), ability.getActivatingPlayer(), ability.getHostCard());
typeList = CardLists.filter(typeList, Presets.UNTAPPED); typeList = CardLists.filter(typeList, Presets.UNTAPPED);
c = typeList.size(); c = typeList.size();
source.setSVar("ChosenX", "Number$" + Integer.toString(c)); source.setSVar("ChosenX", "Number$" + Integer.toString(c));
@@ -534,7 +534,7 @@ public class AiCostDecision extends CostDecisionMakerBase implements ICostVisito
final String sVar = ability.getSVar(amount); final String sVar = ability.getSVar(amount);
if (sVar.equals("XChoice")) { if (sVar.equals("XChoice")) {
List<Card> typeList = player.getGame().getCardsIn(ZoneType.Battlefield); List<Card> typeList = player.getGame().getCardsIn(ZoneType.Battlefield);
typeList = CardLists.getValidCards(typeList, cost.getType().split(";"), player, ability.getSourceCard()); typeList = CardLists.getValidCards(typeList, cost.getType().split(";"), player, ability.getHostCard());
if (!cost.canUntapSource) { if (!cost.canUntapSource) {
typeList.remove(source); typeList.remove(source);
} }

View File

@@ -75,10 +75,10 @@ public class ComputerUtil {
public static boolean handlePlayingSpellAbility(final Player ai, final SpellAbility sa, final Game game) { public static boolean handlePlayingSpellAbility(final Player ai, final SpellAbility sa, final Game game) {
game.getStack().freezeStack(); game.getStack().freezeStack();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
if (sa.isSpell() && !source.isCopiedSpell()) { if (sa.isSpell() && !source.isCopiedSpell()) {
sa.setSourceCard(game.getAction().moveToStack(source)); sa.setHostCard(game.getAction().moveToStack(source));
} }
if (sa.getApi() == ApiType.Charm && !sa.isWrapper()) { if (sa.getApi() == ApiType.Charm && !sa.isWrapper()) {
@@ -86,7 +86,7 @@ public class ComputerUtil {
} }
if (sa.hasParam("Bestow")) { if (sa.hasParam("Bestow")) {
sa.getSourceCard().animateBestow(); sa.getHostCard().animateBestow();
} }
final Cost cost = sa.getPayCosts(); final Cost cost = sa.getPayCosts();
@@ -109,7 +109,7 @@ public class ComputerUtil {
} }
} }
//Should not arrive here //Should not arrive here
System.out.println("AI failed to play " + sa.getSourceCard()); System.out.println("AI failed to play " + sa.getHostCard());
return false; return false;
} }
@@ -143,7 +143,7 @@ public class ComputerUtil {
int restrict = 0; int restrict = 0;
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
@@ -212,9 +212,9 @@ public class ComputerUtil {
if (!ComputerUtilCost.canPayCost(sa, ai)) if (!ComputerUtilCost.canPayCost(sa, ai))
return; return;
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
if (sa.isSpell() && !source.isCopiedSpell()) { if (sa.isSpell() && !source.isCopiedSpell()) {
sa.setSourceCard(game.getAction().moveToStack(source)); sa.setHostCard(game.getAction().moveToStack(source));
} }
final Cost cost = sa.getPayCosts(); final Cost cost = sa.getPayCosts();
if (cost == null) { if (cost == null) {
@@ -239,9 +239,9 @@ public class ComputerUtil {
public static final void playSpellAbilityForFree(final Player ai, final SpellAbility sa) { public static final void playSpellAbilityForFree(final Player ai, final SpellAbility sa) {
sa.setActivatingPlayer(ai); sa.setActivatingPlayer(ai);
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
if (sa.isSpell() && !source.isCopiedSpell()) { if (sa.isSpell() && !source.isCopiedSpell()) {
sa.setSourceCard(ai.getGame().getAction().moveToStack(source)); sa.setHostCard(ai.getGame().getAction().moveToStack(source));
} }
ai.getGame().getStack().add(sa); ai.getGame().getStack().add(sa);
@@ -263,9 +263,9 @@ public class ComputerUtil {
return; return;
} }
final Card source = newSA.getSourceCard(); final Card source = newSA.getHostCard();
if (newSA.isSpell() && !source.isCopiedSpell()) { if (newSA.isSpell() && !source.isCopiedSpell()) {
newSA.setSourceCard(game.getAction().moveToStack(source)); newSA.setHostCard(game.getAction().moveToStack(source));
} }
final CostPayment pay = new CostPayment(newSA.getPayCosts(), newSA); final CostPayment pay = new CostPayment(newSA.getPayCosts(), newSA);
@@ -286,9 +286,9 @@ public class ComputerUtil {
sa.setActivatingPlayer(ai); sa.setActivatingPlayer(ai);
// TODO: We should really restrict what doesn't use the Stack // TODO: We should really restrict what doesn't use the Stack
if (ComputerUtilCost.canPayCost(sa, ai)) { if (ComputerUtilCost.canPayCost(sa, ai)) {
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
if (sa.isSpell() && !source.isCopiedSpell()) { if (sa.isSpell() && !source.isCopiedSpell()) {
sa.setSourceCard(game.getAction().moveToStack(source)); sa.setHostCard(game.getAction().moveToStack(source));
} }
final Cost cost = sa.getPayCosts(); final Cost cost = sa.getPayCosts();
@@ -795,10 +795,10 @@ public class ComputerUtil {
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
if (tgt != null) { if (tgt != null) {
if (CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), controller, sa.getSourceCard()).contains(card)) { if (CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), controller, sa.getHostCard()).contains(card)) {
return true; return true;
} }
} else if (AbilityUtils.getDefinedCards(sa.getSourceCard(), sa.getParam("Defined"), sa).contains(card)) { } else if (AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa).contains(card)) {
return true; return true;
} }
@@ -838,13 +838,13 @@ public class ComputerUtil {
if (sa.getApi() == ApiType.PreventDamage && sa.canPlay() if (sa.getApi() == ApiType.PreventDamage && sa.canPlay()
&& ComputerUtilCost.canPayCost(sa, controller)) { && ComputerUtilCost.canPayCost(sa, controller)) {
if (AbilityUtils.getDefinedCards(sa.getSourceCard(), sa.getParam("Defined"), sa).contains(card)) { if (AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa).contains(card)) {
prevented += AbilityUtils.calculateAmount(sa.getSourceCard(), sa.getParam("Amount"), sa); prevented += AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("Amount"), sa);
} }
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
if (tgt != null) { if (tgt != null) {
if (CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), controller, sa.getSourceCard()).contains(card)) { if (CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), controller, sa.getHostCard()).contains(card)) {
prevented += AbilityUtils.calculateAmount(sa.getSourceCard(), sa.getParam("Amount"), sa); prevented += AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("Amount"), sa);
} }
} }
@@ -867,7 +867,7 @@ public class ComputerUtil {
* @return a boolean. * @return a boolean.
*/ */
public static boolean castPermanentInMain1(final Player ai, final SpellAbility sa) { public static boolean castPermanentInMain1(final Player ai, final SpellAbility sa) {
final Card card = sa.getSourceCard(); final Card card = sa.getHostCard();
if ("True".equals(card.getSVar("NonStackingEffect")) && card.getController().isCardInPlay(card.getName())) { if ("True".equals(card.getSVar("NonStackingEffect")) && card.getController().isCardInPlay(card.getName())) {
return false; return false;
} }
@@ -1038,12 +1038,12 @@ public class ComputerUtil {
final Game game = sa.getActivatingPlayer().getGame(); final Game game = sa.getActivatingPlayer().getGame();
final PhaseHandler ph = game.getPhaseHandler(); final PhaseHandler ph = game.getPhaseHandler();
return (sa.getSourceCard().isCreature() return (sa.getHostCard().isCreature()
&& sa.getPayCosts().hasTapCost() && sa.getPayCosts().hasTapCost()
&& (ph.getPhase().isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS) && (ph.getPhase().isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS)
|| !ph.getNextTurn().equals(sa.getActivatingPlayer())) || !ph.getNextTurn().equals(sa.getActivatingPlayer()))
&& !sa.getSourceCard().hasKeyword("At the beginning of the end step, exile CARDNAME.") && !sa.getHostCard().hasKeyword("At the beginning of the end step, exile CARDNAME.")
&& !sa.getSourceCard().hasKeyword("At the beginning of the end step, sacrifice CARDNAME.")); && !sa.getHostCard().hasKeyword("At the beginning of the end step, sacrifice CARDNAME."));
} }
/** /**
@@ -1056,7 +1056,7 @@ public class ComputerUtil {
* @return a boolean (returns true if it's better to wait until blockers are declared). * @return a boolean (returns true if it's better to wait until blockers are declared).
*/ */
public static boolean castSpellInMain1(final Player ai, final SpellAbility sa) { public static boolean castSpellInMain1(final Player ai, final SpellAbility sa) {
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final SpellAbility sub = sa.getSubAbility(); final SpellAbility sub = sa.getSubAbility();
// Cipher spells // Cipher spells
@@ -1073,7 +1073,7 @@ public class ComputerUtil {
} }
} }
final List<Card> buffed = ai.getCardsIn(ZoneType.Battlefield); final List<Card> buffed = ai.getCardsIn(ZoneType.Battlefield);
boolean checkThreshold = sa.isSpell() && !ai.hasThreshold() && !sa.getSourceCard().isInZone(ZoneType.Graveyard); boolean checkThreshold = sa.isSpell() && !ai.hasThreshold() && !sa.getHostCard().isInZone(ZoneType.Graveyard);
for (Card buffedCard : buffed) { for (Card buffedCard : buffed) {
if (buffedCard.hasSVar("BuffedBy")) { if (buffedCard.hasSVar("BuffedBy")) {
final String buffedby = buffedCard.getSVar("BuffedBy"); final String buffedby = buffedCard.getSVar("BuffedBy");
@@ -1144,7 +1144,7 @@ public class ComputerUtil {
*/ */
public static boolean activateForCost(SpellAbility sa, final Player ai) { public static boolean activateForCost(SpellAbility sa, final Player ai) {
final Cost abCost = sa.getPayCosts(); final Cost abCost = sa.getPayCosts();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
if (abCost == null) { if (abCost == null) {
return false; return false;
} }
@@ -1240,7 +1240,7 @@ public class ComputerUtil {
continue; continue;
} }
final String numDam = sa.getParam("NumDmg"); final String numDam = sa.getParam("NumDmg");
int dmg = AbilityUtils.calculateAmount(sa.getSourceCard(), numDam, sa); int dmg = AbilityUtils.calculateAmount(sa.getHostCard(), numDam, sa);
if (dmg <= damage) { if (dmg <= damage) {
continue; continue;
} }
@@ -1307,7 +1307,7 @@ public class ComputerUtil {
return objects; return objects;
} }
final Card source = topStack.getSourceCard(); final Card source = topStack.getHostCard();
final ApiType threatApi = topStack.getApi(); final ApiType threatApi = topStack.getApi();
// Can only Predict things from AFs // Can only Predict things from AFs
@@ -1333,7 +1333,7 @@ public class ComputerUtil {
// Lethal Damage => prevent damage/regeneration/bounce/shroud // Lethal Damage => prevent damage/regeneration/bounce/shroud
if (threatApi == ApiType.DealDamage || threatApi == ApiType.DamageAll) { if (threatApi == ApiType.DealDamage || threatApi == ApiType.DamageAll) {
// If PredictDamage is >= Lethal Damage // If PredictDamage is >= Lethal Damage
final int dmg = AbilityUtils.calculateAmount(topStack.getSourceCard(), final int dmg = AbilityUtils.calculateAmount(topStack.getHostCard(),
topStack.getParam("NumDmg"), topStack); topStack.getParam("NumDmg"), topStack);
for (final Object o : objects) { for (final Object o : objects) {
if (o instanceof Card) { if (o instanceof Card) {
@@ -1452,7 +1452,7 @@ public class ComputerUtil {
} }
public static boolean playImmediately(Player ai, SpellAbility sa) { public static boolean playImmediately(Player ai, SpellAbility sa) {
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final Zone zone = source.getZone(); final Zone zone = source.getZone();
if (zone.getZoneType() == ZoneType.Battlefield) { if (zone.getZoneType() == ZoneType.Battlefield) {

View File

@@ -848,7 +848,7 @@ public class ComputerUtilCombat {
} }
if (ComputerUtilCost.canPayCost(ability, defender.getController())) { if (ComputerUtilCost.canPayCost(ability, defender.getController())) {
int pBonus = AbilityUtils.calculateAmount(ability.getSourceCard(), ability.getParam("NumAtt"), ability); int pBonus = AbilityUtils.calculateAmount(ability.getHostCard(), ability.getParam("NumAtt"), ability);
if (pBonus > 0) { if (pBonus > 0) {
power += pBonus; power += pBonus;
} }
@@ -859,7 +859,7 @@ public class ComputerUtilCombat {
} }
if (ComputerUtilCost.canPayCost(ability, defender.getController())) { if (ComputerUtilCost.canPayCost(ability, defender.getController())) {
int pBonus = AbilityUtils.calculateAmount(ability.getSourceCard(), ability.getParam("CounterNum"), ability); int pBonus = AbilityUtils.calculateAmount(ability.getHostCard(), ability.getParam("CounterNum"), ability);
if (pBonus > 0) { if (pBonus > 0) {
power += pBonus; power += pBonus;
} }
@@ -977,7 +977,7 @@ public class ComputerUtilCombat {
if (ability.getApi() != ApiType.Pump || !ability.hasParam("NumDef")) { if (ability.getApi() != ApiType.Pump || !ability.hasParam("NumDef")) {
if (ComputerUtilCost.canPayCost(ability, defender.getController())) { if (ComputerUtilCost.canPayCost(ability, defender.getController())) {
int tBonus = AbilityUtils.calculateAmount(ability.getSourceCard(), ability.getParam("NumDef"), ability); int tBonus = AbilityUtils.calculateAmount(ability.getHostCard(), ability.getParam("NumDef"), ability);
if (tBonus > 0) { if (tBonus > 0) {
toughness += tBonus; toughness += tBonus;
} }
@@ -988,7 +988,7 @@ public class ComputerUtilCombat {
} }
if (ComputerUtilCost.canPayCost(ability, defender.getController())) { if (ComputerUtilCost.canPayCost(ability, defender.getController())) {
int tBonus = AbilityUtils.calculateAmount(ability.getSourceCard(), ability.getParam("CounterNum"), ability); int tBonus = AbilityUtils.calculateAmount(ability.getHostCard(), ability.getParam("CounterNum"), ability);
if (tBonus > 0) { if (tBonus > 0) {
toughness += tBonus; toughness += tBonus;
} }
@@ -1154,7 +1154,7 @@ public class ComputerUtilCombat {
} }
if (!ability.getPayCosts().hasTapCost() && ComputerUtilCost.canPayCost(ability, attacker.getController())) { if (!ability.getPayCosts().hasTapCost() && ComputerUtilCost.canPayCost(ability, attacker.getController())) {
int pBonus = AbilityUtils.calculateAmount(ability.getSourceCard(), ability.getParam("NumAtt"), ability); int pBonus = AbilityUtils.calculateAmount(ability.getHostCard(), ability.getParam("NumAtt"), ability);
if (pBonus > 0) { if (pBonus > 0) {
power += pBonus; power += pBonus;
} }
@@ -1165,7 +1165,7 @@ public class ComputerUtilCombat {
} }
if (!ability.getPayCosts().hasTapCost() && ComputerUtilCost.canPayCost(ability, attacker.getController())) { if (!ability.getPayCosts().hasTapCost() && ComputerUtilCost.canPayCost(ability, attacker.getController())) {
int pBonus = AbilityUtils.calculateAmount(ability.getSourceCard(), ability.getParam("CounterNum"), ability); int pBonus = AbilityUtils.calculateAmount(ability.getHostCard(), ability.getParam("CounterNum"), ability);
if (pBonus > 0) { if (pBonus > 0) {
power += pBonus; power += pBonus;
} }
@@ -1335,7 +1335,7 @@ public class ComputerUtilCombat {
if (ability.getApi() != ApiType.Pump || !ability.hasParam("NumDef")) { if (ability.getApi() != ApiType.Pump || !ability.hasParam("NumDef")) {
if (!ability.getPayCosts().hasTapCost() && ComputerUtilCost.canPayCost(ability, attacker.getController())) { if (!ability.getPayCosts().hasTapCost() && ComputerUtilCost.canPayCost(ability, attacker.getController())) {
int tBonus = AbilityUtils.calculateAmount(ability.getSourceCard(), ability.getParam("NumDef"), ability); int tBonus = AbilityUtils.calculateAmount(ability.getHostCard(), ability.getParam("NumDef"), ability);
if (tBonus > 0) { if (tBonus > 0) {
toughness += tBonus; toughness += tBonus;
} }
@@ -1346,7 +1346,7 @@ public class ComputerUtilCombat {
} }
if (!ability.getPayCosts().hasTapCost() && ComputerUtilCost.canPayCost(ability, attacker.getController())) { if (!ability.getPayCosts().hasTapCost() && ComputerUtilCost.canPayCost(ability, attacker.getController())) {
int tBonus = AbilityUtils.calculateAmount(ability.getSourceCard(), ability.getParam("CounterNum"), ability); int tBonus = AbilityUtils.calculateAmount(ability.getHostCard(), ability.getParam("CounterNum"), ability);
if (tBonus > 0) { if (tBonus > 0) {
toughness += tBonus; toughness += tBonus;
} }

View File

@@ -349,7 +349,7 @@ public class ComputerUtilCost {
} // canPayCost() } // canPayCost()
public static boolean willPayUnlessCost(SpellAbility sa, Player payer, Cost cost, boolean alreadyPaid, List<Player> payers) { public static boolean willPayUnlessCost(SpellAbility sa, Player payer, Cost cost, boolean alreadyPaid, List<Player> payers) {
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
boolean payForOwnOnly = "OnlyOwn".equals(sa.getParam("UnlessAI")); boolean payForOwnOnly = "OnlyOwn".equals(sa.getParam("UnlessAI"));
boolean payOwner = sa.hasParam("UnlessAI") ? sa.getParam("UnlessAI").startsWith("Defined") : false; boolean payOwner = sa.hasParam("UnlessAI") ? sa.getParam("UnlessAI").startsWith("Defined") : false;
boolean payNever = "Never".equals(sa.getParam("UnlessAI")); boolean payNever = "Never".equals(sa.getParam("UnlessAI"));

View File

@@ -87,7 +87,7 @@ public class ComputerUtilMana {
} }
private static boolean payManaCost(final ManaCostBeingPaid cost, final SpellAbility sa, final Player ai, final boolean test, final int extraMana, boolean checkPlayable, boolean clearManaPaid) { private static boolean payManaCost(final ManaCostBeingPaid cost, final SpellAbility sa, final Player ai, final boolean test, final int extraMana, boolean checkPlayable, boolean clearManaPaid) {
adjustManaCostToAvoidNegEffects(cost, sa.getSourceCard(), ai); adjustManaCostToAvoidNegEffects(cost, sa.getHostCard(), ai);
final ManaPool manapool = ai.getManaPool(); final ManaPool manapool = ai.getManaPool();
List<ManaCostShard> unpaidShards = cost.getUnpaidShards(); List<ManaCostShard> unpaidShards = cost.getUnpaidShards();
@@ -129,7 +129,7 @@ public class ComputerUtilMana {
// for (Entry<ManaCostShard, Collection<SpellAbility>> src : sourcesForShards.entrySet()) { // for (Entry<ManaCostShard, Collection<SpellAbility>> src : sourcesForShards.entrySet()) {
// System.out.println("\t" +src.getKey() + " : " + src.getValue().size() + " source(s)"); // System.out.println("\t" +src.getKey() + " : " + src.getValue().size() + " source(s)");
// for (SpellAbility sss : src.getValue()) { // for (SpellAbility sss : src.getValue()) {
// System.out.printf("\t\t%s - %s%n", sss.getSourceCard(), sss); // System.out.printf("\t\t%s - %s%n", sss.getHostCard(), sss);
// } // }
// } // }
// } // }
@@ -145,12 +145,12 @@ public class ComputerUtilMana {
SpellAbility saPayment = null; SpellAbility saPayment = null;
if (saList != null) { if (saList != null) {
for (final SpellAbility ma : saList) { for (final SpellAbility ma : saList) {
if (ma.getSourceCard() == sa.getSourceCard()) { if (ma.getHostCard() == sa.getHostCard()) {
continue; continue;
} }
final String typeRes = cost.getSourceRestriction(); final String typeRes = cost.getSourceRestriction();
if (StringUtils.isNotBlank(typeRes) && !ma.getSourceCard().isType(typeRes)) { if (StringUtils.isNotBlank(typeRes) && !ma.getHostCard().isType(typeRes)) {
continue; continue;
} }
@@ -164,7 +164,7 @@ public class ComputerUtilMana {
} }
if (DEBUG_MANA_PAYMENT) { if (DEBUG_MANA_PAYMENT) {
paymentPlan.add(String.format("%s : (%s) %s", toPay, saPayment == null ? "LIFE" : saPayment.getSourceCard(), saPayment)); paymentPlan.add(String.format("%s : (%s) %s", toPay, saPayment == null ? "LIFE" : saPayment.getHostCard(), saPayment));
} }
if (saPayment == null) { if (saPayment == null) {
@@ -174,7 +174,7 @@ public class ComputerUtilMana {
cost.payPhyrexian(); cost.payPhyrexian();
if (!test) { if (!test) {
ai.payLife(2, sa.getSourceCard()); ai.payLife(2, sa.getHostCard());
} }
continue; continue;
} }
@@ -192,7 +192,7 @@ public class ComputerUtilMana {
Iterator<SpellAbility> itSa = kv.iterator(); Iterator<SpellAbility> itSa = kv.iterator();
while (itSa.hasNext()) { while (itSa.hasNext()) {
SpellAbility srcSa = itSa.next(); SpellAbility srcSa = itSa.next();
if (srcSa.getSourceCard().equals(saPayment.getSourceCard())) { if (srcSa.getHostCard().equals(saPayment.getHostCard())) {
itSa.remove(); itSa.remove();
} }
} }
@@ -207,8 +207,8 @@ public class ComputerUtilMana {
} }
} }
else { else {
System.err.println("Ability " + saPayment + " from " + saPayment.getSourceCard() + " had NULL as payCost"); System.err.println("Ability " + saPayment + " from " + saPayment.getHostCard() + " had NULL as payCost");
saPayment.getSourceCard().tap(); saPayment.getHostCard().tap();
} }
ai.getGame().getStack().addAndUnfreeze(saPayment); ai.getGame().getStack().addAndUnfreeze(saPayment);
@@ -228,7 +228,7 @@ public class ComputerUtilMana {
// if (DEBUG_MANA_PAYMENT) { // if (DEBUG_MANA_PAYMENT) {
// System.err.printf("%s > [%s] payment has %s (%s +%d) for (%s) %s:%n\t%s%n%n", // System.err.printf("%s > [%s] payment has %s (%s +%d) for (%s) %s:%n\t%s%n%n",
// FThreads.debugGetCurrThreadId(), test ? "test" : "PROD", cost.isPaid() ? "*PAID*" : "failed", originalCost, // FThreads.debugGetCurrThreadId(), test ? "test" : "PROD", cost.isPaid() ? "*PAID*" : "failed", originalCost,
// extraMana, sa.getSourceCard(), sa.toUnsuppressedString(), StringUtils.join(paymentPlan, "\n\t")); // extraMana, sa.getHostCard(), sa.toUnsuppressedString(), StringUtils.join(paymentPlan, "\n\t"));
// } // }
if (!cost.isPaid()) { if (!cost.isPaid()) {
@@ -236,14 +236,14 @@ public class ComputerUtilMana {
return false; return false;
} }
else { else {
System.out.println("ComputerUtil : payManaCost() cost was not paid for " + sa.getSourceCard().getName() + ". Didn't find what to pay for " + toPay); System.out.println("ComputerUtil : payManaCost() cost was not paid for " + sa.getHostCard().getName() + ". Didn't find what to pay for " + toPay);
return false; return false;
} }
} }
sa.getSourceCard().setColorsPaid(cost.getColorsPaid()); sa.getHostCard().setColorsPaid(cost.getColorsPaid());
// if (sa instanceof Spell_Permanent) // should probably add this // if (sa instanceof Spell_Permanent) // should probably add this
sa.getSourceCard().setSunburstValue(cost.getSunburst()); sa.getHostCard().setSunburstValue(cost.getSunburst());
return true; return true;
} // payManaCost() } // payManaCost()
@@ -254,7 +254,7 @@ public class ComputerUtilMana {
if (m.isComboMana()) if (m.isComboMana())
getComboManaChoice(ai, saPayment, sa, cost); getComboManaChoice(ai, saPayment, sa, cost);
else if (saPayment.getApi() == ApiType.ManaReflected) { else if (saPayment.getApi() == ApiType.ManaReflected) {
System.out.println("Evaluate reflected mana of: " + saPayment.getSourceCard()); System.out.println("Evaluate reflected mana of: " + saPayment.getHostCard());
Set<String> reflected = CardUtil.getReflectableManaColors(saPayment); Set<String> reflected = CardUtil.getReflectableManaColors(saPayment);
for (byte c : MagicColor.WUBRG) { for (byte c : MagicColor.WUBRG) {
@@ -280,7 +280,7 @@ public class ComputerUtilMana {
} }
private static boolean canPayShardWithSpellAbility(ManaCostShard toPay, Player ai, SpellAbility ma, SpellAbility sa, boolean checkCosts) { private static boolean canPayShardWithSpellAbility(ManaCostShard toPay, Player ai, SpellAbility ma, SpellAbility sa, boolean checkCosts) {
final Card sourceCard = ma.getSourceCard(); final Card sourceCard = ma.getHostCard();
if (toPay.isSnow() && !sourceCard.isSnow()) { return false; } if (toPay.isSnow() && !sourceCard.isSnow()) { return false; }
@@ -367,7 +367,7 @@ public class ComputerUtilMana {
*/ */
private static void getComboManaChoice(final Player ai, final SpellAbility manaAb, final SpellAbility saRoot, final ManaCostBeingPaid cost) { private static void getComboManaChoice(final Player ai, final SpellAbility manaAb, final SpellAbility saRoot, final ManaCostBeingPaid cost) {
final StringBuilder choiceString = new StringBuilder(); final StringBuilder choiceString = new StringBuilder();
final Card source = manaAb.getSourceCard(); final Card source = manaAb.getHostCard();
final AbilityManaPart abMana = manaAb.getManaPart(); final AbilityManaPart abMana = manaAb.getManaPart();
if (abMana.isComboMana()) { if (abMana.isComboMana()) {
@@ -515,8 +515,8 @@ public class ComputerUtilMana {
private static ManaCostBeingPaid calculateManaCost(final SpellAbility sa, final boolean test, final int extraMana) { private static ManaCostBeingPaid calculateManaCost(final SpellAbility sa, final boolean test, final int extraMana) {
ZoneType castFromBackup = null; ZoneType castFromBackup = null;
if (test && sa.isSpell()) { if (test && sa.isSpell()) {
castFromBackup = sa.getSourceCard().getCastFrom(); castFromBackup = sa.getHostCard().getCastFrom();
sa.getSourceCard().setCastFrom(sa.getSourceCard().getZone().getZoneType()); sa.getHostCard().setCastFrom(sa.getHostCard().getZone().getZoneType());
} }
Cost payCosts = sa.getPayCosts(); Cost payCosts = sa.getPayCosts();
@@ -529,7 +529,7 @@ public class ComputerUtilMana {
ManaCostBeingPaid cost = new ManaCostBeingPaid(mana, restriction); ManaCostBeingPaid cost = new ManaCostBeingPaid(mana, restriction);
cost.applySpellCostChange(sa, test); cost.applySpellCostChange(sa, test);
final Card card = sa.getSourceCard(); final Card card = sa.getHostCard();
// Tack xMana Payments into mana here if X is a set value // Tack xMana Payments into mana here if X is a set value
if ((sa.getPayCosts() != null) && (cost.getXcounter() > 0 || extraMana > 0)) { if ((sa.getPayCosts() != null) && (cost.getXcounter() > 0 || extraMana > 0)) {
int manaToAdd = 0; int manaToAdd = 0;
@@ -559,7 +559,7 @@ public class ComputerUtilMana {
} }
if (test && sa.isSpell()) { if (test && sa.isSpell()) {
sa.getSourceCard().setCastFrom(castFromBackup); sa.getHostCard().setCastFrom(castFromBackup);
} }
return cost; return cost;
@@ -797,7 +797,7 @@ public class ComputerUtilMana {
final Card offering = sa.getSacrificedAsOffering(); final Card offering = sa.getSacrificedAsOffering();
offering.setUsedToPay(false); offering.setUsedToPay(false);
if (costIsPaid && !test) { if (costIsPaid && !test) {
sa.getSourceCard().getController().getGame().getAction().sacrifice(offering, sa); sa.getHostCard().getController().getGame().getAction().sacrifice(offering, sa);
} }
sa.resetSacrificedAsOffering(); sa.resetSacrificedAsOffering();
} }

View File

@@ -86,7 +86,7 @@ public abstract class SpellAbilityAi extends SaTargetRoutines {
* @return a boolean. * @return a boolean.
*/ */
protected static boolean isSorcerySpeed(final SpellAbility sa) { protected static boolean isSorcerySpeed(final SpellAbility sa) {
return ( sa.isSpell() && sa.getSourceCard().isSorcery() ) return ( sa.isSpell() && sa.getHostCard().isSorcery() )
|| ( sa.isAbility() && sa.getRestrictions().isSorcerySpeed() ); || ( sa.isAbility() && sa.getRestrictions().isSorcerySpeed() );
} }

View File

@@ -50,14 +50,14 @@ public class AddTurnAi extends SpellAbilityAi {
break; break;
} }
} }
if (!sa.getTargetRestrictions().isMinTargetsChosen(sa.getSourceCard(), sa) && sa.canTarget(opp)) { if (!sa.getTargetRestrictions().isMinTargetsChosen(sa.getHostCard(), sa) && sa.canTarget(opp)) {
sa.getTargets().add(opp); sa.getTargets().add(opp);
} else { } else {
return false; return false;
} }
} }
} else { } else {
final List<Player> tgtPlayers = AbilityUtils.getDefinedPlayers(sa.getSourceCard(), sa.getParam("Defined"), sa); final List<Player> tgtPlayers = AbilityUtils.getDefinedPlayers(sa.getHostCard(), sa.getParam("Defined"), sa);
for (final Player p : tgtPlayers) { for (final Player p : tgtPlayers) {
if (p.isOpponentOf(ai) && !mandatory) { if (p.isOpponentOf(ai) && !mandatory) {
return false; return false;

View File

@@ -32,7 +32,7 @@ public class AnimateAi extends SpellAbilityAi {
@Override @Override
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) { protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final Game game = aiPlayer.getGame(); final Game game = aiPlayer.getGame();
final PhaseHandler ph = game.getPhaseHandler(); final PhaseHandler ph = game.getPhaseHandler();

View File

@@ -31,7 +31,7 @@ public class AttachAi extends SpellAbilityAi {
protected boolean canPlayAI(Player ai, SpellAbility sa) { protected boolean canPlayAI(Player ai, SpellAbility sa) {
final Random r = MyRandom.getRandom(); final Random r = MyRandom.getRandom();
final Cost abCost = sa.getPayCosts(); final Cost abCost = sa.getPayCosts();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
if (abCost != null) { if (abCost != null) {
// AI currently disabled for these costs // AI currently disabled for these costs
@@ -319,7 +319,7 @@ public class AttachAi extends SpellAbilityAi {
final Card attachSource) { final Card attachSource) {
// AI For choosing a Card to Animate. // AI For choosing a Card to Animate.
List<Card> betterList = CardLists.getNotType(list, "Creature"); List<Card> betterList = CardLists.getNotType(list, "Creature");
if (sa.getSourceCard().getName().equals("Animate Artifact")) { if (sa.getHostCard().getName().equals("Animate Artifact")) {
betterList = CardLists.filter(betterList, new Predicate<Card>() { betterList = CardLists.filter(betterList, new Predicate<Card>() {
@Override @Override
public boolean apply(final Card c) { public boolean apply(final Card c) {
@@ -385,7 +385,7 @@ public class AttachAi extends SpellAbilityAi {
// I know this isn't much better than Hardcoding, but some cards need it for now // I know this isn't much better than Hardcoding, but some cards need it for now
final Player ai = sa.getActivatingPlayer(); final Player ai = sa.getActivatingPlayer();
Card chosen = null; Card chosen = null;
if ("Guilty Conscience".equals(sa.getSourceCard().getName())) { if ("Guilty Conscience".equals(sa.getHostCard().getName())) {
List<Card> aiStuffies = CardLists.filter(list, new Predicate<Card>() { List<Card> aiStuffies = CardLists.filter(list, new Predicate<Card>() {
@Override @Override
public boolean apply(final Card c) { public boolean apply(final Card c) {
@@ -611,12 +611,12 @@ public class AttachAi extends SpellAbilityAi {
*/ */
@Override @Override
protected boolean doTriggerAINoCost(final Player ai, final SpellAbility sa, final boolean mandatory) { protected boolean doTriggerAINoCost(final Player ai, final SpellAbility sa, final boolean mandatory) {
final Card card = sa.getSourceCard(); final Card card = sa.getHostCard();
// Check if there are any valid targets // Check if there are any valid targets
List<GameObject> targets = new ArrayList<GameObject>(); List<GameObject> targets = new ArrayList<GameObject>();
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
if (tgt == null) { if (tgt == null) {
targets = AbilityUtils.getDefinedObjects(sa.getSourceCard(), sa.getParam("Defined"), sa); targets = AbilityUtils.getDefinedObjects(sa.getHostCard(), sa.getParam("Defined"), sa);
} else { } else {
AttachAi.attachPreference(sa, tgt, mandatory); AttachAi.attachPreference(sa, tgt, mandatory);
targets = sa.getTargets().getTargets(); targets = sa.getTargets().getTargets();
@@ -930,7 +930,7 @@ public class AttachAi extends SpellAbilityAi {
*/ */
private static Card attachToCardAIPreferences(final Player aiPlayer, final SpellAbility sa, final boolean mandatory) { private static Card attachToCardAIPreferences(final Player aiPlayer, final SpellAbility sa, final boolean mandatory) {
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
final Card attachSource = sa.getSourceCard(); final Card attachSource = sa.getHostCard();
// TODO AttachSource is currently set for the Source of the Spell, but // TODO AttachSource is currently set for the Source of the Spell, but
// at some point can support attaching a different card // at some point can support attaching a different card

View File

@@ -18,7 +18,7 @@ public class BecomesBlockedAi extends SpellAbilityAi {
@Override @Override
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) { protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
final Game game = aiPlayer.getGame(); final Game game = aiPlayer.getGame();

View File

@@ -149,7 +149,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
// Fetching should occur fairly often as it helps cast more spells, and // Fetching should occur fairly often as it helps cast more spells, and
// have access to more mana // have access to more mana
final Cost abCost = sa.getPayCosts(); final Cost abCost = sa.getPayCosts();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
ZoneType origin = null; ZoneType origin = null;
final Player opponent = ai.getOpponent(); final Player opponent = ai.getOpponent();
boolean activateForCost = ComputerUtil.activateForCost(sa, ai); boolean activateForCost = ComputerUtil.activateForCost(sa, ai);
@@ -241,9 +241,9 @@ public class ChangeZoneAi extends SpellAbilityAi {
pDefined = sa.getTargets().getTargetPlayers(); pDefined = sa.getTargets().getTargetPlayers();
} else { } else {
if (sa.hasParam("DefinedPlayer")) { if (sa.hasParam("DefinedPlayer")) {
pDefined = AbilityUtils.getDefinedPlayers(sa.getSourceCard(), sa.getParam("DefinedPlayer"), sa); pDefined = AbilityUtils.getDefinedPlayers(sa.getHostCard(), sa.getParam("DefinedPlayer"), sa);
} else { } else {
pDefined = AbilityUtils.getDefinedPlayers(sa.getSourceCard(), sa.getParam("Defined"), sa); pDefined = AbilityUtils.getDefinedPlayers(sa.getHostCard(), sa.getParam("Defined"), sa);
} }
} }
@@ -357,7 +357,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
// Fetching should occur fairly often as it helps cast more spells, and // Fetching should occur fairly often as it helps cast more spells, and
// have access to more mana // have access to more mana
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
List<ZoneType> origin = new ArrayList<ZoneType>(); List<ZoneType> origin = new ArrayList<ZoneType>();
@@ -404,7 +404,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
if (mandatory) { if (mandatory) {
return true; return true;
} }
pDefined = AbilityUtils.getDefinedPlayers(sa.getSourceCard(), sa.getParam("Defined"), sa); pDefined = AbilityUtils.getDefinedPlayers(sa.getHostCard(), sa.getParam("Defined"), sa);
} }
for (final Player p : pDefined) { for (final Player p : pDefined) {
@@ -540,7 +540,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
private static boolean knownOriginCanPlayAI(final Player ai, final SpellAbility sa) { private static boolean knownOriginCanPlayAI(final Player ai, final SpellAbility sa) {
// Retrieve either this card, or target Cards in Graveyard // Retrieve either this card, or target Cards in Graveyard
final Cost abCost = sa.getPayCosts(); final Cost abCost = sa.getPayCosts();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final ZoneType origin = ZoneType.smartValueOf(sa.getParam("Origin")); final ZoneType origin = ZoneType.smartValueOf(sa.getParam("Origin"));
final ZoneType destination = ZoneType.smartValueOf(sa.getParam("Destination")); final ZoneType destination = ZoneType.smartValueOf(sa.getParam("Destination"));
@@ -683,7 +683,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
* @return a boolean. * @return a boolean.
*/ */
private static boolean isPreferredTarget(final Player ai, final SpellAbility sa, final boolean mandatory) { private static boolean isPreferredTarget(final Player ai, final SpellAbility sa, final boolean mandatory) {
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final ZoneType origin = ZoneType.listValueOf(sa.getParam("Origin")).get(0); final ZoneType origin = ZoneType.listValueOf(sa.getParam("Origin")).get(0);
final ZoneType destination = ZoneType.smartValueOf(sa.getParam("Destination")); final ZoneType destination = ZoneType.smartValueOf(sa.getParam("Destination"));
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
@@ -709,7 +709,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
list = CardLists.filter(list, Predicates.not(CardPredicates.nameEquals(source.getName()))); // Don't get the same card back. list = CardLists.filter(list, Predicates.not(CardPredicates.nameEquals(source.getName()))); // Don't get the same card back.
} }
if (list.size() < tgt.getMinTargets(sa.getSourceCard(), sa)) { if (list.size() < tgt.getMinTargets(sa.getHostCard(), sa)) {
return false; return false;
} }
@@ -724,7 +724,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
// if it's blink or bounce, try to save my about to die stuff // if it's blink or bounce, try to save my about to die stuff
if ((destination.equals(ZoneType.Hand) || (destination.equals(ZoneType.Exile) if ((destination.equals(ZoneType.Hand) || (destination.equals(ZoneType.Exile)
&& (subApi == ApiType.DelayedTrigger || (subApi == ApiType.ChangeZone && subAffected.equals("Remembered"))))) && (subApi == ApiType.DelayedTrigger || (subApi == ApiType.ChangeZone && subAffected.equals("Remembered")))))
&& (tgt.getMinTargets(sa.getSourceCard(), sa) <= 1)) { && (tgt.getMinTargets(sa.getHostCard(), sa) <= 1)) {
// check stack for something on the stack that will kill // check stack for something on the stack that will kill
// anything i control // anything i control
@@ -784,7 +784,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
// counters TODO check good and // counters TODO check good and
// bad counters // bad counters
// checks only if there is a dangerous ETB effect // checks only if there is a dangerous ETB effect
return !c.equals(sa.getSourceCard()) && SpellPermanent.checkETBEffects(c, ai); return !c.equals(sa.getHostCard()) && SpellPermanent.checkETBEffects(c, ai);
} }
}); });
if (!aiPermanents.isEmpty()) { if (!aiPermanents.isEmpty()) {
@@ -855,12 +855,12 @@ public class ChangeZoneAi extends SpellAbilityAi {
return false; return false;
} }
if (!mandatory && list.size() < tgt.getMinTargets(sa.getSourceCard(), sa)) { if (!mandatory && list.size() < tgt.getMinTargets(sa.getHostCard(), sa)) {
return false; return false;
} }
// target loop // target loop
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getSourceCard(), sa)) { while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getHostCard(), sa)) {
// AI Targeting // AI Targeting
Card choice = null; Card choice = null;
@@ -909,7 +909,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
} }
} }
if (choice == null) { // can't find anything left if (choice == null) { // can't find anything left
if (sa.getTargets().getNumTargeted() == 0 || sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa)) { if (sa.getTargets().getNumTargeted() == 0 || sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) {
if (!mandatory) { if (!mandatory) {
sa.resetTargets(); sa.resetTargets();
} }
@@ -948,7 +948,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
return false; return false;
} }
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final ZoneType origin = ZoneType.listValueOf(sa.getParam("Origin")).get(0); final ZoneType origin = ZoneType.listValueOf(sa.getParam("Origin")).get(0);
final ZoneType destination = ZoneType.smartValueOf(sa.getParam("Destination")); final ZoneType destination = ZoneType.smartValueOf(sa.getParam("Destination"));
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
@@ -978,7 +978,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
} }
// target loop // target loop
while (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa)) { while (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) {
// AI Targeting // AI Targeting
Card choice = null; Card choice = null;
@@ -1020,7 +1020,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
} }
} }
if (choice == null) { // can't find anything left if (choice == null) { // can't find anything left
if ((sa.getTargets().getNumTargeted() == 0) || (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa))) { if ((sa.getTargets().getNumTargeted() == 0) || (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa))) {
sa.resetTargets(); sa.resetTargets();
return false; return false;
} else { } else {
@@ -1057,7 +1057,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
if (sa.getTargetRestrictions() == null) { if (sa.getTargetRestrictions() == null) {
// Just in case of Defined cases // Just in case of Defined cases
if (!mandatory && sa.hasParam("AttachedTo")) { if (!mandatory && sa.hasParam("AttachedTo")) {
final List<Card> list = AbilityUtils.getDefinedCards(sa.getSourceCard(), sa.getParam("AttachedTo"), sa); final List<Card> list = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("AttachedTo"), sa);
if (!list.isEmpty()) { if (!list.isEmpty()) {
final Card attachedTo = list.get(0); final Card attachedTo = list.get(0);
// This code is for the Dragon auras // This code is for the Dragon auras
@@ -1132,7 +1132,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
} }
} else { } else {
// Don't fetch another tutor with the same name // Don't fetch another tutor with the same name
List<Card> sameNamed = CardLists.filter(fetchList, Predicates.not(CardPredicates.nameEquals(sa.getSourceCard().getName()))); List<Card> sameNamed = CardLists.filter(fetchList, Predicates.not(CardPredicates.nameEquals(sa.getHostCard().getName())));
if (origin.contains(ZoneType.Library) && !sameNamed.isEmpty()) { if (origin.contains(ZoneType.Library) && !sameNamed.isEmpty()) {
fetchList = sameNamed; fetchList = sameNamed;
} }

View File

@@ -26,7 +26,7 @@ public class ChangeZoneAllAi extends SpellAbilityAi {
protected boolean canPlayAI(Player ai, SpellAbility sa) { protected boolean canPlayAI(Player ai, SpellAbility sa) {
// Change Zone All, can be any type moving from one zone to another // Change Zone All, can be any type moving from one zone to another
final Cost abCost = sa.getPayCosts(); final Cost abCost = sa.getPayCosts();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final ZoneType destination = ZoneType.smartValueOf(sa.getParam("Destination")); final ZoneType destination = ZoneType.smartValueOf(sa.getParam("Destination"));
final ZoneType origin = ZoneType.listValueOf(sa.getParam("Origin")).get(0); final ZoneType origin = ZoneType.listValueOf(sa.getParam("Origin")).get(0);

View File

@@ -26,7 +26,7 @@ public class ChooseCardAi extends SpellAbilityAi {
*/ */
@Override @Override
protected boolean canPlayAI(final Player ai, SpellAbility sa) { protected boolean canPlayAI(final Player ai, SpellAbility sa) {
final Card host = sa.getSourceCard(); final Card host = sa.getHostCard();
final Game game = ai.getGame(); final Game game = ai.getGame();
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
@@ -100,7 +100,7 @@ public class ChooseCardAi extends SpellAbilityAi {
*/ */
@Override @Override
public Card chooseSingleCard(final Player ai, SpellAbility sa, Collection<Card> options, boolean isOptional, Player targetedPlayer) { public Card chooseSingleCard(final Player ai, SpellAbility sa, Collection<Card> options, boolean isOptional, Player targetedPlayer) {
final Card host = sa.getSourceCard(); final Card host = sa.getHostCard();
final String logic = sa.getParam("AILogic"); final String logic = sa.getParam("AILogic");
Card choice = null; Card choice = null;
if (logic == null) { if (logic == null) {

View File

@@ -13,7 +13,7 @@ public class ChooseCardNameAi extends SpellAbilityAi {
@Override @Override
protected boolean canPlayAI(Player ai, SpellAbility sa) { protected boolean canPlayAI(Player ai, SpellAbility sa) {
Card source = sa.getSourceCard(); Card source = sa.getHostCard();
if (sa.hasParam("AILogic")) { if (sa.hasParam("AILogic")) {
// Don't tap creatures that may be able to block // Don't tap creatures that may be able to block
if (ComputerUtil.waitForBlocking(sa)) { if (ComputerUtil.waitForBlocking(sa)) {

View File

@@ -35,9 +35,9 @@ public class ChooseSourceAi extends SpellAbilityAi {
// to be prevented (e.g. so the AI doesn't attack with a creature that will not deal any damage // to be prevented (e.g. so the AI doesn't attack with a creature that will not deal any damage
// to the player because a CoP was pre-activated on it - unless, of course, there's another // to the player because a CoP was pre-activated on it - unless, of course, there's another
// possible reason to attack with that creature). // possible reason to attack with that creature).
final Card host = sa.getSourceCard(); final Card host = sa.getHostCard();
final Cost abCost = sa.getPayCosts(); final Cost abCost = sa.getPayCosts();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
if (abCost != null) { if (abCost != null) {
// AI currently disabled for these costs // AI currently disabled for these costs
@@ -72,7 +72,7 @@ public class ChooseSourceAi extends SpellAbilityAi {
if (sa.getParam("AILogic").equals("NeedsPrevention")) { if (sa.getParam("AILogic").equals("NeedsPrevention")) {
if (!game.getStack().isEmpty()) { if (!game.getStack().isEmpty()) {
final SpellAbility topStack = game.getStack().peekAbility(); final SpellAbility topStack = game.getStack().peekAbility();
if (sa.hasParam("Choices") && !topStack.getSourceCard().isValid(sa.getParam("Choices"), ai, source)) { if (sa.hasParam("Choices") && !topStack.getHostCard().isValid(sa.getParam("Choices"), ai, source)) {
return false; return false;
} }
final ApiType threatApi = topStack.getApi(); final ApiType threatApi = topStack.getApi();
@@ -80,7 +80,7 @@ public class ChooseSourceAi extends SpellAbilityAi {
return false; return false;
} }
final Card threatSource = topStack.getSourceCard(); final Card threatSource = topStack.getHostCard();
List<? extends GameObject> objects = getTargets(topStack); List<? extends GameObject> objects = getTargets(topStack);
if (!topStack.usesTargeting() && topStack.hasParam("ValidPlayers") && !topStack.hasParam("Defined")) { if (!topStack.usesTargeting() && topStack.hasParam("ValidPlayers") && !topStack.hasParam("Defined")) {
objects = AbilityUtils.getDefinedPlayers(threatSource, topStack.getParam("ValidPlayers"), topStack); objects = AbilityUtils.getDefinedPlayers(threatSource, topStack.getParam("ValidPlayers"), topStack);
@@ -159,7 +159,7 @@ public class ChooseSourceAi extends SpellAbilityAi {
final Card source = si.getSourceCard(); final Card source = si.getSourceCard();
final SpellAbility abilityOnStack = si.getSpellAbility(); final SpellAbility abilityOnStack = si.getSpellAbility();
if (sa.hasParam("Choices") && !abilityOnStack.getSourceCard().isValid(sa.getParam("Choices"), ai, sa.getSourceCard())) { if (sa.hasParam("Choices") && !abilityOnStack.getHostCard().isValid(sa.getParam("Choices"), ai, sa.getHostCard())) {
continue; continue;
} }
final ApiType threatApi = abilityOnStack.getApi(); final ApiType threatApi = abilityOnStack.getApi();

View File

@@ -21,7 +21,7 @@ public class ChooseTypeAi extends SpellAbilityAi {
sa.resetTargets(); sa.resetTargets();
sa.getTargets().add(ai); sa.getTargets().add(ai);
} else { } else {
for (final Player p : AbilityUtils.getDefinedPlayers(sa.getSourceCard(), sa.getParam("Defined"), sa)) { for (final Player p : AbilityUtils.getDefinedPlayers(sa.getHostCard(), sa.getParam("Defined"), sa)) {
if (p.isOpponentOf(ai) && !mandatory) { if (p.isOpponentOf(ai) && !mandatory) {
return false; return false;
} }

View File

@@ -18,7 +18,7 @@ public class CloneAi extends SpellAbilityAi {
@Override @Override
protected boolean canPlayAI(Player ai, SpellAbility sa) { protected boolean canPlayAI(Player ai, SpellAbility sa) {
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final Game game = source.getGame(); final Game game = source.getGame();
boolean useAbility = true; boolean useAbility = true;

View File

@@ -28,7 +28,7 @@ public class ControlExchangeAi extends SpellAbilityAi {
sa.resetTargets(); sa.resetTargets();
List<Card> list = List<Card> list =
CardLists.getValidCards(ai.getOpponent().getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), ai, sa.getSourceCard()); CardLists.getValidCards(ai.getOpponent().getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), ai, sa.getHostCard());
// AI won't try to grab cards that are filtered out of AI decks on // AI won't try to grab cards that are filtered out of AI decks on
// purpose // purpose
list = CardLists.filter(list, new Predicate<Card>() { list = CardLists.filter(list, new Predicate<Card>() {
@@ -40,10 +40,10 @@ public class ControlExchangeAi extends SpellAbilityAi {
}); });
object1 = ComputerUtilCard.getBestAI(list); object1 = ComputerUtilCard.getBestAI(list);
if (sa.hasParam("Defined")) { if (sa.hasParam("Defined")) {
object2 = AbilityUtils.getDefinedCards(sa.getSourceCard(), sa.getParam("Defined"), sa).get(0); object2 = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa).get(0);
} else if (tgt.getMinTargets(sa.getSourceCard(), sa) > 1) { } else if (tgt.getMinTargets(sa.getHostCard(), sa) > 1) {
List<Card> list2 = ai.getCardsIn(ZoneType.Battlefield); List<Card> list2 = ai.getCardsIn(ZoneType.Battlefield);
list2 = CardLists.getValidCards(list2, tgt.getValidTgts(), ai, sa.getSourceCard()); list2 = CardLists.getValidCards(list2, tgt.getValidTgts(), ai, sa.getHostCard());
object2 = ComputerUtilCard.getWorstAI(list2); object2 = ComputerUtilCard.getWorstAI(list2);
sa.getTargets().add(object2); sa.getTargets().add(object2);
} }

View File

@@ -106,7 +106,7 @@ public class ControlGainAi extends SpellAbilityAi {
} }
List<Card> list = List<Card> list =
CardLists.getValidCards(opp.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard()); CardLists.getValidCards(opp.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getHostCard());
// AI won't try to grab cards that are filtered out of AI decks on purpose // AI won't try to grab cards that are filtered out of AI decks on purpose
list = CardLists.filter(list, new Predicate<Card>() { list = CardLists.filter(list, new Predicate<Card>() {
@@ -130,7 +130,7 @@ public class ControlGainAi extends SpellAbilityAi {
return false; return false;
} }
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getSourceCard(), sa)) { while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getHostCard(), sa)) {
Card t = null; Card t = null;
for (final Card c : list) { for (final Card c : list) {
if (c.isCreature()) { if (c.isCreature()) {
@@ -148,7 +148,7 @@ public class ControlGainAi extends SpellAbilityAi {
} }
if (list.isEmpty()) { if (list.isEmpty()) {
if ((sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa)) || (sa.getTargets().getNumTargeted() == 0)) { if ((sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) || (sa.getTargets().getNumTargeted() == 0)) {
sa.resetTargets(); sa.resetTargets();
return false; return false;
} else { } else {

View File

@@ -25,7 +25,7 @@ public class CopyPermanentAi extends SpellAbilityAi {
*/ */
@Override @Override
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) { protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
// Card source = sa.getSourceCard(); // Card source = sa.getHostCard();
// TODO - I'm sure someone can do this AI better // TODO - I'm sure someone can do this AI better
if (ComputerUtil.preventRunAwayActivations(sa)) { if (ComputerUtil.preventRunAwayActivations(sa)) {
@@ -41,7 +41,7 @@ public class CopyPermanentAi extends SpellAbilityAi {
@Override @Override
protected boolean doTriggerAINoCost(final Player aiPlayer, SpellAbility sa, boolean mandatory) { protected boolean doTriggerAINoCost(final Player aiPlayer, SpellAbility sa, boolean mandatory) {
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
// //// // ////
// Targeting // Targeting
@@ -61,9 +61,9 @@ public class CopyPermanentAi extends SpellAbilityAi {
}); });
sa.resetTargets(); sa.resetTargets();
// target loop // target loop
while (sa.getTargets().getNumTargeted() < abTgt.getMaxTargets(sa.getSourceCard(), sa)) { while (sa.getTargets().getNumTargeted() < abTgt.getMaxTargets(sa.getHostCard(), sa)) {
if (list.isEmpty()) { if (list.isEmpty()) {
if ((sa.getTargets().getNumTargeted() < abTgt.getMinTargets(sa.getSourceCard(), sa)) if ((sa.getTargets().getNumTargeted() < abTgt.getMinTargets(sa.getHostCard(), sa))
|| (sa.getTargets().getNumTargeted() == 0)) { || (sa.getTargets().getNumTargeted() == 0)) {
sa.resetTargets(); sa.resetTargets();
return false; return false;
@@ -87,7 +87,7 @@ public class CopyPermanentAi extends SpellAbilityAi {
} }
if (choice == null) { // can't find anything left if (choice == null) { // can't find anything left
if ((sa.getTargets().getNumTargeted() < abTgt.getMinTargets(sa.getSourceCard(), sa)) if ((sa.getTargets().getNumTargeted() < abTgt.getMinTargets(sa.getHostCard(), sa))
|| (sa.getTargets().getNumTargeted() == 0)) { || (sa.getTargets().getNumTargeted() == 0)) {
sa.resetTargets(); sa.resetTargets();
return false; return false;

View File

@@ -19,7 +19,7 @@ public class CounterAi extends SpellAbilityAi {
protected boolean canPlayAI(Player ai, SpellAbility sa) { protected boolean canPlayAI(Player ai, SpellAbility sa) {
boolean toReturn = true; boolean toReturn = true;
final Cost abCost = sa.getPayCosts(); final Cost abCost = sa.getPayCosts();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final Game game = ai.getGame(); final Game game = ai.getGame();
if (game.getStack().isEmpty()) { if (game.getStack().isEmpty()) {
return false; return false;
@@ -39,12 +39,12 @@ public class CounterAi extends SpellAbilityAi {
if (tgt != null) { if (tgt != null) {
final SpellAbility topSA = game.getStack().peekAbility(); final SpellAbility topSA = game.getStack().peekAbility();
if (!CardFactoryUtil.isCounterableBy(topSA.getSourceCard(), sa) || topSA.getActivatingPlayer() == ai) { if (!CardFactoryUtil.isCounterableBy(topSA.getHostCard(), sa) || topSA.getActivatingPlayer() == ai) {
// might as well check for player's friendliness // might as well check for player's friendliness
return false; return false;
} }
if (sa.hasParam("AITgts") && (topSA.getSourceCard() == null if (sa.hasParam("AITgts") && (topSA.getHostCard() == null
|| !topSA.getSourceCard().isValid(sa.getParam("AITgts"), sa.getActivatingPlayer(), source))) { || !topSA.getHostCard().isValid(sa.getParam("AITgts"), sa.getActivatingPlayer(), source))) {
return false; return false;
} }
@@ -115,7 +115,7 @@ public class CounterAi extends SpellAbilityAi {
return false; return false;
} }
final SpellAbility topSA = game.getStack().peekAbility(); final SpellAbility topSA = game.getStack().peekAbility();
if (!CardFactoryUtil.isCounterableBy(topSA.getSourceCard(), sa) || topSA.getActivatingPlayer() == ai) { if (!CardFactoryUtil.isCounterableBy(topSA.getHostCard(), sa) || topSA.getActivatingPlayer() == ai) {
return false; return false;
} }
@@ -128,7 +128,7 @@ public class CounterAi extends SpellAbilityAi {
String unlessCost = sa.hasParam("UnlessCost") ? sa.getParam("UnlessCost").trim() : null; String unlessCost = sa.hasParam("UnlessCost") ? sa.getParam("UnlessCost").trim() : null;
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
if (unlessCost != null) { if (unlessCost != null) {
// Is this Usable Mana Sources? Or Total Available Mana? // Is this Usable Mana Sources? Or Total Available Mana?
final int usableManaSources = ComputerUtilMana.getAvailableMana(ai.getOpponent(), true).size(); final int usableManaSources = ComputerUtilMana.getAvailableMana(ai.getOpponent(), true).size();

View File

@@ -28,7 +28,7 @@ public class CountersMoveAi extends SpellAbilityAi {
// TODO handle proper calculation of X values based on Cost // TODO handle proper calculation of X values based on Cost
int amount = 0; int amount = 0;
if (!sa.getParam("CounterNum").equals("All")) { if (!sa.getParam("CounterNum").equals("All")) {
amount = AbilityUtils.calculateAmount(sa.getSourceCard(), amountStr, sa); amount = AbilityUtils.calculateAmount(sa.getHostCard(), amountStr, sa);
} }
// don't use it if no counters to add // don't use it if no counters to add
if (amount <= 0) { if (amount <= 0) {
@@ -47,13 +47,13 @@ public class CountersMoveAi extends SpellAbilityAi {
@Override @Override
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) { protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
final Card host = sa.getSourceCard(); final Card host = sa.getHostCard();
final TargetRestrictions abTgt = sa.getTargetRestrictions(); final TargetRestrictions abTgt = sa.getTargetRestrictions();
final String type = sa.getParam("CounterType"); final String type = sa.getParam("CounterType");
final String amountStr = sa.getParam("CounterNum"); final String amountStr = sa.getParam("CounterNum");
int amount = 0; int amount = 0;
if (!sa.getParam("CounterNum").equals("All")) { if (!sa.getParam("CounterNum").equals("All")) {
amount = AbilityUtils.calculateAmount(sa.getSourceCard(), amountStr, sa); amount = AbilityUtils.calculateAmount(sa.getHostCard(), amountStr, sa);
} }
boolean chance = false; boolean chance = false;
boolean preferred = true; boolean preferred = true;

View File

@@ -32,7 +32,7 @@ public class CountersPutAi extends SpellAbilityAi {
final Random r = MyRandom.getRandom(); final Random r = MyRandom.getRandom();
final Cost abCost = sa.getPayCosts(); final Cost abCost = sa.getPayCosts();
final TargetRestrictions abTgt = sa.getTargetRestrictions(); final TargetRestrictions abTgt = sa.getTargetRestrictions();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
List<Card> list; List<Card> list;
Card choice = null; Card choice = null;
final String type = sa.getParam("CounterType"); final String type = sa.getParam("CounterType");
@@ -120,9 +120,9 @@ public class CountersPutAi extends SpellAbilityAi {
if (list.size() < abTgt.getMinTargets(source, sa)) { if (list.size() < abTgt.getMinTargets(source, sa)) {
return false; return false;
} }
while (sa.getTargets().getNumTargeted() < abTgt.getMaxTargets(sa.getSourceCard(), sa)) { while (sa.getTargets().getNumTargeted() < abTgt.getMaxTargets(sa.getHostCard(), sa)) {
if (list.isEmpty()) { if (list.isEmpty()) {
if ((sa.getTargets().getNumTargeted() < abTgt.getMinTargets(sa.getSourceCard(), sa)) if ((sa.getTargets().getNumTargeted() < abTgt.getMinTargets(sa.getHostCard(), sa))
|| (sa.getTargets().getNumTargeted() == 0)) { || (sa.getTargets().getNumTargeted() == 0)) {
sa.resetTargets(); sa.resetTargets();
return false; return false;
@@ -139,7 +139,7 @@ public class CountersPutAi extends SpellAbilityAi {
} }
if (choice == null) { // can't find anything left if (choice == null) { // can't find anything left
if ((sa.getTargets().getNumTargeted() < abTgt.getMinTargets(sa.getSourceCard(), sa)) if ((sa.getTargets().getNumTargeted() < abTgt.getMinTargets(sa.getHostCard(), sa))
|| (sa.getTargets().getNumTargeted() == 0)) { || (sa.getTargets().getNumTargeted() == 0)) {
sa.resetTargets(); sa.resetTargets();
return false; return false;
@@ -158,7 +158,7 @@ public class CountersPutAi extends SpellAbilityAi {
} }
} }
} else { } else {
final List<Card> cards = AbilityUtils.getDefinedCards(sa.getSourceCard(), sa.getParam("Defined"), sa); final List<Card> cards = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa);
// Don't activate Curse abilities on my cards and non-curse abilites // Don't activate Curse abilities on my cards and non-curse abilites
// on my opponents // on my opponents
if (cards.isEmpty() || !cards.get(0).getController().equals(player)) { if (cards.isEmpty() || !cards.get(0).getController().equals(player)) {
@@ -197,12 +197,12 @@ public class CountersPutAi extends SpellAbilityAi {
public boolean chkAIDrawback(final SpellAbility sa, Player ai) { public boolean chkAIDrawback(final SpellAbility sa, Player ai) {
boolean chance = true; boolean chance = true;
final TargetRestrictions abTgt = sa.getTargetRestrictions(); final TargetRestrictions abTgt = sa.getTargetRestrictions();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
Card choice = null; Card choice = null;
final String type = sa.getParam("CounterType"); final String type = sa.getParam("CounterType");
final String amountStr = sa.getParam("CounterNum"); final String amountStr = sa.getParam("CounterNum");
final boolean divided = sa.hasParam("DividedAsYouChoose"); final boolean divided = sa.hasParam("DividedAsYouChoose");
final int amount = AbilityUtils.calculateAmount(sa.getSourceCard(), amountStr, sa); final int amount = AbilityUtils.calculateAmount(sa.getHostCard(), amountStr, sa);
final Player player = sa.isCurse() ? ai.getOpponent() : ai; final Player player = sa.isCurse() ? ai.getOpponent() : ai;
@@ -216,7 +216,7 @@ public class CountersPutAi extends SpellAbilityAi {
sa.resetTargets(); sa.resetTargets();
// target loop // target loop
while (sa.getTargets().getNumTargeted() < abTgt.getMaxTargets(sa.getSourceCard(), sa)) { while (sa.getTargets().getNumTargeted() < abTgt.getMaxTargets(sa.getHostCard(), sa)) {
list = CardLists.filter(list, new Predicate<Card>() { list = CardLists.filter(list, new Predicate<Card>() {
@Override @Override
public boolean apply(final Card c) { public boolean apply(final Card c) {
@@ -224,7 +224,7 @@ public class CountersPutAi extends SpellAbilityAi {
} }
}); });
if (list.size() == 0) { if (list.size() == 0) {
if ((sa.getTargets().getNumTargeted() < abTgt.getMinTargets(sa.getSourceCard(), sa)) if ((sa.getTargets().getNumTargeted() < abTgt.getMinTargets(sa.getHostCard(), sa))
|| (sa.getTargets().getNumTargeted() == 0)) { || (sa.getTargets().getNumTargeted() == 0)) {
sa.resetTargets(); sa.resetTargets();
return false; return false;
@@ -240,7 +240,7 @@ public class CountersPutAi extends SpellAbilityAi {
} }
if (choice == null) { // can't find anything left if (choice == null) { // can't find anything left
if ((sa.getTargets().getNumTargeted() < abTgt.getMinTargets(sa.getSourceCard(), sa)) if ((sa.getTargets().getNumTargeted() < abTgt.getMinTargets(sa.getHostCard(), sa))
|| (sa.getTargets().getNumTargeted() == 0)) { || (sa.getTargets().getNumTargeted() == 0)) {
sa.resetTargets(); sa.resetTargets();
return false; return false;
@@ -264,7 +264,7 @@ public class CountersPutAi extends SpellAbilityAi {
@Override @Override
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) { protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
final TargetRestrictions abTgt = sa.getTargetRestrictions(); final TargetRestrictions abTgt = sa.getTargetRestrictions();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
// boolean chance = true; // boolean chance = true;
boolean preferred = true; boolean preferred = true;
List<Card> list; List<Card> list;
@@ -273,7 +273,7 @@ public class CountersPutAi extends SpellAbilityAi {
final String type = sa.getParam("CounterType"); final String type = sa.getParam("CounterType");
final String amountStr = sa.getParam("CounterNum"); final String amountStr = sa.getParam("CounterNum");
final boolean divided = sa.hasParam("DividedAsYouChoose"); final boolean divided = sa.hasParam("DividedAsYouChoose");
final int amount = AbilityUtils.calculateAmount(sa.getSourceCard(), amountStr, sa); final int amount = AbilityUtils.calculateAmount(sa.getHostCard(), amountStr, sa);
if (abTgt == null) { if (abTgt == null) {
// No target. So must be defined // No target. So must be defined
@@ -348,7 +348,7 @@ public class CountersPutAi extends SpellAbilityAi {
*/ */
@Override @Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) {
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
if (mode == PlayerActionConfirmMode.Tribute) { if (mode == PlayerActionConfirmMode.Tribute) {
// add counter if that opponent has a giant creature // add counter if that opponent has a giant creature
final List<Card> creats = player.getCreaturesInPlay(); final List<Card> creats = player.getCreaturesInPlay();

View File

@@ -29,7 +29,7 @@ public class CountersPutAllAi extends SpellAbilityAi {
// the expected targets could be // the expected targets could be
final Random r = MyRandom.getRandom(); final Random r = MyRandom.getRandom();
final Cost abCost = sa.getPayCosts(); final Cost abCost = sa.getPayCosts();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
List<Card> hList; List<Card> hList;
List<Card> cList; List<Card> cList;
final String type = sa.getParam("CounterType"); final String type = sa.getParam("CounterType");
@@ -72,7 +72,7 @@ public class CountersPutAllAi extends SpellAbilityAi {
amount = ComputerUtilMana.determineLeftoverMana(sa, ai); amount = ComputerUtilMana.determineLeftoverMana(sa, ai);
source.setSVar("PayX", Integer.toString(amount)); source.setSVar("PayX", Integer.toString(amount));
} else { } else {
amount = AbilityUtils.calculateAmount(sa.getSourceCard(), amountStr, sa); amount = AbilityUtils.calculateAmount(sa.getHostCard(), amountStr, sa);
} }
// prevent run-away activations - first time will always return true // prevent run-away activations - first time will always return true

View File

@@ -51,7 +51,7 @@ public class CountersPutOrRemoveAi extends SpellAbilityAi {
List<ZoneType> zones = ZoneType.listValueOf(sa.getParamOrDefault("TgtZones", "Battlefield")); List<ZoneType> zones = ZoneType.listValueOf(sa.getParamOrDefault("TgtZones", "Battlefield"));
List<Card> validCards = CardLists.getValidCards(ai.getGame().getCardsIn(zones), List<Card> validCards = CardLists.getValidCards(ai.getGame().getCardsIn(zones),
tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard()); tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getHostCard());
if (validCards.isEmpty()) { if (validCards.isEmpty()) {
return false; return false;
@@ -72,9 +72,9 @@ public class CountersPutOrRemoveAi extends SpellAbilityAi {
} }
} }
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getSourceCard(), sa)) { while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getHostCard(), sa)) {
Card targetCard = null; Card targetCard = null;
if (cWithCounters.isEmpty() && ((sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa)) if (cWithCounters.isEmpty() && ((sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa))
|| (sa.getTargets().getNumTargeted() == 0))) { || (sa.getTargets().getNumTargeted() == 0))) {
sa.resetTargets(); sa.resetTargets();
return false; return false;

View File

@@ -20,7 +20,7 @@ public class CountersRemoveAi extends SpellAbilityAi {
// the expected targets could be // the expected targets could be
final Cost abCost = sa.getPayCosts(); final Cost abCost = sa.getPayCosts();
TargetRestrictions abTgt = sa.getTargetRestrictions(); TargetRestrictions abTgt = sa.getTargetRestrictions();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
// List<Card> list; // List<Card> list;
// Card choice = null; // Card choice = null;
@@ -59,7 +59,7 @@ public class CountersRemoveAi extends SpellAbilityAi {
} }
// TODO handle proper calculation of X values based on Cost // TODO handle proper calculation of X values based on Cost
// final int amount = calculateAmount(sa.getSourceCard(), amountStr, sa); // final int amount = calculateAmount(sa.getHostCard(), amountStr, sa);
if (ComputerUtil.preventRunAwayActivations(sa)) { if (ComputerUtil.preventRunAwayActivations(sa)) {
return false; return false;
@@ -77,7 +77,7 @@ public class CountersRemoveAi extends SpellAbilityAi {
} }
if (!type.matches("Any")) { if (!type.matches("Any")) {
final int currCounters = sa.getSourceCard().getCounters(CounterType.valueOf(type)); final int currCounters = sa.getHostCard().getCounters(CounterType.valueOf(type));
if (currCounters < 1) { if (currCounters < 1) {
return false; return false;
} }

View File

@@ -31,9 +31,9 @@ public abstract class DamageAiBase extends SpellAbilityAi {
} }
if (!noPrevention) { if (!noPrevention) {
restDamage = ComputerUtilCombat.predictDamageTo(enemy, restDamage, sa.getSourceCard(), false); restDamage = ComputerUtilCombat.predictDamageTo(enemy, restDamage, sa.getHostCard(), false);
} else { } else {
restDamage = enemy.staticReplaceDamage(restDamage, sa.getSourceCard(), false); restDamage = enemy.staticReplaceDamage(restDamage, sa.getHostCard(), false);
} }
if (restDamage == 0) { if (restDamage == 0) {

View File

@@ -24,12 +24,12 @@ public class DamageAllAi extends SpellAbilityAi {
// based on what the expected targets could be // based on what the expected targets could be
final Random r = MyRandom.getRandom(); final Random r = MyRandom.getRandom();
final Cost abCost = sa.getPayCosts(); final Cost abCost = sa.getPayCosts();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
String validP = ""; String validP = "";
final String damage = sa.getParam("NumDmg"); final String damage = sa.getParam("NumDmg");
int dmg = AbilityUtils.calculateAmount(sa.getSourceCard(), damage, sa); int dmg = AbilityUtils.calculateAmount(sa.getHostCard(), damage, sa);
if (damage.equals("X") && sa.getSVar(damage).equals("Count$xPaid")) { if (damage.equals("X") && sa.getSVar(damage).equals("Count$xPaid")) {
@@ -99,11 +99,11 @@ public class DamageAllAi extends SpellAbilityAi {
@Override @Override
public boolean chkAIDrawback(SpellAbility sa, Player ai) { public boolean chkAIDrawback(SpellAbility sa, Player ai) {
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
String validP = ""; String validP = "";
final String damage = sa.getParam("NumDmg"); final String damage = sa.getParam("NumDmg");
int dmg = AbilityUtils.calculateAmount(sa.getSourceCard(), damage, sa); int dmg = AbilityUtils.calculateAmount(sa.getHostCard(), damage, sa);
if (damage.equals("X") && sa.getSVar(damage).equals("Count$xPaid")) { if (damage.equals("X") && sa.getSVar(damage).equals("Count$xPaid")) {
// Set PayX here to maximum value. // Set PayX here to maximum value.
@@ -161,7 +161,7 @@ public class DamageAllAi extends SpellAbilityAi {
* @return a {@link forge.CardList} object. * @return a {@link forge.CardList} object.
*/ */
private List<Card> getKillableCreatures(final SpellAbility sa, final Player player, final int dmg) { private List<Card> getKillableCreatures(final SpellAbility sa, final Player player, final int dmg) {
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
String validC = sa.hasParam("ValidCards") ? sa.getParam("ValidCards") : ""; String validC = sa.hasParam("ValidCards") ? sa.getParam("ValidCards") : "";
// TODO: X may be something different than X paid // TODO: X may be something different than X paid
@@ -183,11 +183,11 @@ public class DamageAllAi extends SpellAbilityAi {
@Override @Override
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) { protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
String validP = ""; String validP = "";
final String damage = sa.getParam("NumDmg"); final String damage = sa.getParam("NumDmg");
int dmg = AbilityUtils.calculateAmount(sa.getSourceCard(), damage, sa); int dmg = AbilityUtils.calculateAmount(sa.getHostCard(), damage, sa);
if (damage.equals("X") && sa.getSVar(damage).equals("Count$xPaid")) { if (damage.equals("X") && sa.getSVar(damage).equals("Count$xPaid")) {
// Set PayX here to maximum value. // Set PayX here to maximum value.

View File

@@ -28,9 +28,9 @@ public class DamageDealAi extends DamageAiBase {
@Override @Override
public boolean chkAIDrawback(SpellAbility sa, Player ai) { public boolean chkAIDrawback(SpellAbility sa, Player ai) {
final String damage = sa.getParam("NumDmg"); final String damage = sa.getParam("NumDmg");
int dmg = AbilityUtils.calculateAmount(sa.getSourceCard(), damage, sa); int dmg = AbilityUtils.calculateAmount(sa.getHostCard(), damage, sa);
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
if (damage.equals("X") && sa.getSVar(damage).equals("Count$xPaid")) { if (damage.equals("X") && sa.getSVar(damage).equals("Count$xPaid")) {
// Set PayX here to maximum value. // Set PayX here to maximum value.
@@ -47,10 +47,10 @@ public class DamageDealAi extends DamageAiBase {
protected boolean canPlayAI(Player ai, SpellAbility sa) { protected boolean canPlayAI(Player ai, SpellAbility sa) {
final Cost abCost = sa.getPayCosts(); final Cost abCost = sa.getPayCosts();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final String damage = sa.getParam("NumDmg"); final String damage = sa.getParam("NumDmg");
int dmg = AbilityUtils.calculateAmount(sa.getSourceCard(), damage, sa); int dmg = AbilityUtils.calculateAmount(sa.getHostCard(), damage, sa);
if (damage.equals("X") && sa.getSVar(damage).equals("Count$xPaid")) { if (damage.equals("X") && sa.getSVar(damage).equals("Count$xPaid")) {
// Set PayX here to maximum value. // Set PayX here to maximum value.
@@ -140,7 +140,7 @@ public class DamageDealAi extends DamageAiBase {
return null; return null;
} }
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
List<Card> hPlay = CardLists.getValidCards(pl.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), ai, source); List<Card> hPlay = CardLists.getValidCards(pl.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), ai, source);
final List<GameObject> objects = Lists.newArrayList(sa.getTargets().getTargets()); final List<GameObject> objects = Lists.newArrayList(sa.getTargets().getTargets());
@@ -231,7 +231,7 @@ public class DamageDealAi extends DamageAiBase {
*/ */
private boolean damageChoosingTargets(final Player ai, final SpellAbility sa, final TargetRestrictions tgt, int dmg, private boolean damageChoosingTargets(final Player ai, final SpellAbility sa, final TargetRestrictions tgt, int dmg,
final boolean isTrigger, final boolean mandatory) { final boolean isTrigger, final boolean mandatory) {
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final boolean noPrevention = sa.hasParam("NoPrevention"); final boolean noPrevention = sa.hasParam("NoPrevention");
final Game game = source.getGame(); final Game game = source.getGame();
final PhaseHandler phase = game.getPhaseHandler(); final PhaseHandler phase = game.getPhaseHandler();
@@ -368,14 +368,14 @@ public class DamageDealAi extends DamageAiBase {
*/ */
private boolean damageChooseNontargeted(Player ai, final SpellAbility saMe, final int dmg) { private boolean damageChooseNontargeted(Player ai, final SpellAbility saMe, final int dmg) {
// TODO: Improve circumstances where the Defined Damage is unwanted // TODO: Improve circumstances where the Defined Damage is unwanted
final List<GameObject> objects = AbilityUtils.getDefinedObjects(saMe.getSourceCard(), saMe.getParam("Defined"), saMe); final List<GameObject> objects = AbilityUtils.getDefinedObjects(saMe.getHostCard(), saMe.getParam("Defined"), saMe);
boolean urgent = false; // can it wait? boolean urgent = false; // can it wait?
boolean positive = false; boolean positive = false;
for (final Object o : objects) { for (final Object o : objects) {
if (o instanceof Card) { if (o instanceof Card) {
Card c = (Card) o; Card c = (Card) o;
final int restDamage = ComputerUtilCombat.predictDamageTo(c, dmg, saMe.getSourceCard(), false); final int restDamage = ComputerUtilCombat.predictDamageTo(c, dmg, saMe.getHostCard(), false);
if (!c.hasKeyword("Indestructible") && ComputerUtilCombat.getDamageToKill(c) <= restDamage) { if (!c.hasKeyword("Indestructible") && ComputerUtilCombat.getDamageToKill(c) <= restDamage) {
if (c.getController().equals(ai)) { if (c.getController().equals(ai)) {
return false; return false;
@@ -388,7 +388,7 @@ public class DamageDealAi extends DamageAiBase {
} }
} else if (o instanceof Player) { } else if (o instanceof Player) {
final Player p = (Player) o; final Player p = (Player) o;
final int restDamage = ComputerUtilCombat.predictDamageTo(p, dmg, saMe.getSourceCard(), false); final int restDamage = ComputerUtilCombat.predictDamageTo(p, dmg, saMe.getHostCard(), false);
if (!p.isOpponentOf(ai) && p.canLoseLife() && restDamage + 3 >= p.getLife() && restDamage > 0) { if (!p.isOpponentOf(ai) && p.canLoseLife() && restDamage + 3 >= p.getLife() && restDamage > 0) {
// from this spell will kill me // from this spell will kill me
return false; return false;
@@ -431,7 +431,7 @@ public class DamageDealAi extends DamageAiBase {
final boolean noPrevention = sa.hasParam("NoPrevention"); final boolean noPrevention = sa.hasParam("NoPrevention");
final boolean divided = sa.hasParam("DividedAsYouChoose"); final boolean divided = sa.hasParam("DividedAsYouChoose");
while (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa)) { while (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) {
// TODO: Consider targeting the planeswalker // TODO: Consider targeting the planeswalker
if (tgt.canTgtCreature()) { if (tgt.canTgtCreature()) {
final Card c = this.dealDamageChooseTgtC(ai, sa, dmg, noPrevention, ai, mandatory); final Card c = this.dealDamageChooseTgtC(ai, sa, dmg, noPrevention, ai, mandatory);
@@ -465,7 +465,7 @@ public class DamageDealAi extends DamageAiBase {
@Override @Override
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) { protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final String damage = sa.getParam("NumDmg"); final String damage = sa.getParam("NumDmg");
int dmg = AbilityUtils.calculateAmount(source, damage, sa); int dmg = AbilityUtils.calculateAmount(source, damage, sa);

View File

@@ -21,7 +21,7 @@ public class DamageEachAi extends DamageAiBase {
} }
final String damage = sa.getParam("NumDmg"); final String damage = sa.getParam("NumDmg");
final int iDmg = AbilityUtils.calculateAmount(sa.getSourceCard(), damage, sa); final int iDmg = AbilityUtils.calculateAmount(sa.getHostCard(), damage, sa);
return this.shouldTgtP(ai, sa, iDmg, false); return this.shouldTgtP(ai, sa, iDmg, false);
} }

View File

@@ -24,7 +24,7 @@ public class DamagePreventAi extends SpellAbilityAi {
@Override @Override
protected boolean canPlayAI(Player ai, SpellAbility sa) { protected boolean canPlayAI(Player ai, SpellAbility sa) {
final Card hostCard = sa.getSourceCard(); final Card hostCard = sa.getHostCard();
final Game game = ai.getGame(); final Game game = ai.getGame();
final Combat combat = game.getCombat(); final Combat combat = game.getCombat();
boolean chance = false; boolean chance = false;
@@ -52,7 +52,7 @@ public class DamagePreventAi extends SpellAbilityAi {
if (tgt == null) { if (tgt == null) {
// As far as I can tell these Defined Cards will only have one of // As far as I can tell these Defined Cards will only have one of
// them // them
final List<GameObject> objects = AbilityUtils.getDefinedObjects(sa.getSourceCard(), sa.getParam("Defined"), sa); final List<GameObject> objects = AbilityUtils.getDefinedObjects(sa.getHostCard(), sa.getParam("Defined"), sa);
// react to threats on the stack // react to threats on the stack
if (!game.getStack().isEmpty()) { if (!game.getStack().isEmpty()) {
@@ -145,7 +145,7 @@ public class DamagePreventAi extends SpellAbilityAi {
} }
} }
if (sa.hasParam("DividedAsYouChoose") && sa.getTargets() != null && !sa.getTargets().getTargets().isEmpty()) { if (sa.hasParam("DividedAsYouChoose") && sa.getTargets() != null && !sa.getTargets().getTargets().isEmpty()) {
tgt.addDividedAllocation(sa.getTargets().getTargets().get(0), AbilityUtils.calculateAmount(sa.getSourceCard(), sa.getParam("Amount"), sa)); tgt.addDividedAllocation(sa.getTargets().getTargets().get(0), AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("Amount"), sa));
} }
return chance; return chance;
@@ -184,7 +184,7 @@ public class DamagePreventAi extends SpellAbilityAi {
// filter AIs battlefield by what I can target // filter AIs battlefield by what I can target
final Game game = ai.getGame(); final Game game = ai.getGame();
List<Card> targetables = game.getCardsIn(ZoneType.Battlefield); List<Card> targetables = game.getCardsIn(ZoneType.Battlefield);
targetables = CardLists.getValidCards(targetables, tgt.getValidTgts(), ai, sa.getSourceCard()); targetables = CardLists.getValidCards(targetables, tgt.getValidTgts(), ai, sa.getHostCard());
final List<Card> compTargetables = CardLists.filterControlledBy(targetables, ai); final List<Card> compTargetables = CardLists.filterControlledBy(targetables, ai);
Card target = null; Card target = null;
@@ -216,7 +216,7 @@ public class DamagePreventAi extends SpellAbilityAi {
} }
sa.getTargets().add(target); sa.getTargets().add(target);
if (sa.hasParam("DividedAsYouChoose")) { if (sa.hasParam("DividedAsYouChoose")) {
tgt.addDividedAllocation(target, AbilityUtils.calculateAmount(sa.getSourceCard(), sa.getParam("Amount"), sa)); tgt.addDividedAllocation(target, AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("Amount"), sa));
} }
return true; return true;
} }

View File

@@ -16,7 +16,7 @@ public class DamagePreventAllAi extends SpellAbilityAi {
*/ */
@Override @Override
protected boolean canPlayAI(Player ai, SpellAbility sa) { protected boolean canPlayAI(Player ai, SpellAbility sa) {
final Card hostCard = sa.getSourceCard(); final Card hostCard = sa.getHostCard();
boolean chance = false; boolean chance = false;
final Cost cost = sa.getPayCosts(); final Cost cost = sa.getPayCosts();

View File

@@ -32,7 +32,7 @@ public class DebuffAi extends SpellAbilityAi {
@Override @Override
protected boolean canPlayAI(final Player ai, final SpellAbility sa) { protected boolean canPlayAI(final Player ai, final SpellAbility sa) {
// if there is no target and host card isn't in play, don't activate // if there is no target and host card isn't in play, don't activate
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final Game game = ai.getGame(); final Game game = ai.getGame();
if ((sa.getTargetRestrictions() == null) && !source.isInPlay()) { if ((sa.getTargetRestrictions() == null) && !source.isInPlay()) {
return false; return false;
@@ -75,7 +75,7 @@ public class DebuffAi extends SpellAbilityAi {
} }
if (!sa.usesTargeting() || !sa.getTargetRestrictions().doesTarget()) { if (!sa.usesTargeting() || !sa.getTargetRestrictions().doesTarget()) {
List<Card> cards = AbilityUtils.getDefinedCards(sa.getSourceCard(), sa.getParam("Defined"), sa); List<Card> cards = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa);
final Combat combat = game.getCombat(); final Combat combat = game.getCombat();
@@ -134,7 +134,7 @@ public class DebuffAi extends SpellAbilityAi {
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
sa.resetTargets(); sa.resetTargets();
List<Card> list = getCurseCreatures(ai, sa, kws == null ? Lists.<String>newArrayList() : kws); List<Card> list = getCurseCreatures(ai, sa, kws == null ? Lists.<String>newArrayList() : kws);
list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard()); list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getHostCard());
// several uses here: // several uses here:
// 1. make human creatures lose evasion when they are attacking // 1. make human creatures lose evasion when they are attacking
@@ -147,12 +147,12 @@ public class DebuffAi extends SpellAbilityAi {
return mandatory && debuffMandatoryTarget(ai, sa, mandatory); return mandatory && debuffMandatoryTarget(ai, sa, mandatory);
} }
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getSourceCard(), sa)) { while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getHostCard(), sa)) {
Card t = null; Card t = null;
// boolean goodt = false; // boolean goodt = false;
if (list.isEmpty()) { if (list.isEmpty()) {
if ((sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa)) || (sa.getTargets().getNumTargeted() == 0)) { if ((sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) || (sa.getTargets().getNumTargeted() == 0)) {
if (mandatory) { if (mandatory) {
return debuffMandatoryTarget(ai, sa, mandatory); return debuffMandatoryTarget(ai, sa, mandatory);
} }
@@ -220,9 +220,9 @@ public class DebuffAi extends SpellAbilityAi {
private boolean debuffMandatoryTarget(final Player ai, final SpellAbility sa, final boolean mandatory) { private boolean debuffMandatoryTarget(final Player ai, final SpellAbility sa, final boolean mandatory) {
List<Card> list = ai.getGame().getCardsIn(ZoneType.Battlefield); List<Card> list = ai.getGame().getCardsIn(ZoneType.Battlefield);
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard()); list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getHostCard());
if (list.size() < tgt.getMinTargets(sa.getSourceCard(), sa)) { if (list.size() < tgt.getMinTargets(sa.getHostCard(), sa)) {
sa.resetTargets(); sa.resetTargets();
return false; return false;
} }
@@ -234,7 +234,7 @@ public class DebuffAi extends SpellAbilityAi {
final List<Card> pref = CardLists.filterControlledBy(list, ai.getOpponent()); final List<Card> pref = CardLists.filterControlledBy(list, ai.getOpponent());
final List<Card> forced = CardLists.filterControlledBy(list, ai); final List<Card> forced = CardLists.filterControlledBy(list, ai);
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(source, sa)) { while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(source, sa)) {
if (pref.isEmpty()) { if (pref.isEmpty()) {
@@ -253,7 +253,7 @@ public class DebuffAi extends SpellAbilityAi {
sa.getTargets().add(c); sa.getTargets().add(c);
} }
while (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa)) { while (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) {
if (forced.isEmpty()) { if (forced.isEmpty()) {
break; break;
} }
@@ -272,7 +272,7 @@ public class DebuffAi extends SpellAbilityAi {
sa.getTargets().add(c); sa.getTargets().add(c);
} }
if (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa)) { if (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) {
sa.resetTargets(); sa.resetTargets();
return false; return false;
} }

View File

@@ -19,8 +19,8 @@ public class DebuffAllAi extends SpellAbilityAi {
protected boolean canPlayAI(Player ai, SpellAbility sa) { protected boolean canPlayAI(Player ai, SpellAbility sa) {
String valid = ""; String valid = "";
final Random r = MyRandom.getRandom(); final Random r = MyRandom.getRandom();
// final Card source = sa.getSourceCard(); // final Card source = sa.getHostCard();
final Card hostCard = sa.getSourceCard(); final Card hostCard = sa.getHostCard();
final Player opp = ai.getOpponent(); final Player opp = ai.getOpponent();
final boolean chance = r.nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn()); // to final boolean chance = r.nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn()); // to

View File

@@ -11,7 +11,7 @@ public class DelayedTriggerAi extends SpellAbilityAi {
@Override @Override
public boolean chkAIDrawback(SpellAbility sa, Player ai) { public boolean chkAIDrawback(SpellAbility sa, Player ai) {
final String svarName = sa.getParam("Execute"); final String svarName = sa.getParam("Execute");
final SpellAbility trigsa = AbilityFactory.getAbility(sa.getSourceCard().getSVar(svarName), sa.getSourceCard()); final SpellAbility trigsa = AbilityFactory.getAbility(sa.getHostCard().getSVar(svarName), sa.getHostCard());
trigsa.setActivatingPlayer(ai); trigsa.setActivatingPlayer(ai);
if (trigsa instanceof AbilitySub) { if (trigsa instanceof AbilitySub) {
@@ -24,7 +24,7 @@ public class DelayedTriggerAi extends SpellAbilityAi {
@Override @Override
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) { protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
final String svarName = sa.getParam("Execute"); final String svarName = sa.getParam("Execute");
final SpellAbility trigsa = AbilityFactory.getAbility(sa.getSourceCard().getSVar(svarName), sa.getSourceCard()); final SpellAbility trigsa = AbilityFactory.getAbility(sa.getHostCard().getSVar(svarName), sa.getHostCard());
trigsa.setActivatingPlayer(ai); trigsa.setActivatingPlayer(ai);
if (!sa.hasParam("OptionalDecider")) { if (!sa.hasParam("OptionalDecider")) {
@@ -37,7 +37,7 @@ public class DelayedTriggerAi extends SpellAbilityAi {
@Override @Override
protected boolean canPlayAI(Player ai, SpellAbility sa) { protected boolean canPlayAI(Player ai, SpellAbility sa) {
final String svarName = sa.getParam("Execute"); final String svarName = sa.getParam("Execute");
final SpellAbility trigsa = AbilityFactory.getAbility(sa.getSourceCard().getSVar(svarName), sa.getSourceCard()); final SpellAbility trigsa = AbilityFactory.getAbility(sa.getHostCard().getSVar(svarName), sa.getHostCard());
trigsa.setActivatingPlayer(ai); trigsa.setActivatingPlayer(ai);
return trigsa.canPlayAI(ai); return trigsa.canPlayAI(ai);
} }

View File

@@ -41,7 +41,7 @@ public class DestroyAi extends SpellAbilityAi {
final Random r = MyRandom.getRandom(); final Random r = MyRandom.getRandom();
final Cost abCost = sa.getPayCosts(); final Cost abCost = sa.getPayCosts();
final TargetRestrictions abTgt = sa.getTargetRestrictions(); final TargetRestrictions abTgt = sa.getTargetRestrictions();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final boolean noRegen = sa.hasParam("NoRegen"); final boolean noRegen = sa.hasParam("NoRegen");
List<Card> list; List<Card> list;
@@ -112,9 +112,9 @@ public class DestroyAi extends SpellAbilityAi {
return false; return false;
} }
// target loop // target loop
while (sa.getTargets().getNumTargeted() < abTgt.getMaxTargets(sa.getSourceCard(), sa)) { while (sa.getTargets().getNumTargeted() < abTgt.getMaxTargets(sa.getHostCard(), sa)) {
if (list.size() == 0) { if (list.size() == 0) {
if ((sa.getTargets().getNumTargeted() < abTgt.getMinTargets(sa.getSourceCard(), sa)) if ((sa.getTargets().getNumTargeted() < abTgt.getMinTargets(sa.getHostCard(), sa))
|| (sa.getTargets().getNumTargeted() == 0)) { || (sa.getTargets().getNumTargeted() == 0)) {
sa.resetTargets(); sa.resetTargets();
return false; return false;
@@ -135,7 +135,7 @@ public class DestroyAi extends SpellAbilityAi {
} }
if (choice == null) { // can't find anything left if (choice == null) { // can't find anything left
if ((sa.getTargets().getNumTargeted() < abTgt.getMinTargets(sa.getSourceCard(), sa)) if ((sa.getTargets().getNumTargeted() < abTgt.getMinTargets(sa.getHostCard(), sa))
|| (sa.getTargets().getNumTargeted() == 0)) { || (sa.getTargets().getNumTargeted() == 0)) {
sa.resetTargets(); sa.resetTargets();
return false; return false;
@@ -175,7 +175,7 @@ public class DestroyAi extends SpellAbilityAi {
@Override @Override
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) { protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final boolean noRegen = sa.hasParam("NoRegen"); final boolean noRegen = sa.hasParam("NoRegen");
if (tgt != null) { if (tgt != null) {
List<Card> list; List<Card> list;
@@ -183,7 +183,7 @@ public class DestroyAi extends SpellAbilityAi {
list = CardLists.getTargetableCards(list, sa); list = CardLists.getTargetableCards(list, sa);
list = CardLists.getValidCards(list, tgt.getValidTgts(), source.getController(), source); list = CardLists.getValidCards(list, tgt.getValidTgts(), source.getController(), source);
if (list.isEmpty() || list.size() < tgt.getMinTargets(sa.getSourceCard(), sa)) { if (list.isEmpty() || list.size() < tgt.getMinTargets(sa.getHostCard(), sa)) {
return false; return false;
} }
@@ -209,10 +209,10 @@ public class DestroyAi extends SpellAbilityAi {
list.remove(c); list.remove(c);
} }
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getSourceCard(), sa)) { while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getHostCard(), sa)) {
if (preferred.isEmpty()) { if (preferred.isEmpty()) {
if ((sa.getTargets().getNumTargeted() == 0) if ((sa.getTargets().getNumTargeted() == 0)
|| (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa))) { || (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa))) {
if (!mandatory) { if (!mandatory) {
sa.resetTargets(); sa.resetTargets();
return false; return false;
@@ -236,7 +236,7 @@ public class DestroyAi extends SpellAbilityAi {
} }
} }
while (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa)) { while (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) {
if (list.isEmpty()) { if (list.isEmpty()) {
break; break;
} else { } else {
@@ -251,7 +251,7 @@ public class DestroyAi extends SpellAbilityAi {
} }
} }
if (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa)) { if (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) {
return false; return false;
} }
} else { } else {

View File

@@ -30,7 +30,7 @@ public class DestroyAllAi extends SpellAbilityAi {
*/ */
@Override @Override
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) { protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
String valid = ""; String valid = "";
if (mandatory) { if (mandatory) {
return true; return true;
@@ -80,7 +80,7 @@ public class DestroyAllAi extends SpellAbilityAi {
// based on what the expected targets could be // based on what the expected targets could be
final Random r = MyRandom.getRandom(); final Random r = MyRandom.getRandom();
final Cost abCost = sa.getPayCosts(); final Cost abCost = sa.getPayCosts();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
String valid = ""; String valid = "";
if (sa.hasParam("ValidCards")) { if (sa.hasParam("ValidCards")) {

View File

@@ -24,7 +24,7 @@ public class DigAi extends SpellAbilityAi {
protected boolean canPlayAI(Player ai, SpellAbility sa) { protected boolean canPlayAI(Player ai, SpellAbility sa) {
Player opp = ai.getOpponent(); Player opp = ai.getOpponent();
final Card host = sa.getSourceCard(); final Card host = sa.getHostCard();
Player libraryOwner = ai; Player libraryOwner = ai;
if (sa.usesTargeting()) { if (sa.usesTargeting()) {

View File

@@ -19,7 +19,7 @@ public class DigUntilAi extends SpellAbilityAi {
@Override @Override
protected boolean canPlayAI(Player ai, SpellAbility sa) { protected boolean canPlayAI(Player ai, SpellAbility sa) {
Card source = sa.getSourceCard(); Card source = sa.getHostCard();
double chance = .4; // 40 percent chance with instant speed stuff double chance = .4; // 40 percent chance with instant speed stuff
if (SpellAbilityAi.isSorcerySpeed(sa)) { if (SpellAbilityAi.isSorcerySpeed(sa)) {
chance = .667; // 66.7% chance for sorcery speed (since it will chance = .667; // 66.7% chance for sorcery speed (since it will

View File

@@ -23,7 +23,7 @@ public class DiscardAi extends SpellAbilityAi {
@Override @Override
protected boolean canPlayAI(Player ai, SpellAbility sa) { protected boolean canPlayAI(Player ai, SpellAbility sa) {
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final Cost abCost = sa.getPayCosts(); final Cost abCost = sa.getPayCosts();
if (abCost != null) { if (abCost != null) {
@@ -54,7 +54,7 @@ public class DiscardAi extends SpellAbilityAi {
} }
} else { } else {
// TODO: Add appropriate restrictions // TODO: Add appropriate restrictions
final List<Player> players = AbilityUtils.getDefinedPlayers(sa.getSourceCard(), final List<Player> players = AbilityUtils.getDefinedPlayers(sa.getHostCard(),
sa.getParam("Defined"), sa); sa.getParam("Defined"), sa);
if (players.size() == 1) { if (players.size() == 1) {
@@ -85,7 +85,7 @@ public class DiscardAi extends SpellAbilityAi {
} }
source.setSVar("PayX", Integer.toString(cardsToDiscard)); source.setSVar("PayX", Integer.toString(cardsToDiscard));
} else { } else {
if (AbilityUtils.calculateAmount(sa.getSourceCard(), sa.getParam("NumCards"), sa) < 1) { if (AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("NumCards"), sa) < 1) {
return false; return false;
} }
} }
@@ -144,11 +144,11 @@ public class DiscardAi extends SpellAbilityAi {
} }
} }
} else { } else {
if ("X".equals(sa.getParam("RevealNumber")) && sa.getSourceCard().getSVar("X").equals("Count$xPaid")) { if ("X".equals(sa.getParam("RevealNumber")) && sa.getHostCard().getSVar("X").equals("Count$xPaid")) {
// Set PayX here to maximum value. // Set PayX here to maximum value.
final int cardsToDiscard = Math.min(ComputerUtilMana.determineLeftoverMana(sa, ai), ai.getOpponent() final int cardsToDiscard = Math.min(ComputerUtilMana.determineLeftoverMana(sa, ai), ai.getOpponent()
.getCardsIn(ZoneType.Hand).size()); .getCardsIn(ZoneType.Hand).size());
sa.getSourceCard().setSVar("PayX", Integer.toString(cardsToDiscard)); sa.getHostCard().setSVar("PayX", Integer.toString(cardsToDiscard));
} }
} }

View File

@@ -18,7 +18,7 @@ public class DrainManaAi extends SpellAbilityAi {
// AI cannot use this properly until he can use SAs during Humans turn // AI cannot use this properly until he can use SAs during Humans turn
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final Player opp = ai.getOpponent(); final Player opp = ai.getOpponent();
final Random r = MyRandom.getRandom(); final Random r = MyRandom.getRandom();
boolean randomReturn = r.nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn()); boolean randomReturn = r.nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn());
@@ -45,7 +45,7 @@ public class DrainManaAi extends SpellAbilityAi {
final Player opp = ai.getOpponent(); final Player opp = ai.getOpponent();
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
if (null == tgt) { if (null == tgt) {
if (mandatory) { if (mandatory) {
@@ -71,7 +71,7 @@ public class DrainManaAi extends SpellAbilityAi {
public boolean chkAIDrawback(SpellAbility sa, Player ai) { public boolean chkAIDrawback(SpellAbility sa, Player ai) {
// AI cannot use this properly until he can use SAs during Humans turn // AI cannot use this properly until he can use SAs during Humans turn
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
boolean randomReturn = true; boolean randomReturn = true;

View File

@@ -47,7 +47,7 @@ public class DrawAi extends SpellAbilityAi {
@Override @Override
protected boolean canPlayAI(Player ai, SpellAbility sa) { protected boolean canPlayAI(Player ai, SpellAbility sa) {
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final Cost abCost = sa.getPayCosts(); final Cost abCost = sa.getPayCosts();
final Game game = ai.getGame(); final Game game = ai.getGame();
@@ -126,7 +126,7 @@ public class DrawAi extends SpellAbilityAi {
private boolean targetAI(final Player ai, final SpellAbility sa, final boolean mandatory) { private boolean targetAI(final Player ai, final SpellAbility sa, final boolean mandatory) {
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final boolean drawback = (sa instanceof AbilitySub); final boolean drawback = (sa instanceof AbilitySub);
final Game game = ai.getGame(); final Game game = ai.getGame();
Player opp = ai.getOpponent(); Player opp = ai.getOpponent();
@@ -143,7 +143,7 @@ public class DrawAi extends SpellAbilityAi {
int numCards = 1; int numCards = 1;
if (sa.hasParam("NumCards")) { if (sa.hasParam("NumCards")) {
numCards = AbilityUtils.calculateAmount(sa.getSourceCard(), sa.getParam("NumCards"), sa); numCards = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("NumCards"), sa);
} }
boolean xPaid = false; boolean xPaid = false;
@@ -261,7 +261,7 @@ public class DrawAi extends SpellAbilityAi {
*/ */
@Override @Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) {
int numCards = sa.hasParam("NumCards") ? AbilityUtils.calculateAmount(sa.getSourceCard(), sa.getParam("NumCards"), sa) : 1; int numCards = sa.hasParam("NumCards") ? AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("NumCards"), sa) : 1;
// AI shouldn't mill itself // AI shouldn't mill itself
return numCards < player.getZone(ZoneType.Library).size(); return numCards < player.getZone(ZoneType.Library).size();
} }

View File

@@ -64,7 +64,7 @@ public class EffectAi extends SpellAbilityAi {
if (tgt != null) { if (tgt != null) {
sa.resetTargets(); sa.resetTargets();
List<Card> list = game.getCombat().getAttackers(); List<Card> list = game.getCombat().getAttackers();
list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard()); list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getHostCard());
list = CardLists.getTargetableCards(list, sa); list = CardLists.getTargetableCards(list, sa);
Card target = ComputerUtilCard.getBestCreatureAI(list); Card target = ComputerUtilCard.getBestCreatureAI(list);
if (target == null) { if (target == null) {
@@ -123,7 +123,7 @@ public class EffectAi extends SpellAbilityAi {
if ("False".equals(sa.getParam("Stackable"))) { if ("False".equals(sa.getParam("Stackable"))) {
String name = sa.getParam("Name"); String name = sa.getParam("Name");
if (name == null) { if (name == null) {
name = sa.getSourceCard().getName() + "'s Effect"; name = sa.getHostCard().getName() + "'s Effect";
} }
final List<Card> list = sa.getActivatingPlayer().getCardsIn(ZoneType.Command, name); final List<Card> list = sa.getActivatingPlayer().getCardsIn(ZoneType.Command, name);
if (!list.isEmpty()) { if (!list.isEmpty()) {

View File

@@ -22,7 +22,7 @@ public class FightAi extends SpellAbilityAi {
@Override @Override
protected boolean canPlayAI(Player ai, SpellAbility sa) { protected boolean canPlayAI(Player ai, SpellAbility sa) {
sa.resetTargets(); sa.resetTargets();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
List<Card> aiCreatures = ai.getCreaturesInPlay(); List<Card> aiCreatures = ai.getCreaturesInPlay();
aiCreatures = CardLists.getTargetableCards(aiCreatures, sa); aiCreatures = CardLists.getTargetableCards(aiCreatures, sa);
@@ -107,7 +107,7 @@ public class FightAi extends SpellAbilityAi {
} }
//try to make a good trade or no trade //try to make a good trade or no trade
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
List<Card> humCreatures = ai.getOpponent().getCreaturesInPlay(); List<Card> humCreatures = ai.getOpponent().getCreaturesInPlay();
humCreatures = CardLists.getTargetableCards(humCreatures, sa); humCreatures = CardLists.getTargetableCards(humCreatures, sa);
if (humCreatures.isEmpty()) { if (humCreatures.isEmpty()) {

View File

@@ -19,7 +19,7 @@ public class LifeGainAi extends SpellAbilityAi {
@Override @Override
protected boolean canPlayAI(Player ai, SpellAbility sa) { protected boolean canPlayAI(Player ai, SpellAbility sa) {
final Cost abCost = sa.getPayCosts(); final Cost abCost = sa.getPayCosts();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final Game game = source.getGame(); final Game game = source.getGame();
final int life = ai.getLife(); final int life = ai.getLife();
final String amountStr = sa.getParam("LifeAmount"); final String amountStr = sa.getParam("LifeAmount");
@@ -31,7 +31,7 @@ public class LifeGainAi extends SpellAbilityAi {
source.setSVar("PayX", Integer.toString(xPay)); source.setSVar("PayX", Integer.toString(xPay));
lifeAmount = xPay; lifeAmount = xPay;
} else { } else {
lifeAmount = AbilityUtils.calculateAmount(sa.getSourceCard(), amountStr, sa); lifeAmount = AbilityUtils.calculateAmount(sa.getHostCard(), amountStr, sa);
} }
// don't use it if no life to gain // don't use it if no life to gain
@@ -148,7 +148,7 @@ public class LifeGainAi extends SpellAbilityAi {
} }
} }
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final String amountStr = sa.getParam("LifeAmount"); final String amountStr = sa.getParam("LifeAmount");
if (amountStr.equals("X") && source.getSVar(amountStr).equals("Count$xPaid")) { if (amountStr.equals("X") && source.getSVar(amountStr).equals("Count$xPaid")) {
// Set PayX here to maximum value. // Set PayX here to maximum value.

View File

@@ -21,7 +21,7 @@ public class LifeLoseAi extends SpellAbilityAi {
List<Player> tgtPlayers = getTargetPlayers(sa); List<Player> tgtPlayers = getTargetPlayers(sa);
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final String amountStr = sa.getParam("LifeAmount"); final String amountStr = sa.getParam("LifeAmount");
int amount = 0; int amount = 0;
if (amountStr.equals("X") && source.getSVar(amountStr).equals("Count$xPaid")) { if (amountStr.equals("X") && source.getSVar(amountStr).equals("Count$xPaid")) {
@@ -46,13 +46,13 @@ public class LifeLoseAi extends SpellAbilityAi {
protected boolean canPlayAI(Player ai, SpellAbility sa) { protected boolean canPlayAI(Player ai, SpellAbility sa) {
final Cost abCost = sa.getPayCosts(); final Cost abCost = sa.getPayCosts();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final String amountStr = sa.getParam("LifeAmount"); final String amountStr = sa.getParam("LifeAmount");
// TODO handle proper calculation of X values based on Cost and what // TODO handle proper calculation of X values based on Cost and what
// would be paid // would be paid
int amount = AbilityUtils.calculateAmount(sa.getSourceCard(), amountStr, sa); int amount = AbilityUtils.calculateAmount(sa.getHostCard(), amountStr, sa);
if (amountStr.equals("X") && source.getSVar(amountStr).equals("Count$xPaid")) { if (amountStr.equals("X") && source.getSVar(amountStr).equals("Count$xPaid")) {
// Set PayX here to maximum value. // Set PayX here to maximum value.
@@ -146,7 +146,7 @@ public class LifeLoseAi extends SpellAbilityAi {
} }
} }
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final String amountStr = sa.getParam("LifeAmount"); final String amountStr = sa.getParam("LifeAmount");
int amount = 0; int amount = 0;
if (amountStr.equals("X") && source.getSVar(amountStr).equals("Count$xPaid")) { if (amountStr.equals("X") && source.getSVar(amountStr).equals("Count$xPaid")) {

View File

@@ -19,7 +19,7 @@ public class LifeSetAi extends SpellAbilityAi {
protected boolean canPlayAI(Player ai, SpellAbility sa) { protected boolean canPlayAI(Player ai, SpellAbility sa) {
final Random r = MyRandom.getRandom(); final Random r = MyRandom.getRandom();
// Ability_Cost abCost = sa.getPayCosts(); // Ability_Cost abCost = sa.getPayCosts();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final int myLife = ai.getLife(); final int myLife = ai.getLife();
final Player opponent = ai.getOpponent(); final Player opponent = ai.getOpponent();
final int hlife = opponent.getLife(); final int hlife = opponent.getLife();
@@ -45,7 +45,7 @@ public class LifeSetAi extends SpellAbilityAi {
source.setSVar("PayX", Integer.toString(xPay)); source.setSVar("PayX", Integer.toString(xPay));
amount = xPay; amount = xPay;
} else { } else {
amount = AbilityUtils.calculateAmount(sa.getSourceCard(), amountStr, sa); amount = AbilityUtils.calculateAmount(sa.getHostCard(), amountStr, sa);
} }
// prevent run-away activations - first time will always return true // prevent run-away activations - first time will always return true
@@ -105,7 +105,7 @@ public class LifeSetAi extends SpellAbilityAi {
final int myLife = ai.getLife(); final int myLife = ai.getLife();
final Player opponent = ai.getOpponent(); final Player opponent = ai.getOpponent();
final int hlife = opponent.getLife(); final int hlife = opponent.getLife();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final String amountStr = sa.getParam("LifeAmount"); final String amountStr = sa.getParam("LifeAmount");
@@ -116,7 +116,7 @@ public class LifeSetAi extends SpellAbilityAi {
source.setSVar("PayX", Integer.toString(xPay)); source.setSVar("PayX", Integer.toString(xPay));
amount = xPay; amount = xPay;
} else { } else {
amount = AbilityUtils.calculateAmount(sa.getSourceCard(), amountStr, sa); amount = AbilityUtils.calculateAmount(sa.getHostCard(), amountStr, sa);
} }
if (source.getName().equals("Eternity Vessel") if (source.getName().equals("Eternity Vessel")

View File

@@ -20,7 +20,7 @@ public class MillAi extends SpellAbilityAi {
@Override @Override
protected boolean canPlayAI(Player ai, SpellAbility sa) { protected boolean canPlayAI(Player ai, SpellAbility sa) {
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final Cost abCost = sa.getPayCosts(); final Cost abCost = sa.getPayCosts();
if (abCost != null) { if (abCost != null) {
@@ -94,7 +94,7 @@ public class MillAi extends SpellAbilityAi {
return false; return false;
} }
final int numCards = AbilityUtils.calculateAmount(sa.getSourceCard(), sa.getParam("NumCards"), sa); final int numCards = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("NumCards"), sa);
final List<Card> pLibrary = opp.getCardsIn(ZoneType.Library); final List<Card> pLibrary = opp.getCardsIn(ZoneType.Library);
@@ -135,7 +135,7 @@ public class MillAi extends SpellAbilityAi {
return false; return false;
} }
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
if (sa.getParam("NumCards").equals("X") && source.getSVar("X").equals("Count$xPaid")) { if (sa.getParam("NumCards").equals("X") && source.getSVar("X").equals("Count$xPaid")) {
// Set PayX here to maximum value. // Set PayX here to maximum value.
final int cardsToDiscard = Math.min(ComputerUtilMana.determineLeftoverMana(sa, aiPlayer), aiPlayer.getOpponent() final int cardsToDiscard = Math.min(ComputerUtilMana.determineLeftoverMana(sa, aiPlayer), aiPlayer.getOpponent()

View File

@@ -33,7 +33,7 @@ public class MustBlockAi extends SpellAbilityAi {
@Override @Override
protected boolean doTriggerAINoCost(final Player ai, SpellAbility sa, boolean mandatory) { protected boolean doTriggerAINoCost(final Player ai, SpellAbility sa, boolean mandatory) {
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final TargetRestrictions abTgt = sa.getTargetRestrictions(); final TargetRestrictions abTgt = sa.getTargetRestrictions();
// only use on creatures that can attack // only use on creatures that can attack
@@ -43,7 +43,7 @@ public class MustBlockAi extends SpellAbilityAi {
Card attacker = null; Card attacker = null;
if (sa.hasParam("DefinedAttacker")) { if (sa.hasParam("DefinedAttacker")) {
final List<Card> cards = AbilityUtils.getDefinedCards(sa.getSourceCard(), sa.getParam("DefinedAttacker"), sa); final List<Card> cards = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("DefinedAttacker"), sa);
if (cards.isEmpty()) { if (cards.isEmpty()) {
return false; return false;
} }

View File

@@ -23,7 +23,7 @@ public class PhasesAi extends SpellAbilityAi {
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) { protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
// This still needs to be fleshed out // This still needs to be fleshed out
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final Random r = MyRandom.getRandom(); final Random r = MyRandom.getRandom();
boolean randomReturn = r.nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn()); boolean randomReturn = r.nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn());
@@ -100,7 +100,7 @@ public class PhasesAi extends SpellAbilityAi {
*/ */
private boolean phasesPrefTargeting(final TargetRestrictions tgt, final SpellAbility sa, private boolean phasesPrefTargeting(final TargetRestrictions tgt, final SpellAbility sa,
final boolean mandatory) { final boolean mandatory) {
// Card source = sa.getSourceCard(); // Card source = sa.getHostCard();
// List<Card> phaseList = // List<Card> phaseList =
// AllZoneUtil.getCardsIn(Zone.Battlefield).getTargetableCards(source) // AllZoneUtil.getCardsIn(Zone.Battlefield).getTargetableCards(source)
@@ -134,7 +134,7 @@ public class PhasesAi extends SpellAbilityAi {
* @return a boolean. * @return a boolean.
*/ */
private boolean phasesUnpreferredTargeting(final Game game, final SpellAbility sa, final boolean mandatory) { private boolean phasesUnpreferredTargeting(final Game game, final SpellAbility sa, final boolean mandatory) {
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
List<Card> list = game.getCardsIn(ZoneType.Battlefield); List<Card> list = game.getCardsIn(ZoneType.Battlefield);

View File

@@ -26,7 +26,7 @@ public class PlayAi extends SpellAbilityAi {
@Override @Override
protected boolean canPlayAI(Player ai, SpellAbility sa) { protected boolean canPlayAI(Player ai, SpellAbility sa) {
final Cost abCost = sa.getPayCosts(); final Cost abCost = sa.getPayCosts();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final Random r = MyRandom.getRandom(); final Random r = MyRandom.getRandom();
@@ -67,7 +67,7 @@ public class PlayAi extends SpellAbilityAi {
} }
sa.getTargets().add(ComputerUtilCard.getBestAI(cards)); sa.getTargets().add(ComputerUtilCard.getBestAI(cards));
} else if (!sa.hasParam("Valid")) { } else if (!sa.hasParam("Valid")) {
cards = new ArrayList<Card>(AbilityUtils.getDefinedCards(sa.getSourceCard(), sa.getParam("Defined"), sa)); cards = new ArrayList<Card>(AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa));
if (cards.isEmpty()) { if (cards.isEmpty()) {
return false; return false;
} }

View File

@@ -26,7 +26,7 @@ public class PoisonAi extends SpellAbilityAi {
@Override @Override
protected boolean canPlayAI(Player ai, SpellAbility sa) { protected boolean canPlayAI(Player ai, SpellAbility sa) {
final Cost abCost = sa.getPayCosts(); final Cost abCost = sa.getPayCosts();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
// int humanPoison = AllZone.getHumanPlayer().getPoisonCounters(); // int humanPoison = AllZone.getHumanPlayer().getPoisonCounters();
// int humanLife = AllZone.getHumanPlayer().getLife(); // int humanLife = AllZone.getHumanPlayer().getLife();
// int aiPoison = AllZone.getComputerPlayer().getPoisonCounters(); // int aiPoison = AllZone.getComputerPlayer().getPoisonCounters();
@@ -75,7 +75,7 @@ public class PoisonAi extends SpellAbilityAi {
if (tgt != null) { if (tgt != null) {
sa.getTargets().add(ai.getOpponent()); sa.getTargets().add(ai.getOpponent());
} else { } else {
final List<Player> players = AbilityUtils.getDefinedPlayers(sa.getSourceCard(), sa.getParam("Defined"), sa); final List<Player> players = AbilityUtils.getDefinedPlayers(sa.getHostCard(), sa.getParam("Defined"), sa);
for (final Player p : players) { for (final Player p : players) {
if (!mandatory && p == ai && (p.getPoisonCounters() > p.getOpponent().getPoisonCounters())) { if (!mandatory && p == ai && (p.getPoisonCounters() > p.getOpponent().getPoisonCounters())) {
return false; return false;

View File

@@ -29,7 +29,7 @@ public class PowerExchangeAi extends SpellAbilityAi {
sa.resetTargets(); sa.resetTargets();
List<Card> list = List<Card> list =
CardLists.getValidCards(ai.getOpponent().getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), ai, sa.getSourceCard()); CardLists.getValidCards(ai.getOpponent().getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), ai, sa.getHostCard());
// AI won't try to grab cards that are filtered out of AI decks on // AI won't try to grab cards that are filtered out of AI decks on
// purpose // purpose
list = CardLists.filter(list, new Predicate<Card>() { list = CardLists.filter(list, new Predicate<Card>() {
@@ -42,10 +42,10 @@ public class PowerExchangeAi extends SpellAbilityAi {
CardLists.sortByPowerAsc(list); CardLists.sortByPowerAsc(list);
c1 = list.isEmpty() ? null : list.get(0); c1 = list.isEmpty() ? null : list.get(0);
if (sa.hasParam("Defined")) { if (sa.hasParam("Defined")) {
c2 = AbilityUtils.getDefinedCards(sa.getSourceCard(), sa.getParam("Defined"), sa).get(0); c2 = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa).get(0);
} else if (tgt.getMinTargets(sa.getSourceCard(), sa) > 1) { } else if (tgt.getMinTargets(sa.getHostCard(), sa) > 1) {
List<Card> list2 = ai.getCardsIn(ZoneType.Battlefield); List<Card> list2 = ai.getCardsIn(ZoneType.Battlefield);
list2 = CardLists.getValidCards(list2, tgt.getValidTgts(), ai, sa.getSourceCard()); list2 = CardLists.getValidCards(list2, tgt.getValidTgts(), ai, sa.getHostCard());
CardLists.sortByPowerAsc(list2); CardLists.sortByPowerAsc(list2);
Collections.reverse(list2); Collections.reverse(list2);
c2 = list2.isEmpty() ? null : list2.get(0); c2 = list2.isEmpty() ? null : list2.get(0);

View File

@@ -109,7 +109,7 @@ public class ProtectAi extends SpellAbilityAi {
@Override @Override
protected boolean canPlayAI(Player ai, SpellAbility sa) { protected boolean canPlayAI(Player ai, SpellAbility sa) {
final Card hostCard = sa.getSourceCard(); final Card hostCard = sa.getHostCard();
final Game game = ai.getGame(); final Game game = ai.getGame();
// if there is no target and host card isn't in play, don't activate // if there is no target and host card isn't in play, don't activate
if ((sa.getTargetRestrictions() == null) && !hostCard.isInPlay()) { if ((sa.getTargetRestrictions() == null) && !hostCard.isInPlay()) {
@@ -149,7 +149,7 @@ public class ProtectAi extends SpellAbilityAi {
} }
if ((sa.getTargetRestrictions() == null) || !sa.getTargetRestrictions().doesTarget()) { if ((sa.getTargetRestrictions() == null) || !sa.getTargetRestrictions().doesTarget()) {
final List<Card> cards = AbilityUtils.getDefinedCards(sa.getSourceCard(), sa.getParam("Defined"), sa); final List<Card> cards = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa);
if (cards.size() == 0) { if (cards.size() == 0) {
return false; return false;
@@ -175,13 +175,13 @@ public class ProtectAi extends SpellAbilityAi {
return false; return false;
} }
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
sa.resetTargets(); sa.resetTargets();
List<Card> list = getProtectCreatures(ai, sa); List<Card> list = getProtectCreatures(ai, sa);
list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard()); list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getHostCard());
/* /*
* TODO - What this should probably do is if it's time for instants and * TODO - What this should probably do is if it's time for instants and
@@ -200,11 +200,11 @@ public class ProtectAi extends SpellAbilityAi {
if ((sa.getPayCosts() != null) && sa.getPayCosts().hasTapCost()) { if ((sa.getPayCosts() != null) && sa.getPayCosts().hasTapCost()) {
if (game.getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS) if (game.getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS)
&& game.getPhaseHandler().isPlayerTurn(ai)) { && game.getPhaseHandler().isPlayerTurn(ai)) {
list.remove(sa.getSourceCard()); list.remove(sa.getHostCard());
} }
if (game.getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS) if (game.getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS)
&& game.getPhaseHandler().isPlayerTurn(ai)) { && game.getPhaseHandler().isPlayerTurn(ai)) {
list.remove(sa.getSourceCard()); list.remove(sa.getHostCard());
} }
} }
} }
@@ -247,9 +247,9 @@ public class ProtectAi extends SpellAbilityAi {
List<Card> list = game.getCardsIn(ZoneType.Battlefield); List<Card> list = game.getCardsIn(ZoneType.Battlefield);
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard()); list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getHostCard());
if (list.size() < tgt.getMinTargets(sa.getSourceCard(), sa)) { if (list.size() < tgt.getMinTargets(sa.getHostCard(), sa)) {
sa.resetTargets(); sa.resetTargets();
return false; return false;
} }
@@ -274,7 +274,7 @@ public class ProtectAi extends SpellAbilityAi {
} }
}); });
final List<Card> forced = CardLists.filterControlledBy(list, ai); final List<Card> forced = CardLists.filterControlledBy(list, ai);
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(source, sa)) { while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(source, sa)) {
if (pref.isEmpty()) { if (pref.isEmpty()) {
@@ -327,7 +327,7 @@ public class ProtectAi extends SpellAbilityAi {
sa.getTargets().add(c); sa.getTargets().add(c);
} }
if (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa)) { if (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) {
sa.resetTargets(); sa.resetTargets();
return false; return false;
} }
@@ -350,7 +350,7 @@ public class ProtectAi extends SpellAbilityAi {
@Override @Override
public boolean chkAIDrawback(SpellAbility sa, Player ai) { public boolean chkAIDrawback(SpellAbility sa, Player ai) {
final Card host = sa.getSourceCard(); final Card host = sa.getHostCard();
if ((sa.getTargetRestrictions() == null) || !sa.getTargetRestrictions().doesTarget()) { if ((sa.getTargetRestrictions() == null) || !sa.getTargetRestrictions().doesTarget()) {
if (host.isCreature()) { if (host.isCreature()) {
// TODO // TODO

View File

@@ -12,7 +12,7 @@ public class ProtectAllAi extends SpellAbilityAi {
@Override @Override
protected boolean canPlayAI(Player ai, SpellAbility sa) { protected boolean canPlayAI(Player ai, SpellAbility sa) {
final Card hostCard = sa.getSourceCard(); final Card hostCard = sa.getHostCard();
// if there is no target and host card isn't in play, don't activate // if there is no target and host card isn't in play, don't activate
if ((sa.getTargetRestrictions() == null) && !hostCard.isInPlay()) { if ((sa.getTargetRestrictions() == null) && !hostCard.isInPlay()) {
return false; return false;

View File

@@ -49,23 +49,23 @@ public class PumpAi extends PumpAiBase {
final String numDefense = sa.hasParam("NumDef") ? sa.getParam("NumDef") : ""; final String numDefense = sa.hasParam("NumDef") ? sa.getParam("NumDef") : "";
final String numAttack = sa.hasParam("NumAtt") ? sa.getParam("NumAtt") : ""; final String numAttack = sa.hasParam("NumAtt") ? sa.getParam("NumAtt") : "";
if (!ComputerUtilCost.checkLifeCost(ai, cost, sa.getSourceCard(), 4, null)) { if (!ComputerUtilCost.checkLifeCost(ai, cost, sa.getHostCard(), 4, null)) {
return false; return false;
} }
if (!ComputerUtilCost.checkDiscardCost(ai, cost, sa.getSourceCard())) { if (!ComputerUtilCost.checkDiscardCost(ai, cost, sa.getHostCard())) {
return false; return false;
} }
if (!ComputerUtilCost.checkCreatureSacrificeCost(ai, cost, sa.getSourceCard())) { if (!ComputerUtilCost.checkCreatureSacrificeCost(ai, cost, sa.getHostCard())) {
return false; return false;
} }
if (!ComputerUtilCost.checkRemoveCounterCost(cost, sa.getSourceCard())) { if (!ComputerUtilCost.checkRemoveCounterCost(cost, sa.getHostCard())) {
return false; return false;
} }
if (game.getStack().isEmpty() && hasTapCost(cost, sa.getSourceCard())) { if (game.getStack().isEmpty() && hasTapCost(cost, sa.getHostCard())) {
if (ph.getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS) && ph.isPlayerTurn(ai)) { if (ph.getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS) && ph.isPlayerTurn(ai)) {
return false; return false;
} }
@@ -98,7 +98,7 @@ public class PumpAi extends PumpAiBase {
return false; return false;
} }
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
if (source.getSVar("X").equals("Count$xPaid")) { if (source.getSVar("X").equals("Count$xPaid")) {
source.setSVar("PayX", ""); source.setSVar("PayX", "");
} }
@@ -113,7 +113,7 @@ public class PumpAi extends PumpAiBase {
defense = -xPay; defense = -xPay;
} }
} else { } else {
defense = AbilityUtils.calculateAmount(sa.getSourceCard(), numDefense, sa); defense = AbilityUtils.calculateAmount(sa.getHostCard(), numDefense, sa);
} }
int attack; int attack;
@@ -129,7 +129,7 @@ public class PumpAi extends PumpAiBase {
attack = Integer.parseInt(toPay); attack = Integer.parseInt(toPay);
} }
} else { } else {
attack = AbilityUtils.calculateAmount(sa.getSourceCard(), numAttack, sa); attack = AbilityUtils.calculateAmount(sa.getHostCard(), numAttack, sa);
} }
if ((numDefense.contains("X") && defense == 0) if ((numDefense.contains("X") && defense == 0)
@@ -139,7 +139,7 @@ public class PumpAi extends PumpAiBase {
//Untargeted //Untargeted
if ((sa.getTargetRestrictions() == null) || !sa.getTargetRestrictions().doesTarget()) { if ((sa.getTargetRestrictions() == null) || !sa.getTargetRestrictions().doesTarget()) {
final List<Card> cards = AbilityUtils.getDefinedCards(sa.getSourceCard(), final List<Card> cards = AbilityUtils.getDefinedCards(sa.getHostCard(),
sa.getParam("Defined"), sa); sa.getParam("Defined"), sa);
if (cards.size() == 0) { if (cards.size() == 0) {
@@ -177,7 +177,7 @@ public class PumpAi extends PumpAiBase {
private boolean pumpTgtAI(final Player ai, final SpellAbility sa, final int defense, final int attack, final boolean mandatory) { 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 List<String> keywords = sa.hasParam("KW") ? Arrays.asList(sa.getParam("KW").split(" & ")) : new ArrayList<String>();
final Game game = ai.getGame(); final Game game = ai.getGame();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
if (!mandatory if (!mandatory
&& !sa.isTrigger() && !sa.isTrigger()
@@ -232,11 +232,11 @@ public class PumpAi extends PumpAiBase {
if (sa.getPayCosts() != null && sa.getPayCosts().hasTapCost()) { if (sa.getPayCosts() != null && sa.getPayCosts().hasTapCost()) {
if (game.getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS) if (game.getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS)
&& game.getPhaseHandler().isPlayerTurn(ai)) { && game.getPhaseHandler().isPlayerTurn(ai)) {
list.remove(sa.getSourceCard()); list.remove(sa.getHostCard());
} }
if (game.getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS) if (game.getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS)
&& game.getPhaseHandler().isPlayerTurn(opp)) { && game.getPhaseHandler().isPlayerTurn(opp)) {
list.remove(sa.getSourceCard()); list.remove(sa.getHostCard());
} }
} }
} }
@@ -281,10 +281,10 @@ public class PumpAi extends PumpAiBase {
List<Card> list = game.getCardsIn(ZoneType.Battlefield); List<Card> list = game.getCardsIn(ZoneType.Battlefield);
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
final Player opp = ai.getOpponent(); final Player opp = ai.getOpponent();
list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard()); list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getHostCard());
list = CardLists.getTargetableCards(list, sa); list = CardLists.getTargetableCards(list, sa);
if (list.size() < tgt.getMinTargets(sa.getSourceCard(), sa)) { if (list.size() < tgt.getMinTargets(sa.getHostCard(), sa)) {
sa.resetTargets(); sa.resetTargets();
return false; return false;
} }
@@ -296,7 +296,7 @@ public class PumpAi extends PumpAiBase {
List<Card> pref; List<Card> pref;
List<Card> forced; List<Card> forced;
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
if (sa.isCurse()) { if (sa.isCurse()) {
pref = CardLists.filterControlledBy(list, opp); pref = CardLists.filterControlledBy(list, opp);
@@ -350,7 +350,7 @@ public class PumpAi extends PumpAiBase {
@Override @Override
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) { protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final String numDefense = sa.hasParam("NumDef") ? sa.getParam("NumDef") : ""; final String numDefense = sa.hasParam("NumDef") ? sa.getParam("NumDef") : "";
final String numAttack = sa.hasParam("NumAtt") ? sa.getParam("NumAtt") : ""; final String numAttack = sa.hasParam("NumAtt") ? sa.getParam("NumAtt") : "";
@@ -361,7 +361,7 @@ public class PumpAi extends PumpAiBase {
source.setSVar("PayX", Integer.toString(xPay)); source.setSVar("PayX", Integer.toString(xPay));
defense = xPay; defense = xPay;
} else { } else {
defense = AbilityUtils.calculateAmount(sa.getSourceCard(), numDefense, sa); defense = AbilityUtils.calculateAmount(sa.getHostCard(), numDefense, sa);
} }
int attack; int attack;
@@ -377,7 +377,7 @@ public class PumpAi extends PumpAiBase {
attack = Integer.parseInt(toPay); attack = Integer.parseInt(toPay);
} }
} else { } else {
attack = AbilityUtils.calculateAmount(sa.getSourceCard(), numAttack, sa); attack = AbilityUtils.calculateAmount(sa.getHostCard(), numAttack, sa);
} }
if (sa.getTargetRestrictions() == null) { if (sa.getTargetRestrictions() == null) {
@@ -394,7 +394,7 @@ public class PumpAi extends PumpAiBase {
@Override @Override
public boolean chkAIDrawback(SpellAbility sa, Player ai) { public boolean chkAIDrawback(SpellAbility sa, Player ai) {
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final String numDefense = sa.hasParam("NumDef") ? sa.getParam("NumDef") : ""; final String numDefense = sa.hasParam("NumDef") ? sa.getParam("NumDef") : "";
final String numAttack = sa.hasParam("NumAtt") ? sa.getParam("NumAtt") : ""; final String numAttack = sa.hasParam("NumAtt") ? sa.getParam("NumAtt") : "";
@@ -403,7 +403,7 @@ public class PumpAi extends PumpAiBase {
if (numDefense.contains("X") && source.getSVar("X").equals("Count$xPaid")) { if (numDefense.contains("X") && source.getSVar("X").equals("Count$xPaid")) {
defense = Integer.parseInt(source.getSVar("PayX")); defense = Integer.parseInt(source.getSVar("PayX"));
} else { } else {
defense = AbilityUtils.calculateAmount(sa.getSourceCard(), numDefense, sa); defense = AbilityUtils.calculateAmount(sa.getHostCard(), numDefense, sa);
} }
int attack; int attack;
@@ -417,7 +417,7 @@ public class PumpAi extends PumpAiBase {
attack = Integer.parseInt(source.getSVar("PayX")); attack = Integer.parseInt(source.getSVar("PayX"));
} }
} else { } else {
attack = AbilityUtils.calculateAmount(sa.getSourceCard(), numAttack, sa); attack = AbilityUtils.calculateAmount(sa.getHostCard(), numAttack, sa);
} }
if ((sa.getTargetRestrictions() == null) || !sa.getTargetRestrictions().doesTarget()) { if ((sa.getTargetRestrictions() == null) || !sa.getTargetRestrictions().doesTarget()) {

View File

@@ -28,12 +28,12 @@ public class PumpAllAi extends PumpAiBase {
@Override @Override
protected boolean canPlayAI(final Player ai, final SpellAbility sa) { protected boolean canPlayAI(final Player ai, final SpellAbility sa) {
String valid = ""; String valid = "";
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final Game game = ai.getGame(); final Game game = ai.getGame();
final Combat combat = game.getCombat(); final Combat combat = game.getCombat();
final int power = AbilityUtils.calculateAmount(sa.getSourceCard(), sa.getParam("NumAtt"), sa); final int power = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("NumAtt"), sa);
final int defense = AbilityUtils.calculateAmount(sa.getSourceCard(), sa.getParam("NumDef"), sa); final int defense = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("NumDef"), sa);
final List<String> keywords = sa.hasParam("KW") ? Arrays.asList(sa.getParam("KW").split(" & ")) : new ArrayList<String>(); final List<String> keywords = sa.hasParam("KW") ? Arrays.asList(sa.getParam("KW").split(" & ")) : new ArrayList<String>();
final PhaseType phase = game.getPhaseHandler().getPhase(); final PhaseType phase = game.getPhaseHandler().getPhase();

View File

@@ -55,7 +55,7 @@ public class RegenerateAi extends SpellAbilityAi {
@Override @Override
protected boolean canPlayAI(Player ai, SpellAbility sa) { protected boolean canPlayAI(Player ai, SpellAbility sa) {
final Card hostCard = sa.getSourceCard(); final Card hostCard = sa.getHostCard();
final Cost abCost = sa.getPayCosts(); final Cost abCost = sa.getPayCosts();
final Game game = ai.getGame(); final Game game = ai.getGame();
final Combat combat = game.getCombat(); final Combat combat = game.getCombat();
@@ -176,7 +176,7 @@ public class RegenerateAi extends SpellAbilityAi {
} }
private static boolean regenMandatoryTarget(final Player ai, final SpellAbility sa, final boolean mandatory) { private static boolean regenMandatoryTarget(final Player ai, final SpellAbility sa, final boolean mandatory) {
final Card hostCard = sa.getSourceCard(); final Card hostCard = sa.getHostCard();
final Game game = ai.getGame(); final Game game = ai.getGame();
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
sa.resetTargets(); sa.resetTargets();

View File

@@ -22,7 +22,7 @@ public class RegenerateAllAi extends SpellAbilityAi {
@Override @Override
protected boolean canPlayAI(Player ai, SpellAbility sa) { protected boolean canPlayAI(Player ai, SpellAbility sa) {
final Card hostCard = sa.getSourceCard(); final Card hostCard = sa.getHostCard();
boolean chance = false; boolean chance = false;
final Cost abCost = sa.getPayCosts(); final Cost abCost = sa.getPayCosts();
final Game game = ai.getGame(); final Game game = ai.getGame();

View File

@@ -46,7 +46,7 @@ public class RepeatAi extends SpellAbilityAi {
} }
// setup subability to repeat // setup subability to repeat
final SpellAbility repeat = AbilityFactory.getAbility(sa.getSourceCard().getSVar(sa.getParam("RepeatSubAbility")), sa.getSourceCard()); final SpellAbility repeat = AbilityFactory.getAbility(sa.getHostCard().getSVar(sa.getParam("RepeatSubAbility")), sa.getHostCard());
if (repeat == null) { if (repeat == null) {
return false; return false;

View File

@@ -15,7 +15,7 @@ public class RevealAi extends RevealAiBase {
protected boolean canPlayAI(Player ai, SpellAbility sa) { protected boolean canPlayAI(Player ai, SpellAbility sa) {
// AI cannot use this properly until he can use SAs during Humans turn // AI cannot use this properly until he can use SAs during Humans turn
final Cost abCost = sa.getPayCosts(); final Cost abCost = sa.getPayCosts();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
if (abCost != null) { if (abCost != null) {
// AI currently disabled for these costs // AI currently disabled for these costs

View File

@@ -19,7 +19,7 @@ public class RevealHandAi extends RevealAiBase {
protected boolean canPlayAI(Player ai, SpellAbility sa) { protected boolean canPlayAI(Player ai, SpellAbility sa) {
// AI cannot use this properly until he can use SAs during Humans turn // AI cannot use this properly until he can use SAs during Humans turn
final Cost abCost = sa.getPayCosts(); final Cost abCost = sa.getPayCosts();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
if (abCost != null) { if (abCost != null) {
// AI currently disabled for these costs // AI currently disabled for these costs

View File

@@ -19,7 +19,7 @@ public class RollPlanarDiceAi extends SpellAbilityAi {
@Override @Override
protected boolean canPlayAI(Player ai, SpellAbility sa) { protected boolean canPlayAI(Player ai, SpellAbility sa) {
AiController aic = ((PlayerControllerAi)ai.getController()).getAi(); AiController aic = ((PlayerControllerAi)ai.getController()).getAi();
Card plane = sa.getSourceCard(); Card plane = sa.getHostCard();
boolean decideToRoll = false; boolean decideToRoll = false;
boolean rollInMain1 = false; boolean rollInMain1 = false;

View File

@@ -49,7 +49,7 @@ public class SacrificeAi extends SpellAbilityAi {
private boolean sacrificeTgtAI(final Player ai, final SpellAbility sa) { private boolean sacrificeTgtAI(final Player ai, final SpellAbility sa) {
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
final boolean destroy = sa.hasParam("Destroy"); final boolean destroy = sa.hasParam("Destroy");
@@ -63,10 +63,10 @@ public class SacrificeAi extends SpellAbilityAi {
final String valid = sa.getParam("SacValid"); final String valid = sa.getParam("SacValid");
String num = sa.getParam("Amount"); String num = sa.getParam("Amount");
num = (num == null) ? "1" : num; num = (num == null) ? "1" : num;
final int amount = AbilityUtils.calculateAmount(sa.getSourceCard(), num, sa); final int amount = AbilityUtils.calculateAmount(sa.getHostCard(), num, sa);
List<Card> list = List<Card> list =
CardLists.getValidCards(ai.getOpponent().getCardsIn(ZoneType.Battlefield), valid.split(","), sa.getActivatingPlayer(), sa.getSourceCard()); CardLists.getValidCards(ai.getOpponent().getCardsIn(ZoneType.Battlefield), valid.split(","), sa.getActivatingPlayer(), sa.getHostCard());
if (!destroy) { if (!destroy) {
list = CardLists.filter(list, CardPredicates.canBeSacrificedBy(sa)); list = CardLists.filter(list, CardPredicates.canBeSacrificedBy(sa));
} else { } else {
@@ -115,7 +115,7 @@ public class SacrificeAi extends SpellAbilityAi {
} }
List<Card> humanList = List<Card> humanList =
CardLists.getValidCards(opp.getCardsIn(ZoneType.Battlefield), valid.split(","), sa.getActivatingPlayer(), sa.getSourceCard()); CardLists.getValidCards(opp.getCardsIn(ZoneType.Battlefield), valid.split(","), sa.getActivatingPlayer(), sa.getHostCard());
// Since all of the cards have remAIDeck:True, I enabled 1 for 1 // Since all of the cards have remAIDeck:True, I enabled 1 for 1
// (or X for X) trades for special decks // (or X for X) trades for special decks
@@ -124,7 +124,7 @@ public class SacrificeAi extends SpellAbilityAi {
} }
} else if (defined.equals("You")) { } else if (defined.equals("You")) {
List<Card> computerList = List<Card> computerList =
CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), valid.split(","), sa.getActivatingPlayer(), sa.getSourceCard()); CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), valid.split(","), sa.getActivatingPlayer(), sa.getHostCard());
for (Card c : computerList) { for (Card c : computerList) {
if (c.hasSVar("SacMe") || ComputerUtilCard.evaluateCreature(c) <= 135) { if (c.hasSVar("SacMe") || ComputerUtilCard.evaluateCreature(c) <= 135) {
return true; return true;

View File

@@ -23,7 +23,7 @@ public class SacrificeAllAi extends SpellAbilityAi {
// based on what the expected targets could be // based on what the expected targets could be
final Random r = MyRandom.getRandom(); final Random r = MyRandom.getRandom();
final Cost abCost = sa.getPayCosts(); final Cost abCost = sa.getPayCosts();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
String valid = ""; String valid = "";
if (sa.hasParam("ValidCards")) { if (sa.hasParam("ValidCards")) {

View File

@@ -35,7 +35,7 @@ public class ScryAi extends SpellAbilityAi {
@Override @Override
protected boolean canPlayAI(Player ai, SpellAbility sa) { protected boolean canPlayAI(Player ai, SpellAbility sa) {
// Card source = sa.getSourceCard(); // Card source = sa.getHostCard();
double chance = .4; // 40 percent chance of milling with instant speed double chance = .4; // 40 percent chance of milling with instant speed
// stuff // stuff

View File

@@ -18,7 +18,7 @@ public class SetStateAi extends SpellAbilityAi {
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) { public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
// Gross generalization, but this always considers alternate // Gross generalization, but this always considers alternate
// states more powerful // states more powerful
return !sa.getSourceCard().isInAlternateState(); return !sa.getHostCard().isInAlternateState();
} }

View File

@@ -15,7 +15,7 @@ public class ShuffleAi extends SpellAbilityAi {
/* /*
* if (!ComputerUtil.canPayCost(sa)) return false; * if (!ComputerUtil.canPayCost(sa)) return false;
* *
* Card source = sa.getSourceCard(); * Card source = sa.getHostCard();
* *
* Random r = MyRandom.random; boolean randomReturn = r.nextFloat() <= * Random r = MyRandom.random; boolean randomReturn = r.nextFloat() <=
* Math.pow(.667, sa.getActivationsThisTurn()+1); * Math.pow(.667, sa.getActivationsThisTurn()+1);

View File

@@ -24,7 +24,7 @@ public class StoreSVarAi extends SpellAbilityAi {
protected boolean canPlayAI(Player ai, SpellAbility sa) { protected boolean canPlayAI(Player ai, SpellAbility sa) {
//Tree of Redemption //Tree of Redemption
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final Game game = ai.getGame(); final Game game = ai.getGame();
final Combat combat = game.getCombat(); final Combat combat = game.getCombat();
final PhaseHandler ph = game.getPhaseHandler(); final PhaseHandler ph = game.getPhaseHandler();

View File

@@ -36,7 +36,7 @@ public class TapAi extends TapAiBase {
} }
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
if (tgt == null) { if (tgt == null) {
final List<Card> defined = AbilityUtils.getDefinedCards(source, sa.getParam("Defined"), sa); final List<Card> defined = AbilityUtils.getDefinedCards(source, sa.getParam("Defined"), sa);

View File

@@ -38,7 +38,7 @@ public abstract class TapAiBase extends SpellAbilityAi {
* @return a boolean. * @return a boolean.
*/ */
private boolean tapTargetList(final Player ai, final SpellAbility sa, final List<Card> tapList, final boolean mandatory) { private boolean tapTargetList(final Player ai, final SpellAbility sa, final List<Card> tapList, final boolean mandatory) {
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
for (final Card c : sa.getTargets().getTargetCards()) { for (final Card c : sa.getTargets().getTargetCards()) {
@@ -74,7 +74,7 @@ public abstract class TapAiBase extends SpellAbilityAi {
} }
if (choice == null) { // can't find anything left if (choice == null) { // can't find anything left
if ((sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa)) || (sa.getTargets().getNumTargeted() == 0)) { if ((sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) || (sa.getTargets().getNumTargeted() == 0)) {
if (!mandatory) { if (!mandatory) {
sa.resetTargets(); sa.resetTargets();
} }
@@ -174,7 +174,7 @@ public abstract class TapAiBase extends SpellAbilityAi {
return CombatUtil.canAttack(c, opp); return CombatUtil.canAttack(c, opp);
} }
}); });
attackers.remove(sa.getSourceCard()); attackers.remove(sa.getHostCard());
} }
Predicate<Card> findBlockers = CardPredicates.possibleBlockerForAtLeastOne(attackers); Predicate<Card> findBlockers = CardPredicates.possibleBlockerForAtLeastOne(attackers);
List<Card> creatureList = CardLists.filter(tapList, findBlockers); List<Card> creatureList = CardLists.filter(tapList, findBlockers);
@@ -204,7 +204,7 @@ public abstract class TapAiBase extends SpellAbilityAi {
} }
if (choice == null) { // can't find anything left if (choice == null) { // can't find anything left
if ((sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa)) || (sa.getTargets().getNumTargeted() == 0)) { if ((sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) || (sa.getTargets().getNumTargeted() == 0)) {
if (!mandatory) { if (!mandatory) {
sa.resetTargets(); sa.resetTargets();
} }
@@ -238,7 +238,7 @@ public abstract class TapAiBase extends SpellAbilityAi {
* @return a boolean. * @return a boolean.
*/ */
protected boolean tapUnpreferredTargeting(final Player ai, final SpellAbility sa, final boolean mandatory) { protected boolean tapUnpreferredTargeting(final Player ai, final SpellAbility sa, final boolean mandatory) {
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
final Game game = ai.getGame(); final Game game = ai.getGame();
@@ -252,7 +252,7 @@ public abstract class TapAiBase extends SpellAbilityAi {
return true; return true;
} }
if (sa.getTargets().getNumTargeted() >= tgt.getMinTargets(sa.getSourceCard(), sa)) { if (sa.getTargets().getNumTargeted() >= tgt.getMinTargets(sa.getHostCard(), sa)) {
return true; return true;
} }
@@ -271,7 +271,7 @@ public abstract class TapAiBase extends SpellAbilityAi {
return true; return true;
} }
if (sa.getTargets().getNumTargeted() >= tgt.getMinTargets(sa.getSourceCard(), sa)) { if (sa.getTargets().getNumTargeted() >= tgt.getMinTargets(sa.getHostCard(), sa)) {
return true; return true;
} }
@@ -289,7 +289,7 @@ public abstract class TapAiBase extends SpellAbilityAi {
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) { protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
if (tgt == null) { if (tgt == null) {
if (mandatory) { if (mandatory) {
@@ -315,7 +315,7 @@ public abstract class TapAiBase extends SpellAbilityAi {
@Override @Override
public boolean chkAIDrawback(SpellAbility sa, Player ai) { public boolean chkAIDrawback(SpellAbility sa, Player ai) {
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
boolean randomReturn = true; boolean randomReturn = true;

View File

@@ -29,7 +29,7 @@ public class TapAllAi extends SpellAbilityAi {
// turn // turn
// or during upkeep/begin combat? // or during upkeep/begin combat?
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final Player opp = ai.getOpponent(); final Player opp = ai.getOpponent();
final Game game = ai.getGame(); final Game game = ai.getGame();
@@ -114,7 +114,7 @@ public class TapAllAi extends SpellAbilityAi {
@Override @Override
protected boolean doTriggerAINoCost(final Player ai, SpellAbility sa, boolean mandatory) { protected boolean doTriggerAINoCost(final Player ai, SpellAbility sa, boolean mandatory) {
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
String valid = ""; String valid = "";
if (sa.hasParam("ValidCards")) { if (sa.hasParam("ValidCards")) {

View File

@@ -18,7 +18,7 @@ public class TapOrUntapAi extends TapAiBase {
@Override @Override
protected boolean canPlayAI(Player ai, SpellAbility sa) { protected boolean canPlayAI(Player ai, SpellAbility sa) {
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final Random r = MyRandom.getRandom(); final Random r = MyRandom.getRandom();
boolean randomReturn = r.nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn()); boolean randomReturn = r.nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn());

View File

@@ -130,7 +130,7 @@ public class TokenAi extends SpellAbilityAi {
// prevent run-away activations - first time will always return true // prevent run-away activations - first time will always return true
final Random r = MyRandom.getRandom(); final Random r = MyRandom.getRandom();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
if (tgt != null) { if (tgt != null) {
@@ -169,7 +169,7 @@ public class TokenAi extends SpellAbilityAi {
} }
if (this.tokenAmount.equals("X") || this.tokenPower.equals("X") || this.tokenToughness.equals("X")) { if (this.tokenAmount.equals("X") || this.tokenPower.equals("X") || this.tokenToughness.equals("X")) {
int x = AbilityUtils.calculateAmount(sa.getSourceCard(), this.tokenAmount, sa); int x = AbilityUtils.calculateAmount(sa.getHostCard(), this.tokenAmount, sa);
if (source.getSVar("X").equals("Count$xPaid")) { if (source.getSVar("X").equals("Count$xPaid")) {
// Set PayX here to maximum value. // Set PayX here to maximum value.
x = ComputerUtilMana.determineLeftoverMana(sa, ai); x = ComputerUtilMana.determineLeftoverMana(sa, ai);
@@ -197,7 +197,7 @@ public class TokenAi extends SpellAbilityAi {
@Override @Override
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) { protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
readParameters(sa); readParameters(sa);
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
if (tgt != null) { if (tgt != null) {
sa.resetTargets(); sa.resetTargets();

View File

@@ -19,7 +19,7 @@ public class TwoPilesAi extends SpellAbilityAi {
*/ */
@Override @Override
protected boolean canPlayAI(Player ai, SpellAbility sa) { protected boolean canPlayAI(Player ai, SpellAbility sa) {
final Card card = sa.getSourceCard(); final Card card = sa.getHostCard();
ZoneType zone = null; ZoneType zone = null;
if (sa.hasParam("Zone")) { if (sa.hasParam("Zone")) {
@@ -47,7 +47,7 @@ public class TwoPilesAi extends SpellAbilityAi {
final Player p = tgtPlayers.get(0); final Player p = tgtPlayers.get(0);
List<Card> pool = new ArrayList<Card>(); List<Card> pool = new ArrayList<Card>();
if (sa.hasParam("DefinedCards")) { if (sa.hasParam("DefinedCards")) {
pool = new ArrayList<Card>(AbilityUtils.getDefinedCards(sa.getSourceCard(), sa.getParam("DefinedCards"), sa)); pool = new ArrayList<Card>(AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("DefinedCards"), sa));
} else { } else {
pool = p.getCardsIn(zone); pool = p.getCardsIn(zone);
} }

View File

@@ -26,7 +26,7 @@ public class UnattachAllAi extends SpellAbilityAi {
protected boolean canPlayAI(Player ai, SpellAbility sa) { protected boolean canPlayAI(Player ai, SpellAbility sa) {
final Random r = MyRandom.getRandom(); final Random r = MyRandom.getRandom();
final Cost abCost = sa.getPayCosts(); final Cost abCost = sa.getPayCosts();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
if (abCost != null) { if (abCost != null) {
// No Aura spells have Additional Costs // No Aura spells have Additional Costs
@@ -65,13 +65,13 @@ public class UnattachAllAi extends SpellAbilityAi {
*/ */
@Override @Override
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) { protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
final Card card = sa.getSourceCard(); final Card card = sa.getHostCard();
final Player opp = ai.getOpponent(); final Player opp = ai.getOpponent();
// Check if there are any valid targets // Check if there are any valid targets
List<GameObject> targets = new ArrayList<GameObject>(); List<GameObject> targets = new ArrayList<GameObject>();
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
if (tgt == null) { if (tgt == null) {
targets = AbilityUtils.getDefinedObjects(sa.getSourceCard(), sa.getParam("Defined"), sa); targets = AbilityUtils.getDefinedObjects(sa.getHostCard(), sa.getParam("Defined"), sa);
} }
if (!mandatory && card.isEquipment() && !targets.isEmpty()) { if (!mandatory && card.isEquipment() && !targets.isEmpty()) {

View File

@@ -26,14 +26,14 @@ public class UntapAi extends SpellAbilityAi {
@Override @Override
protected boolean canPlayAI(Player ai, SpellAbility sa) { protected boolean canPlayAI(Player ai, SpellAbility sa) {
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final Cost cost = sa.getPayCosts(); final Cost cost = sa.getPayCosts();
if (!ComputerUtilCost.checkAddM1M1CounterCost(cost, source)) { if (!ComputerUtilCost.checkAddM1M1CounterCost(cost, source)) {
return false; return false;
} }
if (!ComputerUtilCost.checkDiscardCost(ai, cost, sa.getSourceCard())) { if (!ComputerUtilCost.checkDiscardCost(ai, cost, sa.getHostCard())) {
return false; return false;
} }
@@ -41,7 +41,7 @@ public class UntapAi extends SpellAbilityAi {
boolean randomReturn = r.nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn() + 1); boolean randomReturn = r.nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn() + 1);
if (tgt == null) { if (tgt == null) {
final List<Card> pDefined = AbilityUtils.getDefinedCards(sa.getSourceCard(), sa.getParam("Defined"), sa); final List<Card> pDefined = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa);
if ((pDefined != null) && pDefined.get(0).isUntapped() && pDefined.get(0).getController() == ai) { if ((pDefined != null) && pDefined.get(0).isUntapped() && pDefined.get(0).getController() == ai) {
return false; return false;
} }
@@ -64,7 +64,7 @@ public class UntapAi extends SpellAbilityAi {
} }
// TODO: use Defined to determine, if this is an unfavorable result // TODO: use Defined to determine, if this is an unfavorable result
final List<Card> pDefined = AbilityUtils.getDefinedCards(sa.getSourceCard(), sa.getParam("Defined"), sa); final List<Card> pDefined = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa);
if ((pDefined != null) && pDefined.get(0).isUntapped() && pDefined.get(0).getController() == ai) { if ((pDefined != null) && pDefined.get(0).isUntapped() && pDefined.get(0).getController() == ai) {
return false; return false;
} }
@@ -115,7 +115,7 @@ public class UntapAi extends SpellAbilityAi {
* @return a boolean. * @return a boolean.
*/ */
private static boolean untapPrefTargeting(final Player ai, final TargetRestrictions tgt, final SpellAbility sa, final boolean mandatory) { private static boolean untapPrefTargeting(final Player ai, final TargetRestrictions tgt, final SpellAbility sa, final boolean mandatory) {
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
Player targetController = ai; Player targetController = ai;
@@ -137,11 +137,11 @@ public class UntapAi extends SpellAbilityAi {
return false; return false;
} }
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getSourceCard(), sa)) { while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getHostCard(), sa)) {
Card choice = null; Card choice = null;
if (untapList.size() == 0) { if (untapList.size() == 0) {
if ((sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa)) || (sa.getTargets().getNumTargeted() == 0)) { if ((sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) || (sa.getTargets().getNumTargeted() == 0)) {
sa.resetTargets(); sa.resetTargets();
return false; return false;
} else { } else {
@@ -162,7 +162,7 @@ public class UntapAi extends SpellAbilityAi {
} }
if (choice == null) { // can't find anything left if (choice == null) { // can't find anything left
if ((sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa)) || (sa.getTargets().getNumTargeted() == 0)) { if ((sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) || (sa.getTargets().getNumTargeted() == 0)) {
sa.resetTargets(); sa.resetTargets();
return false; return false;
} else { } else {
@@ -191,7 +191,7 @@ public class UntapAi extends SpellAbilityAi {
* @return 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 Card source = sa.getHostCard();
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
List<Card> list = sa.getActivatingPlayer().getGame().getCardsIn(ZoneType.Battlefield); List<Card> list = sa.getActivatingPlayer().getGame().getCardsIn(ZoneType.Battlefield);
@@ -280,7 +280,7 @@ public class UntapAi extends SpellAbilityAi {
} }
if (choice == null) { // can't find anything left if (choice == null) { // can't find anything left
if ((sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa)) || (sa.getTargets().getNumTargeted() == 0)) { if ((sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) || (sa.getTargets().getNumTargeted() == 0)) {
if (!mandatory) { if (!mandatory) {
sa.resetTargets(); sa.resetTargets();
} }

View File

@@ -14,7 +14,7 @@ public class UntapAllAi extends SpellAbilityAi {
@Override @Override
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) { protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final AbilitySub abSub = sa.getSubAbility(); final AbilitySub abSub = sa.getSubAbility();
if (abSub != null) { if (abSub != null) {

View File

@@ -22,7 +22,7 @@ public class ZoneExchangeAi extends SpellAbilityAi {
protected boolean canPlayAI(Player ai, final SpellAbility sa) { protected boolean canPlayAI(Player ai, final SpellAbility sa) {
Card object1 = null; Card object1 = null;
Card object2 = null; Card object2 = null;
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final String type = sa.getParam("Type"); final String type = sa.getParam("Type");
if (sa.hasParam("Object")) { if (sa.hasParam("Object")) {
object1 = AbilityUtils.getDefinedCards(source, sa.getParam("Object"), sa).get(0); object1 = AbilityUtils.getDefinedCards(source, sa.getParam("Object"), sa).get(0);

View File

@@ -15,11 +15,10 @@ import forge.util.Expressions;
import java.util.*; import java.util.*;
/** /**
* Base class for Triggers and ReplacementEffects. * Base class for Triggers,ReplacementEffects and StaticAbilities.
* Provides the matchesValid function to both classes.
* *
*/ */
public abstract class CardTraitBase { public abstract class CardTraitBase extends GameObject {
/** The host card. */ /** The host card. */
protected Card hostCard; protected Card hostCard;
@@ -31,19 +30,13 @@ public abstract class CardTraitBase {
protected boolean intrinsic; protected boolean intrinsic;
/** The temporary. */ /** The temporary. */
private boolean temporary = false; protected boolean temporary = false;
/** The suppressed. */ /** The suppressed. */
private boolean suppressed = false; protected boolean suppressed = false;
/** The temporarily suppressed. */ /** The temporarily suppressed. */
private boolean temporarilySuppressed = false; protected boolean temporarilySuppressed = false;
protected EnumSet<ZoneType> validHostZones;
/** The overriding ability. */
private SpellAbility overridingAbility = null;
/** /**
* Sets the temporary. * Sets the temporary.
@@ -89,7 +82,9 @@ public abstract class CardTraitBase {
return this.intrinsic; return this.intrinsic;
} }
public void setIntrinsic(boolean i) {
this.intrinsic = i;
}
/** /**
* <p> * <p>
@@ -98,7 +93,7 @@ public abstract class CardTraitBase {
* *
* @return a {@link forge.game.card.Card} object. * @return a {@link forge.game.card.Card} object.
*/ */
public final Card getHostCard() { public Card getHostCard() {
return this.hostCard; return this.hostCard;
} }
@@ -110,49 +105,8 @@ public abstract class CardTraitBase {
* @param c * @param c
* a {@link forge.game.card.Card} object. * a {@link forge.game.card.Card} object.
*/ */
public final void setHostCard(final Card c) { public void setHostCard(final Card c) {
this.hostCard = c; this.hostCard = c;
if (overridingAbility != null) {
CardFactoryUtil.correctAbilityChainSourceCard(overridingAbility, c);
}
}
public void setActiveZone(EnumSet<ZoneType> zones) {
validHostZones = zones;
}
/**
* <p>
* zonesCheck.
* </p>
*
* @return a boolean.
*/
public final boolean zonesCheck(Zone hostCardZone) {
return !this.hostCard.isPhasedOut()
&& (validHostZones == null || validHostZones.isEmpty()
|| (hostCardZone != null && validHostZones.contains(hostCardZone.getZoneType()))
);
}
/**
* Gets the overriding ability.
*
* @return the overridingAbility
*/
public SpellAbility getOverridingAbility() {
return this.overridingAbility;
}
/**
* Sets the overriding ability.
*
* @param overridingAbility0
* the overridingAbility to set
*/
public void setOverridingAbility(final SpellAbility overridingAbility0) {
this.overridingAbility = overridingAbility0;
} }
/** /**

View File

@@ -1628,7 +1628,7 @@ public class GameAction {
} }
for (final SpellAbility sa : usableFromOpeningHand) { for (final SpellAbility sa : usableFromOpeningHand) {
if (!takesAction.getZone(ZoneType.Hand).contains(sa.getSourceCard())) { if (!takesAction.getZone(ZoneType.Hand).contains(sa.getHostCard())) {
continue; continue;
} }

View File

@@ -150,7 +150,7 @@ public final class GameActionUtil {
*/ */
public static final ArrayList<SpellAbility> getAlternativeCosts(SpellAbility sa) { public static final ArrayList<SpellAbility> getAlternativeCosts(SpellAbility sa) {
ArrayList<SpellAbility> alternatives = new ArrayList<SpellAbility>(); ArrayList<SpellAbility> alternatives = new ArrayList<SpellAbility>();
Card source = sa.getSourceCard(); Card source = sa.getHostCard();
if (!sa.isBasicSpell()) { if (!sa.isBasicSpell()) {
return alternatives; return alternatives;
} }
@@ -208,7 +208,7 @@ public final class GameActionUtil {
newSA.setBasicSpell(false); newSA.setBasicSpell(false);
String kw = keyword; String kw = keyword;
if (keyword.contains("ConvertedManaCost")) { if (keyword.contains("ConvertedManaCost")) {
final String cmc = Integer.toString(sa.getSourceCard().getCMC()); final String cmc = Integer.toString(sa.getHostCard().getCMC());
kw = keyword.replace("ConvertedManaCost", cmc); kw = keyword.replace("ConvertedManaCost", cmc);
} }
final Cost cost = new Cost(kw.substring(17), false).add(newSA.getPayCosts().copyWithNoMana()); final Cost cost = new Cost(kw.substring(17), false).add(newSA.getPayCosts().copyWithNoMana());
@@ -232,7 +232,7 @@ public final class GameActionUtil {
} }
if (sa.isSpell() && keyword.endsWith(" offering")) { if (sa.isSpell() && keyword.endsWith(" offering")) {
final String offeringType = keyword.split(" ")[0]; final String offeringType = keyword.split(" ")[0];
List<Card> canOffer = CardLists.filter(sa.getSourceCard().getController().getCardsIn(ZoneType.Battlefield), List<Card> canOffer = CardLists.filter(sa.getHostCard().getController().getCardsIn(ZoneType.Battlefield),
CardPredicates.isType(offeringType)); CardPredicates.isType(offeringType));
if (source.getController().hasKeyword("You can't sacrifice creatures to cast spells or activate abilities.")) { if (source.getController().hasKeyword("You can't sacrifice creatures to cast spells or activate abilities.")) {
canOffer = CardLists.getNotType(canOffer, "Creature"); canOffer = CardLists.getNotType(canOffer, "Creature");
@@ -274,7 +274,7 @@ public final class GameActionUtil {
public static List<SpellAbility> getOptionalCosts(final SpellAbility original) { public static List<SpellAbility> getOptionalCosts(final SpellAbility original) {
final List<SpellAbility> abilities = new ArrayList<SpellAbility>(); final List<SpellAbility> abilities = new ArrayList<SpellAbility>();
final Card source = original.getSourceCard(); final Card source = original.getHostCard();
abilities.add(original); abilities.add(original);
if (!original.isSpell()) { if (!original.isSpell()) {
return abilities; return abilities;
@@ -389,7 +389,7 @@ public final class GameActionUtil {
// Splice // Splice
final List<SpellAbility> newAbilities = new ArrayList<SpellAbility>(); final List<SpellAbility> newAbilities = new ArrayList<SpellAbility>();
for (SpellAbility sa : abilities) { for (SpellAbility sa : abilities) {
if (sa.isSpell() && sa.getSourceCard().isType("Arcane") && sa.getApi() != null ) { if (sa.isSpell() && sa.getHostCard().isType("Arcane") && sa.getApi() != null ) {
newAbilities.addAll(GameActionUtil.getSpliceAbilities(sa)); newAbilities.addAll(GameActionUtil.getSpliceAbilities(sa));
} }
} }
@@ -411,7 +411,7 @@ public final class GameActionUtil {
ArrayList<SpellAbility> newSAs = new ArrayList<SpellAbility>(); ArrayList<SpellAbility> newSAs = new ArrayList<SpellAbility>();
ArrayList<SpellAbility> allSaCombinations = new ArrayList<SpellAbility>(); ArrayList<SpellAbility> allSaCombinations = new ArrayList<SpellAbility>();
allSaCombinations.add(sa); allSaCombinations.add(sa);
Card source = sa.getSourceCard(); Card source = sa.getHostCard();
for (Card c : sa.getActivatingPlayer().getCardsIn(ZoneType.Hand)) { for (Card c : sa.getActivatingPlayer().getCardsIn(ZoneType.Hand)) {
if (c.equals(source)) { if (c.equals(source)) {
@@ -458,7 +458,7 @@ public final class GameActionUtil {
//set correct source and activating player to all the spliced abilities //set correct source and activating player to all the spliced abilities
child = subAbility; child = subAbility;
while (child != null) { while (child != null) {
child.setSourceCard(source); child.setHostCard(source);
child.setActivatingPlayer(newSA.getActivatingPlayer()); child.setActivatingPlayer(newSA.getActivatingPlayer());
child = child.getSubAbility(); child = child.getSubAbility();
} }
@@ -497,7 +497,7 @@ public final class GameActionUtil {
public static String generatedMana(final SpellAbility sa) { public static String generatedMana(final SpellAbility sa) {
// Calculate generated mana here for stack description and resolving // Calculate generated mana here for stack description and resolving
int amount = sa.hasParam("Amount") ? AbilityUtils.calculateAmount(sa.getSourceCard(), sa.getParam("Amount"), sa) : 1; int amount = sa.hasParam("Amount") ? AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("Amount"), sa) : 1;
AbilityManaPart abMana = sa.getManaPart(); AbilityManaPart abMana = sa.getManaPart();
String baseMana; String baseMana;

View File

@@ -37,7 +37,7 @@ public class GameLogFormatter extends IGameEventVisitor.Base<GameLogEntry> {
*/ */
@Override @Override
public GameLogEntry visit(GameEventSpellResolved ev) { public GameLogEntry visit(GameEventSpellResolved ev) {
String messageForLog = ev.hasFizzled ? ev.spell.getSourceCard().getName() + " ability fizzles." : ev.spell.getStackDescription(); String messageForLog = ev.hasFizzled ? ev.spell.getHostCard().getName() + " ability fizzles." : ev.spell.getStackDescription();
return new GameLogEntry(GameLogEntryType.STACK_RESOLVE, messageForLog); return new GameLogEntry(GameLogEntryType.STACK_RESOLVE, messageForLog);
} }
@@ -46,7 +46,7 @@ public class GameLogFormatter extends IGameEventVisitor.Base<GameLogEntry> {
public GameLogEntry visit(GameEventSpellAbilityCast event) { public GameLogEntry visit(GameEventSpellAbilityCast event) {
String who = event.sa.getActivatingPlayer().getName(); String who = event.sa.getActivatingPlayer().getName();
String action = event.sa.isSpell() ? " cast " : " activated "; String action = event.sa.isSpell() ? " cast " : " activated ";
String what = event.sa.getStackDescription().startsWith("Morph ") ? "Morph" : event.sa.getSourceCard().toString(); String what = event.sa.getStackDescription().startsWith("Morph ") ? "Morph" : event.sa.getHostCard().toString();
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(who).append(action).append(what); sb.append(who).append(action).append(what);

View File

@@ -23,25 +23,25 @@ public class AbilityApiBased extends AbilityActivated {
public AbilityApiBased(ApiType api0, Card sourceCard, Cost abCost, TargetRestrictions tgt, Map<String, String> params0) { public AbilityApiBased(ApiType api0, Card sourceCard, Cost abCost, TargetRestrictions tgt, Map<String, String> params0) {
super(sourceCard, abCost, tgt); super(sourceCard, abCost, tgt);
params = params0; mapParams.putAll(params0);
api = api0; api = api0;
effect = api.getSpellEffect(); effect = api.getSpellEffect();
ai = api.getAi(); ai = api.getAi();
if (effect instanceof ManaEffect || effect instanceof ManaReflectedEffect) { if (effect instanceof ManaEffect || effect instanceof ManaReflectedEffect) {
this.setManaPart(new AbilityManaPart(sourceCard, params)); this.setManaPart(new AbilityManaPart(sourceCard, mapParams));
this.setUndoable(true); // will try at least this.setUndoable(true); // will try at least
} }
if (effect instanceof ChangeZoneEffect || effect instanceof ChangeZoneAllEffect) { if (effect instanceof ChangeZoneEffect || effect instanceof ChangeZoneAllEffect) {
AbilityFactory.adjustChangeZoneTarget(params, this); AbilityFactory.adjustChangeZoneTarget(mapParams, this);
} }
} }
@Override @Override
public String getStackDescription() { public String getStackDescription() {
return effect.getStackDescriptionWithSubs(params, this); return effect.getStackDescriptionWithSubs(mapParams, this);
} }
/* (non-Javadoc) /* (non-Javadoc)
@@ -50,7 +50,7 @@ public class AbilityApiBased extends AbilityActivated {
@Override @Override
public AbilityActivated getCopy() { public AbilityActivated getCopy() {
TargetRestrictions tgt = getTargetRestrictions() == null ? null : new TargetRestrictions(getTargetRestrictions()); TargetRestrictions tgt = getTargetRestrictions() == null ? null : new TargetRestrictions(getTargetRestrictions());
AbilityActivated res = new AbilityApiBased(api, getSourceCard(), getPayCosts(), tgt, params); AbilityActivated res = new AbilityApiBased(api, getHostCard(), getPayCosts(), tgt, mapParams);
CardFactory.copySpellAbility(this, res); CardFactory.copySpellAbility(this, res);
return res; return res;
} }

View File

@@ -171,7 +171,7 @@ public final class AbilityFactory {
} }
if (spellAbility instanceof SpellApiBased && hostCard.isPermanent()) { if (spellAbility instanceof SpellApiBased && hostCard.isPermanent()) {
spellAbility.setDescription(spellAbility.getSourceCard().getName()); spellAbility.setDescription(spellAbility.getHostCard().getName());
} else if (mapParams.containsKey("SpellDescription")) { } else if (mapParams.containsKey("SpellDescription")) {
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
@@ -363,7 +363,7 @@ public final class AbilityFactory {
} }
public static final SpellAbility buildEntwineAbility(final SpellAbility sa) { public static final SpellAbility buildEntwineAbility(final SpellAbility sa) {
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final String[] saChoices = sa.getParam("Choices").split(","); final String[] saChoices = sa.getParam("Choices").split(",");
if (sa.getApi() != ApiType.Charm || saChoices.length != 2) if (sa.getApi() != ApiType.Charm || saChoices.length != 2)
throw new IllegalStateException("Entwine ability may be built only on charm cards"); throw new IllegalStateException("Entwine ability may be built only on charm cards");

View File

@@ -36,7 +36,7 @@ public class AbilityUtils {
} catch (Exception e) { } catch (Exception e) {
String type = sa.getSVar(name); String type = sa.getSVar(name);
if (type.equals("")) { if (type.equals("")) {
type = sa.getSourceCard().getSVar(name); type = sa.getHostCard().getSVar(name);
} }
if (type.equals("")) { if (type.equals("")) {
@@ -388,7 +388,7 @@ public class AbilityUtils {
else if (hType.startsWith("Property")) { else if (hType.startsWith("Property")) {
String defined = hType.split("Property")[1]; String defined = hType.split("Property")[1];
for (Player p : game.getPlayers()) { for (Player p : game.getPlayers()) {
if (p.hasProperty(defined, ability.getActivatingPlayer(), ability.getSourceCard())) { if (p.hasProperty(defined, ability.getActivatingPlayer(), ability.getHostCard())) {
players.add(p); players.add(p);
} }
} }
@@ -492,7 +492,7 @@ public class AbilityUtils {
} }
} }
for (final SpellAbility s : sas) { for (final SpellAbility s : sas) {
final Player p = s.getSourceCard().getController(); final Player p = s.getHostCard().getController();
if (!players.contains(p)) { if (!players.contains(p)) {
players.add(p); players.add(p);
} }
@@ -504,7 +504,7 @@ public class AbilityUtils {
final List<SpellAbility> saList = getDefinedSpellAbilities(card, "Targeted", ability); final List<SpellAbility> saList = getDefinedSpellAbilities(card, "Targeted", ability);
for (final SpellAbility s : saList) { for (final SpellAbility s : saList) {
tgtList.addAll(getDefinedCards(s.getSourceCard(), "Targeted", s)); tgtList.addAll(getDefinedCards(s.getHostCard(), "Targeted", s));
} }
return CardFactoryUtil.handlePaid(tgtList, calcX[1], card) * multiplier; return CardFactoryUtil.handlePaid(tgtList, calcX[1], card) * multiplier;
} }
@@ -521,7 +521,7 @@ public class AbilityUtils {
if (calcX[0].equals("TriggeredSpellAbility")) { if (calcX[0].equals("TriggeredSpellAbility")) {
final SpellAbility root = ability.getRootAbility(); final SpellAbility root = ability.getRootAbility();
SpellAbility sat = (SpellAbility) root.getTriggeringObject("SpellAbility"); SpellAbility sat = (SpellAbility) root.getTriggeringObject("SpellAbility");
return calculateAmount(sat.getSourceCard(), calcX[1], sat); return calculateAmount(sat.getHostCard(), calcX[1], sat);
} }
// Added on 9/30/12 (ArsenalNut) - Ended up not using but might be useful in future // Added on 9/30/12 (ArsenalNut) - Ended up not using but might be useful in future
/* /*
@@ -540,7 +540,7 @@ public class AbilityUtils {
final SpellAbility root = ability.getRootAbility(); final SpellAbility root = ability.getRootAbility();
list = root.getPaidList("Discarded"); list = root.getPaidList("Discarded");
if ((null == list) && root.isTrigger()) { if ((null == list) && root.isTrigger()) {
list = root.getSourceCard().getSpellPermanent().getPaidList("Discarded"); list = root.getHostCard().getSpellPermanent().getPaidList("Discarded");
} }
} }
else if (calcX[0].startsWith("Exiled")) { else if (calcX[0].startsWith("Exiled")) {
@@ -643,7 +643,7 @@ public class AbilityUtils {
// Filter List Can send a different Source card in for things like // Filter List Can send a different Source card in for things like
// Mishra and Lobotomy // Mishra and Lobotomy
Card source = sa.getSourceCard(); Card source = sa.getHostCard();
final Object o; final Object o;
if (type.startsWith("Triggered")) { if (type.startsWith("Triggered")) {
if (type.contains("Card")) { if (type.contains("Card")) {
@@ -861,7 +861,7 @@ public class AbilityUtils {
o = ((Card) c).getController(); o = ((Card) c).getController();
} }
if (c instanceof SpellAbility) { if (c instanceof SpellAbility) {
o = ((SpellAbility) c).getSourceCard().getController(); o = ((SpellAbility) c).getHostCard().getController();
} }
} }
else if (defined.endsWith("Opponent")) { else if (defined.endsWith("Opponent")) {
@@ -872,7 +872,7 @@ public class AbilityUtils {
o = ((Card) c).getController().getOpponents(); o = ((Card) c).getController().getOpponents();
} }
if (c instanceof SpellAbility) { if (c instanceof SpellAbility) {
o = ((SpellAbility) c).getSourceCard().getController().getOpponents(); o = ((SpellAbility) c).getHostCard().getController().getOpponents();
} }
} }
else if (defined.endsWith("Owner")) { else if (defined.endsWith("Owner")) {
@@ -923,7 +923,7 @@ public class AbilityUtils {
o = ((Card) c).getController(); o = ((Card) c).getController();
} }
if (c instanceof SpellAbility) { if (c instanceof SpellAbility) {
o = ((SpellAbility) c).getSourceCard().getController(); o = ((SpellAbility) c).getHostCard().getController();
} }
} }
else if (defined.endsWith("Opponent")) { else if (defined.endsWith("Opponent")) {
@@ -934,7 +934,7 @@ public class AbilityUtils {
o = ((Card) c).getController().getOpponent(); o = ((Card) c).getController().getOpponent();
} }
if (c instanceof SpellAbility) { if (c instanceof SpellAbility) {
o = ((SpellAbility) c).getSourceCard().getController().getOpponent(); o = ((SpellAbility) c).getHostCard().getController().getOpponent();
} }
} }
else if (defined.endsWith("Owner")) { else if (defined.endsWith("Owner")) {
@@ -981,7 +981,7 @@ public class AbilityUtils {
} }
} }
else if (defined.equals("EnchantedPlayer")) { else if (defined.equals("EnchantedPlayer")) {
final Object o = sa.getSourceCard().getEnchanting(); final Object o = sa.getHostCard().getEnchanting();
if (o instanceof Player) { if (o instanceof Player) {
if (!players.contains(o)) { if (!players.contains(o)) {
players.add((Player) o); players.add((Player) o);
@@ -1004,7 +1004,7 @@ public class AbilityUtils {
} }
} }
else if (defined.equals("SourceController")) { else if (defined.equals("SourceController")) {
final Player p = sa.getSourceCard().getController(); final Player p = sa.getHostCard().getController();
if (!players.contains(p)) { if (!players.contains(p)) {
players.add(p); players.add(p);
} }
@@ -1022,8 +1022,8 @@ public class AbilityUtils {
} }
else if (defined.startsWith("Flipped")) { else if (defined.startsWith("Flipped")) {
for (Player p : game.getPlayers()) { for (Player p : game.getPlayers()) {
if (null != sa.getSourceCard().getFlipResult(p)) { if (null != sa.getHostCard().getFlipResult(p)) {
if (sa.getSourceCard().getFlipResult(p).equals(defined.substring(7))) { if (sa.getHostCard().getFlipResult(p).equals(defined.substring(7))) {
players.add(p); players.add(p);
} }
} }
@@ -1043,7 +1043,7 @@ public class AbilityUtils {
} }
else { else {
for (Player p : game.getPlayers()) { for (Player p : game.getPlayers()) {
if (p.isValid(defined, sa.getActivatingPlayer(), sa.getSourceCard())) { if (p.isValid(defined, sa.getActivatingPlayer(), sa.getHostCard())) {
players.add(p); players.add(p);
} }
} }
@@ -1183,11 +1183,11 @@ public class AbilityUtils {
} }
private static void handleUnlessCost(final SpellAbility sa, final Game game) { private static void handleUnlessCost(final SpellAbility sa, final Game game) {
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
// The player who has the chance to cancel the ability // The player who has the chance to cancel the ability
final String pays = sa.hasParam("UnlessPayer") ? sa.getParam("UnlessPayer") : "TargetedController"; final String pays = sa.hasParam("UnlessPayer") ? sa.getParam("UnlessPayer") : "TargetedController";
final List<Player> allPayers = getDefinedPlayers(sa.getSourceCard(), pays, sa); final List<Player> allPayers = getDefinedPlayers(sa.getHostCard(), pays, sa);
final String resolveSubs = sa.getParam("UnlessResolveSubs"); // no value means 'Always' final String resolveSubs = sa.getParam("UnlessResolveSubs"); // no value means 'Always'
final boolean execSubsWhenPaid = "WhenPaid".equals(resolveSubs) || StringUtils.isBlank(resolveSubs); final boolean execSubsWhenPaid = "WhenPaid".equals(resolveSubs) || StringUtils.isBlank(resolveSubs);
final boolean execSubsWhenNotPaid = "WhenNotPaid".equals(resolveSubs) || StringUtils.isBlank(resolveSubs); final boolean execSubsWhenNotPaid = "WhenNotPaid".equals(resolveSubs) || StringUtils.isBlank(resolveSubs);
@@ -1252,7 +1252,7 @@ public class AbilityUtils {
* a SpellAbility object. * a SpellAbility object.
*/ */
public static void handleRemembering(final SpellAbility sa) { public static void handleRemembering(final SpellAbility sa) {
Card host = sa.getSourceCard(); Card host = sa.getHostCard();
if (sa.hasParam("RememberTargets") && sa.getTargetRestrictions() != null) { if (sa.hasParam("RememberTargets") && sa.getTargetRestrictions() != null) {
if (sa.hasParam("ForgetOtherTargets")) { if (sa.hasParam("ForgetOtherTargets")) {

View File

@@ -23,7 +23,7 @@ public class SaTargetRoutines {
boolean useTargets = sa.usesTargeting() && (!definedFirst || !sa.hasParam(definedParam)) boolean useTargets = sa.usesTargeting() && (!definedFirst || !sa.hasParam(definedParam))
&& sa.getTargets() != null && (sa.getTargets().isTargetingAnyCard() || sa.getTargets().getTargets().isEmpty()); && sa.getTargets() != null && (sa.getTargets().isTargetingAnyCard() || sa.getTargets().getTargets().isEmpty());
return useTargets ? Lists.newArrayList(sa.getTargets().getTargetCards()) return useTargets ? Lists.newArrayList(sa.getTargets().getTargetCards())
: AbilityUtils.getDefinedCards(sa.getSourceCard(), sa.getParam(definedParam), sa); : AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam(definedParam), sa);
} }
// Players // Players
@@ -35,7 +35,7 @@ public class SaTargetRoutines {
private List<Player> getPlayers(boolean definedFirst, String definedParam, SpellAbility sa) { private List<Player> getPlayers(boolean definedFirst, String definedParam, SpellAbility sa) {
boolean useTargets = sa.usesTargeting() && (!definedFirst || !sa.hasParam(definedParam)); boolean useTargets = sa.usesTargeting() && (!definedFirst || !sa.hasParam(definedParam));
return useTargets ? Lists.newArrayList(sa.getTargets().getTargetPlayers()) return useTargets ? Lists.newArrayList(sa.getTargets().getTargetPlayers())
: AbilityUtils.getDefinedPlayers(sa.getSourceCard(), sa.getParam(definedParam), sa); : AbilityUtils.getDefinedPlayers(sa.getHostCard(), sa.getParam(definedParam), sa);
} }
// Spells // Spells
@@ -46,7 +46,7 @@ public class SaTargetRoutines {
private List<SpellAbility> getSpells(boolean definedFirst, String definedParam, SpellAbility sa) { private List<SpellAbility> getSpells(boolean definedFirst, String definedParam, SpellAbility sa) {
boolean useTargets = sa.usesTargeting() && (!definedFirst || !sa.hasParam(definedParam)); boolean useTargets = sa.usesTargeting() && (!definedFirst || !sa.hasParam(definedParam));
return useTargets ? Lists.newArrayList(sa.getTargets().getTargetSpells()) return useTargets ? Lists.newArrayList(sa.getTargets().getTargetSpells())
: AbilityUtils.getDefinedSpellAbilities(sa.getSourceCard(), sa.getParam(definedParam), sa); : AbilityUtils.getDefinedSpellAbilities(sa.getHostCard(), sa.getParam(definedParam), sa);
} }
// Targets of unspecified type // Targets of unspecified type
@@ -57,6 +57,6 @@ public class SaTargetRoutines {
private List<GameObject> getTargetables(boolean definedFirst, String definedParam, SpellAbility sa) { private List<GameObject> getTargetables(boolean definedFirst, String definedParam, SpellAbility sa) {
boolean useTargets = sa.usesTargeting() && (!definedFirst || !sa.hasParam(definedParam)); boolean useTargets = sa.usesTargeting() && (!definedFirst || !sa.hasParam(definedParam));
return useTargets ? Lists.newArrayList(sa.getTargets().getTargets()) return useTargets ? Lists.newArrayList(sa.getTargets().getTargets())
: AbilityUtils.getDefinedObjects(sa.getSourceCard(), sa.getParam(definedParam), sa); : AbilityUtils.getDefinedObjects(sa.getHostCard(), sa.getParam(definedParam), sa);
} }
} }

View File

@@ -49,7 +49,7 @@ import java.util.StringTokenizer;
// prelude for when this is root ability // prelude for when this is root ability
if (!(sa instanceof AbilitySub)) { if (!(sa instanceof AbilitySub)) {
sb.append(sa.getSourceCard()).append(" -"); sb.append(sa.getHostCard()).append(" -");
} }
sb.append(" "); sb.append(" ");
@@ -57,7 +57,7 @@ import java.util.StringTokenizer;
String stackDesc = params.get("StackDescription"); String stackDesc = params.get("StackDescription");
if (stackDesc != null) { if (stackDesc != null) {
if ("SpellDescription".equalsIgnoreCase(stackDesc)) { // by typing "none" they want to suppress output if ("SpellDescription".equalsIgnoreCase(stackDesc)) { // by typing "none" they want to suppress output
sb.append(params.get("SpellDescription").replace("CARDNAME", sa.getSourceCard().getName())); sb.append(params.get("SpellDescription").replace("CARDNAME", sa.getHostCard().getName()));
if (sa.getTargets() != null && !sa.getTargets().getTargets().isEmpty()) { if (sa.getTargets() != null && !sa.getTargets().getTargets().isEmpty()) {
sb.append(" (Targeting: " + sa.getTargets().getTargets() + ")"); sb.append(" (Targeting: " + sa.getTargets().getTargets() + ")");
} }
@@ -81,7 +81,7 @@ import java.util.StringTokenizer;
if (sa.hasParam("Announce")) { if (sa.hasParam("Announce")) {
String svar = sa.getParam("Announce"); String svar = sa.getParam("Announce");
int amount = CardFactoryUtil.xCount(sa.getSourceCard(), sa.getSVar(svar)); int amount = CardFactoryUtil.xCount(sa.getHostCard(), sa.getSVar(svar));
sb.append(String.format(" (%s=%d)", svar, amount)); sb.append(String.format(" (%s=%d)", svar, amount));
} }
@@ -103,17 +103,17 @@ import java.util.StringTokenizer;
if ( "{".equals(t) ) { isPlainText = false; continue; } if ( "{".equals(t) ) { isPlainText = false; continue; }
if ( "}".equals(t) ) { isPlainText = true; continue; } if ( "}".equals(t) ) { isPlainText = true; continue; }
if ( isPlainText ) if ( isPlainText )
sb.append(t.replace("CARDNAME", sa.getSourceCard().getName())); sb.append(t.replace("CARDNAME", sa.getHostCard().getName()));
else { else {
List<?> objs = null; List<?> objs = null;
if ( t.startsWith("p:") ) if ( t.startsWith("p:") )
objs = AbilityUtils.getDefinedPlayers(sa.getSourceCard(), t.substring(2), sa); objs = AbilityUtils.getDefinedPlayers(sa.getHostCard(), t.substring(2), sa);
else if ( t.startsWith("s:")) else if ( t.startsWith("s:"))
objs = AbilityUtils.getDefinedSpellAbilities(sa.getSourceCard(), t.substring(2), sa); objs = AbilityUtils.getDefinedSpellAbilities(sa.getHostCard(), t.substring(2), sa);
else if ( t.startsWith("c:")) else if ( t.startsWith("c:"))
objs = AbilityUtils.getDefinedCards(sa.getSourceCard(), t.substring(2), sa); objs = AbilityUtils.getDefinedCards(sa.getHostCard(), t.substring(2), sa);
else else
objs = AbilityUtils.getDefinedObjects(sa.getSourceCard(), t, sa); objs = AbilityUtils.getDefinedObjects(sa.getHostCard(), t, sa);
sb.append(StringUtils.join(objs, ", ")); sb.append(StringUtils.join(objs, ", "));
} }

View File

@@ -23,23 +23,23 @@ public class SpellApiBased extends Spell {
super(sourceCard, abCost); super(sourceCard, abCost);
this.setTargetRestrictions(tgt); this.setTargetRestrictions(tgt);
params = params0; mapParams.putAll(params0);
api = api0; api = api0;
effect = api.getSpellEffect(); effect = api.getSpellEffect();
ai = api.getAi(); ai = api.getAi();
if (effect instanceof ManaEffect || effect instanceof ManaReflectedEffect) { if (effect instanceof ManaEffect || effect instanceof ManaReflectedEffect) {
this.setManaPart(new AbilityManaPart(sourceCard, params)); this.setManaPart(new AbilityManaPart(sourceCard, mapParams));
} }
if (effect instanceof ChangeZoneEffect || effect instanceof ChangeZoneAllEffect) { if (effect instanceof ChangeZoneEffect || effect instanceof ChangeZoneAllEffect) {
AbilityFactory.adjustChangeZoneTarget(params, this); AbilityFactory.adjustChangeZoneTarget(mapParams, this);
} }
} }
@Override @Override
public String getStackDescription() { public String getStackDescription() {
return effect.getStackDescriptionWithSubs(params, this); return effect.getStackDescriptionWithSubs(mapParams, this);
} }
/* (non-Javadoc) /* (non-Javadoc)

View File

@@ -18,19 +18,19 @@ public class StaticAbilityApiBased extends AbilityStatic {
public StaticAbilityApiBased(ApiType api0, Card sourceCard, Cost abCost, TargetRestrictions tgt, Map<String, String> params0) { public StaticAbilityApiBased(ApiType api0, Card sourceCard, Cost abCost, TargetRestrictions tgt, Map<String, String> params0) {
super(sourceCard, abCost, tgt); super(sourceCard, abCost, tgt);
params = params0; mapParams.putAll(params0);
api = api0; api = api0;
effect = api.getSpellEffect(); effect = api.getSpellEffect();
ai = api.getAi(); ai = api.getAi();
if (effect instanceof ChangeZoneEffect || effect instanceof ChangeZoneAllEffect) { if (effect instanceof ChangeZoneEffect || effect instanceof ChangeZoneAllEffect) {
AbilityFactory.adjustChangeZoneTarget(params, this); AbilityFactory.adjustChangeZoneTarget(mapParams, this);
} }
} }
@Override @Override
public String getStackDescription() { public String getStackDescription() {
return effect.getStackDescriptionWithSubs(params, this); return effect.getStackDescriptionWithSubs(mapParams, this);
} }

View File

@@ -16,7 +16,7 @@ public class AbandonEffect extends SpellAbilityEffect {
*/ */
@Override @Override
public void resolve(SpellAbility sa) { public void resolve(SpellAbility sa) {
Card source = sa.getSourceCard(); Card source = sa.getHostCard();
Player controller = source.getController(); Player controller = source.getController();
final Game game = controller.getGame(); final Game game = controller.getGame();

View File

@@ -14,7 +14,7 @@ public class AddTurnEffect extends SpellAbilityEffect {
protected String getStackDescription(SpellAbility sa) { protected String getStackDescription(SpellAbility sa) {
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
final int numTurns = AbilityUtils.calculateAmount(sa.getSourceCard(), sa.getParam("NumTurns"), sa); final int numTurns = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("NumTurns"), sa);
List<Player> tgtPlayers = getTargetPlayers(sa); List<Player> tgtPlayers = getTargetPlayers(sa);
@@ -36,7 +36,7 @@ public class AddTurnEffect extends SpellAbilityEffect {
@Override @Override
public void resolve(SpellAbility sa) { public void resolve(SpellAbility sa) {
final int numTurns = AbilityUtils.calculateAmount(sa.getSourceCard(), sa.getParam("NumTurns"), sa); final int numTurns = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("NumTurns"), sa);
List<Player> tgtPlayers = getTargetPlayers(sa); List<Player> tgtPlayers = getTargetPlayers(sa);

View File

@@ -31,7 +31,7 @@ public class AnimateAllEffect extends AnimateEffectBase {
@Override @Override
public void resolve(final SpellAbility sa) { public void resolve(final SpellAbility sa) {
final Card host = sa.getSourceCard(); final Card host = sa.getHostCard();
final Map<String, String> svars = host.getSVars(); final Map<String, String> svars = host.getSVars();
// AF specific sa // AF specific sa

View File

@@ -27,14 +27,14 @@ public class AnimateEffect extends AnimateEffectBase {
*/ */
@Override @Override
public void resolve(final SpellAbility sa) { public void resolve(final SpellAbility sa) {
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
final Map<String, String> svars = source.getSVars(); final Map<String, String> svars = source.getSVars();
String animateRemembered = null; String animateRemembered = null;
//if host is not on the battlefield don't apply //if host is not on the battlefield don't apply
if (sa.hasParam("UntilHostLeavesPlay") if (sa.hasParam("UntilHostLeavesPlay")
&& !sa.getSourceCard().isInPlay()) { && !sa.getHostCard().isInPlay()) {
return; return;
} }
@@ -303,7 +303,7 @@ public class AnimateEffect extends AnimateEffectBase {
*/ */
@Override @Override
protected String getStackDescription(SpellAbility sa) { protected String getStackDescription(SpellAbility sa) {
final Card host = sa.getSourceCard(); final Card host = sa.getHostCard();
final Map<String, String> svars = host.getSVars(); final Map<String, String> svars = host.getSVars();
int power = -1; int power = -1;

View File

@@ -25,19 +25,19 @@ public class AttachEffect extends SpellAbilityEffect {
*/ */
@Override @Override
public void resolve(SpellAbility sa) { public void resolve(SpellAbility sa) {
if (sa.getSourceCard().isAura() && sa.isSpell()) { if (sa.getHostCard().isAura() && sa.isSpell()) {
final Player ap = sa.getActivatingPlayer(); final Player ap = sa.getActivatingPlayer();
// The Spell_Permanent (Auras) version of this AF needs to // The Spell_Permanent (Auras) version of this AF needs to
// move the card into play before Attaching // move the card into play before Attaching
sa.getSourceCard().setController(ap, 0); sa.getHostCard().setController(ap, 0);
final Card c = ap.getGame().getAction().moveTo(ap.getZone(ZoneType.Battlefield), sa.getSourceCard()); final Card c = ap.getGame().getAction().moveTo(ap.getZone(ZoneType.Battlefield), sa.getHostCard());
sa.setSourceCard(c); sa.setHostCard(c);
} }
Card source = sa.getSourceCard(); Card source = sa.getHostCard();
Card card = sa.getSourceCard(); Card card = sa.getHostCard();
final List<GameObject> targets = getTargets(sa); final List<GameObject> targets = getTargets(sa);

View File

@@ -23,7 +23,7 @@ public class BalanceEffect extends SpellAbilityEffect {
@Override @Override
public void resolve(SpellAbility sa) { public void resolve(SpellAbility sa) {
Player activator = sa.getActivatingPlayer(); Player activator = sa.getActivatingPlayer();
Card source = sa.getSourceCard(); Card source = sa.getHostCard();
Game game = activator.getGame(); Game game = activator.getGame();
String valid = sa.hasParam("Valid") ? sa.getParam("Valid") : "Card"; String valid = sa.hasParam("Valid") ? sa.getParam("Valid") : "Card";
ZoneType zone = sa.hasParam("Zone") ? ZoneType.smartValueOf(sa.getParam("Zone")) : ZoneType.Battlefield; ZoneType zone = sa.hasParam("Zone") ? ZoneType.smartValueOf(sa.getParam("Zone")) : ZoneType.Battlefield;

View File

@@ -12,7 +12,7 @@ public class BondEffect extends SpellAbilityEffect {
@Override @Override
public void resolve(SpellAbility sa) { public void resolve(SpellAbility sa) {
// find card that triggered pairing first // find card that triggered pairing first
List<Card> trigCards = AbilityUtils.getDefinedCards(sa.getSourceCard(), sa.getParam("Defined"), sa); List<Card> trigCards = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa);
// Check that this card hasn't already become paired by an earlier trigger // Check that this card hasn't already become paired by an earlier trigger
if (trigCards.get(0).isPaired() || !trigCards.get(0).isInZone(ZoneType.Battlefield)) { if (trigCards.get(0).isPaired() || !trigCards.get(0).isInZone(ZoneType.Battlefield)) {
@@ -39,7 +39,7 @@ public class BondEffect extends SpellAbilityEffect {
@Override @Override
protected String getStackDescription(SpellAbility sa) { protected String getStackDescription(SpellAbility sa) {
List<Card> tgts = AbilityUtils.getDefinedCards(sa.getSourceCard(), sa.getParam("Defined"), sa); List<Card> tgts = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa);
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();

View File

@@ -46,7 +46,7 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
// Redirect rules read 'you MAY choose new targets' ... okay! // Redirect rules read 'you MAY choose new targets' ... okay!
boolean isOptional = sa.hasParam("Optional"); boolean isOptional = sa.hasParam("Optional");
if( isOptional && !chooser.getController().confirmAction(sa, null, "Do you want to change targets of " + tgtSA.getSourceCard() + "?")) if( isOptional && !chooser.getController().confirmAction(sa, null, "Do you want to change targets of " + tgtSA.getHostCard() + "?"))
continue; continue;
if( changesOneTarget ) { if( changesOneTarget ) {
@@ -103,10 +103,10 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
if (null != newTarget) { if (null != newTarget) {
if (sa.hasParam("TargetRestriction")) { if (sa.hasParam("TargetRestriction")) {
if (newTarget.getFirstTargetedCard() != null && newTarget.getFirstTargetedCard(). if (newTarget.getFirstTargetedCard() != null && newTarget.getFirstTargetedCard().
isValid(sa.getParam("TargetRestriction").split(","), activator, sa.getSourceCard())) { isValid(sa.getParam("TargetRestriction").split(","), activator, sa.getHostCard())) {
changingTgtSI.updateTarget(newTarget); changingTgtSI.updateTarget(newTarget);
} else if (newTarget.getFirstTargetedPlayer() != null && newTarget.getFirstTargetedPlayer(). } else if (newTarget.getFirstTargetedPlayer() != null && newTarget.getFirstTargetedPlayer().
isValid(sa.getParam("TargetRestriction").split(","), activator, sa.getSourceCard())) { isValid(sa.getParam("TargetRestriction").split(","), activator, sa.getHostCard())) {
changingTgtSI.updateTarget(newTarget); changingTgtSI.updateTarget(newTarget);
} }
} else { } else {
@@ -118,7 +118,7 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
} }
} }
if (remember) { if (remember) {
sa.getSourceCard().addRemembered(tgtSA.getSourceCard()); sa.getHostCard().addRemembered(tgtSA.getHostCard());
} }
} }
} }

View File

@@ -40,7 +40,7 @@ public class ChangeZoneAllEffect extends SpellAbilityEffect {
List<Player> tgtPlayers = getTargetPlayers(sa); List<Player> tgtPlayers = getTargetPlayers(sa);
final Game game = sa.getActivatingPlayer().getGame(); final Game game = sa.getActivatingPlayer().getGame();
final Card source = sa.getSourceCard(); final Card source = sa.getHostCard();
if ((!sa.usesTargeting() && !sa.hasParam("Defined")) || sa.hasParam("UseAllOriginZones")) { if ((!sa.usesTargeting() && !sa.hasParam("Defined")) || sa.hasParam("UseAllOriginZones")) {
cards = game.getCardsIn(origin); cards = game.getCardsIn(origin);
@@ -75,7 +75,7 @@ public class ChangeZoneAllEffect extends SpellAbilityEffect {
cards = AbilityUtils.filterListByType(cards, sa.getParam("ChangeType"), sa); cards = AbilityUtils.filterListByType(cards, sa.getParam("ChangeType"), sa);
if (sa.hasParam("ForgetOtherRemembered")) { if (sa.hasParam("ForgetOtherRemembered")) {
sa.getSourceCard().clearRemembered(); sa.getHostCard().clearRemembered();
} }
final String remember = sa.getParam("RememberChanged"); final String remember = sa.getParam("RememberChanged");

Some files were not shown because too many files have changed in this diff Show More