mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
*Reintroduced TriggerReplacementBase as a specialized subclass of CardTraitBase
This commit is contained in:
@@ -498,9 +498,9 @@ public class AiController {
|
||||
int b1 = b.getPayCosts() == null ? 0 : b.getPayCosts().getTotalMana().getCMC();
|
||||
|
||||
// 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;
|
||||
} 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;
|
||||
}
|
||||
|
||||
@@ -519,13 +519,13 @@ public class AiController {
|
||||
|
||||
private int getSpellAbilityPriority(SpellAbility sa) {
|
||||
int p = 0;
|
||||
Card source = sa.getSourceCard();
|
||||
Card source = sa.getHostCard();
|
||||
// puts creatures in front of spells
|
||||
if (source.isCreature()) {
|
||||
p += 1;
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
// artifacts and enchantments with effects that do not stack
|
||||
@@ -566,7 +566,7 @@ public class AiController {
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -581,7 +581,7 @@ public class AiController {
|
||||
final List<Card> discardList = new ArrayList<Card>();
|
||||
int count = 0;
|
||||
if (sa != null) {
|
||||
sourceCard = sa.getSourceCard();
|
||||
sourceCard = sa.getHostCard();
|
||||
}
|
||||
|
||||
// look for good discards
|
||||
@@ -729,7 +729,7 @@ public class AiController {
|
||||
if(landsWannaPlay != null && !landsWannaPlay.isEmpty() && player.canPlayLand(null)) {
|
||||
Card land = chooseBestLandToPlay(landsWannaPlay);
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -835,7 +835,7 @@ public class AiController {
|
||||
for(int i = 0; i < result.size(); i++) {
|
||||
SpellAbility sa = result.get(i);
|
||||
|
||||
String srcName = sa.getSourceCard().getName();
|
||||
String srcName = sa.getHostCard().getName();
|
||||
if("Gemstone Caverns".equals(srcName)) {
|
||||
if(saGemstones == null)
|
||||
saGemstones = sa;
|
||||
@@ -1042,9 +1042,9 @@ public class AiController {
|
||||
switch(sa.getApi())
|
||||
{
|
||||
case SetLife:
|
||||
if (relatedPlayer.equals(sa.getSourceCard().getController())) {
|
||||
if (relatedPlayer.equals(sa.getHostCard().getController())) {
|
||||
return Collections.max(options);
|
||||
} else if (relatedPlayer.isOpponentOf(sa.getSourceCard().getController())) {
|
||||
} else if (relatedPlayer.isOpponentOf(sa.getHostCard().getController())) {
|
||||
return Collections.min(options);
|
||||
} else {
|
||||
return options.get(0);
|
||||
|
||||
@@ -29,7 +29,7 @@ public class AiCostDecision extends CostDecisionMakerBase implements ICostVisito
|
||||
public AiCostDecision(Player ai0, SpellAbility sa) {
|
||||
super(ai0);
|
||||
ability = sa;
|
||||
source = ability.getSourceCard();
|
||||
source = ability.getHostCard();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -362,7 +362,7 @@ public class AiCostDecision extends CostDecisionMakerBase implements ICostVisito
|
||||
final String sVar = ability.getSVar(amount);
|
||||
if (sVar.equals("XChoice")) {
|
||||
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);
|
||||
c = typeList.size();
|
||||
source.setSVar("ChosenX", "Number$" + Integer.toString(c));
|
||||
@@ -534,7 +534,7 @@ public class AiCostDecision extends CostDecisionMakerBase implements ICostVisito
|
||||
final String sVar = ability.getSVar(amount);
|
||||
if (sVar.equals("XChoice")) {
|
||||
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) {
|
||||
typeList.remove(source);
|
||||
}
|
||||
|
||||
@@ -75,10 +75,10 @@ public class ComputerUtil {
|
||||
public static boolean handlePlayingSpellAbility(final Player ai, final SpellAbility sa, final Game game) {
|
||||
|
||||
game.getStack().freezeStack();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
if (sa.isSpell() && !source.isCopiedSpell()) {
|
||||
sa.setSourceCard(game.getAction().moveToStack(source));
|
||||
sa.setHostCard(game.getAction().moveToStack(source));
|
||||
}
|
||||
|
||||
if (sa.getApi() == ApiType.Charm && !sa.isWrapper()) {
|
||||
@@ -86,7 +86,7 @@ public class ComputerUtil {
|
||||
}
|
||||
|
||||
if (sa.hasParam("Bestow")) {
|
||||
sa.getSourceCard().animateBestow();
|
||||
sa.getHostCard().animateBestow();
|
||||
}
|
||||
|
||||
final Cost cost = sa.getPayCosts();
|
||||
@@ -109,7 +109,7 @@ public class ComputerUtil {
|
||||
}
|
||||
}
|
||||
//Should not arrive here
|
||||
System.out.println("AI failed to play " + sa.getSourceCard());
|
||||
System.out.println("AI failed to play " + sa.getHostCard());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ public class ComputerUtil {
|
||||
|
||||
int restrict = 0;
|
||||
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
|
||||
|
||||
@@ -212,9 +212,9 @@ public class ComputerUtil {
|
||||
if (!ComputerUtilCost.canPayCost(sa, ai))
|
||||
return;
|
||||
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
if (sa.isSpell() && !source.isCopiedSpell()) {
|
||||
sa.setSourceCard(game.getAction().moveToStack(source));
|
||||
sa.setHostCard(game.getAction().moveToStack(source));
|
||||
}
|
||||
final Cost cost = sa.getPayCosts();
|
||||
if (cost == null) {
|
||||
@@ -239,9 +239,9 @@ public class ComputerUtil {
|
||||
public static final void playSpellAbilityForFree(final Player ai, final SpellAbility sa) {
|
||||
sa.setActivatingPlayer(ai);
|
||||
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
if (sa.isSpell() && !source.isCopiedSpell()) {
|
||||
sa.setSourceCard(ai.getGame().getAction().moveToStack(source));
|
||||
sa.setHostCard(ai.getGame().getAction().moveToStack(source));
|
||||
}
|
||||
|
||||
ai.getGame().getStack().add(sa);
|
||||
@@ -263,9 +263,9 @@ public class ComputerUtil {
|
||||
return;
|
||||
}
|
||||
|
||||
final Card source = newSA.getSourceCard();
|
||||
final Card source = newSA.getHostCard();
|
||||
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);
|
||||
@@ -286,9 +286,9 @@ public class ComputerUtil {
|
||||
sa.setActivatingPlayer(ai);
|
||||
// TODO: We should really restrict what doesn't use the Stack
|
||||
if (ComputerUtilCost.canPayCost(sa, ai)) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
if (sa.isSpell() && !source.isCopiedSpell()) {
|
||||
sa.setSourceCard(game.getAction().moveToStack(source));
|
||||
sa.setHostCard(game.getAction().moveToStack(source));
|
||||
}
|
||||
|
||||
final Cost cost = sa.getPayCosts();
|
||||
@@ -795,10 +795,10 @@ public class ComputerUtil {
|
||||
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
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;
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
|
||||
@@ -838,13 +838,13 @@ public class ComputerUtil {
|
||||
|
||||
if (sa.getApi() == ApiType.PreventDamage && sa.canPlay()
|
||||
&& ComputerUtilCost.canPayCost(sa, controller)) {
|
||||
if (AbilityUtils.getDefinedCards(sa.getSourceCard(), sa.getParam("Defined"), sa).contains(card)) {
|
||||
prevented += AbilityUtils.calculateAmount(sa.getSourceCard(), sa.getParam("Amount"), sa);
|
||||
if (AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa).contains(card)) {
|
||||
prevented += AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("Amount"), sa);
|
||||
}
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
if (tgt != null) {
|
||||
if (CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), controller, sa.getSourceCard()).contains(card)) {
|
||||
prevented += AbilityUtils.calculateAmount(sa.getSourceCard(), sa.getParam("Amount"), sa);
|
||||
if (CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), controller, sa.getHostCard()).contains(card)) {
|
||||
prevented += AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("Amount"), sa);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -867,7 +867,7 @@ public class ComputerUtil {
|
||||
* @return a boolean.
|
||||
*/
|
||||
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())) {
|
||||
return false;
|
||||
}
|
||||
@@ -1038,12 +1038,12 @@ public class ComputerUtil {
|
||||
final Game game = sa.getActivatingPlayer().getGame();
|
||||
final PhaseHandler ph = game.getPhaseHandler();
|
||||
|
||||
return (sa.getSourceCard().isCreature()
|
||||
return (sa.getHostCard().isCreature()
|
||||
&& sa.getPayCosts().hasTapCost()
|
||||
&& (ph.getPhase().isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS)
|
||||
|| !ph.getNextTurn().equals(sa.getActivatingPlayer()))
|
||||
&& !sa.getSourceCard().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, exile 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).
|
||||
*/
|
||||
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();
|
||||
|
||||
// Cipher spells
|
||||
@@ -1073,7 +1073,7 @@ public class ComputerUtil {
|
||||
}
|
||||
}
|
||||
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) {
|
||||
if (buffedCard.hasSVar("BuffedBy")) {
|
||||
final String buffedby = buffedCard.getSVar("BuffedBy");
|
||||
@@ -1144,7 +1144,7 @@ public class ComputerUtil {
|
||||
*/
|
||||
public static boolean activateForCost(SpellAbility sa, final Player ai) {
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
if (abCost == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -1240,7 +1240,7 @@ public class ComputerUtil {
|
||||
continue;
|
||||
}
|
||||
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) {
|
||||
continue;
|
||||
}
|
||||
@@ -1307,7 +1307,7 @@ public class ComputerUtil {
|
||||
return objects;
|
||||
}
|
||||
|
||||
final Card source = topStack.getSourceCard();
|
||||
final Card source = topStack.getHostCard();
|
||||
final ApiType threatApi = topStack.getApi();
|
||||
|
||||
// Can only Predict things from AFs
|
||||
@@ -1333,7 +1333,7 @@ public class ComputerUtil {
|
||||
// Lethal Damage => prevent damage/regeneration/bounce/shroud
|
||||
if (threatApi == ApiType.DealDamage || threatApi == ApiType.DamageAll) {
|
||||
// If PredictDamage is >= Lethal Damage
|
||||
final int dmg = AbilityUtils.calculateAmount(topStack.getSourceCard(),
|
||||
final int dmg = AbilityUtils.calculateAmount(topStack.getHostCard(),
|
||||
topStack.getParam("NumDmg"), topStack);
|
||||
for (final Object o : objects) {
|
||||
if (o instanceof Card) {
|
||||
@@ -1452,7 +1452,7 @@ public class ComputerUtil {
|
||||
}
|
||||
|
||||
public static boolean playImmediately(Player ai, SpellAbility sa) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final Zone zone = source.getZone();
|
||||
|
||||
if (zone.getZoneType() == ZoneType.Battlefield) {
|
||||
|
||||
@@ -848,7 +848,7 @@ public class ComputerUtilCombat {
|
||||
}
|
||||
|
||||
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) {
|
||||
power += pBonus;
|
||||
}
|
||||
@@ -859,7 +859,7 @@ public class ComputerUtilCombat {
|
||||
}
|
||||
|
||||
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) {
|
||||
power += pBonus;
|
||||
}
|
||||
@@ -977,7 +977,7 @@ public class ComputerUtilCombat {
|
||||
|
||||
if (ability.getApi() != ApiType.Pump || !ability.hasParam("NumDef")) {
|
||||
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) {
|
||||
toughness += tBonus;
|
||||
}
|
||||
@@ -988,7 +988,7 @@ public class ComputerUtilCombat {
|
||||
}
|
||||
|
||||
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) {
|
||||
toughness += tBonus;
|
||||
}
|
||||
@@ -1154,7 +1154,7 @@ public class ComputerUtilCombat {
|
||||
}
|
||||
|
||||
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) {
|
||||
power += pBonus;
|
||||
}
|
||||
@@ -1165,7 +1165,7 @@ public class ComputerUtilCombat {
|
||||
}
|
||||
|
||||
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) {
|
||||
power += pBonus;
|
||||
}
|
||||
@@ -1335,7 +1335,7 @@ public class ComputerUtilCombat {
|
||||
|
||||
if (ability.getApi() != ApiType.Pump || !ability.hasParam("NumDef")) {
|
||||
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) {
|
||||
toughness += tBonus;
|
||||
}
|
||||
@@ -1346,7 +1346,7 @@ public class ComputerUtilCombat {
|
||||
}
|
||||
|
||||
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) {
|
||||
toughness += tBonus;
|
||||
}
|
||||
|
||||
@@ -349,7 +349,7 @@ public class ComputerUtilCost {
|
||||
} // canPayCost()
|
||||
|
||||
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 payOwner = sa.hasParam("UnlessAI") ? sa.getParam("UnlessAI").startsWith("Defined") : false;
|
||||
boolean payNever = "Never".equals(sa.getParam("UnlessAI"));
|
||||
|
||||
@@ -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) {
|
||||
adjustManaCostToAvoidNegEffects(cost, sa.getSourceCard(), ai);
|
||||
adjustManaCostToAvoidNegEffects(cost, sa.getHostCard(), ai);
|
||||
|
||||
final ManaPool manapool = ai.getManaPool();
|
||||
List<ManaCostShard> unpaidShards = cost.getUnpaidShards();
|
||||
@@ -129,7 +129,7 @@ public class ComputerUtilMana {
|
||||
// for (Entry<ManaCostShard, Collection<SpellAbility>> src : sourcesForShards.entrySet()) {
|
||||
// System.out.println("\t" +src.getKey() + " : " + src.getValue().size() + " source(s)");
|
||||
// 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;
|
||||
if (saList != null) {
|
||||
for (final SpellAbility ma : saList) {
|
||||
if (ma.getSourceCard() == sa.getSourceCard()) {
|
||||
if (ma.getHostCard() == sa.getHostCard()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final String typeRes = cost.getSourceRestriction();
|
||||
if (StringUtils.isNotBlank(typeRes) && !ma.getSourceCard().isType(typeRes)) {
|
||||
if (StringUtils.isNotBlank(typeRes) && !ma.getHostCard().isType(typeRes)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ public class ComputerUtilMana {
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -174,7 +174,7 @@ public class ComputerUtilMana {
|
||||
|
||||
cost.payPhyrexian();
|
||||
if (!test) {
|
||||
ai.payLife(2, sa.getSourceCard());
|
||||
ai.payLife(2, sa.getHostCard());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -192,7 +192,7 @@ public class ComputerUtilMana {
|
||||
Iterator<SpellAbility> itSa = kv.iterator();
|
||||
while (itSa.hasNext()) {
|
||||
SpellAbility srcSa = itSa.next();
|
||||
if (srcSa.getSourceCard().equals(saPayment.getSourceCard())) {
|
||||
if (srcSa.getHostCard().equals(saPayment.getHostCard())) {
|
||||
itSa.remove();
|
||||
}
|
||||
}
|
||||
@@ -207,8 +207,8 @@ public class ComputerUtilMana {
|
||||
}
|
||||
}
|
||||
else {
|
||||
System.err.println("Ability " + saPayment + " from " + saPayment.getSourceCard() + " had NULL as payCost");
|
||||
saPayment.getSourceCard().tap();
|
||||
System.err.println("Ability " + saPayment + " from " + saPayment.getHostCard() + " had NULL as payCost");
|
||||
saPayment.getHostCard().tap();
|
||||
}
|
||||
|
||||
ai.getGame().getStack().addAndUnfreeze(saPayment);
|
||||
@@ -228,7 +228,7 @@ public class ComputerUtilMana {
|
||||
// if (DEBUG_MANA_PAYMENT) {
|
||||
// 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,
|
||||
// extraMana, sa.getSourceCard(), sa.toUnsuppressedString(), StringUtils.join(paymentPlan, "\n\t"));
|
||||
// extraMana, sa.getHostCard(), sa.toUnsuppressedString(), StringUtils.join(paymentPlan, "\n\t"));
|
||||
// }
|
||||
|
||||
if (!cost.isPaid()) {
|
||||
@@ -236,14 +236,14 @@ public class ComputerUtilMana {
|
||||
return false;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
sa.getSourceCard().setColorsPaid(cost.getColorsPaid());
|
||||
sa.getHostCard().setColorsPaid(cost.getColorsPaid());
|
||||
// if (sa instanceof Spell_Permanent) // should probably add this
|
||||
sa.getSourceCard().setSunburstValue(cost.getSunburst());
|
||||
sa.getHostCard().setSunburstValue(cost.getSunburst());
|
||||
return true;
|
||||
} // payManaCost()
|
||||
|
||||
@@ -254,7 +254,7 @@ public class ComputerUtilMana {
|
||||
if (m.isComboMana())
|
||||
getComboManaChoice(ai, saPayment, sa, cost);
|
||||
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);
|
||||
|
||||
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) {
|
||||
final Card sourceCard = ma.getSourceCard();
|
||||
final Card sourceCard = ma.getHostCard();
|
||||
|
||||
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) {
|
||||
final StringBuilder choiceString = new StringBuilder();
|
||||
final Card source = manaAb.getSourceCard();
|
||||
final Card source = manaAb.getHostCard();
|
||||
final AbilityManaPart abMana = manaAb.getManaPart();
|
||||
|
||||
if (abMana.isComboMana()) {
|
||||
@@ -515,8 +515,8 @@ public class ComputerUtilMana {
|
||||
private static ManaCostBeingPaid calculateManaCost(final SpellAbility sa, final boolean test, final int extraMana) {
|
||||
ZoneType castFromBackup = null;
|
||||
if (test && sa.isSpell()) {
|
||||
castFromBackup = sa.getSourceCard().getCastFrom();
|
||||
sa.getSourceCard().setCastFrom(sa.getSourceCard().getZone().getZoneType());
|
||||
castFromBackup = sa.getHostCard().getCastFrom();
|
||||
sa.getHostCard().setCastFrom(sa.getHostCard().getZone().getZoneType());
|
||||
}
|
||||
|
||||
Cost payCosts = sa.getPayCosts();
|
||||
@@ -529,7 +529,7 @@ public class ComputerUtilMana {
|
||||
ManaCostBeingPaid cost = new ManaCostBeingPaid(mana, restriction);
|
||||
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
|
||||
if ((sa.getPayCosts() != null) && (cost.getXcounter() > 0 || extraMana > 0)) {
|
||||
int manaToAdd = 0;
|
||||
@@ -559,7 +559,7 @@ public class ComputerUtilMana {
|
||||
}
|
||||
|
||||
if (test && sa.isSpell()) {
|
||||
sa.getSourceCard().setCastFrom(castFromBackup);
|
||||
sa.getHostCard().setCastFrom(castFromBackup);
|
||||
}
|
||||
|
||||
return cost;
|
||||
@@ -797,7 +797,7 @@ public class ComputerUtilMana {
|
||||
final Card offering = sa.getSacrificedAsOffering();
|
||||
offering.setUsedToPay(false);
|
||||
if (costIsPaid && !test) {
|
||||
sa.getSourceCard().getController().getGame().getAction().sacrifice(offering, sa);
|
||||
sa.getHostCard().getController().getGame().getAction().sacrifice(offering, sa);
|
||||
}
|
||||
sa.resetSacrificedAsOffering();
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ public abstract class SpellAbilityAi extends SaTargetRoutines {
|
||||
* @return a boolean.
|
||||
*/
|
||||
protected static boolean isSorcerySpeed(final SpellAbility sa) {
|
||||
return ( sa.isSpell() && sa.getSourceCard().isSorcery() )
|
||||
return ( sa.isSpell() && sa.getHostCard().isSorcery() )
|
||||
|| ( sa.isAbility() && sa.getRestrictions().isSorcerySpeed() );
|
||||
}
|
||||
|
||||
|
||||
@@ -50,14 +50,14 @@ public class AddTurnAi extends SpellAbilityAi {
|
||||
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);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} 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) {
|
||||
if (p.isOpponentOf(ai) && !mandatory) {
|
||||
return false;
|
||||
|
||||
@@ -32,7 +32,7 @@ public class AnimateAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final Game game = aiPlayer.getGame();
|
||||
final PhaseHandler ph = game.getPhaseHandler();
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public class AttachAi extends SpellAbilityAi {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Random r = MyRandom.getRandom();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
if (abCost != null) {
|
||||
// AI currently disabled for these costs
|
||||
@@ -319,7 +319,7 @@ public class AttachAi extends SpellAbilityAi {
|
||||
final Card attachSource) {
|
||||
// AI For choosing a Card to Animate.
|
||||
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>() {
|
||||
@Override
|
||||
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
|
||||
final Player ai = sa.getActivatingPlayer();
|
||||
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>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
@@ -611,12 +611,12 @@ public class AttachAi extends SpellAbilityAi {
|
||||
*/
|
||||
@Override
|
||||
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
|
||||
List<GameObject> targets = new ArrayList<GameObject>();
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
if (tgt == null) {
|
||||
targets = AbilityUtils.getDefinedObjects(sa.getSourceCard(), sa.getParam("Defined"), sa);
|
||||
targets = AbilityUtils.getDefinedObjects(sa.getHostCard(), sa.getParam("Defined"), sa);
|
||||
} else {
|
||||
AttachAi.attachPreference(sa, tgt, mandatory);
|
||||
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) {
|
||||
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
|
||||
// at some point can support attaching a different card
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ public class BecomesBlockedAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final Game game = aiPlayer.getGame();
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
// Fetching should occur fairly often as it helps cast more spells, and
|
||||
// have access to more mana
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
ZoneType origin = null;
|
||||
final Player opponent = ai.getOpponent();
|
||||
boolean activateForCost = ComputerUtil.activateForCost(sa, ai);
|
||||
@@ -241,9 +241,9 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
pDefined = sa.getTargets().getTargetPlayers();
|
||||
} else {
|
||||
if (sa.hasParam("DefinedPlayer")) {
|
||||
pDefined = AbilityUtils.getDefinedPlayers(sa.getSourceCard(), sa.getParam("DefinedPlayer"), sa);
|
||||
pDefined = AbilityUtils.getDefinedPlayers(sa.getHostCard(), sa.getParam("DefinedPlayer"), sa);
|
||||
} 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
|
||||
// have access to more mana
|
||||
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
|
||||
List<ZoneType> origin = new ArrayList<ZoneType>();
|
||||
@@ -404,7 +404,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
if (mandatory) {
|
||||
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) {
|
||||
@@ -540,7 +540,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
private static boolean knownOriginCanPlayAI(final Player ai, final SpellAbility sa) {
|
||||
// Retrieve either this card, or target Cards in Graveyard
|
||||
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 destination = ZoneType.smartValueOf(sa.getParam("Destination"));
|
||||
@@ -683,7 +683,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
* @return a boolean.
|
||||
*/
|
||||
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 destination = ZoneType.smartValueOf(sa.getParam("Destination"));
|
||||
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.
|
||||
}
|
||||
|
||||
if (list.size() < tgt.getMinTargets(sa.getSourceCard(), sa)) {
|
||||
if (list.size() < tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
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 ((destination.equals(ZoneType.Hand) || (destination.equals(ZoneType.Exile)
|
||||
&& (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
|
||||
// anything i control
|
||||
@@ -784,7 +784,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
// counters TODO check good and
|
||||
// bad counters
|
||||
// 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()) {
|
||||
@@ -855,12 +855,12 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mandatory && list.size() < tgt.getMinTargets(sa.getSourceCard(), sa)) {
|
||||
if (!mandatory && list.size() < tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// target loop
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getSourceCard(), sa)) {
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getHostCard(), sa)) {
|
||||
// AI Targeting
|
||||
Card choice = null;
|
||||
|
||||
@@ -909,7 +909,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
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) {
|
||||
sa.resetTargets();
|
||||
}
|
||||
@@ -948,7 +948,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final ZoneType origin = ZoneType.listValueOf(sa.getParam("Origin")).get(0);
|
||||
final ZoneType destination = ZoneType.smartValueOf(sa.getParam("Destination"));
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
@@ -978,7 +978,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// target loop
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa)) {
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
// AI Targeting
|
||||
Card choice = null;
|
||||
|
||||
@@ -1020,7 +1020,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
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();
|
||||
return false;
|
||||
} else {
|
||||
@@ -1057,7 +1057,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
if (sa.getTargetRestrictions() == null) {
|
||||
// Just in case of Defined cases
|
||||
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()) {
|
||||
final Card attachedTo = list.get(0);
|
||||
// This code is for the Dragon auras
|
||||
@@ -1132,7 +1132,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
}
|
||||
} else {
|
||||
// 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()) {
|
||||
fetchList = sameNamed;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class ChangeZoneAllAi extends SpellAbilityAi {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
// Change Zone All, can be any type moving from one zone to another
|
||||
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 origin = ZoneType.listValueOf(sa.getParam("Origin")).get(0);
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public class ChooseCardAi extends SpellAbilityAi {
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(final Player ai, SpellAbility sa) {
|
||||
final Card host = sa.getSourceCard();
|
||||
final Card host = sa.getHostCard();
|
||||
final Game game = ai.getGame();
|
||||
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
@@ -100,7 +100,7 @@ public class ChooseCardAi extends SpellAbilityAi {
|
||||
*/
|
||||
@Override
|
||||
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");
|
||||
Card choice = null;
|
||||
if (logic == null) {
|
||||
|
||||
@@ -13,7 +13,7 @@ public class ChooseCardNameAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
Card source = sa.getSourceCard();
|
||||
Card source = sa.getHostCard();
|
||||
if (sa.hasParam("AILogic")) {
|
||||
// Don't tap creatures that may be able to block
|
||||
if (ComputerUtil.waitForBlocking(sa)) {
|
||||
|
||||
@@ -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 the player because a CoP was pre-activated on it - unless, of course, there's another
|
||||
// possible reason to attack with that creature).
|
||||
final Card host = sa.getSourceCard();
|
||||
final Card host = sa.getHostCard();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
if (abCost != null) {
|
||||
// AI currently disabled for these costs
|
||||
@@ -72,7 +72,7 @@ public class ChooseSourceAi extends SpellAbilityAi {
|
||||
if (sa.getParam("AILogic").equals("NeedsPrevention")) {
|
||||
if (!game.getStack().isEmpty()) {
|
||||
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;
|
||||
}
|
||||
final ApiType threatApi = topStack.getApi();
|
||||
@@ -80,7 +80,7 @@ public class ChooseSourceAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Card threatSource = topStack.getSourceCard();
|
||||
final Card threatSource = topStack.getHostCard();
|
||||
List<? extends GameObject> objects = getTargets(topStack);
|
||||
if (!topStack.usesTargeting() && topStack.hasParam("ValidPlayers") && !topStack.hasParam("Defined")) {
|
||||
objects = AbilityUtils.getDefinedPlayers(threatSource, topStack.getParam("ValidPlayers"), topStack);
|
||||
@@ -159,7 +159,7 @@ public class ChooseSourceAi extends SpellAbilityAi {
|
||||
final Card source = si.getSourceCard();
|
||||
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;
|
||||
}
|
||||
final ApiType threatApi = abilityOnStack.getApi();
|
||||
|
||||
@@ -21,7 +21,7 @@ public class ChooseTypeAi extends SpellAbilityAi {
|
||||
sa.resetTargets();
|
||||
sa.getTargets().add(ai);
|
||||
} 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) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public class CloneAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final Game game = source.getGame();
|
||||
|
||||
boolean useAbility = true;
|
||||
|
||||
@@ -28,7 +28,7 @@ public class ControlExchangeAi extends SpellAbilityAi {
|
||||
sa.resetTargets();
|
||||
|
||||
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
|
||||
// purpose
|
||||
list = CardLists.filter(list, new Predicate<Card>() {
|
||||
@@ -40,10 +40,10 @@ public class ControlExchangeAi extends SpellAbilityAi {
|
||||
});
|
||||
object1 = ComputerUtilCard.getBestAI(list);
|
||||
if (sa.hasParam("Defined")) {
|
||||
object2 = AbilityUtils.getDefinedCards(sa.getSourceCard(), sa.getParam("Defined"), sa).get(0);
|
||||
} else if (tgt.getMinTargets(sa.getSourceCard(), sa) > 1) {
|
||||
object2 = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa).get(0);
|
||||
} else if (tgt.getMinTargets(sa.getHostCard(), sa) > 1) {
|
||||
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);
|
||||
sa.getTargets().add(object2);
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public class ControlGainAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
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
|
||||
list = CardLists.filter(list, new Predicate<Card>() {
|
||||
@@ -130,7 +130,7 @@ public class ControlGainAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getSourceCard(), sa)) {
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getHostCard(), sa)) {
|
||||
Card t = null;
|
||||
for (final Card c : list) {
|
||||
if (c.isCreature()) {
|
||||
@@ -148,7 +148,7 @@ public class ControlGainAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
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();
|
||||
return false;
|
||||
} else {
|
||||
|
||||
@@ -25,7 +25,7 @@ public class CopyPermanentAi extends SpellAbilityAi {
|
||||
*/
|
||||
@Override
|
||||
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
|
||||
|
||||
if (ComputerUtil.preventRunAwayActivations(sa)) {
|
||||
@@ -41,7 +41,7 @@ public class CopyPermanentAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(final Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
// ////
|
||||
// Targeting
|
||||
@@ -61,9 +61,9 @@ public class CopyPermanentAi extends SpellAbilityAi {
|
||||
});
|
||||
sa.resetTargets();
|
||||
// target loop
|
||||
while (sa.getTargets().getNumTargeted() < abTgt.getMaxTargets(sa.getSourceCard(), sa)) {
|
||||
while (sa.getTargets().getNumTargeted() < abTgt.getMaxTargets(sa.getHostCard(), sa)) {
|
||||
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.resetTargets();
|
||||
return false;
|
||||
@@ -87,7 +87,7 @@ public class CopyPermanentAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
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.resetTargets();
|
||||
return false;
|
||||
|
||||
@@ -19,7 +19,7 @@ public class CounterAi extends SpellAbilityAi {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
boolean toReturn = true;
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final Game game = ai.getGame();
|
||||
if (game.getStack().isEmpty()) {
|
||||
return false;
|
||||
@@ -39,12 +39,12 @@ public class CounterAi extends SpellAbilityAi {
|
||||
if (tgt != null) {
|
||||
|
||||
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
|
||||
return false;
|
||||
}
|
||||
if (sa.hasParam("AITgts") && (topSA.getSourceCard() == null
|
||||
|| !topSA.getSourceCard().isValid(sa.getParam("AITgts"), sa.getActivatingPlayer(), source))) {
|
||||
if (sa.hasParam("AITgts") && (topSA.getHostCard() == null
|
||||
|| !topSA.getHostCard().isValid(sa.getParam("AITgts"), sa.getActivatingPlayer(), source))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ public class CounterAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ public class CounterAi extends SpellAbilityAi {
|
||||
|
||||
String unlessCost = sa.hasParam("UnlessCost") ? sa.getParam("UnlessCost").trim() : null;
|
||||
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
if (unlessCost != null) {
|
||||
// Is this Usable Mana Sources? Or Total Available Mana?
|
||||
final int usableManaSources = ComputerUtilMana.getAvailableMana(ai.getOpponent(), true).size();
|
||||
|
||||
@@ -28,7 +28,7 @@ public class CountersMoveAi extends SpellAbilityAi {
|
||||
// TODO handle proper calculation of X values based on Cost
|
||||
int amount = 0;
|
||||
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
|
||||
if (amount <= 0) {
|
||||
@@ -47,13 +47,13 @@ public class CountersMoveAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
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 String type = sa.getParam("CounterType");
|
||||
final String amountStr = sa.getParam("CounterNum");
|
||||
int amount = 0;
|
||||
if (!sa.getParam("CounterNum").equals("All")) {
|
||||
amount = AbilityUtils.calculateAmount(sa.getSourceCard(), amountStr, sa);
|
||||
amount = AbilityUtils.calculateAmount(sa.getHostCard(), amountStr, sa);
|
||||
}
|
||||
boolean chance = false;
|
||||
boolean preferred = true;
|
||||
|
||||
@@ -32,7 +32,7 @@ public class CountersPutAi extends SpellAbilityAi {
|
||||
final Random r = MyRandom.getRandom();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final TargetRestrictions abTgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
List<Card> list;
|
||||
Card choice = null;
|
||||
final String type = sa.getParam("CounterType");
|
||||
@@ -120,9 +120,9 @@ public class CountersPutAi extends SpellAbilityAi {
|
||||
if (list.size() < abTgt.getMinTargets(source, sa)) {
|
||||
return false;
|
||||
}
|
||||
while (sa.getTargets().getNumTargeted() < abTgt.getMaxTargets(sa.getSourceCard(), sa)) {
|
||||
while (sa.getTargets().getNumTargeted() < abTgt.getMaxTargets(sa.getHostCard(), sa)) {
|
||||
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.resetTargets();
|
||||
return false;
|
||||
@@ -139,7 +139,7 @@ public class CountersPutAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
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.resetTargets();
|
||||
return false;
|
||||
@@ -158,7 +158,7 @@ public class CountersPutAi extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
} 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
|
||||
// on my opponents
|
||||
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) {
|
||||
boolean chance = true;
|
||||
final TargetRestrictions abTgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
Card choice = null;
|
||||
final String type = sa.getParam("CounterType");
|
||||
final String amountStr = sa.getParam("CounterNum");
|
||||
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;
|
||||
|
||||
@@ -216,7 +216,7 @@ public class CountersPutAi extends SpellAbilityAi {
|
||||
|
||||
sa.resetTargets();
|
||||
// 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>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
@@ -224,7 +224,7 @@ public class CountersPutAi extends SpellAbilityAi {
|
||||
}
|
||||
});
|
||||
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.resetTargets();
|
||||
return false;
|
||||
@@ -240,7 +240,7 @@ public class CountersPutAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
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.resetTargets();
|
||||
return false;
|
||||
@@ -264,7 +264,7 @@ public class CountersPutAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final TargetRestrictions abTgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
// boolean chance = true;
|
||||
boolean preferred = true;
|
||||
List<Card> list;
|
||||
@@ -273,7 +273,7 @@ public class CountersPutAi extends SpellAbilityAi {
|
||||
final String type = sa.getParam("CounterType");
|
||||
final String amountStr = sa.getParam("CounterNum");
|
||||
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) {
|
||||
// No target. So must be defined
|
||||
@@ -348,7 +348,7 @@ public class CountersPutAi extends SpellAbilityAi {
|
||||
*/
|
||||
@Override
|
||||
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) {
|
||||
// add counter if that opponent has a giant creature
|
||||
final List<Card> creats = player.getCreaturesInPlay();
|
||||
|
||||
@@ -29,7 +29,7 @@ public class CountersPutAllAi extends SpellAbilityAi {
|
||||
// the expected targets could be
|
||||
final Random r = MyRandom.getRandom();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
List<Card> hList;
|
||||
List<Card> cList;
|
||||
final String type = sa.getParam("CounterType");
|
||||
@@ -72,7 +72,7 @@ public class CountersPutAllAi extends SpellAbilityAi {
|
||||
amount = ComputerUtilMana.determineLeftoverMana(sa, ai);
|
||||
source.setSVar("PayX", Integer.toString(amount));
|
||||
} 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
|
||||
|
||||
@@ -51,7 +51,7 @@ public class CountersPutOrRemoveAi extends SpellAbilityAi {
|
||||
|
||||
List<ZoneType> zones = ZoneType.listValueOf(sa.getParamOrDefault("TgtZones", "Battlefield"));
|
||||
List<Card> validCards = CardLists.getValidCards(ai.getGame().getCardsIn(zones),
|
||||
tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard());
|
||||
tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getHostCard());
|
||||
|
||||
if (validCards.isEmpty()) {
|
||||
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;
|
||||
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.resetTargets();
|
||||
return false;
|
||||
|
||||
@@ -20,7 +20,7 @@ public class CountersRemoveAi extends SpellAbilityAi {
|
||||
// the expected targets could be
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
TargetRestrictions abTgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
// List<Card> list;
|
||||
// Card choice = null;
|
||||
|
||||
@@ -59,7 +59,7 @@ public class CountersRemoveAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// 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)) {
|
||||
return false;
|
||||
@@ -77,7 +77,7 @@ public class CountersRemoveAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
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) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -31,9 +31,9 @@ public abstract class DamageAiBase extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
if (!noPrevention) {
|
||||
restDamage = ComputerUtilCombat.predictDamageTo(enemy, restDamage, sa.getSourceCard(), false);
|
||||
restDamage = ComputerUtilCombat.predictDamageTo(enemy, restDamage, sa.getHostCard(), false);
|
||||
} else {
|
||||
restDamage = enemy.staticReplaceDamage(restDamage, sa.getSourceCard(), false);
|
||||
restDamage = enemy.staticReplaceDamage(restDamage, sa.getHostCard(), false);
|
||||
}
|
||||
|
||||
if (restDamage == 0) {
|
||||
|
||||
@@ -24,12 +24,12 @@ public class DamageAllAi extends SpellAbilityAi {
|
||||
// based on what the expected targets could be
|
||||
final Random r = MyRandom.getRandom();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
String validP = "";
|
||||
|
||||
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")) {
|
||||
@@ -99,11 +99,11 @@ public class DamageAllAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player ai) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
String validP = "";
|
||||
|
||||
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")) {
|
||||
// Set PayX here to maximum value.
|
||||
@@ -161,7 +161,7 @@ public class DamageAllAi extends SpellAbilityAi {
|
||||
* @return a {@link forge.CardList} object.
|
||||
*/
|
||||
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") : "";
|
||||
|
||||
// TODO: X may be something different than X paid
|
||||
@@ -183,11 +183,11 @@ public class DamageAllAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
String validP = "";
|
||||
|
||||
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")) {
|
||||
// Set PayX here to maximum value.
|
||||
|
||||
@@ -28,9 +28,9 @@ public class DamageDealAi extends DamageAiBase {
|
||||
@Override
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player ai) {
|
||||
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")) {
|
||||
// Set PayX here to maximum value.
|
||||
@@ -47,10 +47,10 @@ public class DamageDealAi extends DamageAiBase {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
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")) {
|
||||
// Set PayX here to maximum value.
|
||||
@@ -140,7 +140,7 @@ public class DamageDealAi extends DamageAiBase {
|
||||
return null;
|
||||
}
|
||||
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);
|
||||
|
||||
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,
|
||||
final boolean isTrigger, final boolean mandatory) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final boolean noPrevention = sa.hasParam("NoPrevention");
|
||||
final Game game = source.getGame();
|
||||
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) {
|
||||
// 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 positive = false;
|
||||
|
||||
for (final Object o : objects) {
|
||||
if (o instanceof Card) {
|
||||
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.getController().equals(ai)) {
|
||||
return false;
|
||||
@@ -388,7 +388,7 @@ public class DamageDealAi extends DamageAiBase {
|
||||
}
|
||||
} else if (o instanceof Player) {
|
||||
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) {
|
||||
// from this spell will kill me
|
||||
return false;
|
||||
@@ -431,7 +431,7 @@ public class DamageDealAi extends DamageAiBase {
|
||||
final boolean noPrevention = sa.hasParam("NoPrevention");
|
||||
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
|
||||
if (tgt.canTgtCreature()) {
|
||||
final Card c = this.dealDamageChooseTgtC(ai, sa, dmg, noPrevention, ai, mandatory);
|
||||
@@ -465,7 +465,7 @@ public class DamageDealAi extends DamageAiBase {
|
||||
@Override
|
||||
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");
|
||||
int dmg = AbilityUtils.calculateAmount(source, damage, sa);
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ public class DamageEachAi extends DamageAiBase {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public class DamagePreventAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Card hostCard = sa.getSourceCard();
|
||||
final Card hostCard = sa.getHostCard();
|
||||
final Game game = ai.getGame();
|
||||
final Combat combat = game.getCombat();
|
||||
boolean chance = false;
|
||||
@@ -52,7 +52,7 @@ public class DamagePreventAi extends SpellAbilityAi {
|
||||
if (tgt == null) {
|
||||
// As far as I can tell these Defined Cards will only have one of
|
||||
// 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
|
||||
if (!game.getStack().isEmpty()) {
|
||||
@@ -145,7 +145,7 @@ public class DamagePreventAi extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
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;
|
||||
@@ -184,7 +184,7 @@ public class DamagePreventAi extends SpellAbilityAi {
|
||||
// filter AIs battlefield by what I can target
|
||||
final Game game = ai.getGame();
|
||||
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);
|
||||
Card target = null;
|
||||
|
||||
@@ -216,7 +216,7 @@ public class DamagePreventAi extends SpellAbilityAi {
|
||||
}
|
||||
sa.getTargets().add(target);
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ public class DamagePreventAllAi extends SpellAbilityAi {
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Card hostCard = sa.getSourceCard();
|
||||
final Card hostCard = sa.getHostCard();
|
||||
boolean chance = false;
|
||||
|
||||
final Cost cost = sa.getPayCosts();
|
||||
|
||||
@@ -32,7 +32,7 @@ public class DebuffAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean canPlayAI(final Player ai, final SpellAbility sa) {
|
||||
// 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();
|
||||
if ((sa.getTargetRestrictions() == null) && !source.isInPlay()) {
|
||||
return false;
|
||||
@@ -75,7 +75,7 @@ public class DebuffAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
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();
|
||||
@@ -134,7 +134,7 @@ public class DebuffAi extends SpellAbilityAi {
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
sa.resetTargets();
|
||||
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:
|
||||
// 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);
|
||||
}
|
||||
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getSourceCard(), sa)) {
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getHostCard(), sa)) {
|
||||
Card t = null;
|
||||
// boolean goodt = false;
|
||||
|
||||
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) {
|
||||
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) {
|
||||
List<Card> list = ai.getGame().getCardsIn(ZoneType.Battlefield);
|
||||
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();
|
||||
return false;
|
||||
}
|
||||
@@ -234,7 +234,7 @@ public class DebuffAi extends SpellAbilityAi {
|
||||
|
||||
final List<Card> pref = CardLists.filterControlledBy(list, ai.getOpponent());
|
||||
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)) {
|
||||
if (pref.isEmpty()) {
|
||||
@@ -253,7 +253,7 @@ public class DebuffAi extends SpellAbilityAi {
|
||||
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()) {
|
||||
break;
|
||||
}
|
||||
@@ -272,7 +272,7 @@ public class DebuffAi extends SpellAbilityAi {
|
||||
sa.getTargets().add(c);
|
||||
}
|
||||
|
||||
if (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa)) {
|
||||
if (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
sa.resetTargets();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ public class DebuffAllAi extends SpellAbilityAi {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
String valid = "";
|
||||
final Random r = MyRandom.getRandom();
|
||||
// final Card source = sa.getSourceCard();
|
||||
final Card hostCard = sa.getSourceCard();
|
||||
// final Card source = sa.getHostCard();
|
||||
final Card hostCard = sa.getHostCard();
|
||||
final Player opp = ai.getOpponent();
|
||||
|
||||
final boolean chance = r.nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn()); // to
|
||||
|
||||
@@ -11,7 +11,7 @@ public class DelayedTriggerAi extends SpellAbilityAi {
|
||||
@Override
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player ai) {
|
||||
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);
|
||||
|
||||
if (trigsa instanceof AbilitySub) {
|
||||
@@ -24,7 +24,7 @@ public class DelayedTriggerAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
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);
|
||||
|
||||
if (!sa.hasParam("OptionalDecider")) {
|
||||
@@ -37,7 +37,7 @@ public class DelayedTriggerAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
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);
|
||||
return trigsa.canPlayAI(ai);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class DestroyAi extends SpellAbilityAi {
|
||||
final Random r = MyRandom.getRandom();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final TargetRestrictions abTgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final boolean noRegen = sa.hasParam("NoRegen");
|
||||
List<Card> list;
|
||||
|
||||
@@ -112,9 +112,9 @@ public class DestroyAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
// 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 ((sa.getTargets().getNumTargeted() < abTgt.getMinTargets(sa.getSourceCard(), sa))
|
||||
if ((sa.getTargets().getNumTargeted() < abTgt.getMinTargets(sa.getHostCard(), sa))
|
||||
|| (sa.getTargets().getNumTargeted() == 0)) {
|
||||
sa.resetTargets();
|
||||
return false;
|
||||
@@ -135,7 +135,7 @@ public class DestroyAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
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.resetTargets();
|
||||
return false;
|
||||
@@ -175,7 +175,7 @@ public class DestroyAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final boolean noRegen = sa.hasParam("NoRegen");
|
||||
if (tgt != null) {
|
||||
List<Card> list;
|
||||
@@ -183,7 +183,7 @@ public class DestroyAi extends SpellAbilityAi {
|
||||
list = CardLists.getTargetableCards(list, sa);
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -209,10 +209,10 @@ public class DestroyAi extends SpellAbilityAi {
|
||||
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 ((sa.getTargets().getNumTargeted() == 0)
|
||||
|| (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa))) {
|
||||
|| (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa))) {
|
||||
if (!mandatory) {
|
||||
sa.resetTargets();
|
||||
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()) {
|
||||
break;
|
||||
} 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;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -30,7 +30,7 @@ public class DestroyAllAi extends SpellAbilityAi {
|
||||
*/
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
String valid = "";
|
||||
if (mandatory) {
|
||||
return true;
|
||||
@@ -80,7 +80,7 @@ public class DestroyAllAi extends SpellAbilityAi {
|
||||
// based on what the expected targets could be
|
||||
final Random r = MyRandom.getRandom();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
String valid = "";
|
||||
|
||||
if (sa.hasParam("ValidCards")) {
|
||||
|
||||
@@ -24,7 +24,7 @@ public class DigAi extends SpellAbilityAi {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
|
||||
Player opp = ai.getOpponent();
|
||||
final Card host = sa.getSourceCard();
|
||||
final Card host = sa.getHostCard();
|
||||
Player libraryOwner = ai;
|
||||
|
||||
if (sa.usesTargeting()) {
|
||||
|
||||
@@ -19,7 +19,7 @@ public class DigUntilAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
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
|
||||
if (SpellAbilityAi.isSorcerySpeed(sa)) {
|
||||
chance = .667; // 66.7% chance for sorcery speed (since it will
|
||||
|
||||
@@ -23,7 +23,7 @@ public class DiscardAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
|
||||
if (abCost != null) {
|
||||
@@ -54,7 +54,7 @@ public class DiscardAi extends SpellAbilityAi {
|
||||
}
|
||||
} else {
|
||||
// TODO: Add appropriate restrictions
|
||||
final List<Player> players = AbilityUtils.getDefinedPlayers(sa.getSourceCard(),
|
||||
final List<Player> players = AbilityUtils.getDefinedPlayers(sa.getHostCard(),
|
||||
sa.getParam("Defined"), sa);
|
||||
|
||||
if (players.size() == 1) {
|
||||
@@ -85,7 +85,7 @@ public class DiscardAi extends SpellAbilityAi {
|
||||
}
|
||||
source.setSVar("PayX", Integer.toString(cardsToDiscard));
|
||||
} else {
|
||||
if (AbilityUtils.calculateAmount(sa.getSourceCard(), sa.getParam("NumCards"), sa) < 1) {
|
||||
if (AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("NumCards"), sa) < 1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -144,11 +144,11 @@ public class DiscardAi extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
} 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.
|
||||
final int cardsToDiscard = Math.min(ComputerUtilMana.determineLeftoverMana(sa, ai), ai.getOpponent()
|
||||
.getCardsIn(ZoneType.Hand).size());
|
||||
sa.getSourceCard().setSVar("PayX", Integer.toString(cardsToDiscard));
|
||||
sa.getHostCard().setSVar("PayX", Integer.toString(cardsToDiscard));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ public class DrainManaAi extends SpellAbilityAi {
|
||||
// AI cannot use this properly until he can use SAs during Humans turn
|
||||
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final Player opp = ai.getOpponent();
|
||||
final Random r = MyRandom.getRandom();
|
||||
boolean randomReturn = r.nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn());
|
||||
@@ -45,7 +45,7 @@ public class DrainManaAi extends SpellAbilityAi {
|
||||
final Player opp = ai.getOpponent();
|
||||
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
if (null == tgt) {
|
||||
if (mandatory) {
|
||||
@@ -71,7 +71,7 @@ public class DrainManaAi extends SpellAbilityAi {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player ai) {
|
||||
// AI cannot use this properly until he can use SAs during Humans turn
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
boolean randomReturn = true;
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ public class DrawAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
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) {
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final boolean drawback = (sa instanceof AbilitySub);
|
||||
final Game game = ai.getGame();
|
||||
Player opp = ai.getOpponent();
|
||||
@@ -143,7 +143,7 @@ public class DrawAi extends SpellAbilityAi {
|
||||
|
||||
int numCards = 1;
|
||||
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;
|
||||
@@ -261,7 +261,7 @@ public class DrawAi extends SpellAbilityAi {
|
||||
*/
|
||||
@Override
|
||||
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
|
||||
return numCards < player.getZone(ZoneType.Library).size();
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class EffectAi extends SpellAbilityAi {
|
||||
if (tgt != null) {
|
||||
sa.resetTargets();
|
||||
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);
|
||||
Card target = ComputerUtilCard.getBestCreatureAI(list);
|
||||
if (target == null) {
|
||||
@@ -123,7 +123,7 @@ public class EffectAi extends SpellAbilityAi {
|
||||
if ("False".equals(sa.getParam("Stackable"))) {
|
||||
String name = sa.getParam("Name");
|
||||
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);
|
||||
if (!list.isEmpty()) {
|
||||
|
||||
@@ -22,7 +22,7 @@ public class FightAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
sa.resetTargets();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
List<Card> aiCreatures = ai.getCreaturesInPlay();
|
||||
aiCreatures = CardLists.getTargetableCards(aiCreatures, sa);
|
||||
@@ -107,7 +107,7 @@ public class FightAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
//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();
|
||||
humCreatures = CardLists.getTargetableCards(humCreatures, sa);
|
||||
if (humCreatures.isEmpty()) {
|
||||
|
||||
@@ -19,7 +19,7 @@ public class LifeGainAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final Game game = source.getGame();
|
||||
final int life = ai.getLife();
|
||||
final String amountStr = sa.getParam("LifeAmount");
|
||||
@@ -31,7 +31,7 @@ public class LifeGainAi extends SpellAbilityAi {
|
||||
source.setSVar("PayX", Integer.toString(xPay));
|
||||
lifeAmount = xPay;
|
||||
} else {
|
||||
lifeAmount = AbilityUtils.calculateAmount(sa.getSourceCard(), amountStr, sa);
|
||||
lifeAmount = AbilityUtils.calculateAmount(sa.getHostCard(), amountStr, sa);
|
||||
}
|
||||
|
||||
// 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");
|
||||
if (amountStr.equals("X") && source.getSVar(amountStr).equals("Count$xPaid")) {
|
||||
// Set PayX here to maximum value.
|
||||
|
||||
@@ -21,7 +21,7 @@ public class LifeLoseAi extends SpellAbilityAi {
|
||||
|
||||
List<Player> tgtPlayers = getTargetPlayers(sa);
|
||||
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final String amountStr = sa.getParam("LifeAmount");
|
||||
int amount = 0;
|
||||
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) {
|
||||
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
final String amountStr = sa.getParam("LifeAmount");
|
||||
|
||||
// TODO handle proper calculation of X values based on Cost and what
|
||||
// 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")) {
|
||||
// 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");
|
||||
int amount = 0;
|
||||
if (amountStr.equals("X") && source.getSVar(amountStr).equals("Count$xPaid")) {
|
||||
|
||||
@@ -19,7 +19,7 @@ public class LifeSetAi extends SpellAbilityAi {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Random r = MyRandom.getRandom();
|
||||
// Ability_Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final int myLife = ai.getLife();
|
||||
final Player opponent = ai.getOpponent();
|
||||
final int hlife = opponent.getLife();
|
||||
@@ -45,7 +45,7 @@ public class LifeSetAi extends SpellAbilityAi {
|
||||
source.setSVar("PayX", Integer.toString(xPay));
|
||||
amount = xPay;
|
||||
} 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
|
||||
@@ -105,7 +105,7 @@ public class LifeSetAi extends SpellAbilityAi {
|
||||
final int myLife = ai.getLife();
|
||||
final Player opponent = ai.getOpponent();
|
||||
final int hlife = opponent.getLife();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
final String amountStr = sa.getParam("LifeAmount");
|
||||
|
||||
@@ -116,7 +116,7 @@ public class LifeSetAi extends SpellAbilityAi {
|
||||
source.setSVar("PayX", Integer.toString(xPay));
|
||||
amount = xPay;
|
||||
} else {
|
||||
amount = AbilityUtils.calculateAmount(sa.getSourceCard(), amountStr, sa);
|
||||
amount = AbilityUtils.calculateAmount(sa.getHostCard(), amountStr, sa);
|
||||
}
|
||||
|
||||
if (source.getName().equals("Eternity Vessel")
|
||||
|
||||
@@ -20,7 +20,7 @@ public class MillAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
|
||||
if (abCost != null) {
|
||||
@@ -94,7 +94,7 @@ public class MillAi extends SpellAbilityAi {
|
||||
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);
|
||||
|
||||
@@ -135,7 +135,7 @@ public class MillAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
if (sa.getParam("NumCards").equals("X") && source.getSVar("X").equals("Count$xPaid")) {
|
||||
// Set PayX here to maximum value.
|
||||
final int cardsToDiscard = Math.min(ComputerUtilMana.determineLeftoverMana(sa, aiPlayer), aiPlayer.getOpponent()
|
||||
|
||||
@@ -33,7 +33,7 @@ public class MustBlockAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
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();
|
||||
|
||||
// only use on creatures that can attack
|
||||
@@ -43,7 +43,7 @@ public class MustBlockAi extends SpellAbilityAi {
|
||||
|
||||
Card attacker = null;
|
||||
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()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class PhasesAi extends SpellAbilityAi {
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
// This still needs to be fleshed out
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
final Random r = MyRandom.getRandom();
|
||||
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,
|
||||
final boolean mandatory) {
|
||||
// Card source = sa.getSourceCard();
|
||||
// Card source = sa.getHostCard();
|
||||
|
||||
// List<Card> phaseList =
|
||||
// AllZoneUtil.getCardsIn(Zone.Battlefield).getTargetableCards(source)
|
||||
@@ -134,7 +134,7 @@ public class PhasesAi extends SpellAbilityAi {
|
||||
* @return a boolean.
|
||||
*/
|
||||
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();
|
||||
|
||||
List<Card> list = game.getCardsIn(ZoneType.Battlefield);
|
||||
|
||||
@@ -26,7 +26,7 @@ public class PlayAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
final Random r = MyRandom.getRandom();
|
||||
|
||||
@@ -67,7 +67,7 @@ public class PlayAi extends SpellAbilityAi {
|
||||
}
|
||||
sa.getTargets().add(ComputerUtilCard.getBestAI(cards));
|
||||
} 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()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class PoisonAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
// int humanPoison = AllZone.getHumanPlayer().getPoisonCounters();
|
||||
// int humanLife = AllZone.getHumanPlayer().getLife();
|
||||
// int aiPoison = AllZone.getComputerPlayer().getPoisonCounters();
|
||||
@@ -75,7 +75,7 @@ public class PoisonAi extends SpellAbilityAi {
|
||||
if (tgt != null) {
|
||||
sa.getTargets().add(ai.getOpponent());
|
||||
} 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) {
|
||||
if (!mandatory && p == ai && (p.getPoisonCounters() > p.getOpponent().getPoisonCounters())) {
|
||||
return false;
|
||||
|
||||
@@ -29,7 +29,7 @@ public class PowerExchangeAi extends SpellAbilityAi {
|
||||
sa.resetTargets();
|
||||
|
||||
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
|
||||
// purpose
|
||||
list = CardLists.filter(list, new Predicate<Card>() {
|
||||
@@ -42,10 +42,10 @@ public class PowerExchangeAi extends SpellAbilityAi {
|
||||
CardLists.sortByPowerAsc(list);
|
||||
c1 = list.isEmpty() ? null : list.get(0);
|
||||
if (sa.hasParam("Defined")) {
|
||||
c2 = AbilityUtils.getDefinedCards(sa.getSourceCard(), sa.getParam("Defined"), sa).get(0);
|
||||
} else if (tgt.getMinTargets(sa.getSourceCard(), sa) > 1) {
|
||||
c2 = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa).get(0);
|
||||
} else if (tgt.getMinTargets(sa.getHostCard(), sa) > 1) {
|
||||
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);
|
||||
Collections.reverse(list2);
|
||||
c2 = list2.isEmpty() ? null : list2.get(0);
|
||||
|
||||
@@ -109,7 +109,7 @@ public class ProtectAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Card hostCard = sa.getSourceCard();
|
||||
final Card hostCard = sa.getHostCard();
|
||||
final Game game = ai.getGame();
|
||||
// if there is no target and host card isn't in play, don't activate
|
||||
if ((sa.getTargetRestrictions() == null) && !hostCard.isInPlay()) {
|
||||
@@ -149,7 +149,7 @@ public class ProtectAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
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) {
|
||||
return false;
|
||||
@@ -175,13 +175,13 @@ public class ProtectAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
sa.resetTargets();
|
||||
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
|
||||
@@ -200,11 +200,11 @@ public class ProtectAi extends SpellAbilityAi {
|
||||
if ((sa.getPayCosts() != null) && sa.getPayCosts().hasTapCost()) {
|
||||
if (game.getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
&& game.getPhaseHandler().isPlayerTurn(ai)) {
|
||||
list.remove(sa.getSourceCard());
|
||||
list.remove(sa.getHostCard());
|
||||
}
|
||||
if (game.getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS)
|
||||
&& 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);
|
||||
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();
|
||||
return false;
|
||||
}
|
||||
@@ -274,7 +274,7 @@ public class ProtectAi extends SpellAbilityAi {
|
||||
}
|
||||
});
|
||||
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)) {
|
||||
if (pref.isEmpty()) {
|
||||
@@ -327,7 +327,7 @@ public class ProtectAi extends SpellAbilityAi {
|
||||
sa.getTargets().add(c);
|
||||
}
|
||||
|
||||
if (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa)) {
|
||||
if (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
sa.resetTargets();
|
||||
return false;
|
||||
}
|
||||
@@ -350,7 +350,7 @@ public class ProtectAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
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 (host.isCreature()) {
|
||||
// TODO
|
||||
|
||||
@@ -12,7 +12,7 @@ public class ProtectAllAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
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 ((sa.getTargetRestrictions() == null) && !hostCard.isInPlay()) {
|
||||
return false;
|
||||
|
||||
@@ -49,23 +49,23 @@ public class PumpAi extends PumpAiBase {
|
||||
final String numDefense = sa.hasParam("NumDef") ? sa.getParam("NumDef") : "";
|
||||
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;
|
||||
}
|
||||
|
||||
if (!ComputerUtilCost.checkDiscardCost(ai, cost, sa.getSourceCard())) {
|
||||
if (!ComputerUtilCost.checkDiscardCost(ai, cost, sa.getHostCard())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ComputerUtilCost.checkCreatureSacrificeCost(ai, cost, sa.getSourceCard())) {
|
||||
if (!ComputerUtilCost.checkCreatureSacrificeCost(ai, cost, sa.getHostCard())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ComputerUtilCost.checkRemoveCounterCost(cost, sa.getSourceCard())) {
|
||||
if (!ComputerUtilCost.checkRemoveCounterCost(cost, sa.getHostCard())) {
|
||||
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)) {
|
||||
return false;
|
||||
}
|
||||
@@ -98,7 +98,7 @@ public class PumpAi extends PumpAiBase {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
if (source.getSVar("X").equals("Count$xPaid")) {
|
||||
source.setSVar("PayX", "");
|
||||
}
|
||||
@@ -113,7 +113,7 @@ public class PumpAi extends PumpAiBase {
|
||||
defense = -xPay;
|
||||
}
|
||||
} else {
|
||||
defense = AbilityUtils.calculateAmount(sa.getSourceCard(), numDefense, sa);
|
||||
defense = AbilityUtils.calculateAmount(sa.getHostCard(), numDefense, sa);
|
||||
}
|
||||
|
||||
int attack;
|
||||
@@ -129,7 +129,7 @@ public class PumpAi extends PumpAiBase {
|
||||
attack = Integer.parseInt(toPay);
|
||||
}
|
||||
} else {
|
||||
attack = AbilityUtils.calculateAmount(sa.getSourceCard(), numAttack, sa);
|
||||
attack = AbilityUtils.calculateAmount(sa.getHostCard(), numAttack, sa);
|
||||
}
|
||||
|
||||
if ((numDefense.contains("X") && defense == 0)
|
||||
@@ -139,7 +139,7 @@ public class PumpAi extends PumpAiBase {
|
||||
|
||||
//Untargeted
|
||||
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);
|
||||
|
||||
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) {
|
||||
final List<String> keywords = sa.hasParam("KW") ? Arrays.asList(sa.getParam("KW").split(" & ")) : new ArrayList<String>();
|
||||
final Game game = ai.getGame();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
if (!mandatory
|
||||
&& !sa.isTrigger()
|
||||
@@ -232,11 +232,11 @@ public class PumpAi extends PumpAiBase {
|
||||
if (sa.getPayCosts() != null && sa.getPayCosts().hasTapCost()) {
|
||||
if (game.getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
&& game.getPhaseHandler().isPlayerTurn(ai)) {
|
||||
list.remove(sa.getSourceCard());
|
||||
list.remove(sa.getHostCard());
|
||||
}
|
||||
if (game.getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS)
|
||||
&& 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);
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
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);
|
||||
|
||||
if (list.size() < tgt.getMinTargets(sa.getSourceCard(), sa)) {
|
||||
if (list.size() < tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
sa.resetTargets();
|
||||
return false;
|
||||
}
|
||||
@@ -296,7 +296,7 @@ public class PumpAi extends PumpAiBase {
|
||||
|
||||
List<Card> pref;
|
||||
List<Card> forced;
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
if (sa.isCurse()) {
|
||||
pref = CardLists.filterControlledBy(list, opp);
|
||||
@@ -350,7 +350,7 @@ public class PumpAi extends PumpAiBase {
|
||||
|
||||
@Override
|
||||
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 numAttack = sa.hasParam("NumAtt") ? sa.getParam("NumAtt") : "";
|
||||
|
||||
@@ -361,7 +361,7 @@ public class PumpAi extends PumpAiBase {
|
||||
source.setSVar("PayX", Integer.toString(xPay));
|
||||
defense = xPay;
|
||||
} else {
|
||||
defense = AbilityUtils.calculateAmount(sa.getSourceCard(), numDefense, sa);
|
||||
defense = AbilityUtils.calculateAmount(sa.getHostCard(), numDefense, sa);
|
||||
}
|
||||
|
||||
int attack;
|
||||
@@ -377,7 +377,7 @@ public class PumpAi extends PumpAiBase {
|
||||
attack = Integer.parseInt(toPay);
|
||||
}
|
||||
} else {
|
||||
attack = AbilityUtils.calculateAmount(sa.getSourceCard(), numAttack, sa);
|
||||
attack = AbilityUtils.calculateAmount(sa.getHostCard(), numAttack, sa);
|
||||
}
|
||||
|
||||
if (sa.getTargetRestrictions() == null) {
|
||||
@@ -394,7 +394,7 @@ public class PumpAi extends PumpAiBase {
|
||||
@Override
|
||||
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 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")) {
|
||||
defense = Integer.parseInt(source.getSVar("PayX"));
|
||||
} else {
|
||||
defense = AbilityUtils.calculateAmount(sa.getSourceCard(), numDefense, sa);
|
||||
defense = AbilityUtils.calculateAmount(sa.getHostCard(), numDefense, sa);
|
||||
}
|
||||
|
||||
int attack;
|
||||
@@ -417,7 +417,7 @@ public class PumpAi extends PumpAiBase {
|
||||
attack = Integer.parseInt(source.getSVar("PayX"));
|
||||
}
|
||||
} else {
|
||||
attack = AbilityUtils.calculateAmount(sa.getSourceCard(), numAttack, sa);
|
||||
attack = AbilityUtils.calculateAmount(sa.getHostCard(), numAttack, sa);
|
||||
}
|
||||
|
||||
if ((sa.getTargetRestrictions() == null) || !sa.getTargetRestrictions().doesTarget()) {
|
||||
|
||||
@@ -28,12 +28,12 @@ public class PumpAllAi extends PumpAiBase {
|
||||
@Override
|
||||
protected boolean canPlayAI(final Player ai, final SpellAbility sa) {
|
||||
String valid = "";
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final Game game = ai.getGame();
|
||||
final Combat combat = game.getCombat();
|
||||
|
||||
final int power = AbilityUtils.calculateAmount(sa.getSourceCard(), sa.getParam("NumAtt"), sa);
|
||||
final int defense = AbilityUtils.calculateAmount(sa.getSourceCard(), sa.getParam("NumDef"), sa);
|
||||
final int power = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("NumAtt"), 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 PhaseType phase = game.getPhaseHandler().getPhase();
|
||||
|
||||
@@ -55,7 +55,7 @@ public class RegenerateAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Card hostCard = sa.getSourceCard();
|
||||
final Card hostCard = sa.getHostCard();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Game game = ai.getGame();
|
||||
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) {
|
||||
final Card hostCard = sa.getSourceCard();
|
||||
final Card hostCard = sa.getHostCard();
|
||||
final Game game = ai.getGame();
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
sa.resetTargets();
|
||||
|
||||
@@ -22,7 +22,7 @@ public class RegenerateAllAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Card hostCard = sa.getSourceCard();
|
||||
final Card hostCard = sa.getHostCard();
|
||||
boolean chance = false;
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Game game = ai.getGame();
|
||||
|
||||
@@ -46,7 +46,7 @@ public class RepeatAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// 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) {
|
||||
return false;
|
||||
|
||||
@@ -15,7 +15,7 @@ public class RevealAi extends RevealAiBase {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
// AI cannot use this properly until he can use SAs during Humans turn
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
if (abCost != null) {
|
||||
// AI currently disabled for these costs
|
||||
|
||||
@@ -19,7 +19,7 @@ public class RevealHandAi extends RevealAiBase {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
// AI cannot use this properly until he can use SAs during Humans turn
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
if (abCost != null) {
|
||||
// AI currently disabled for these costs
|
||||
|
||||
@@ -19,7 +19,7 @@ public class RollPlanarDiceAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
AiController aic = ((PlayerControllerAi)ai.getController()).getAi();
|
||||
Card plane = sa.getSourceCard();
|
||||
Card plane = sa.getHostCard();
|
||||
|
||||
boolean decideToRoll = false;
|
||||
boolean rollInMain1 = false;
|
||||
|
||||
@@ -49,7 +49,7 @@ public class SacrificeAi extends SpellAbilityAi {
|
||||
|
||||
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 boolean destroy = sa.hasParam("Destroy");
|
||||
|
||||
@@ -63,10 +63,10 @@ public class SacrificeAi extends SpellAbilityAi {
|
||||
final String valid = sa.getParam("SacValid");
|
||||
String num = sa.getParam("Amount");
|
||||
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 =
|
||||
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) {
|
||||
list = CardLists.filter(list, CardPredicates.canBeSacrificedBy(sa));
|
||||
} else {
|
||||
@@ -115,7 +115,7 @@ public class SacrificeAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
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
|
||||
// (or X for X) trades for special decks
|
||||
@@ -124,7 +124,7 @@ public class SacrificeAi extends SpellAbilityAi {
|
||||
}
|
||||
} else if (defined.equals("You")) {
|
||||
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) {
|
||||
if (c.hasSVar("SacMe") || ComputerUtilCard.evaluateCreature(c) <= 135) {
|
||||
return true;
|
||||
|
||||
@@ -23,7 +23,7 @@ public class SacrificeAllAi extends SpellAbilityAi {
|
||||
// based on what the expected targets could be
|
||||
final Random r = MyRandom.getRandom();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
String valid = "";
|
||||
|
||||
if (sa.hasParam("ValidCards")) {
|
||||
|
||||
@@ -35,7 +35,7 @@ public class ScryAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
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
|
||||
// stuff
|
||||
|
||||
@@ -18,7 +18,7 @@ public class SetStateAi extends SpellAbilityAi {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
// Gross generalization, but this always considers alternate
|
||||
// states more powerful
|
||||
return !sa.getSourceCard().isInAlternateState();
|
||||
return !sa.getHostCard().isInAlternateState();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ public class ShuffleAi extends SpellAbilityAi {
|
||||
/*
|
||||
* if (!ComputerUtil.canPayCost(sa)) return false;
|
||||
*
|
||||
* Card source = sa.getSourceCard();
|
||||
* Card source = sa.getHostCard();
|
||||
*
|
||||
* Random r = MyRandom.random; boolean randomReturn = r.nextFloat() <=
|
||||
* Math.pow(.667, sa.getActivationsThisTurn()+1);
|
||||
|
||||
@@ -24,7 +24,7 @@ public class StoreSVarAi extends SpellAbilityAi {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
//Tree of Redemption
|
||||
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final Game game = ai.getGame();
|
||||
final Combat combat = game.getCombat();
|
||||
final PhaseHandler ph = game.getPhaseHandler();
|
||||
|
||||
@@ -36,7 +36,7 @@ public class TapAi extends TapAiBase {
|
||||
}
|
||||
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
if (tgt == null) {
|
||||
final List<Card> defined = AbilityUtils.getDefinedCards(source, sa.getParam("Defined"), sa);
|
||||
|
||||
@@ -38,7 +38,7 @@ public abstract class TapAiBase extends SpellAbilityAi {
|
||||
* @return a boolean.
|
||||
*/
|
||||
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();
|
||||
|
||||
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 ((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) {
|
||||
sa.resetTargets();
|
||||
}
|
||||
@@ -174,7 +174,7 @@ public abstract class TapAiBase extends SpellAbilityAi {
|
||||
return CombatUtil.canAttack(c, opp);
|
||||
}
|
||||
});
|
||||
attackers.remove(sa.getSourceCard());
|
||||
attackers.remove(sa.getHostCard());
|
||||
}
|
||||
Predicate<Card> findBlockers = CardPredicates.possibleBlockerForAtLeastOne(attackers);
|
||||
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 ((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) {
|
||||
sa.resetTargets();
|
||||
}
|
||||
@@ -238,7 +238,7 @@ public abstract class TapAiBase extends SpellAbilityAi {
|
||||
* @return a boolean.
|
||||
*/
|
||||
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 Game game = ai.getGame();
|
||||
|
||||
@@ -252,7 +252,7 @@ public abstract class TapAiBase extends SpellAbilityAi {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sa.getTargets().getNumTargeted() >= tgt.getMinTargets(sa.getSourceCard(), sa)) {
|
||||
if (sa.getTargets().getNumTargeted() >= tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -271,7 +271,7 @@ public abstract class TapAiBase extends SpellAbilityAi {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sa.getTargets().getNumTargeted() >= tgt.getMinTargets(sa.getSourceCard(), sa)) {
|
||||
if (sa.getTargets().getNumTargeted() >= tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -289,7 +289,7 @@ public abstract class TapAiBase extends SpellAbilityAi {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
if (tgt == null) {
|
||||
if (mandatory) {
|
||||
@@ -315,7 +315,7 @@ public abstract class TapAiBase extends SpellAbilityAi {
|
||||
@Override
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player ai) {
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
boolean randomReturn = true;
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ public class TapAllAi extends SpellAbilityAi {
|
||||
// turn
|
||||
// or during upkeep/begin combat?
|
||||
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final Player opp = ai.getOpponent();
|
||||
final Game game = ai.getGame();
|
||||
|
||||
@@ -114,7 +114,7 @@ public class TapAllAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(final Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
String valid = "";
|
||||
if (sa.hasParam("ValidCards")) {
|
||||
|
||||
@@ -18,7 +18,7 @@ public class TapOrUntapAi extends TapAiBase {
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
final Random r = MyRandom.getRandom();
|
||||
boolean randomReturn = r.nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn());
|
||||
|
||||
@@ -130,7 +130,7 @@ public class TokenAi extends SpellAbilityAi {
|
||||
|
||||
// prevent run-away activations - first time will always return true
|
||||
final Random r = MyRandom.getRandom();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
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")) {
|
||||
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")) {
|
||||
// Set PayX here to maximum value.
|
||||
x = ComputerUtilMana.determineLeftoverMana(sa, ai);
|
||||
@@ -197,7 +197,7 @@ public class TokenAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
readParameters(sa);
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
if (tgt != null) {
|
||||
sa.resetTargets();
|
||||
|
||||
@@ -19,7 +19,7 @@ public class TwoPilesAi extends SpellAbilityAi {
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Card card = sa.getSourceCard();
|
||||
final Card card = sa.getHostCard();
|
||||
ZoneType zone = null;
|
||||
|
||||
if (sa.hasParam("Zone")) {
|
||||
@@ -47,7 +47,7 @@ public class TwoPilesAi extends SpellAbilityAi {
|
||||
final Player p = tgtPlayers.get(0);
|
||||
List<Card> pool = new ArrayList<Card>();
|
||||
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 {
|
||||
pool = p.getCardsIn(zone);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class UnattachAllAi extends SpellAbilityAi {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Random r = MyRandom.getRandom();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
if (abCost != null) {
|
||||
// No Aura spells have Additional Costs
|
||||
@@ -65,13 +65,13 @@ public class UnattachAllAi extends SpellAbilityAi {
|
||||
*/
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final Card card = sa.getSourceCard();
|
||||
final Card card = sa.getHostCard();
|
||||
final Player opp = ai.getOpponent();
|
||||
// Check if there are any valid targets
|
||||
List<GameObject> targets = new ArrayList<GameObject>();
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
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()) {
|
||||
|
||||
@@ -26,14 +26,14 @@ public class UntapAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final Cost cost = sa.getPayCosts();
|
||||
|
||||
if (!ComputerUtilCost.checkAddM1M1CounterCost(cost, source)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ComputerUtilCost.checkDiscardCost(ai, cost, sa.getSourceCard())) {
|
||||
if (!ComputerUtilCost.checkDiscardCost(ai, cost, sa.getHostCard())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class UntapAi extends SpellAbilityAi {
|
||||
boolean randomReturn = r.nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn() + 1);
|
||||
|
||||
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) {
|
||||
return false;
|
||||
}
|
||||
@@ -64,7 +64,7 @@ public class UntapAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// 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) {
|
||||
return false;
|
||||
}
|
||||
@@ -115,7 +115,7 @@ public class UntapAi extends SpellAbilityAi {
|
||||
* @return a boolean.
|
||||
*/
|
||||
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;
|
||||
|
||||
@@ -137,11 +137,11 @@ public class UntapAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getSourceCard(), sa)) {
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getHostCard(), sa)) {
|
||||
Card choice = null;
|
||||
|
||||
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();
|
||||
return false;
|
||||
} else {
|
||||
@@ -162,7 +162,7 @@ public class UntapAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
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();
|
||||
return false;
|
||||
} else {
|
||||
@@ -191,7 +191,7 @@ public class UntapAi extends SpellAbilityAi {
|
||||
* @return a boolean.
|
||||
*/
|
||||
private boolean untapUnpreferredTargeting(final SpellAbility sa, final boolean mandatory) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
|
||||
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 ((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) {
|
||||
sa.resetTargets();
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public class UntapAllAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
final AbilitySub abSub = sa.getSubAbility();
|
||||
if (abSub != null) {
|
||||
|
||||
@@ -22,7 +22,7 @@ public class ZoneExchangeAi extends SpellAbilityAi {
|
||||
protected boolean canPlayAI(Player ai, final SpellAbility sa) {
|
||||
Card object1 = null;
|
||||
Card object2 = null;
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final String type = sa.getParam("Type");
|
||||
if (sa.hasParam("Object")) {
|
||||
object1 = AbilityUtils.getDefinedCards(source, sa.getParam("Object"), sa).get(0);
|
||||
|
||||
@@ -15,11 +15,10 @@ import forge.util.Expressions;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Base class for Triggers and ReplacementEffects.
|
||||
* Provides the matchesValid function to both classes.
|
||||
* Base class for Triggers,ReplacementEffects and StaticAbilities.
|
||||
*
|
||||
*/
|
||||
public abstract class CardTraitBase {
|
||||
public abstract class CardTraitBase extends GameObject {
|
||||
|
||||
/** The host card. */
|
||||
protected Card hostCard;
|
||||
@@ -31,19 +30,13 @@ public abstract class CardTraitBase {
|
||||
protected boolean intrinsic;
|
||||
|
||||
/** The temporary. */
|
||||
private boolean temporary = false;
|
||||
protected boolean temporary = false;
|
||||
|
||||
/** The suppressed. */
|
||||
private boolean suppressed = false;
|
||||
protected boolean suppressed = false;
|
||||
|
||||
/** The temporarily suppressed. */
|
||||
private boolean temporarilySuppressed = false;
|
||||
|
||||
protected EnumSet<ZoneType> validHostZones;
|
||||
|
||||
/** The overriding ability. */
|
||||
private SpellAbility overridingAbility = null;
|
||||
|
||||
protected boolean temporarilySuppressed = false;
|
||||
|
||||
/**
|
||||
* Sets the temporary.
|
||||
@@ -89,7 +82,9 @@ public abstract class CardTraitBase {
|
||||
return this.intrinsic;
|
||||
}
|
||||
|
||||
|
||||
public void setIntrinsic(boolean i) {
|
||||
this.intrinsic = i;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -98,7 +93,7 @@ public abstract class CardTraitBase {
|
||||
*
|
||||
* @return a {@link forge.game.card.Card} object.
|
||||
*/
|
||||
public final Card getHostCard() {
|
||||
public Card getHostCard() {
|
||||
return this.hostCard;
|
||||
}
|
||||
|
||||
@@ -110,49 +105,8 @@ public abstract class CardTraitBase {
|
||||
* @param c
|
||||
* a {@link forge.game.card.Card} object.
|
||||
*/
|
||||
public final void setHostCard(final Card c) {
|
||||
public void setHostCard(final Card 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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1628,7 +1628,7 @@ public class GameAction {
|
||||
}
|
||||
|
||||
for (final SpellAbility sa : usableFromOpeningHand) {
|
||||
if (!takesAction.getZone(ZoneType.Hand).contains(sa.getSourceCard())) {
|
||||
if (!takesAction.getZone(ZoneType.Hand).contains(sa.getHostCard())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ public final class GameActionUtil {
|
||||
*/
|
||||
public static final ArrayList<SpellAbility> getAlternativeCosts(SpellAbility sa) {
|
||||
ArrayList<SpellAbility> alternatives = new ArrayList<SpellAbility>();
|
||||
Card source = sa.getSourceCard();
|
||||
Card source = sa.getHostCard();
|
||||
if (!sa.isBasicSpell()) {
|
||||
return alternatives;
|
||||
}
|
||||
@@ -208,7 +208,7 @@ public final class GameActionUtil {
|
||||
newSA.setBasicSpell(false);
|
||||
String kw = keyword;
|
||||
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);
|
||||
}
|
||||
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")) {
|
||||
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));
|
||||
if (source.getController().hasKeyword("You can't sacrifice creatures to cast spells or activate abilities.")) {
|
||||
canOffer = CardLists.getNotType(canOffer, "Creature");
|
||||
@@ -274,7 +274,7 @@ public final class GameActionUtil {
|
||||
public static List<SpellAbility> getOptionalCosts(final SpellAbility original) {
|
||||
final List<SpellAbility> abilities = new ArrayList<SpellAbility>();
|
||||
|
||||
final Card source = original.getSourceCard();
|
||||
final Card source = original.getHostCard();
|
||||
abilities.add(original);
|
||||
if (!original.isSpell()) {
|
||||
return abilities;
|
||||
@@ -389,7 +389,7 @@ public final class GameActionUtil {
|
||||
// Splice
|
||||
final List<SpellAbility> newAbilities = new ArrayList<SpellAbility>();
|
||||
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));
|
||||
}
|
||||
}
|
||||
@@ -411,7 +411,7 @@ public final class GameActionUtil {
|
||||
ArrayList<SpellAbility> newSAs = new ArrayList<SpellAbility>();
|
||||
ArrayList<SpellAbility> allSaCombinations = new ArrayList<SpellAbility>();
|
||||
allSaCombinations.add(sa);
|
||||
Card source = sa.getSourceCard();
|
||||
Card source = sa.getHostCard();
|
||||
|
||||
for (Card c : sa.getActivatingPlayer().getCardsIn(ZoneType.Hand)) {
|
||||
if (c.equals(source)) {
|
||||
@@ -458,7 +458,7 @@ public final class GameActionUtil {
|
||||
//set correct source and activating player to all the spliced abilities
|
||||
child = subAbility;
|
||||
while (child != null) {
|
||||
child.setSourceCard(source);
|
||||
child.setHostCard(source);
|
||||
child.setActivatingPlayer(newSA.getActivatingPlayer());
|
||||
child = child.getSubAbility();
|
||||
}
|
||||
@@ -497,7 +497,7 @@ public final class GameActionUtil {
|
||||
public static String generatedMana(final SpellAbility sa) {
|
||||
// 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();
|
||||
String baseMana;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class GameLogFormatter extends IGameEventVisitor.Base<GameLogEntry> {
|
||||
*/
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class GameLogFormatter extends IGameEventVisitor.Base<GameLogEntry> {
|
||||
public GameLogEntry visit(GameEventSpellAbilityCast event) {
|
||||
String who = event.sa.getActivatingPlayer().getName();
|
||||
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();
|
||||
sb.append(who).append(action).append(what);
|
||||
|
||||
@@ -23,25 +23,25 @@ public class AbilityApiBased extends AbilityActivated {
|
||||
|
||||
public AbilityApiBased(ApiType api0, Card sourceCard, Cost abCost, TargetRestrictions tgt, Map<String, String> params0) {
|
||||
super(sourceCard, abCost, tgt);
|
||||
params = params0;
|
||||
mapParams.putAll(params0);
|
||||
api = api0;
|
||||
effect = api.getSpellEffect();
|
||||
ai = api.getAi();
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
if (effect instanceof ChangeZoneEffect || effect instanceof ChangeZoneAllEffect) {
|
||||
AbilityFactory.adjustChangeZoneTarget(params, this);
|
||||
AbilityFactory.adjustChangeZoneTarget(mapParams, this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStackDescription() {
|
||||
return effect.getStackDescriptionWithSubs(params, this);
|
||||
return effect.getStackDescriptionWithSubs(mapParams, this);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -50,7 +50,7 @@ public class AbilityApiBased extends AbilityActivated {
|
||||
@Override
|
||||
public AbilityActivated getCopy() {
|
||||
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);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ public final class AbilityFactory {
|
||||
}
|
||||
|
||||
if (spellAbility instanceof SpellApiBased && hostCard.isPermanent()) {
|
||||
spellAbility.setDescription(spellAbility.getSourceCard().getName());
|
||||
spellAbility.setDescription(spellAbility.getHostCard().getName());
|
||||
} else if (mapParams.containsKey("SpellDescription")) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
|
||||
@@ -363,7 +363,7 @@ public final class AbilityFactory {
|
||||
}
|
||||
|
||||
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(",");
|
||||
if (sa.getApi() != ApiType.Charm || saChoices.length != 2)
|
||||
throw new IllegalStateException("Entwine ability may be built only on charm cards");
|
||||
|
||||
@@ -36,7 +36,7 @@ public class AbilityUtils {
|
||||
} catch (Exception e) {
|
||||
String type = sa.getSVar(name);
|
||||
if (type.equals("")) {
|
||||
type = sa.getSourceCard().getSVar(name);
|
||||
type = sa.getHostCard().getSVar(name);
|
||||
}
|
||||
|
||||
if (type.equals("")) {
|
||||
@@ -388,7 +388,7 @@ public class AbilityUtils {
|
||||
else if (hType.startsWith("Property")) {
|
||||
String defined = hType.split("Property")[1];
|
||||
for (Player p : game.getPlayers()) {
|
||||
if (p.hasProperty(defined, ability.getActivatingPlayer(), ability.getSourceCard())) {
|
||||
if (p.hasProperty(defined, ability.getActivatingPlayer(), ability.getHostCard())) {
|
||||
players.add(p);
|
||||
}
|
||||
}
|
||||
@@ -492,7 +492,7 @@ public class AbilityUtils {
|
||||
}
|
||||
}
|
||||
for (final SpellAbility s : sas) {
|
||||
final Player p = s.getSourceCard().getController();
|
||||
final Player p = s.getHostCard().getController();
|
||||
if (!players.contains(p)) {
|
||||
players.add(p);
|
||||
}
|
||||
@@ -504,7 +504,7 @@ public class AbilityUtils {
|
||||
final List<SpellAbility> saList = getDefinedSpellAbilities(card, "Targeted", ability);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -521,7 +521,7 @@ public class AbilityUtils {
|
||||
if (calcX[0].equals("TriggeredSpellAbility")) {
|
||||
final SpellAbility root = ability.getRootAbility();
|
||||
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
|
||||
/*
|
||||
@@ -540,7 +540,7 @@ public class AbilityUtils {
|
||||
final SpellAbility root = ability.getRootAbility();
|
||||
list = root.getPaidList("Discarded");
|
||||
if ((null == list) && root.isTrigger()) {
|
||||
list = root.getSourceCard().getSpellPermanent().getPaidList("Discarded");
|
||||
list = root.getHostCard().getSpellPermanent().getPaidList("Discarded");
|
||||
}
|
||||
}
|
||||
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
|
||||
// Mishra and Lobotomy
|
||||
|
||||
Card source = sa.getSourceCard();
|
||||
Card source = sa.getHostCard();
|
||||
final Object o;
|
||||
if (type.startsWith("Triggered")) {
|
||||
if (type.contains("Card")) {
|
||||
@@ -861,7 +861,7 @@ public class AbilityUtils {
|
||||
o = ((Card) c).getController();
|
||||
}
|
||||
if (c instanceof SpellAbility) {
|
||||
o = ((SpellAbility) c).getSourceCard().getController();
|
||||
o = ((SpellAbility) c).getHostCard().getController();
|
||||
}
|
||||
}
|
||||
else if (defined.endsWith("Opponent")) {
|
||||
@@ -872,7 +872,7 @@ public class AbilityUtils {
|
||||
o = ((Card) c).getController().getOpponents();
|
||||
}
|
||||
if (c instanceof SpellAbility) {
|
||||
o = ((SpellAbility) c).getSourceCard().getController().getOpponents();
|
||||
o = ((SpellAbility) c).getHostCard().getController().getOpponents();
|
||||
}
|
||||
}
|
||||
else if (defined.endsWith("Owner")) {
|
||||
@@ -923,7 +923,7 @@ public class AbilityUtils {
|
||||
o = ((Card) c).getController();
|
||||
}
|
||||
if (c instanceof SpellAbility) {
|
||||
o = ((SpellAbility) c).getSourceCard().getController();
|
||||
o = ((SpellAbility) c).getHostCard().getController();
|
||||
}
|
||||
}
|
||||
else if (defined.endsWith("Opponent")) {
|
||||
@@ -934,7 +934,7 @@ public class AbilityUtils {
|
||||
o = ((Card) c).getController().getOpponent();
|
||||
}
|
||||
if (c instanceof SpellAbility) {
|
||||
o = ((SpellAbility) c).getSourceCard().getController().getOpponent();
|
||||
o = ((SpellAbility) c).getHostCard().getController().getOpponent();
|
||||
}
|
||||
}
|
||||
else if (defined.endsWith("Owner")) {
|
||||
@@ -981,7 +981,7 @@ public class AbilityUtils {
|
||||
}
|
||||
}
|
||||
else if (defined.equals("EnchantedPlayer")) {
|
||||
final Object o = sa.getSourceCard().getEnchanting();
|
||||
final Object o = sa.getHostCard().getEnchanting();
|
||||
if (o instanceof Player) {
|
||||
if (!players.contains(o)) {
|
||||
players.add((Player) o);
|
||||
@@ -1004,7 +1004,7 @@ public class AbilityUtils {
|
||||
}
|
||||
}
|
||||
else if (defined.equals("SourceController")) {
|
||||
final Player p = sa.getSourceCard().getController();
|
||||
final Player p = sa.getHostCard().getController();
|
||||
if (!players.contains(p)) {
|
||||
players.add(p);
|
||||
}
|
||||
@@ -1022,8 +1022,8 @@ public class AbilityUtils {
|
||||
}
|
||||
else if (defined.startsWith("Flipped")) {
|
||||
for (Player p : game.getPlayers()) {
|
||||
if (null != sa.getSourceCard().getFlipResult(p)) {
|
||||
if (sa.getSourceCard().getFlipResult(p).equals(defined.substring(7))) {
|
||||
if (null != sa.getHostCard().getFlipResult(p)) {
|
||||
if (sa.getHostCard().getFlipResult(p).equals(defined.substring(7))) {
|
||||
players.add(p);
|
||||
}
|
||||
}
|
||||
@@ -1043,7 +1043,7 @@ public class AbilityUtils {
|
||||
}
|
||||
else {
|
||||
for (Player p : game.getPlayers()) {
|
||||
if (p.isValid(defined, sa.getActivatingPlayer(), sa.getSourceCard())) {
|
||||
if (p.isValid(defined, sa.getActivatingPlayer(), sa.getHostCard())) {
|
||||
players.add(p);
|
||||
}
|
||||
}
|
||||
@@ -1183,11 +1183,11 @@ public class AbilityUtils {
|
||||
}
|
||||
|
||||
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
|
||||
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 boolean execSubsWhenPaid = "WhenPaid".equals(resolveSubs) || StringUtils.isBlank(resolveSubs);
|
||||
final boolean execSubsWhenNotPaid = "WhenNotPaid".equals(resolveSubs) || StringUtils.isBlank(resolveSubs);
|
||||
@@ -1252,7 +1252,7 @@ public class AbilityUtils {
|
||||
* a SpellAbility object.
|
||||
*/
|
||||
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("ForgetOtherTargets")) {
|
||||
|
||||
@@ -23,7 +23,7 @@ public class SaTargetRoutines {
|
||||
boolean useTargets = sa.usesTargeting() && (!definedFirst || !sa.hasParam(definedParam))
|
||||
&& sa.getTargets() != null && (sa.getTargets().isTargetingAnyCard() || sa.getTargets().getTargets().isEmpty());
|
||||
return useTargets ? Lists.newArrayList(sa.getTargets().getTargetCards())
|
||||
: AbilityUtils.getDefinedCards(sa.getSourceCard(), sa.getParam(definedParam), sa);
|
||||
: AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam(definedParam), sa);
|
||||
}
|
||||
|
||||
// Players
|
||||
@@ -35,7 +35,7 @@ public class SaTargetRoutines {
|
||||
private List<Player> getPlayers(boolean definedFirst, String definedParam, SpellAbility sa) {
|
||||
boolean useTargets = sa.usesTargeting() && (!definedFirst || !sa.hasParam(definedParam));
|
||||
return useTargets ? Lists.newArrayList(sa.getTargets().getTargetPlayers())
|
||||
: AbilityUtils.getDefinedPlayers(sa.getSourceCard(), sa.getParam(definedParam), sa);
|
||||
: AbilityUtils.getDefinedPlayers(sa.getHostCard(), sa.getParam(definedParam), sa);
|
||||
}
|
||||
|
||||
// Spells
|
||||
@@ -46,7 +46,7 @@ public class SaTargetRoutines {
|
||||
private List<SpellAbility> getSpells(boolean definedFirst, String definedParam, SpellAbility sa) {
|
||||
boolean useTargets = sa.usesTargeting() && (!definedFirst || !sa.hasParam(definedParam));
|
||||
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
|
||||
@@ -57,6 +57,6 @@ public class SaTargetRoutines {
|
||||
private List<GameObject> getTargetables(boolean definedFirst, String definedParam, SpellAbility sa) {
|
||||
boolean useTargets = sa.usesTargeting() && (!definedFirst || !sa.hasParam(definedParam));
|
||||
return useTargets ? Lists.newArrayList(sa.getTargets().getTargets())
|
||||
: AbilityUtils.getDefinedObjects(sa.getSourceCard(), sa.getParam(definedParam), sa);
|
||||
: AbilityUtils.getDefinedObjects(sa.getHostCard(), sa.getParam(definedParam), sa);
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,7 @@ import java.util.StringTokenizer;
|
||||
|
||||
// prelude for when this is root ability
|
||||
if (!(sa instanceof AbilitySub)) {
|
||||
sb.append(sa.getSourceCard()).append(" -");
|
||||
sb.append(sa.getHostCard()).append(" -");
|
||||
}
|
||||
sb.append(" ");
|
||||
|
||||
@@ -57,7 +57,7 @@ import java.util.StringTokenizer;
|
||||
String stackDesc = params.get("StackDescription");
|
||||
if (stackDesc != null) {
|
||||
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()) {
|
||||
sb.append(" (Targeting: " + sa.getTargets().getTargets() + ")");
|
||||
}
|
||||
@@ -81,7 +81,7 @@ import java.util.StringTokenizer;
|
||||
|
||||
if (sa.hasParam("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));
|
||||
}
|
||||
|
||||
@@ -103,17 +103,17 @@ import java.util.StringTokenizer;
|
||||
if ( "{".equals(t) ) { isPlainText = false; continue; }
|
||||
if ( "}".equals(t) ) { isPlainText = true; continue; }
|
||||
if ( isPlainText )
|
||||
sb.append(t.replace("CARDNAME", sa.getSourceCard().getName()));
|
||||
sb.append(t.replace("CARDNAME", sa.getHostCard().getName()));
|
||||
else {
|
||||
List<?> objs = null;
|
||||
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:"))
|
||||
objs = AbilityUtils.getDefinedSpellAbilities(sa.getSourceCard(), t.substring(2), sa);
|
||||
objs = AbilityUtils.getDefinedSpellAbilities(sa.getHostCard(), t.substring(2), sa);
|
||||
else if ( t.startsWith("c:"))
|
||||
objs = AbilityUtils.getDefinedCards(sa.getSourceCard(), t.substring(2), sa);
|
||||
objs = AbilityUtils.getDefinedCards(sa.getHostCard(), t.substring(2), sa);
|
||||
else
|
||||
objs = AbilityUtils.getDefinedObjects(sa.getSourceCard(), t, sa);
|
||||
objs = AbilityUtils.getDefinedObjects(sa.getHostCard(), t, sa);
|
||||
|
||||
sb.append(StringUtils.join(objs, ", "));
|
||||
}
|
||||
|
||||
@@ -23,23 +23,23 @@ public class SpellApiBased extends Spell {
|
||||
super(sourceCard, abCost);
|
||||
this.setTargetRestrictions(tgt);
|
||||
|
||||
params = params0;
|
||||
mapParams.putAll(params0);
|
||||
api = api0;
|
||||
effect = api.getSpellEffect();
|
||||
ai = api.getAi();
|
||||
|
||||
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) {
|
||||
AbilityFactory.adjustChangeZoneTarget(params, this);
|
||||
AbilityFactory.adjustChangeZoneTarget(mapParams, this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStackDescription() {
|
||||
return effect.getStackDescriptionWithSubs(params, this);
|
||||
return effect.getStackDescriptionWithSubs(mapParams, this);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
@@ -18,19 +18,19 @@ public class StaticAbilityApiBased extends AbilityStatic {
|
||||
|
||||
public StaticAbilityApiBased(ApiType api0, Card sourceCard, Cost abCost, TargetRestrictions tgt, Map<String, String> params0) {
|
||||
super(sourceCard, abCost, tgt);
|
||||
params = params0;
|
||||
mapParams.putAll(params0);
|
||||
api = api0;
|
||||
effect = api.getSpellEffect();
|
||||
ai = api.getAi();
|
||||
|
||||
if (effect instanceof ChangeZoneEffect || effect instanceof ChangeZoneAllEffect) {
|
||||
AbilityFactory.adjustChangeZoneTarget(params, this);
|
||||
AbilityFactory.adjustChangeZoneTarget(mapParams, this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStackDescription() {
|
||||
return effect.getStackDescriptionWithSubs(params, this);
|
||||
return effect.getStackDescriptionWithSubs(mapParams, this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ public class AbandonEffect extends SpellAbilityEffect {
|
||||
*/
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
Card source = sa.getSourceCard();
|
||||
Card source = sa.getHostCard();
|
||||
Player controller = source.getController();
|
||||
|
||||
final Game game = controller.getGame();
|
||||
|
||||
@@ -14,7 +14,7 @@ public class AddTurnEffect extends SpellAbilityEffect {
|
||||
protected String getStackDescription(SpellAbility sa) {
|
||||
|
||||
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);
|
||||
|
||||
@@ -36,7 +36,7 @@ public class AddTurnEffect extends SpellAbilityEffect {
|
||||
|
||||
@Override
|
||||
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);
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public class AnimateAllEffect extends AnimateEffectBase {
|
||||
|
||||
@Override
|
||||
public void resolve(final SpellAbility sa) {
|
||||
final Card host = sa.getSourceCard();
|
||||
final Card host = sa.getHostCard();
|
||||
final Map<String, String> svars = host.getSVars();
|
||||
|
||||
// AF specific sa
|
||||
|
||||
@@ -27,14 +27,14 @@ public class AnimateEffect extends AnimateEffectBase {
|
||||
*/
|
||||
@Override
|
||||
public void resolve(final SpellAbility sa) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final Map<String, String> svars = source.getSVars();
|
||||
|
||||
String animateRemembered = null;
|
||||
|
||||
//if host is not on the battlefield don't apply
|
||||
if (sa.hasParam("UntilHostLeavesPlay")
|
||||
&& !sa.getSourceCard().isInPlay()) {
|
||||
&& !sa.getHostCard().isInPlay()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -303,7 +303,7 @@ public class AnimateEffect extends AnimateEffectBase {
|
||||
*/
|
||||
@Override
|
||||
protected String getStackDescription(SpellAbility sa) {
|
||||
final Card host = sa.getSourceCard();
|
||||
final Card host = sa.getHostCard();
|
||||
final Map<String, String> svars = host.getSVars();
|
||||
|
||||
int power = -1;
|
||||
|
||||
@@ -25,19 +25,19 @@ public class AttachEffect extends SpellAbilityEffect {
|
||||
*/
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
if (sa.getSourceCard().isAura() && sa.isSpell()) {
|
||||
if (sa.getHostCard().isAura() && sa.isSpell()) {
|
||||
|
||||
final Player ap = sa.getActivatingPlayer();
|
||||
// The Spell_Permanent (Auras) version of this AF needs to
|
||||
// move the card into play before Attaching
|
||||
|
||||
sa.getSourceCard().setController(ap, 0);
|
||||
final Card c = ap.getGame().getAction().moveTo(ap.getZone(ZoneType.Battlefield), sa.getSourceCard());
|
||||
sa.setSourceCard(c);
|
||||
sa.getHostCard().setController(ap, 0);
|
||||
final Card c = ap.getGame().getAction().moveTo(ap.getZone(ZoneType.Battlefield), sa.getHostCard());
|
||||
sa.setHostCard(c);
|
||||
}
|
||||
|
||||
Card source = sa.getSourceCard();
|
||||
Card card = sa.getSourceCard();
|
||||
Card source = sa.getHostCard();
|
||||
Card card = sa.getHostCard();
|
||||
|
||||
final List<GameObject> targets = getTargets(sa);
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ public class BalanceEffect extends SpellAbilityEffect {
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
Player activator = sa.getActivatingPlayer();
|
||||
Card source = sa.getSourceCard();
|
||||
Card source = sa.getHostCard();
|
||||
Game game = activator.getGame();
|
||||
String valid = sa.hasParam("Valid") ? sa.getParam("Valid") : "Card";
|
||||
ZoneType zone = sa.hasParam("Zone") ? ZoneType.smartValueOf(sa.getParam("Zone")) : ZoneType.Battlefield;
|
||||
|
||||
@@ -12,7 +12,7 @@ public class BondEffect extends SpellAbilityEffect {
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
// 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
|
||||
if (trigCards.get(0).isPaired() || !trigCards.get(0).isInZone(ZoneType.Battlefield)) {
|
||||
@@ -39,7 +39,7 @@ public class BondEffect extends SpellAbilityEffect {
|
||||
|
||||
@Override
|
||||
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();
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
|
||||
|
||||
// Redirect rules read 'you MAY choose new targets' ... okay!
|
||||
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;
|
||||
|
||||
if( changesOneTarget ) {
|
||||
@@ -103,10 +103,10 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
|
||||
if (null != newTarget) {
|
||||
if (sa.hasParam("TargetRestriction")) {
|
||||
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);
|
||||
} 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);
|
||||
}
|
||||
} else {
|
||||
@@ -118,7 +118,7 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
|
||||
}
|
||||
}
|
||||
if (remember) {
|
||||
sa.getSourceCard().addRemembered(tgtSA.getSourceCard());
|
||||
sa.getHostCard().addRemembered(tgtSA.getHostCard());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class ChangeZoneAllEffect extends SpellAbilityEffect {
|
||||
|
||||
List<Player> tgtPlayers = getTargetPlayers(sa);
|
||||
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")) {
|
||||
cards = game.getCardsIn(origin);
|
||||
@@ -75,7 +75,7 @@ public class ChangeZoneAllEffect extends SpellAbilityEffect {
|
||||
cards = AbilityUtils.filterListByType(cards, sa.getParam("ChangeType"), sa);
|
||||
|
||||
if (sa.hasParam("ForgetOtherRemembered")) {
|
||||
sa.getSourceCard().clearRemembered();
|
||||
sa.getHostCard().clearRemembered();
|
||||
}
|
||||
|
||||
final String remember = sa.getParam("RememberChanged");
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user