Large Commit: Passing in SpellAbilities into isValid/hasProperty to fix Harness the Storm not being possible otherwise.

Fixes a bunch of javadoc errors
This commit is contained in:
Sol
2016-04-20 17:47:28 +00:00
parent 3785488317
commit 87c7e8bbdd
129 changed files with 408 additions and 470 deletions

View File

@@ -375,7 +375,7 @@ public class AiController {
public boolean apply(final Card c) { public boolean apply(final Card c) {
if (!c.getSVar("NeedsToPlay").isEmpty()) { if (!c.getSVar("NeedsToPlay").isEmpty()) {
final String needsToPlay = c.getSVar("NeedsToPlay"); final String needsToPlay = c.getSVar("NeedsToPlay");
CardCollection list = CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), needsToPlay.split(","), c.getController(), c); CardCollection list = CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), needsToPlay.split(","), c.getController(), c, null);
if (list.isEmpty()) { if (list.isEmpty()) {
return false; return false;
} }
@@ -697,7 +697,7 @@ public class AiController {
SpellAbility effectExile = AbilityFactory.getAbility(card.getSVar("TrigExile"), card); SpellAbility effectExile = AbilityFactory.getAbility(card.getSVar("TrigExile"), card);
final ZoneType origin = ZoneType.listValueOf(effectExile.getParam("Origin")).get(0); final ZoneType origin = ZoneType.listValueOf(effectExile.getParam("Origin")).get(0);
final TargetRestrictions tgt = effectExile.getTargetRestrictions(); final TargetRestrictions tgt = effectExile.getTargetRestrictions();
final CardCollection list = CardLists.getValidCards(game.getCardsIn(origin), tgt.getValidTgts(), player, card); final CardCollection list = CardLists.getValidCards(game.getCardsIn(origin), tgt.getValidTgts(), player, card, effectExile);
CardCollection targets = CardLists.getTargetableCards(list, sa); CardCollection targets = CardLists.getTargetableCards(list, sa);
if (sa.getHostCard().getName().equals("Suspension Field")) { if (sa.getHostCard().getName().equals("Suspension Field")) {
//existing "exile until leaves" enchantments only target opponent's permanents //existing "exile until leaves" enchantments only target opponent's permanents
@@ -794,7 +794,7 @@ public class AiController {
final String needsToPlay = card.getSVar("NeedsToPlay"); final String needsToPlay = card.getSVar("NeedsToPlay");
CardCollectionView list = game.getCardsIn(ZoneType.Battlefield); CardCollectionView list = game.getCardsIn(ZoneType.Battlefield);
list = CardLists.getValidCards(list, needsToPlay.split(","), card.getController(), card); list = CardLists.getValidCards(list, needsToPlay.split(","), card.getController(), card, null);
if (list.isEmpty()) { if (list.isEmpty()) {
return AiPlayDecision.MissingNeededCards; return AiPlayDecision.MissingNeededCards;
} }
@@ -917,7 +917,7 @@ public class AiController {
public CardCollection getCardsToDiscard(final int numDiscard, final String[] uTypes, final SpellAbility sa) { public CardCollection getCardsToDiscard(final int numDiscard, final String[] uTypes, final SpellAbility sa) {
CardCollection hand = new CardCollection(player.getCardsIn(ZoneType.Hand)); CardCollection hand = new CardCollection(player.getCardsIn(ZoneType.Hand));
if ((uTypes != null) && (sa != null)) { if ((uTypes != null) && (sa != null)) {
hand = CardLists.getValidCards(hand, uTypes, sa.getActivatingPlayer(), sa.getHostCard()); hand = CardLists.getValidCards(hand, uTypes, sa.getActivatingPlayer(), sa.getHostCard(), sa);
} }
return getCardsToDiscard(numDiscard, numDiscard, hand, sa); return getCardsToDiscard(numDiscard, numDiscard, hand, sa);
} }
@@ -1356,7 +1356,6 @@ public class AiController {
* Ai should run. * Ai should run.
* *
* @param sa the sa * @param sa the sa
* @param ai
* @return true, if successful * @return true, if successful
*/ */
public final boolean aiShouldRun(final ReplacementEffect effect, final SpellAbility sa) { public final boolean aiShouldRun(final ReplacementEffect effect, final SpellAbility sa) {

View File

@@ -173,7 +173,7 @@ public class AiCostDecision extends CostDecisionMakerBase {
List<SpellAbility> chosen = new ArrayList<SpellAbility>(); List<SpellAbility> chosen = new ArrayList<SpellAbility>();
for (SpellAbilityStackInstance si :source.getGame().getStack()) { for (SpellAbilityStackInstance si :source.getGame().getStack()) {
SpellAbility sp = si.getSpellAbility(true).getRootAbility(); SpellAbility sp = si.getSpellAbility(true).getRootAbility();
if (si.getSourceCard().isValid(cost.getType().split(";"), source.getController(), source)) { if (si.getSourceCard().isValid(cost.getType().split(";"), source.getController(), source, sp)) {
chosen.add(sp); chosen.add(sp);
} }
} }
@@ -189,7 +189,7 @@ public class AiCostDecision extends CostDecisionMakerBase {
c = AbilityUtils.calculateAmount(source, cost.getAmount(), ability); c = AbilityUtils.calculateAmount(source, cost.getAmount(), ability);
} }
CardCollection typeList = CardLists.getValidCards(player.getGame().getCardsIn(ZoneType.Exile), cost.getType().split(";"), player, source); CardCollection typeList = CardLists.getValidCards(player.getGame().getCardsIn(ZoneType.Exile), cost.getType().split(";"), player, source, ability);
if (typeList.size() < c) { if (typeList.size() < c) {
return null; return null;
@@ -230,7 +230,7 @@ public class AiCostDecision extends CostDecisionMakerBase {
c = AbilityUtils.calculateAmount(source, cost.getAmount(), ability); c = AbilityUtils.calculateAmount(source, cost.getAmount(), ability);
} }
final CardCollection typeList = CardLists.getValidCards(player.getGame().getCardsIn(ZoneType.Battlefield), cost.getType().split(";"), player, source); final CardCollection typeList = CardLists.getValidCards(player.getGame().getCardsIn(ZoneType.Battlefield), cost.getType().split(";"), player, source, ability);
if (typeList.size() < c) { if (typeList.size() < c) {
return null; return null;
@@ -329,7 +329,7 @@ public class AiCostDecision extends CostDecisionMakerBase {
c = AbilityUtils.calculateAmount(source, cost.getAmount(), ability); c = AbilityUtils.calculateAmount(source, cost.getAmount(), ability);
} }
list = CardLists.getValidCards(list, cost.getType().split(";"), player, source); list = CardLists.getValidCards(list, cost.getType().split(";"), player, source, ability);
if (cost.isSameZone()) { if (cost.isSameZone()) {
// Jotun Grunt // Jotun Grunt
@@ -356,7 +356,8 @@ public class AiCostDecision extends CostDecisionMakerBase {
return PaymentDecision.card(source); return PaymentDecision.card(source);
} }
final CardCollection typeList = CardLists.getValidCards(player.getGame().getCardsIn(ZoneType.Battlefield), cost.getType().split(";"), player, source); final CardCollection typeList = CardLists.getValidCards(player.getGame().getCardsIn(ZoneType.Battlefield),
cost.getType().split(";"), player, source, ability);
Card card; Card card;
if (cost.getType().equals("Creature.YouCtrl")) { if (cost.getType().equals("Creature.YouCtrl")) {
@@ -382,7 +383,8 @@ public class AiCostDecision extends CostDecisionMakerBase {
final String sVar = ability.getSVar(amount); final String sVar = ability.getSVar(amount);
if (sVar.equals("XChoice")) { if (sVar.equals("XChoice")) {
CardCollectionView typeList = CardCollectionView typeList =
CardLists.getValidCards(player.getCardsIn(ZoneType.Battlefield), cost.getType().split(";"), ability.getActivatingPlayer(), ability.getHostCard()); CardLists.getValidCards(player.getCardsIn(ZoneType.Battlefield), cost.getType().split(";"),
ability.getActivatingPlayer(), ability.getHostCard(), ability);
typeList = CardLists.filter(typeList, Presets.UNTAPPED); typeList = CardLists.filter(typeList, Presets.UNTAPPED);
c = typeList.size(); c = typeList.size();
source.setSVar("ChosenX", "Number$" + Integer.toString(c)); source.setSVar("ChosenX", "Number$" + Integer.toString(c));
@@ -467,7 +469,7 @@ public class AiCostDecision extends CostDecisionMakerBase {
return null; return null;
} }
hand = CardLists.getValidCards(hand, type.split(";"), player, source); hand = CardLists.getValidCards(hand, type.split(";"), player, source, ability);
Integer c = cost.convertAmount(); Integer c = cost.convertAmount();
if (c == null) { if (c == null) {
final String sVar = ability.getSVar(cost.getAmount()); final String sVar = ability.getSVar(cost.getAmount());
@@ -488,7 +490,7 @@ public class AiCostDecision extends CostDecisionMakerBase {
final int c = AbilityUtils.calculateAmount(source, amount, ability); final int c = AbilityUtils.calculateAmount(source, amount, ability);
final String type = cost.getType(); final String type = cost.getType();
CardCollectionView typeList = CardLists.getValidCards(player.getCardsIn(ZoneType.Battlefield), type.split(";"), player, source); CardCollectionView typeList = CardLists.getValidCards(player.getCardsIn(ZoneType.Battlefield), type.split(";"), player, source, ability);
CardCollectionView hperms = CardLists.filter(typeList, new Predicate<Card>() { CardCollectionView hperms = CardLists.filter(typeList, new Predicate<Card>() {
@Override @Override
public boolean apply(final Card crd) { public boolean apply(final Card crd) {
@@ -539,7 +541,7 @@ public class AiCostDecision extends CostDecisionMakerBase {
if (type.equals("OriginalHost")) { if (type.equals("OriginalHost")) {
typeList = new CardCollection(ability.getOriginalHost()); typeList = new CardCollection(ability.getOriginalHost());
} else { } else {
typeList = CardLists.getValidCards(player.getCardsIn(cost.zone), type.split(";"), player, source); typeList = CardLists.getValidCards(player.getCardsIn(cost.zone), type.split(";"), player, source, ability);
} }
for (Card card : typeList) { for (Card card : typeList) {
if (card.getCounters(cost.counter) >= c) { if (card.getCounters(cost.counter) >= c) {
@@ -564,7 +566,8 @@ public class AiCostDecision extends CostDecisionMakerBase {
if (c == null) { if (c == null) {
final String sVar = ability.getSVar(amount); final String sVar = ability.getSVar(amount);
if (sVar.equals("XChoice")) { if (sVar.equals("XChoice")) {
CardCollection typeList = CardLists.getValidCards(player.getGame().getCardsIn(ZoneType.Battlefield), cost.getType().split(";"), player, ability.getHostCard()); CardCollection typeList = CardLists.getValidCards(player.getGame().getCardsIn(ZoneType.Battlefield),
cost.getType().split(";"), player, ability.getHostCard(), ability);
if (!cost.canUntapSource) { if (!cost.canUntapSource) {
typeList.remove(source); typeList.remove(source);
} }

View File

@@ -278,7 +278,7 @@ public class ComputerUtil {
if (activate != null) { if (activate != null) {
final String[] prefValid = activate.getSVar("AIPreference").split("\\$"); final String[] prefValid = activate.getSVar("AIPreference").split("\\$");
if (prefValid[0].equals(pref)) { if (prefValid[0].equals(pref)) {
final CardCollection prefList = CardLists.getValidCards(typeList, prefValid[1].split(","), activate.getController(), activate); final CardCollection prefList = CardLists.getValidCards(typeList, prefValid[1].split(","), activate.getController(), activate, null);
if (prefList.size() != 0) { if (prefList.size() != 0) {
CardLists.shuffle(prefList); CardLists.shuffle(prefList);
return prefList.get(0); return prefList.get(0);
@@ -371,7 +371,7 @@ public class ComputerUtil {
} }
public static CardCollection chooseSacrificeType(final Player ai, final String type, final Card source, final Card target, final int amount) { public static CardCollection chooseSacrificeType(final Player ai, final String type, final Card source, final Card target, final int amount) {
CardCollection typeList = CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), type.split(";"), source.getController(), source); CardCollection typeList = CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), type.split(";"), source.getController(), source, null);
if (ai.hasKeyword("You can't sacrifice creatures to cast spells or activate abilities.")) { if (ai.hasKeyword("You can't sacrifice creatures to cast spells or activate abilities.")) {
typeList = CardLists.getNotType(typeList, "Creature"); typeList = CardLists.getNotType(typeList, "Creature");
} }
@@ -404,7 +404,7 @@ public class ComputerUtil {
public static CardCollection chooseExileFrom(final Player ai, final ZoneType zone, final String type, final Card activate, public static CardCollection chooseExileFrom(final Player ai, final ZoneType zone, final String type, final Card activate,
final Card target, final int amount) { final Card target, final int amount) {
CardCollection typeList = CardLists.getValidCards(ai.getCardsIn(zone), type.split(";"), activate.getController(), activate); CardCollection typeList = CardLists.getValidCards(ai.getCardsIn(zone), type.split(";"), activate.getController(), activate, null);
if ((target != null) && target.getController() == ai && typeList.contains(target)) { if ((target != null) && target.getController() == ai && typeList.contains(target)) {
typeList.remove(target); // don't exile the card we're pumping typeList.remove(target); // don't exile the card we're pumping
@@ -425,7 +425,7 @@ public class ComputerUtil {
public static CardCollection choosePutToLibraryFrom(final Player ai, final ZoneType zone, final String type, final Card activate, public static CardCollection choosePutToLibraryFrom(final Player ai, final ZoneType zone, final String type, final Card activate,
final Card target, final int amount) { final Card target, final int amount) {
CardCollection typeList = CardLists.getValidCards(ai.getCardsIn(zone), type.split(";"), activate.getController(), activate); CardCollection typeList = CardLists.getValidCards(ai.getCardsIn(zone), type.split(";"), activate.getController(), activate, null);
if ((target != null) && target.getController() == ai && typeList.contains(target)) { if ((target != null) && target.getController() == ai && typeList.contains(target)) {
typeList.remove(target); // don't move the card we're pumping typeList.remove(target); // don't move the card we're pumping
@@ -450,7 +450,7 @@ public class ComputerUtil {
public static CardCollection chooseTapType(final Player ai, final String type, final Card activate, final boolean tap, final int amount) { public static CardCollection chooseTapType(final Player ai, final String type, final Card activate, final boolean tap, final int amount) {
CardCollection typeList = CardCollection typeList =
CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), type.split(";"), activate.getController(), activate); CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), type.split(";"), activate.getController(), activate, null);
// is this needed? // is this needed?
typeList = CardLists.filter(typeList, Presets.UNTAPPED); typeList = CardLists.filter(typeList, Presets.UNTAPPED);
@@ -475,7 +475,7 @@ public class ComputerUtil {
public static CardCollection chooseUntapType(final Player ai, final String type, final Card activate, final boolean untap, final int amount) { public static CardCollection chooseUntapType(final Player ai, final String type, final Card activate, final boolean untap, final int amount) {
CardCollection typeList = CardCollection typeList =
CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), type.split(";"), activate.getController(), activate); CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), type.split(";"), activate.getController(), activate, null);
// is this needed? // is this needed?
typeList = CardLists.filter(typeList, Presets.TAPPED); typeList = CardLists.filter(typeList, Presets.TAPPED);
@@ -500,7 +500,7 @@ public class ComputerUtil {
public static CardCollection chooseReturnType(final Player ai, final String type, final Card activate, final Card target, final int amount) { public static CardCollection chooseReturnType(final Player ai, final String type, final Card activate, final Card target, final int amount) {
final CardCollection typeList = final CardCollection typeList =
CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), type.split(";"), activate.getController(), activate); CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), type.split(";"), activate.getController(), activate, null);
if ((target != null) && target.getController() == ai && typeList.contains(target)) { if ((target != null) && target.getController() == ai && typeList.contains(target)) {
// don't bounce the card we're pumping // don't bounce the card we're pumping
typeList.remove(target); typeList.remove(target);
@@ -661,7 +661,7 @@ public class ComputerUtil {
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
if (tgt != null) { if (tgt != null) {
if (CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), controller, sa.getHostCard()).contains(card)) { if (CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), controller, sa.getHostCard(), sa).contains(card)) {
return true; return true;
} }
} else if (AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa).contains(card)) { } else if (AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa).contains(card)) {
@@ -699,7 +699,7 @@ public class ComputerUtil {
} }
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
if (tgt != null) { if (tgt != null) {
if (CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), controller, sa.getHostCard()).contains(card)) { if (CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), controller, sa.getHostCard(), null).contains(card)) {
prevented += AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("Amount"), sa); prevented += AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("Amount"), sa);
} }
@@ -768,7 +768,7 @@ public class ComputerUtil {
if (buffedcard.hasSVar("BuffedBy")) { if (buffedcard.hasSVar("BuffedBy")) {
final String buffedby = buffedcard.getSVar("BuffedBy"); final String buffedby = buffedcard.getSVar("BuffedBy");
final String[] bffdby = buffedby.split(","); final String[] bffdby = buffedby.split(",");
if (card.isValid(bffdby, buffedcard.getController(), buffedcard)) { if (card.isValid(bffdby, buffedcard.getController(), buffedcard, sa)) {
return true; return true;
} }
} }
@@ -797,7 +797,7 @@ public class ComputerUtil {
if (buffedcard.hasSVar("AntiBuffedBy")) { if (buffedcard.hasSVar("AntiBuffedBy")) {
final String buffedby = buffedcard.getSVar("AntiBuffedBy"); final String buffedby = buffedcard.getSVar("AntiBuffedBy");
final String[] bffdby = buffedby.split(","); final String[] bffdby = buffedby.split(",");
if (card.isValid(bffdby, buffedcard.getController(), buffedcard)) { if (card.isValid(bffdby, buffedcard.getController(), buffedcard, sa)) {
return true; return true;
} }
} }
@@ -884,7 +884,7 @@ public class ComputerUtil {
// not castable for at least one other turn. // not castable for at least one other turn.
return true; return true;
} else if (landsInPlay.size() > 5 && discard.getCMC() <= 1 } else if (landsInPlay.size() > 5 && discard.getCMC() <= 1
&& !discard.hasProperty("hasXCost", ai, null)) { && !discard.hasProperty("hasXCost", ai, null, null)) {
// Probably don't need small stuff now. // Probably don't need small stuff now.
return true; return true;
} }
@@ -929,7 +929,7 @@ public class ComputerUtil {
if (buffedCard.hasSVar("BuffedBy")) { if (buffedCard.hasSVar("BuffedBy")) {
final String buffedby = buffedCard.getSVar("BuffedBy"); final String buffedby = buffedCard.getSVar("BuffedBy");
final String[] bffdby = buffedby.split(","); final String[] bffdby = buffedby.split(",");
if (source.isValid(bffdby, buffedCard.getController(), buffedCard)) { if (source.isValid(bffdby, buffedCard.getController(), buffedCard, sa)) {
return true; return true;
} }
} }
@@ -949,7 +949,7 @@ public class ComputerUtil {
if (buffedcard.hasSVar("AntiBuffedBy")) { if (buffedcard.hasSVar("AntiBuffedBy")) {
final String buffedby = buffedcard.getSVar("AntiBuffedBy"); final String buffedby = buffedcard.getSVar("AntiBuffedBy");
final String[] bffdby = buffedby.split(","); final String[] bffdby = buffedby.split(",");
if (source.isValid(bffdby, buffedcard.getController(), buffedcard)) { if (source.isValid(bffdby, buffedcard.getController(), buffedcard, sa)) {
return true; return true;
} }
} }
@@ -1008,7 +1008,7 @@ public class ComputerUtil {
} }
final CardCollection typeList = final CardCollection typeList =
CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), type.split(","), source.getController(), source); CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), type.split(","), source.getController(), source, sa);
for (Card c : typeList) { for (Card c : typeList) {
if (c.getSVar("SacMe").equals("6")) { if (c.getSVar("SacMe").equals("6")) {
return true; return true;
@@ -1150,7 +1150,7 @@ public class ComputerUtil {
objects = AbilityUtils.getDefinedObjects(source, topStack.getParam("Defined"), topStack); objects = AbilityUtils.getDefinedObjects(source, topStack.getParam("Defined"), topStack);
} else if (topStack.hasParam("ValidCards")) { } else if (topStack.hasParam("ValidCards")) {
CardCollectionView battleField = aiPlayer.getCardsIn(ZoneType.Battlefield); CardCollectionView battleField = aiPlayer.getCardsIn(ZoneType.Battlefield);
objects = CardLists.getValidCards(battleField, topStack.getParam("ValidCards").split(","), source.getController(), source); objects = CardLists.getValidCards(battleField, topStack.getParam("ValidCards").split(","), source.getController(), source, topStack);
} else { } else {
return threatened; return threatened;
} }
@@ -1797,13 +1797,13 @@ public class ComputerUtil {
continue; continue;
} }
if (trigParams.containsKey("ValidCard")) { if (trigParams.containsKey("ValidCard")) {
if (!card.isValid(trigParams.get("ValidCard"), source.getController(), source)) { if (!card.isValid(trigParams.get("ValidCard"), source.getController(), source, sa)) {
continue; continue;
} }
} }
if (trigParams.containsKey("ValidActivatingPlayer")) { if (trigParams.containsKey("ValidActivatingPlayer")) {
if (!player.isValid(trigParams.get("ValidActivatingPlayer"), source.getController(), source)) { if (!player.isValid(trigParams.get("ValidActivatingPlayer"), source.getController(), source, sa)) {
continue; continue;
} }
} }
@@ -1869,7 +1869,7 @@ public class ComputerUtil {
continue; continue;
} }
if (trigParams.containsKey("ValidCard")) { if (trigParams.containsKey("ValidCard")) {
if (!permanent.isValid(trigParams.get("ValidCard"), source.getController(), source)) { if (!permanent.isValid(trigParams.get("ValidCard"), source.getController(), source, null)) {
continue; continue;
} }
} }

View File

@@ -73,7 +73,6 @@ public class ComputerUtilCard {
* </p> * </p>
* *
* @param list * @param list
* a {@link forge.CardList} object.
*/ */
public static void sortByEvaluateCreature(final CardCollection list) { public static void sortByEvaluateCreature(final CardCollection list) {
Collections.sort(list, ComputerUtilCard.EvaluateCreatureComparator); Collections.sort(list, ComputerUtilCard.EvaluateCreatureComparator);
@@ -86,7 +85,6 @@ public class ComputerUtilCard {
* </p> * </p>
* *
* @param list * @param list
* a {@link forge.CardList} object.
* @return a {@link forge.game.card.Card} object. * @return a {@link forge.game.card.Card} object.
*/ */
public static Card getBestArtifactAI(final List<Card> list) { public static Card getBestArtifactAI(final List<Card> list) {
@@ -119,7 +117,6 @@ public class ComputerUtilCard {
* </p> * </p>
* *
* @param list * @param list
* a {@link forge.CardList} object.
* @param spell * @param spell
* a {@link forge.game.card.Card} object. * a {@link forge.game.card.Card} object.
* @param targeted * @param targeted
@@ -148,7 +145,6 @@ public class ComputerUtilCard {
* </p> * </p>
* *
* @param list * @param list
* a {@link forge.CardList} object.
* @return a {@link forge.game.card.Card} object. * @return a {@link forge.game.card.Card} object.
*/ */
public static Card getBestLandAI(final Iterable<Card> list) { public static Card getBestLandAI(final Iterable<Card> list) {
@@ -199,8 +195,7 @@ public class ComputerUtilCard {
* getCheapestPermanentAI. * getCheapestPermanentAI.
* </p> * </p>
* *
* @param list * @param all
* a {@link forge.CardList} object.
* @param spell * @param spell
* a {@link forge.game.card.Card} object. * a {@link forge.game.card.Card} object.
* @param targeted * @param targeted
@@ -240,7 +235,6 @@ public class ComputerUtilCard {
* </p> * </p>
* *
* @param list * @param list
* a {@link forge.CardList} object.
* @return a {@link forge.game.card.Card} object. * @return a {@link forge.game.card.Card} object.
*/ */
public static Card getBestAI(final Iterable<Card> list) { public static Card getBestAI(final Iterable<Card> list) {
@@ -274,7 +268,6 @@ public class ComputerUtilCard {
* </p> * </p>
* *
* @param list * @param list
* a {@link forge.CardList} object.
* @return a {@link forge.game.card.Card} object. * @return a {@link forge.game.card.Card} object.
*/ */
public static Card getWorstCreatureAI(final Iterable<Card> list) { public static Card getWorstCreatureAI(final Iterable<Card> list) {
@@ -288,7 +281,6 @@ public class ComputerUtilCard {
* </p> * </p>
* *
* @param list * @param list
* a {@link forge.CardList} object.
* @return a {@link forge.game.card.Card} object. * @return a {@link forge.game.card.Card} object.
*/ */
public static Card getBestCreatureToBounceAI(final CardCollectionView list) { public static Card getBestCreatureToBounceAI(final CardCollectionView list) {
@@ -314,7 +306,6 @@ public class ComputerUtilCard {
* </p> * </p>
* *
* @param list * @param list
* a {@link forge.CardList} object.
* @return a {@link forge.game.card.Card} object. * @return a {@link forge.game.card.Card} object.
*/ */
public static Card getWorstAI(final Iterable<Card> list) { public static Card getWorstAI(final Iterable<Card> list) {
@@ -327,7 +318,6 @@ public class ComputerUtilCard {
* </p> * </p>
* *
* @param list * @param list
* a {@link forge.CardList} object.
* @param biasEnch * @param biasEnch
* a boolean. * a boolean.
* @param biasLand * @param biasLand
@@ -586,7 +576,6 @@ public class ComputerUtilCard {
* </p> * </p>
* *
* @param list * @param list
* a {@link forge.CardList} object.
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
public static String getMostProminentCreatureType(final CardCollectionView list) { public static String getMostProminentCreatureType(final CardCollectionView list) {
@@ -630,7 +619,6 @@ public class ComputerUtilCard {
* </p> * </p>
* *
* @param list * @param list
* a {@link forge.CardList} object.
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
public static String getMostProminentColor(final Iterable<Card> list) { public static String getMostProminentColor(final Iterable<Card> list) {
@@ -690,7 +678,6 @@ public class ComputerUtilCard {
* </p> * </p>
* *
* @param lands * @param lands
* a {@link forge.CardList} object.
* @return a {@link forge.game.card.Card} object. * @return a {@link forge.game.card.Card} object.
*/ */
public static Card getWorstLand(final List<Card> lands) { public static Card getWorstLand(final List<Card> lands) {
@@ -1310,7 +1297,7 @@ public class ComputerUtilCard {
continue; continue;
} }
final String valid = params.get("Affected"); final String valid = params.get("Affected");
if (!vCard.isValid(valid, c.getController(), c)) { if (!vCard.isValid(valid, c.getController(), c, null)) {
continue; continue;
} }
if (params.containsKey("AddPower")) { if (params.containsKey("AddPower")) {
@@ -1359,7 +1346,7 @@ public class ComputerUtilCard {
return false; return false;
} }
CardCollection targetables = CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), ai, sa.getHostCard()); CardCollection targetables = CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), ai, sa.getHostCard(), sa);
targetables = CardLists.getTargetableCards(targetables, sa); targetables = CardLists.getTargetableCards(targetables, sa);
targetables = ComputerUtil.getSafeTargets(ai, sa, targetables); targetables = ComputerUtil.getSafeTargets(ai, sa, targetables);
for (final Card c : targetables) { for (final Card c : targetables) {

View File

@@ -69,8 +69,6 @@ public class ComputerUtilCombat {
* *
* @param attacker * @param attacker
* a {@link forge.game.card.Card} object. * a {@link forge.game.card.Card} object.
* @param def
* the defending {@link GameEntity}.
* @return a boolean. * @return a boolean.
*/ */
public static boolean canAttackNextTurn(final Card attacker) { public static boolean canAttackNextTurn(final Card attacker) {
@@ -89,7 +87,7 @@ public class ComputerUtilCombat {
* *
* @param atacker * @param atacker
* a {@link forge.game.card.Card} object. * a {@link forge.game.card.Card} object.
* @param def * @param defender
* the defending {@link GameEntity}. * the defending {@link GameEntity}.
* @return a boolean. * @return a boolean.
*/ */
@@ -206,8 +204,6 @@ public class ComputerUtilCombat {
* a {@link forge.game.card.Card} object. * a {@link forge.game.card.Card} object.
* @param attacked * @param attacked
* a {@link forge.game.player.Player} object. * a {@link forge.game.player.Player} object.
* @param combat
* a {@link forge.game.combat.Combat} object.
* @return a int. * @return a int.
*/ */
public static int poisonIfUnblocked(final Card attacker, final Player attacked) { public static int poisonIfUnblocked(final Card attacker, final Player attacked) {
@@ -233,7 +229,6 @@ public class ComputerUtilCombat {
* </p> * </p>
* *
* @param attackers * @param attackers
* a {@link forge.CardList} object.
* @param attacked * @param attacked
* a {@link forge.game.player.Player} object. * a {@link forge.game.player.Player} object.
* @return a int. * @return a int.
@@ -253,7 +248,6 @@ public class ComputerUtilCombat {
* </p> * </p>
* *
* @param attackers * @param attackers
* a {@link forge.CardList} object.
* @param attacked * @param attacked
* a {@link forge.game.player.Player} object. * a {@link forge.game.player.Player} object.
* @return a int. * @return a int.
@@ -474,7 +468,6 @@ public class ComputerUtilCombat {
* @param attacker * @param attacker
* a {@link forge.game.card.Card} object. * a {@link forge.game.card.Card} object.
* @param defenders * @param defenders
* a {@link forge.CardList} object.
* @return a int. * @return a int.
*/ */
public static int totalDamageOfBlockers(final Card attacker, final List<Card> defenders) { public static int totalDamageOfBlockers(final Card attacker, final List<Card> defenders) {
@@ -589,7 +582,6 @@ public class ComputerUtilCombat {
* @param attacker * @param attacker
* a {@link forge.game.card.Card} object. * a {@link forge.game.card.Card} object.
* @param defenders * @param defenders
* a {@link forge.CardList} object.
* @return a int. * @return a int.
*/ */
public static int totalShieldDamage(final Card attacker, final List<Card> defenders) { public static int totalShieldDamage(final Card attacker, final List<Card> defenders) {
@@ -612,7 +604,7 @@ public class ComputerUtilCombat {
* *
* @param attacker * @param attacker
* a {@link forge.game.card.Card} object. * a {@link forge.game.card.Card} object.
* @param defender * @param blocker
* a {@link forge.game.card.Card} object. * a {@link forge.game.card.Card} object.
* @return a int. * @return a int.
*/ */
@@ -886,7 +878,7 @@ public class ComputerUtilCombat {
continue; continue;
} }
final String valid = params.get("Affected").replace("blocking", "Creature"); final String valid = params.get("Affected").replace("blocking", "Creature");
if (!blocker.isValid(valid, card.getController(), card)) { if (!blocker.isValid(valid, card.getController(), card, null)) {
continue; continue;
} }
if (params.containsKey("AddPower")) { if (params.containsKey("AddPower")) {
@@ -1223,7 +1215,7 @@ public class ComputerUtilCombat {
continue; continue;
} }
final String valid = params.get("Affected").replace("attacking", "Creature"); final String valid = params.get("Affected").replace("attacking", "Creature");
if (!attacker.isValid(valid, card.getController(), card)) { if (!attacker.isValid(valid, card.getController(), card, null)) {
continue; continue;
} }
if (params.containsKey("AddPower")) { if (params.containsKey("AddPower")) {
@@ -1267,9 +1259,9 @@ public class ComputerUtilCombat {
list.add(attacker); list.add(attacker);
} }
if (abilityParams.containsKey("ValidCards")) { if (abilityParams.containsKey("ValidCards")) {
if (attacker.isValid(abilityParams.get("ValidCards").split(","), source.getController(), source) if (attacker.isValid(abilityParams.get("ValidCards").split(","), source.getController(), source, null)
|| attacker.isValid(abilityParams.get("ValidCards").replace("attacking+", "").split(","), || attacker.isValid(abilityParams.get("ValidCards").replace("attacking+", "").split(","),
source.getController(), source)) { source.getController(), source, null)) {
list.add(attacker); list.add(attacker);
} }
} }
@@ -1396,7 +1388,7 @@ public class ComputerUtilCombat {
continue; continue;
} }
final String valid = params.get("Affected").replace("attacking", "Creature"); final String valid = params.get("Affected").replace("attacking", "Creature");
if (!attacker.isValid(valid, card.getController(), card)) { if (!attacker.isValid(valid, card.getController(), card, null)) {
continue; continue;
} }
if (params.containsKey("AddToughness")) { if (params.containsKey("AddToughness")) {
@@ -1459,9 +1451,9 @@ public class ComputerUtilCombat {
list.add(attacker); list.add(attacker);
} }
if (abilityParams.containsKey("ValidCards")) { if (abilityParams.containsKey("ValidCards")) {
if (attacker.isValid(abilityParams.get("ValidCards").split(","), source.getController(), source) if (attacker.isValid(abilityParams.get("ValidCards").split(","), source.getController(), source, null)
|| attacker.isValid(abilityParams.get("ValidCards").replace("attacking+", "").split(","), || attacker.isValid(abilityParams.get("ValidCards").replace("attacking+", "").split(","),
source.getController(), source)) { source.getController(), source, null)) {
list.add(attacker); list.add(attacker);
} }
} }
@@ -1966,7 +1958,6 @@ public class ComputerUtilCombat {
* @param attacker * @param attacker
* a {@link forge.game.card.Card} object. * a {@link forge.game.card.Card} object.
* @param block * @param block
* a {@link forge.CardList} object.
* @param dmgCanDeal * @param dmgCanDeal
* a int. * a int.
* @param defender * @param defender
@@ -2169,11 +2160,11 @@ public class ComputerUtilCombat {
continue; continue;
} }
if (params.containsKey("ValidSource") if (params.containsKey("ValidSource")
&& !source.isValid(params.get("ValidSource"), ca.getController(), ca)) { && !source.isValid(params.get("ValidSource"), ca.getController(), ca, null)) {
continue; continue;
} }
if (params.containsKey("ValidTarget") if (params.containsKey("ValidTarget")
&& !target.isValid(params.get("ValidTarget"), ca.getController(), ca)) { && !target.isValid(params.get("ValidTarget"), ca.getController(), ca, null)) {
continue; continue;
} }
if (params.containsKey("IsCombat")) { if (params.containsKey("IsCombat")) {

View File

@@ -108,7 +108,7 @@ public class ComputerUtilCost {
if (type.equals("CARDNAME") && source.getAbilityText().contains("Bloodrush")) { if (type.equals("CARDNAME") && source.getAbilityText().contains("Bloodrush")) {
continue; continue;
} }
final CardCollection typeList = CardLists.getValidCards(ai.getCardsIn(ZoneType.Hand), type.split(","), source.getController(), source); final CardCollection typeList = CardLists.getValidCards(ai.getCardsIn(ZoneType.Hand), type.split(","), source.getController(), source, null);
if (typeList.size() > ai.getMaxHandSize()) { if (typeList.size() > ai.getMaxHandSize()) {
continue; continue;
} }
@@ -217,7 +217,7 @@ public class ComputerUtilCost {
continue; continue;
} }
final CardCollection typeList = CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), type.split(","), source.getController(), source); final CardCollection typeList = CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), type.split(","), source.getController(), source, null);
if (ComputerUtil.getCardPreference(ai, source, "SacCost", typeList) == null) { if (ComputerUtil.getCardPreference(ai, source, "SacCost", typeList) == null) {
return false; return false;
} }
@@ -257,7 +257,7 @@ public class ComputerUtilCost {
continue; continue;
} }
final CardCollection typeList = CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), type.split(","), source.getController(), source); final CardCollection typeList = CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), type.split(","), source.getController(), source, null);
if (ComputerUtil.getCardPreference(ai, source, "SacCost", typeList) == null) { if (ComputerUtil.getCardPreference(ai, source, "SacCost", typeList) == null) {
return false; return false;
} }
@@ -321,8 +321,7 @@ public class ComputerUtilCost {
* *
* @param hostCard * @param hostCard
* a {@link forge.game.card.Card} object. * a {@link forge.game.card.Card} object.
* @param costString * @param cost
* a {@link java.lang.String} object.
* @return a boolean. * @return a boolean.
*/ */
public static boolean shouldPayCost(final Player ai, final Card hostCard, final Cost cost) { public static boolean shouldPayCost(final Player ai, final Card hostCard, final Cost cost) {
@@ -368,7 +367,7 @@ public class ComputerUtilCost {
final String snem = c.getSVar("AI_SpellsNeedExtraMana"); final String snem = c.getSVar("AI_SpellsNeedExtraMana");
if (!StringUtils.isBlank(snem)) { if (!StringUtils.isBlank(snem)) {
String[] parts = TextUtil.split(snem, ' '); String[] parts = TextUtil.split(snem, ' ');
boolean meetsRestriction = parts.length == 1 || player.isValid(parts[1], c.getController(), c); boolean meetsRestriction = parts.length == 1 || player.isValid(parts[1], c.getController(), c, sa);
if(!meetsRestriction) if(!meetsRestriction)
continue; continue;

View File

@@ -76,14 +76,15 @@ public class AnimateAi extends SpellAbilityAi {
num = (num == null) ? "1" : num; num = (num == null) ? "1" : num;
final int nToSac = AbilityUtils.calculateAmount(topStack.getHostCard(), num, topStack); final int nToSac = AbilityUtils.calculateAmount(topStack.getHostCard(), num, topStack);
CardCollection list = CardCollection list =
CardLists.getValidCards(aiPlayer.getCardsIn(ZoneType.Battlefield), valid.split(","), aiPlayer.getOpponent(), topStack.getHostCard()); CardLists.getValidCards(aiPlayer.getCardsIn(ZoneType.Battlefield), valid.split(","),
aiPlayer.getOpponent(), topStack.getHostCard(), topStack);
list = CardLists.filter(list, CardPredicates.canBeSacrificedBy(topStack)); list = CardLists.filter(list, CardPredicates.canBeSacrificedBy(topStack));
ComputerUtilCard.sortByEvaluateCreature(list); ComputerUtilCard.sortByEvaluateCreature(list);
if (!list.isEmpty() && list.size() == nToSac && ComputerUtilCost.canPayCost(sa, aiPlayer)) { if (!list.isEmpty() && list.size() == nToSac && ComputerUtilCost.canPayCost(sa, aiPlayer)) {
Card animatedCopy = CardFactory.copyCard(source, true); Card animatedCopy = CardFactory.copyCard(source, true);
becomeAnimated(animatedCopy, source.hasSickness(), sa); becomeAnimated(animatedCopy, source.hasSickness(), sa);
list.add(animatedCopy); list.add(animatedCopy);
list = CardLists.getValidCards(list, valid.split(","), aiPlayer.getOpponent(), topStack.getHostCard()); list = CardLists.getValidCards(list, valid.split(","), aiPlayer.getOpponent(), topStack.getHostCard(), topStack);
list = CardLists.filter(list, CardPredicates.canBeSacrificedBy(topStack)); list = CardLists.filter(list, CardPredicates.canBeSacrificedBy(topStack));
if (ComputerUtilCard.evaluateCreature(animatedCopy) < ComputerUtilCard.evaluateCreature(list.get(0)) if (ComputerUtilCard.evaluateCreature(animatedCopy) < ComputerUtilCard.evaluateCreature(list.get(0))
&& list.contains(animatedCopy)) { && list.contains(animatedCopy)) {
@@ -98,7 +99,7 @@ public class AnimateAi extends SpellAbilityAi {
if (ph.getPlayerTurn().isOpponentOf(aiPlayer) || ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)) { if (ph.getPlayerTurn().isOpponentOf(aiPlayer) || ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)) {
return false; return false;
} }
List<Card> list = CardLists.getValidCards(aiPlayer.getCreaturesInPlay(), tgt.getValidTgts(), aiPlayer, source); List<Card> list = CardLists.getValidCards(aiPlayer.getCreaturesInPlay(), tgt.getValidTgts(), aiPlayer, source, sa);
for (Card c : list) { for (Card c : list) {
if (ComputerUtilCard.doesCreatureAttackAI(aiPlayer, c)) { if (ComputerUtilCard.doesCreatureAttackAI(aiPlayer, c)) {
sa.getTargets().add(c); sa.getTargets().add(c);
@@ -237,7 +238,7 @@ public class AnimateAi extends SpellAbilityAi {
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
final Card animateSource = sa.getHostCard(); final Card animateSource = sa.getHostCard();
CardCollectionView list = aiPlayer.getGame().getCardsIn(tgt.getZone()); CardCollectionView list = aiPlayer.getGame().getCardsIn(tgt.getZone());
list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), animateSource); list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), animateSource, sa);
CardCollection prefList = CardLists.getValidCards(list, sa.getParam("AITgts"), sa.getActivatingPlayer(), animateSource); CardCollection prefList = CardLists.getValidCards(list, sa.getParam("AITgts"), sa.getActivatingPlayer(), animateSource);
if (!prefList.isEmpty()){ if (!prefList.isEmpty()){
CardLists.shuffle(prefList); CardLists.shuffle(prefList);

View File

@@ -81,7 +81,7 @@ public class AttachAi extends SpellAbilityAi {
final SpellAbility effectExile = AbilityFactory.getAbility(source.getSVar("TrigExile"), source); final SpellAbility effectExile = AbilityFactory.getAbility(source.getSVar("TrigExile"), source);
final ZoneType origin = ZoneType.listValueOf(effectExile.getParam("Origin")).get(0); final ZoneType origin = ZoneType.listValueOf(effectExile.getParam("Origin")).get(0);
final TargetRestrictions exile_tgt = effectExile.getTargetRestrictions(); final TargetRestrictions exile_tgt = effectExile.getTargetRestrictions();
final CardCollection list = CardLists.getValidCards(ai.getGame().getCardsIn(origin), exile_tgt.getValidTgts(), ai, source); final CardCollection list = CardLists.getValidCards(ai.getGame().getCardsIn(origin), exile_tgt.getValidTgts(), ai, source, effectExile);
final CardCollection targets = CardLists.filter(list, new Predicate<Card>() { final CardCollection targets = CardLists.filter(list, new Predicate<Card>() {
@Override @Override
public boolean apply(final Card c) { public boolean apply(final Card c) {
@@ -284,8 +284,6 @@ public class AttachAi extends SpellAbilityAi {
/** /**
* Attach to player ai preferences. * Attach to player ai preferences.
* *
* @param af
* the af
* @param sa * @param sa
* the sa * the sa
* @param mandatory * @param mandatory
@@ -695,8 +693,6 @@ public class AttachAi extends SpellAbilityAi {
* the sa * the sa
* @param mandatory * @param mandatory
* the mandatory * the mandatory
* @param af
* the af
* *
* @return true, if successful * @return true, if successful
*/ */
@@ -767,8 +763,6 @@ public class AttachAi extends SpellAbilityAi {
/** /**
* Attach preference. * Attach preference.
* *
* @param af
* the af
* @param sa * @param sa
* the sa * the sa
* @param sa * @param sa
@@ -1051,7 +1045,7 @@ public class AttachAi extends SpellAbilityAi {
if (tgt == null) { if (tgt == null) {
list = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa); list = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa);
} else { } else {
list = CardLists.getValidCards(aiPlayer.getGame().getCardsIn(tgt.getZone()), tgt.getValidTgts(), sa.getActivatingPlayer(), attachSource); list = CardLists.getValidCards(aiPlayer.getGame().getCardsIn(tgt.getZone()), tgt.getValidTgts(), sa.getActivatingPlayer(), attachSource, sa);
// TODO If Attaching without casting, don't need to actually target. // TODO If Attaching without casting, don't need to actually target.
// I believe this is the only case where mandatory will be true, so just // I believe this is the only case where mandatory will be true, so just
// check that when starting that work // check that when starting that work
@@ -1370,7 +1364,7 @@ public class AttachAi extends SpellAbilityAi {
/** /**
* Checks if it is useful to execute the attach action given the current context. * Checks if it is useful to execute the attach action given the current context.
* *
* @param card * @param c
* the card * the card
* @param sa SpellAbility * @param sa SpellAbility
* @return true, if the action is useful (beneficial) in the current minimal context (Card vs. Attach SpellAbility) * @return true, if the action is useful (beneficial) in the current minimal context (Card vs. Attach SpellAbility)

View File

@@ -28,7 +28,7 @@ public class BecomesBlockedAi extends SpellAbilityAi {
if (tgt != null) { if (tgt != null) {
sa.resetTargets(); sa.resetTargets();
CardCollection list = CardLists.filterControlledBy(game.getCardsIn(ZoneType.Battlefield), aiPlayer.getOpponents()); CardCollection list = CardLists.filterControlledBy(game.getCardsIn(ZoneType.Battlefield), aiPlayer.getOpponents());
list = CardLists.getValidCards(list, tgt.getValidTgts(), source.getController(), source); list = CardLists.getValidCards(list, tgt.getValidTgts(), source.getController(), source, sa);
list = CardLists.getTargetableCards(list, sa); list = CardLists.getTargetableCards(list, sa);
list = CardLists.getNotKeyword(list, "Trample"); list = CardLists.getNotKeyword(list, "Trample");

View File

@@ -25,7 +25,7 @@ public class BidLifeAi extends SpellAbilityAi {
sa.resetTargets(); sa.resetTargets();
if (tgt.canTgtCreature()) { if (tgt.canTgtCreature()) {
List<Card> list = CardLists.getTargetableCards(aiPlayer.getOpponent().getCardsIn(ZoneType.Battlefield), sa); List<Card> list = CardLists.getTargetableCards(aiPlayer.getOpponent().getCardsIn(ZoneType.Battlefield), sa);
list = CardLists.getValidCards(list, tgt.getValidTgts(), source.getController(), source); list = CardLists.getValidCards(list, tgt.getValidTgts(), source.getController(), source, sa);
if (list.isEmpty()) { if (list.isEmpty()) {
return false; return false;
} }

View File

@@ -42,8 +42,6 @@ public class ChangeZoneAi extends SpellAbilityAi {
* </p> * </p>
* @param sa * @param sa
* a {@link forge.game.spellability.SpellAbility} object. * a {@link forge.game.spellability.SpellAbility} object.
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
* *
* @return a boolean. * @return a boolean.
*/ */
@@ -81,8 +79,6 @@ public class ChangeZoneAi extends SpellAbilityAi {
* </p> * </p>
* @param sa * @param sa
* a {@link forge.game.spellability.SpellAbility} object. * a {@link forge.game.spellability.SpellAbility} object.
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
* *
* @return a boolean. * @return a boolean.
*/ */
@@ -109,8 +105,6 @@ public class ChangeZoneAi extends SpellAbilityAi {
* a {@link forge.game.spellability.SpellAbility} object. * a {@link forge.game.spellability.SpellAbility} object.
* @param mandatory * @param mandatory
* a boolean. * a boolean.
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
* *
* @return a boolean. * @return a boolean.
*/ */
@@ -145,8 +139,6 @@ public class ChangeZoneAi extends SpellAbilityAi {
* changeHiddenOriginCanPlayAI. * changeHiddenOriginCanPlayAI.
* </p> * </p>
* *
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
* @param sa * @param sa
* a {@link forge.game.spellability.SpellAbility} object. * a {@link forge.game.spellability.SpellAbility} object.
* @return a boolean. * @return a boolean.
@@ -350,8 +342,6 @@ public class ChangeZoneAi extends SpellAbilityAi {
* changeHiddenOriginPlayDrawbackAI. * changeHiddenOriginPlayDrawbackAI.
* </p> * </p>
* *
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
* @param sa * @param sa
* a {@link forge.game.spellability.SpellAbility} object. * a {@link forge.game.spellability.SpellAbility} object.
* @return a boolean. * @return a boolean.
@@ -380,8 +370,6 @@ public class ChangeZoneAi extends SpellAbilityAi {
* changeHiddenTriggerAI. * changeHiddenTriggerAI.
* </p> * </p>
* *
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
* @param sa * @param sa
* a {@link forge.game.spellability.SpellAbility} object. * a {@link forge.game.spellability.SpellAbility} object.
* @param mandatory * @param mandatory
@@ -465,7 +453,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
* @param ai * @param ai
* *
* @param list * @param list
* a {@link forge.CardList} object. * a List<Card> object.
* @return a {@link forge.game.card.Card} object. * @return a {@link forge.game.card.Card} object.
*/ */
private static Card basicManaFixing(final Player ai, final List<Card> list) { // Search for a Basic Land private static Card basicManaFixing(final Player ai, final List<Card> list) { // Search for a Basic Land
@@ -561,8 +549,6 @@ public class ChangeZoneAi extends SpellAbilityAi {
* changeKnownOriginCanPlayAI. * changeKnownOriginCanPlayAI.
* </p> * </p>
* *
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
* @param sa * @param sa
* a {@link forge.game.spellability.SpellAbility} object. * a {@link forge.game.spellability.SpellAbility} object.
* @return a boolean. * @return a boolean.
@@ -690,8 +676,6 @@ public class ChangeZoneAi extends SpellAbilityAi {
* changeKnownOriginPlayDrawbackAI. * changeKnownOriginPlayDrawbackAI.
* </p> * </p>
* *
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
* @param sa * @param sa
* a {@link forge.game.spellability.SpellAbility} object. * a {@link forge.game.spellability.SpellAbility} object.
* @return a boolean. * @return a boolean.
@@ -709,8 +693,6 @@ public class ChangeZoneAi extends SpellAbilityAi {
* changeKnownPreferredTarget. * changeKnownPreferredTarget.
* </p> * </p>
* *
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
* @param sa * @param sa
* a {@link forge.game.spellability.SpellAbility} object. * a {@link forge.game.spellability.SpellAbility} object.
* @param mandatory * @param mandatory
@@ -735,7 +717,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
} }
sa.resetTargets(); sa.resetTargets();
CardCollection list = CardLists.getValidCards(game.getCardsIn(origin), tgt.getValidTgts(), ai, source); CardCollection list = CardLists.getValidCards(game.getCardsIn(origin), tgt.getValidTgts(), ai, source, sa);
list = CardLists.getTargetableCards(list, sa); list = CardLists.getTargetableCards(list, sa);
if (sa.hasParam("AITgts")) { if (sa.hasParam("AITgts")) {
list = CardLists.getValidCards(list, sa.getParam("AITgts"), ai, source); list = CardLists.getValidCards(list, sa.getParam("AITgts"), ai, source);
@@ -753,7 +735,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
@Override @Override
public boolean apply(final Card c) { public boolean apply(final Card c) {
for (Card card : game.getCardsIn(ZoneType.Battlefield)) { for (Card card : game.getCardsIn(ZoneType.Battlefield)) {
if (card.isValid(sa.getParam("AttachedTo"), ai, c)) { if (card.isValid(sa.getParam("AttachedTo"), ai, c, sa)) {
return true; return true;
} }
} }
@@ -1114,7 +1096,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
final ZoneType destination = ZoneType.smartValueOf(sa.getParam("Destination")); final ZoneType destination = ZoneType.smartValueOf(sa.getParam("Destination"));
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
CardCollection list = CardLists.getValidCards(ai.getGame().getCardsIn(origin), tgt.getValidTgts(), ai, source); CardCollection list = CardLists.getValidCards(ai.getGame().getCardsIn(origin), tgt.getValidTgts(), ai, source, sa);
// Narrow down the list: // Narrow down the list:
if (origin.equals(ZoneType.Battlefield)) { if (origin.equals(ZoneType.Battlefield)) {
@@ -1204,8 +1186,6 @@ public class ChangeZoneAi extends SpellAbilityAi {
* changeKnownOriginTriggerAI. * changeKnownOriginTriggerAI.
* </p> * </p>
* *
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
* @param sa * @param sa
* a {@link forge.game.spellability.SpellAbility} object. * a {@link forge.game.spellability.SpellAbility} object.
* @param mandatory * @param mandatory

View File

@@ -74,7 +74,7 @@ public class ChooseSourceAi extends SpellAbilityAi {
if (sa.getParam("AILogic").equals("NeedsPrevention")) { if (sa.getParam("AILogic").equals("NeedsPrevention")) {
if (!game.getStack().isEmpty()) { if (!game.getStack().isEmpty()) {
final SpellAbility topStack = game.getStack().peekAbility(); final SpellAbility topStack = game.getStack().peekAbility();
if (sa.hasParam("Choices") && !topStack.getHostCard().isValid(sa.getParam("Choices"), ai, source)) { if (sa.hasParam("Choices") && !topStack.getHostCard().isValid(sa.getParam("Choices"), ai, source, sa)) {
return false; return false;
} }
final ApiType threatApi = topStack.getApi(); final ApiType threatApi = topStack.getApi();
@@ -161,7 +161,7 @@ public class ChooseSourceAi extends SpellAbilityAi {
final Card source = si.getSourceCard(); final Card source = si.getSourceCard();
final SpellAbility abilityOnStack = si.getSpellAbility(true); final SpellAbility abilityOnStack = si.getSpellAbility(true);
if (sa.hasParam("Choices") && !abilityOnStack.getHostCard().isValid(sa.getParam("Choices"), ai, sa.getHostCard())) { if (sa.hasParam("Choices") && !abilityOnStack.getHostCard().isValid(sa.getParam("Choices"), ai, sa.getHostCard(), sa)) {
continue; continue;
} }
final ApiType threatApi = abilityOnStack.getApi(); final ApiType threatApi = abilityOnStack.getApi();

View File

@@ -31,7 +31,7 @@ public class ControlExchangeAi extends SpellAbilityAi {
sa.resetTargets(); sa.resetTargets();
List<Card> list = List<Card> list =
CardLists.getValidCards(ai.getOpponent().getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), ai, sa.getHostCard()); CardLists.getValidCards(ai.getOpponent().getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), ai, sa.getHostCard(), sa);
// AI won't try to grab cards that are filtered out of AI decks on // AI won't try to grab cards that are filtered out of AI decks on
// purpose // purpose
list = CardLists.filter(list, new Predicate<Card>() { list = CardLists.filter(list, new Predicate<Card>() {
@@ -46,7 +46,7 @@ public class ControlExchangeAi extends SpellAbilityAi {
object2 = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa).get(0); object2 = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa).get(0);
} else if (tgt.getMinTargets(sa.getHostCard(), sa) > 1) { } else if (tgt.getMinTargets(sa.getHostCard(), sa) > 1) {
CardCollectionView list2 = ai.getCardsIn(ZoneType.Battlefield); CardCollectionView list2 = ai.getCardsIn(ZoneType.Battlefield);
list2 = CardLists.getValidCards(list2, tgt.getValidTgts(), ai, sa.getHostCard()); list2 = CardLists.getValidCards(list2, tgt.getValidTgts(), ai, sa.getHostCard(), sa);
object2 = ComputerUtilCard.getWorstAI(list2); object2 = ComputerUtilCard.getWorstAI(list2);
sa.getTargets().add(object2); sa.getTargets().add(object2);
} }
@@ -69,7 +69,8 @@ public class ControlExchangeAi extends SpellAbilityAi {
} }
} else { } else {
if (mandatory) { if (mandatory) {
CardCollection list2 = CardLists.getValidCards(aiPlayer.getGame().getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), aiPlayer, sa.getHostCard()); CardCollection list2 = CardLists.getValidCards(aiPlayer.getGame().getCardsIn(ZoneType.Battlefield),
tgt.getValidTgts(), aiPlayer, sa.getHostCard(), sa);
while (!list2.isEmpty()) { while (!list2.isEmpty()) {
Card best = ComputerUtilCard.getBestAI(list2); Card best = ComputerUtilCard.getBestAI(list2);
if (sa.canTarget(best)) { if (sa.canTarget(best)) {

View File

@@ -119,7 +119,7 @@ public class ControlGainAi extends SpellAbilityAi {
} }
CardCollection list = CardCollection list =
CardLists.getValidCards(opp.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getHostCard()); CardLists.getValidCards(opp.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getHostCard(), sa);
// AI won't try to grab cards that are filtered out of AI decks on purpose // AI won't try to grab cards that are filtered out of AI decks on purpose
list = CardLists.filter(list, new Predicate<Card>() { list = CardLists.filter(list, new Predicate<Card>() {

View File

@@ -57,7 +57,8 @@ public class CopyPermanentAi extends SpellAbilityAi {
if (abTgt != null) { if (abTgt != null) {
sa.resetTargets(); sa.resetTargets();
CardCollection list = CardLists.getValidCards(aiPlayer.getGame().getCardsIn(abTgt.getZone()), abTgt.getValidTgts(), source.getController(), source); CardCollection list = CardLists.getValidCards(aiPlayer.getGame().getCardsIn(abTgt.getZone()),
abTgt.getValidTgts(), source.getController(), source, sa);
list = CardLists.getTargetableCards(list, sa); list = CardLists.getTargetableCards(list, sa);
list = CardLists.filter(list, new Predicate<Card>() { list = CardLists.filter(list, new Predicate<Card>() {
@Override @Override

View File

@@ -48,7 +48,7 @@ public class CounterAi extends SpellAbilityAi {
return false; return false;
} }
if (sa.hasParam("AITgts") && (topSA.getHostCard() == null if (sa.hasParam("AITgts") && (topSA.getHostCard() == null
|| !topSA.getHostCard().isValid(sa.getParam("AITgts"), sa.getActivatingPlayer(), source))) { || !topSA.getHostCard().isValid(sa.getParam("AITgts"), sa.getActivatingPlayer(), source, sa))) {
return false; return false;
} }

View File

@@ -79,12 +79,12 @@ public class CountersMoveAi extends SpellAbilityAi {
} else { // targeted } else { // targeted
final Player player = sa.isCurse() ? ai.getOpponent() : ai; final Player player = sa.isCurse() ? ai.getOpponent() : ai;
CardCollectionView list = CardLists.getTargetableCards(player.getCardsIn(ZoneType.Battlefield), sa); CardCollectionView list = CardLists.getTargetableCards(player.getCardsIn(ZoneType.Battlefield), sa);
list = CardLists.getValidCards(list, abTgt.getValidTgts(), host.getController(), host); list = CardLists.getValidCards(list, abTgt.getValidTgts(), host.getController(), host, sa);
if (list.isEmpty() && mandatory) { if (list.isEmpty() && mandatory) {
// If there isn't any prefered cards to target, gotta choose // If there isn't any prefered cards to target, gotta choose
// non-preferred ones // non-preferred ones
list = CardLists.getTargetableCards(player.getOpponent().getCardsIn(ZoneType.Battlefield), sa); list = CardLists.getTargetableCards(player.getOpponent().getCardsIn(ZoneType.Battlefield), sa);
list = CardLists.getValidCards(list, abTgt.getValidTgts(), host.getController(), host); list = CardLists.getValidCards(list, abTgt.getValidTgts(), host.getController(), host, sa);
preferred = false; preferred = false;
} }
// Not mandatory, or the the list was regenerated and is still // Not mandatory, or the the list was regenerated and is still

View File

@@ -211,7 +211,7 @@ public class CountersPutAi extends SpellAbilityAi {
} }
}); });
list = CardLists.getValidCards(list, abTgt.getValidTgts(), source.getController(), source); list = CardLists.getValidCards(list, abTgt.getValidTgts(), source.getController(), source, sa);
if (list.size() < abTgt.getMinTargets(source, sa)) { if (list.size() < abTgt.getMinTargets(source, sa)) {
return false; return false;
@@ -365,7 +365,7 @@ public class CountersPutAi extends SpellAbilityAi {
if (abTgt != null) { if (abTgt != null) {
CardCollection list = CardCollection list =
CardLists.getValidCards(player.getCardsIn(ZoneType.Battlefield), abTgt.getValidTgts(), source.getController(), source); CardLists.getValidCards(player.getCardsIn(ZoneType.Battlefield), abTgt.getValidTgts(), source.getController(), source, sa);
if (list.size() == 0) { if (list.size() == 0) {
return false; return false;
@@ -454,7 +454,7 @@ public class CountersPutAi extends SpellAbilityAi {
} }
} else { } else {
list = CardLists.getTargetableCards(player.getCardsIn(ZoneType.Battlefield), sa); list = CardLists.getTargetableCards(player.getCardsIn(ZoneType.Battlefield), sa);
list = CardLists.getValidCards(list, abTgt.getValidTgts(), source.getController(), source); list = CardLists.getValidCards(list, abTgt.getValidTgts(), source.getController(), source, sa);
int totalTargets = list.size(); int totalTargets = list.size();
@@ -468,7 +468,7 @@ public class CountersPutAi extends SpellAbilityAi {
if (list.isEmpty() && preferred) { if (list.isEmpty() && preferred) {
// If it's required to choose targets and the list is empty, get a new list // If it's required to choose targets and the list is empty, get a new list
list = CardLists.getTargetableCards(player.getOpponent().getCardsIn(ZoneType.Battlefield), sa); list = CardLists.getTargetableCards(player.getOpponent().getCardsIn(ZoneType.Battlefield), sa);
list = CardLists.getValidCards(list, abTgt.getValidTgts(), source.getController(), source); list = CardLists.getValidCards(list, abTgt.getValidTgts(), source.getController(), source, sa);
preferred = false; preferred = false;
} }
} }

View File

@@ -51,7 +51,7 @@ public class CountersPutOrRemoveAi extends SpellAbilityAi {
List<ZoneType> zones = ZoneType.listValueOf(sa.getParamOrDefault("TgtZones", "Battlefield")); List<ZoneType> zones = ZoneType.listValueOf(sa.getParamOrDefault("TgtZones", "Battlefield"));
List<Card> validCards = CardLists.getValidCards(ai.getGame().getCardsIn(zones), List<Card> validCards = CardLists.getValidCards(ai.getGame().getCardsIn(zones),
tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getHostCard()); tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getHostCard(), sa);
if (validCards.isEmpty()) { if (validCards.isEmpty()) {
return false; return false;

View File

@@ -186,7 +186,7 @@ public class DamageAllAi extends SpellAbilityAi {
// TODO: X may be something different than X paid // TODO: X may be something different than X paid
CardCollection list = CardCollection list =
CardLists.getValidCards(player.getCardsIn(ZoneType.Battlefield), validC.split(","), source.getController(), source); CardLists.getValidCards(player.getCardsIn(ZoneType.Battlefield), validC.split(","), source.getController(), source, sa);
final Predicate<Card> filterKillable = new Predicate<Card>() { final Predicate<Card> filterKillable = new Predicate<Card>() {
@Override @Override

View File

@@ -167,7 +167,7 @@ public class DamageDealAi extends DamageAiBase {
} }
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
final Card source = sa.getHostCard(); final Card source = sa.getHostCard();
List<Card> hPlay = CardLists.getValidCards(pl.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), ai, source); List<Card> hPlay = CardLists.getValidCards(pl.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), ai, source, sa);
final List<GameObject> objects = Lists.newArrayList(sa.getTargets().getTargets()); final List<GameObject> objects = Lists.newArrayList(sa.getTargets().getTargets());
if (sa.hasParam("TargetUnique")) { if (sa.hasParam("TargetUnique")) {

View File

@@ -102,7 +102,7 @@ public class DamagePreventAi extends SpellAbilityAi {
} }
final List<Card> threatenedTargets = new ArrayList<Card>(); final List<Card> threatenedTargets = new ArrayList<Card>();
// filter AIs battlefield by what I can target // filter AIs battlefield by what I can target
List<Card> targetables = CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), ai, hostCard); List<Card> targetables = CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), ai, hostCard, sa);
targetables = CardLists.getTargetableCards(targetables, sa); targetables = CardLists.getTargetableCards(targetables, sa);
for (final Card c : targetables) { for (final Card c : targetables) {
@@ -129,7 +129,7 @@ public class DamagePreventAi extends SpellAbilityAi {
} else { } else {
// filter AIs battlefield by what I can target // filter AIs battlefield by what I can target
CardCollectionView targetables = ai.getCardsIn(ZoneType.Battlefield); CardCollectionView targetables = ai.getCardsIn(ZoneType.Battlefield);
targetables = CardLists.getValidCards(targetables, tgt.getValidTgts(), ai, hostCard); targetables = CardLists.getValidCards(targetables, tgt.getValidTgts(), ai, hostCard, sa);
targetables = CardLists.getTargetableCards(targetables, sa); targetables = CardLists.getTargetableCards(targetables, sa);
if (targetables.isEmpty()) { if (targetables.isEmpty()) {
@@ -172,8 +172,6 @@ public class DamagePreventAi extends SpellAbilityAi {
* preventDamageMandatoryTarget. * preventDamageMandatoryTarget.
* </p> * </p>
* *
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
* @param sa * @param sa
* a {@link forge.game.spellability.SpellAbility} object. * a {@link forge.game.spellability.SpellAbility} object.
* @param mandatory * @param mandatory
@@ -186,7 +184,7 @@ public class DamagePreventAi extends SpellAbilityAi {
// filter AIs battlefield by what I can target // filter AIs battlefield by what I can target
final Game game = ai.getGame(); final Game game = ai.getGame();
CardCollectionView targetables = game.getCardsIn(ZoneType.Battlefield); CardCollectionView targetables = game.getCardsIn(ZoneType.Battlefield);
targetables = CardLists.getValidCards(targetables, tgt.getValidTgts(), ai, sa.getHostCard()); targetables = CardLists.getValidCards(targetables, tgt.getValidTgts(), ai, sa.getHostCard(), sa);
final List<Card> compTargetables = CardLists.filterControlledBy(targetables, ai); final List<Card> compTargetables = CardLists.filterControlledBy(targetables, ai);
Card target = null; Card target = null;

View File

@@ -108,8 +108,6 @@ public class DebuffAi extends SpellAbilityAi {
* debuffTgtAI. * debuffTgtAI.
* </p> * </p>
* *
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
* @param sa * @param sa
* a {@link forge.game.spellability.SpellAbility} object. * a {@link forge.game.spellability.SpellAbility} object.
* @param kws * @param kws
@@ -127,7 +125,7 @@ public class DebuffAi extends SpellAbilityAi {
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
sa.resetTargets(); sa.resetTargets();
CardCollection list = getCurseCreatures(ai, sa, kws == null ? Lists.<String>newArrayList() : kws); CardCollection list = getCurseCreatures(ai, sa, kws == null ? Lists.<String>newArrayList() : kws);
list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getHostCard()); list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getHostCard(), sa);
// several uses here: // several uses here:
// 1. make human creatures lose evasion when they are attacking // 1. make human creatures lose evasion when they are attacking
@@ -171,13 +169,11 @@ public class DebuffAi extends SpellAbilityAi {
* getCurseCreatures. * getCurseCreatures.
* </p> * </p>
* *
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
* @param sa * @param sa
* a {@link forge.game.spellability.SpellAbility} object. * a {@link forge.game.spellability.SpellAbility} object.
* @param kws * @param kws
* a {@link java.util.ArrayList} object. * a {@link java.util.ArrayList} object.
* @return a {@link forge.CardList} object. * @return a CardCollection.
*/ */
private CardCollection getCurseCreatures(final Player ai, final SpellAbility sa, final List<String> kws) { private CardCollection getCurseCreatures(final Player ai, final SpellAbility sa, final List<String> kws) {
final Player opp = ai.getOpponent(); final Player opp = ai.getOpponent();
@@ -199,8 +195,6 @@ public class DebuffAi extends SpellAbilityAi {
* debuffMandatoryTarget. * debuffMandatoryTarget.
* </p> * </p>
* *
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
* @param sa * @param sa
* a {@link forge.game.spellability.SpellAbility} object. * a {@link forge.game.spellability.SpellAbility} object.
* @param mandatory * @param mandatory
@@ -209,7 +203,8 @@ public class DebuffAi extends SpellAbilityAi {
*/ */
private boolean debuffMandatoryTarget(final Player ai, final SpellAbility sa, final boolean mandatory) { private boolean debuffMandatoryTarget(final Player ai, final SpellAbility sa, final boolean mandatory) {
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
CardCollection list = CardLists.getValidCards(ai.getGame().getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getHostCard()); CardCollection list = CardLists.getValidCards(ai.getGame().getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(),
sa.getActivatingPlayer(), sa.getHostCard(), sa);
if (list.size() < tgt.getMinTargets(sa.getHostCard(), sa)) { if (list.size() < tgt.getMinTargets(sa.getHostCard(), sa)) {
sa.resetTargets(); sa.resetTargets();

View File

@@ -246,7 +246,7 @@ public class DestroyAi extends SpellAbilityAi {
sa.resetTargets(); sa.resetTargets();
CardCollection list = CardLists.getTargetableCards(ai.getGame().getCardsIn(ZoneType.Battlefield), sa); CardCollection list = CardLists.getTargetableCards(ai.getGame().getCardsIn(ZoneType.Battlefield), sa);
list = CardLists.getValidCards(list, tgt.getValidTgts(), source.getController(), source); list = CardLists.getValidCards(list, tgt.getValidTgts(), source.getController(), source, sa);
if (list.isEmpty() || list.size() < tgt.getMinTargets(sa.getHostCard(), sa)) { if (list.isEmpty() || list.size() < tgt.getMinTargets(sa.getHostCard(), sa)) {
return false; return false;

View File

@@ -35,8 +35,10 @@ public class DestroyAllAi extends SpellAbilityAi {
if (sa.hasParam("ValidCards")) { if (sa.hasParam("ValidCards")) {
valid = sa.getParam("ValidCards"); valid = sa.getParam("ValidCards");
} }
CardCollection humanlist = CardLists.getValidCards(ai.getOpponent().getCardsIn(ZoneType.Battlefield), valid.split(","), source.getController(), source); CardCollection humanlist = CardLists.getValidCards(ai.getOpponent().getCardsIn(ZoneType.Battlefield),
CardCollection computerlist = CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), valid.split(","), source.getController(), source); valid.split(","), source.getController(), source, sa);
CardCollection computerlist = CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), valid.split(","),
source.getController(), source, sa);
if (sa.usesTargeting()) { if (sa.usesTargeting()) {
sa.resetTargets(); sa.resetTargets();
@@ -94,8 +96,10 @@ public class DestroyAllAi extends SpellAbilityAi {
valid = valid.replace("X", Integer.toString(xPay)); valid = valid.replace("X", Integer.toString(xPay));
} }
CardCollection humanlist = CardLists.getValidCards(ai.getOpponent().getCardsIn(ZoneType.Battlefield), valid.split(","), source.getController(), source); CardCollection humanlist = CardLists.getValidCards(ai.getOpponent().getCardsIn(ZoneType.Battlefield),
CardCollection computerlist = CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), valid.split(","), source.getController(), source); valid.split(","), source.getController(), source, sa);
CardCollection computerlist = CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), valid.split(","),
source.getController(), source, sa);
if (sa.usesTargeting()) { if (sa.usesTargeting()) {
sa.resetTargets(); sa.resetTargets();
sa.getTargets().add(ai.getOpponent()); sa.getTargets().add(ai.getOpponent());

View File

@@ -42,7 +42,7 @@ public class DigUntilAi extends SpellAbilityAi {
} else { } else {
if (sa.hasParam("Valid")) { if (sa.hasParam("Valid")) {
final String valid = sa.getParam("Valid"); final String valid = sa.getParam("Valid");
if (CardLists.getValidCards(ai.getCardsIn(ZoneType.Library), valid.split(","), source.getController(), source).isEmpty()) { if (CardLists.getValidCards(ai.getCardsIn(ZoneType.Library), valid.split(","), source.getController(), source, sa).isEmpty()) {
return false; return false;
} }
} }

View File

@@ -74,7 +74,7 @@ public class EffectAi extends SpellAbilityAi {
} }
} else { } else {
List<Card> list = game.getCombat().getAttackers(); List<Card> list = game.getCombat().getAttackers();
list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getHostCard()); list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getHostCard(), sa);
list = CardLists.getTargetableCards(list, sa); list = CardLists.getTargetableCards(list, sa);
Card target = ComputerUtilCard.getBestCreatureAI(list); Card target = ComputerUtilCard.getBestCreatureAI(list);
if (target == null) { if (target == null) {

View File

@@ -62,7 +62,7 @@ public class MustBlockAi extends SpellAbilityAi {
if (abTgt != null) { if (abTgt != null) {
List<Card> list = CardLists.filter(ai.getOpponent().getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES); List<Card> list = CardLists.filter(ai.getOpponent().getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES);
list = CardLists.getTargetableCards(list, sa); list = CardLists.getTargetableCards(list, sa);
list = CardLists.getValidCards(list, abTgt.getValidTgts(), source.getController(), source); list = CardLists.getValidCards(list, abTgt.getValidTgts(), source.getController(), source, sa);
list = CardLists.filter(list, new Predicate<Card>() { list = CardLists.filter(list, new Predicate<Card>() {
@Override @Override
public boolean apply(final Card c) { public boolean apply(final Card c) {

View File

@@ -107,7 +107,7 @@ public class PhasesAi extends SpellAbilityAi {
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
CardCollectionView list = game.getCardsIn(ZoneType.Battlefield); CardCollectionView list = game.getCardsIn(ZoneType.Battlefield);
list = CardLists.getTargetableCards(CardLists.getValidCards(list, tgt.getValidTgts(), source.getController(), source), sa); list = CardLists.getTargetableCards(CardLists.getValidCards(list, tgt.getValidTgts(), source.getController(), source, sa), sa);
return false; return false;
} }

View File

@@ -63,7 +63,7 @@ public class PlayAi extends SpellAbilityAi {
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
if (tgt != null) { if (tgt != null) {
ZoneType zone = tgt.getZone().get(0); ZoneType zone = tgt.getZone().get(0);
cards = CardLists.getValidCards(ai.getGame().getCardsIn(zone), tgt.getValidTgts(), ai, source); cards = CardLists.getValidCards(ai.getGame().getCardsIn(zone), tgt.getValidTgts(), ai, source, sa);
if (cards.isEmpty()) { if (cards.isEmpty()) {
return false; return false;
} }
@@ -85,8 +85,6 @@ public class PlayAi extends SpellAbilityAi {
* a {@link forge.game.spellability.SpellAbility} object. * a {@link forge.game.spellability.SpellAbility} object.
* @param mandatory * @param mandatory
* a boolean. * a boolean.
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
* *
* @return a boolean. * @return a boolean.
*/ */

View File

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

View File

@@ -100,9 +100,6 @@ public class ProtectAi extends SpellAbilityAi {
* getProtectCreatures. * getProtectCreatures.
* </p> * </p>
* *
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
* @return a {@link forge.CardList} object.
*/ */
public static CardCollection getProtectCreatures(final Player ai, final SpellAbility sa) { public static CardCollection getProtectCreatures(final Player ai, final SpellAbility sa) {
final List<String> gains = ProtectEffect.getProtectionList(sa); final List<String> gains = ProtectEffect.getProtectionList(sa);
@@ -252,7 +249,7 @@ public class ProtectAi extends SpellAbilityAi {
sa.resetTargets(); sa.resetTargets();
CardCollection list = getProtectCreatures(ai, sa); CardCollection list = getProtectCreatures(ai, sa);
list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getHostCard()); list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getHostCard(), sa);
if (game.getStack().isEmpty()) { if (game.getStack().isEmpty()) {
// If the cost is tapping, don't activate before declare // If the cost is tapping, don't activate before declare
@@ -306,7 +303,7 @@ public class ProtectAi extends SpellAbilityAi {
final Game game = ai.getGame(); final Game game = ai.getGame();
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
CardCollection list = CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getHostCard()); CardCollection list = CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getHostCard(), sa);
if (list.size() < tgt.getMinTargets(sa.getHostCard(), sa)) { if (list.size() < tgt.getMinTargets(sa.getHostCard(), sa)) {
sa.resetTargets(); sa.resetTargets();

View File

@@ -240,7 +240,7 @@ public class PumpAi extends PumpAiBase {
CardCollection list; CardCollection list;
if (sa.hasParam("AILogic")) { if (sa.hasParam("AILogic")) {
if (sa.getParam("AILogic").equals("HighestPower")) { if (sa.getParam("AILogic").equals("HighestPower")) {
list = CardLists.getValidCards(CardLists.filter(game.getCardsIn(ZoneType.Battlefield), Presets.CREATURES), tgt.getValidTgts(), ai, source); list = CardLists.getValidCards(CardLists.filter(game.getCardsIn(ZoneType.Battlefield), Presets.CREATURES), tgt.getValidTgts(), ai, source, sa);
list = CardLists.getTargetableCards(list, sa); list = CardLists.getTargetableCards(list, sa);
CardLists.sortByPowerDesc(list); CardLists.sortByPowerDesc(list);
if (!list.isEmpty()) { if (!list.isEmpty()) {
@@ -274,7 +274,7 @@ public class PumpAi extends PumpAiBase {
} }
} }
list = CardLists.getValidCards(list, tgt.getValidTgts(), ai, source); list = CardLists.getValidCards(list, tgt.getValidTgts(), ai, source, sa);
if (game.getStack().isEmpty()) { if (game.getStack().isEmpty()) {
// If the cost is tapping, don't activate before declare // If the cost is tapping, don't activate before declare
// attack/block // attack/block
@@ -359,7 +359,7 @@ public class PumpAi extends PumpAiBase {
final Game game = ai.getGame(); final Game game = ai.getGame();
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
final Player opp = ai.getOpponent(); final Player opp = ai.getOpponent();
CardCollection list = CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getHostCard()); CardCollection list = CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getHostCard(), sa);
list = CardLists.getTargetableCards(list, sa); list = CardLists.getTargetableCards(list, sa);
if (list.size() < tgt.getMinTargets(sa.getHostCard(), sa)) { if (list.size() < tgt.getMinTargets(sa.getHostCard(), sa)) {

View File

@@ -115,7 +115,7 @@ public class RegenerateAi extends SpellAbilityAi {
} else { } else {
sa.resetTargets(); sa.resetTargets();
// filter AIs battlefield by what I can target // filter AIs battlefield by what I can target
List<Card> targetables = CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), ai, hostCard); List<Card> targetables = CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), ai, hostCard, sa);
targetables = CardLists.getTargetableCards(targetables, sa); targetables = CardLists.getTargetableCards(targetables, sa);
if (targetables.size() == 0) { if (targetables.size() == 0) {
@@ -184,7 +184,7 @@ public class RegenerateAi extends SpellAbilityAi {
sa.resetTargets(); sa.resetTargets();
// filter AIs battlefield by what I can target // filter AIs battlefield by what I can target
CardCollectionView targetables = game.getCardsIn(ZoneType.Battlefield); CardCollectionView targetables = game.getCardsIn(ZoneType.Battlefield);
targetables = CardLists.getValidCards(targetables, tgt.getValidTgts(), ai, hostCard); targetables = CardLists.getValidCards(targetables, tgt.getValidTgts(), ai, hostCard, sa);
targetables = CardLists.getTargetableCards(targetables, sa); targetables = CardLists.getTargetableCards(targetables, sa);
final List<Card> compTargetables = CardLists.filterControlledBy(targetables, ai); final List<Card> compTargetables = CardLists.filterControlledBy(targetables, ai);

View File

@@ -50,7 +50,7 @@ public class RegenerateAllAi extends SpellAbilityAi {
} }
CardCollectionView list = game.getCardsIn(ZoneType.Battlefield); CardCollectionView list = game.getCardsIn(ZoneType.Battlefield);
list = CardLists.getValidCards(list, valid.split(","), hostCard.getController(), hostCard); list = CardLists.getValidCards(list, valid.split(","), hostCard.getController(), hostCard, sa);
list = CardLists.filter(list, CardPredicates.isController(ai)); list = CardLists.filter(list, CardPredicates.isController(ai));
if (list.size() == 0) { if (list.size() == 0) {

View File

@@ -72,7 +72,7 @@ public class SacrificeAi extends SpellAbilityAi {
final int amount = AbilityUtils.calculateAmount(sa.getHostCard(), num, sa); final int amount = AbilityUtils.calculateAmount(sa.getHostCard(), num, sa);
List<Card> list = List<Card> list =
CardLists.getValidCards(ai.getOpponent().getCardsIn(ZoneType.Battlefield), valid.split(","), sa.getActivatingPlayer(), sa.getHostCard()); CardLists.getValidCards(ai.getOpponent().getCardsIn(ZoneType.Battlefield), valid.split(","), sa.getActivatingPlayer(), sa.getHostCard(), sa);
for (Card c : list) { for (Card c : list) {
if (c.hasSVar("SacMe") && Integer.parseInt(c.getSVar("SacMe")) > 3) { if (c.hasSVar("SacMe") && Integer.parseInt(c.getSVar("SacMe")) > 3) {
return false; return false;
@@ -126,7 +126,7 @@ public class SacrificeAi extends SpellAbilityAi {
} }
List<Card> humanList = List<Card> humanList =
CardLists.getValidCards(opp.getCardsIn(ZoneType.Battlefield), valid.split(","), sa.getActivatingPlayer(), sa.getHostCard()); CardLists.getValidCards(opp.getCardsIn(ZoneType.Battlefield), valid.split(","), sa.getActivatingPlayer(), sa.getHostCard(), sa);
// Since all of the cards have remAIDeck:True, I enabled 1 for 1 // Since all of the cards have remAIDeck:True, I enabled 1 for 1
// (or X for X) trades for special decks // (or X for X) trades for special decks
@@ -135,7 +135,7 @@ public class SacrificeAi extends SpellAbilityAi {
} }
} else if (defined.equals("You")) { } else if (defined.equals("You")) {
List<Card> computerList = List<Card> computerList =
CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), valid.split(","), sa.getActivatingPlayer(), sa.getHostCard()); CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), valid.split(","), sa.getActivatingPlayer(), sa.getHostCard(), sa);
for (Card c : computerList) { for (Card c : computerList) {
if (c.hasSVar("SacMe") || ComputerUtilCard.evaluateCreature(c) <= 135) { if (c.hasSVar("SacMe") || ComputerUtilCard.evaluateCreature(c) <= 135) {
return true; return true;

View File

@@ -38,9 +38,9 @@ public class SacrificeAllAi extends SpellAbilityAi {
} }
CardCollection humanlist = CardCollection humanlist =
CardLists.getValidCards(ai.getOpponent().getCardsIn(ZoneType.Battlefield), valid.split(","), source.getController(), source); CardLists.getValidCards(ai.getOpponent().getCardsIn(ZoneType.Battlefield), valid.split(","), source.getController(), source, sa);
CardCollection computerlist = CardCollection computerlist =
CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), valid.split(","), source.getController(), source); CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), valid.split(","), source.getController(), source, sa);
if (abCost != null) { if (abCost != null) {
// AI currently disabled for some costs // AI currently disabled for some costs

View File

@@ -29,12 +29,11 @@ public abstract class TapAiBase extends SpellAbilityAi {
* tapTargetList. * tapTargetList.
* </p> * </p>
* *
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
* @param sa * @param sa
* a {@link forge.game.spellability.SpellAbility} object. * a {@link forge.game.spellability.SpellAbility} object.
* @param tapList * @param tapList
* a {@link forge.CardList} object. * a CardCollection object.
* @param mandatory * @param mandatory
* a boolean. * a boolean.
* @return a boolean. * @return a boolean.
@@ -105,8 +104,6 @@ public abstract class TapAiBase extends SpellAbilityAi {
* a {@link forge.game.card.Card} object. * a {@link forge.game.card.Card} object.
* @param tgt * @param tgt
* a {@link forge.game.spellability.TargetRestrictions} object. * a {@link forge.game.spellability.TargetRestrictions} object.
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
* @param sa * @param sa
* a {@link forge.game.spellability.SpellAbility} object. * a {@link forge.game.spellability.SpellAbility} object.
* @param mandatory * @param mandatory
@@ -117,7 +114,7 @@ public abstract class TapAiBase extends SpellAbilityAi {
final Player opp = ai.getOpponent(); final Player opp = ai.getOpponent();
final Game game = ai.getGame(); final Game game = ai.getGame();
CardCollection tapList = CardLists.filterControlledBy(game.getCardsIn(ZoneType.Battlefield), ai.getOpponents()); CardCollection tapList = CardLists.filterControlledBy(game.getCardsIn(ZoneType.Battlefield), ai.getOpponents());
tapList = CardLists.getValidCards(tapList, tgt.getValidTgts(), source.getController(), source); tapList = CardLists.getValidCards(tapList, tgt.getValidTgts(), source.getController(), source, sa);
tapList = CardLists.getTargetableCards(tapList, sa); tapList = CardLists.getTargetableCards(tapList, sa);
tapList = CardLists.filter(tapList, Presets.UNTAPPED); tapList = CardLists.filter(tapList, Presets.UNTAPPED);
tapList = CardLists.filter(tapList, new Predicate<Card>() { tapList = CardLists.filter(tapList, new Predicate<Card>() {
@@ -139,7 +136,7 @@ public abstract class TapAiBase extends SpellAbilityAi {
//use broader approach when the cost is a positive thing //use broader approach when the cost is a positive thing
if (tapList.isEmpty() && ComputerUtil.activateForCost(sa, ai)) { if (tapList.isEmpty() && ComputerUtil.activateForCost(sa, ai)) {
tapList = CardLists.filterControlledBy(game.getCardsIn(ZoneType.Battlefield), ai.getOpponents()); tapList = CardLists.filterControlledBy(game.getCardsIn(ZoneType.Battlefield), ai.getOpponents());
tapList = CardLists.getValidCards(tapList, tgt.getValidTgts(), source.getController(), source); tapList = CardLists.getValidCards(tapList, tgt.getValidTgts(), source.getController(), source, sa);
tapList = CardLists.getTargetableCards(tapList, sa); tapList = CardLists.getTargetableCards(tapList, sa);
tapList = CardLists.filter(tapList, new Predicate<Card>() { tapList = CardLists.filter(tapList, new Predicate<Card>() {
@Override @Override
@@ -253,8 +250,6 @@ public abstract class TapAiBase extends SpellAbilityAi {
* tapUnpreferredTargeting. * tapUnpreferredTargeting.
* </p> * </p>
* *
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
* @param sa * @param sa
* a {@link forge.game.spellability.SpellAbility} object. * a {@link forge.game.spellability.SpellAbility} object.
* @param mandatory * @param mandatory
@@ -266,7 +261,7 @@ public abstract class TapAiBase extends SpellAbilityAi {
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
final Game game = ai.getGame(); final Game game = ai.getGame();
CardCollection list = CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), source.getController(), source); CardCollection list = CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), source.getController(), source, sa);
list = CardLists.getTargetableCards(list, sa); list = CardLists.getTargetableCards(list, sa);
// try to tap anything controlled by the computer // try to tap anything controlled by the computer
@@ -281,7 +276,7 @@ public abstract class TapAiBase extends SpellAbilityAi {
// filter by enchantments and planeswalkers, their tapped state doesn't matter. // filter by enchantments and planeswalkers, their tapped state doesn't matter.
final String[] tappablePermanents = { "Enchantment", "Planeswalker" }; final String[] tappablePermanents = { "Enchantment", "Planeswalker" };
tapList = CardLists.getValidCards(list, tappablePermanents, source.getController(), source); tapList = CardLists.getValidCards(list, tappablePermanents, source.getController(), source, sa);
if (tapTargetList(ai, sa, tapList, mandatory)) { if (tapTargetList(ai, sa, tapList, mandatory)) {
return true; return true;

View File

@@ -181,7 +181,7 @@ public class TokenAi extends SpellAbilityAi {
} else { } else {
//Flash Foliage //Flash Foliage
CardCollection list = CardLists.filterControlledBy(game.getCardsIn(ZoneType.Battlefield), ai.getOpponents()); CardCollection list = CardLists.filterControlledBy(game.getCardsIn(ZoneType.Battlefield), ai.getOpponents());
list = CardLists.getValidCards(list, tgt.getValidTgts(), source.getController(), source); list = CardLists.getValidCards(list, tgt.getValidTgts(), source.getController(), source, sa);
list = CardLists.getTargetableCards(list, sa); list = CardLists.getTargetableCards(list, sa);
CardCollection betterList = CardLists.filter(list, new Predicate<Card>() { CardCollection betterList = CardLists.filter(list, new Predicate<Card>() {
@Override @Override
@@ -233,14 +233,14 @@ public class TokenAi extends SpellAbilityAi {
num = (num == null) ? "1" : num; num = (num == null) ? "1" : num;
final int nToSac = AbilityUtils.calculateAmount(topStack.getHostCard(), num, topStack); final int nToSac = AbilityUtils.calculateAmount(topStack.getHostCard(), num, topStack);
CardCollection list = CardCollection list =
CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), valid.split(","), opp, topStack.getHostCard()); CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), valid.split(","), opp, topStack.getHostCard(), sa);
list = CardLists.filter(list, CardPredicates.canBeSacrificedBy(topStack)); list = CardLists.filter(list, CardPredicates.canBeSacrificedBy(topStack));
if (!list.isEmpty() && nTokens > 0 && list.size() == nToSac) { //only care about saving single creature for now if (!list.isEmpty() && nTokens > 0 && list.size() == nToSac) { //only care about saving single creature for now
ComputerUtilCard.sortByEvaluateCreature(list); ComputerUtilCard.sortByEvaluateCreature(list);
Card token = spawnToken(ai, sa); Card token = spawnToken(ai, sa);
if (token != null) { if (token != null) {
list.add(token); list.add(token);
list = CardLists.getValidCards(list, valid.split(","), ai.getOpponent(), topStack.getHostCard()); list = CardLists.getValidCards(list, valid.split(","), ai.getOpponent(), topStack.getHostCard(), sa);
list = CardLists.filter(list, CardPredicates.canBeSacrificedBy(topStack)); list = CardLists.filter(list, CardPredicates.canBeSacrificedBy(topStack));
if (ComputerUtilCard.evaluateCreature(token) < ComputerUtilCard.evaluateCreature(list.get(0)) if (ComputerUtilCard.evaluateCreature(token) < ComputerUtilCard.evaluateCreature(list.get(0))
&& list.contains(token)) { && list.contains(token)) {

View File

@@ -109,8 +109,6 @@ public class UntapAi extends SpellAbilityAi {
* *
* @param tgt * @param tgt
* a {@link forge.game.spellability.TargetRestrictions} object. * a {@link forge.game.spellability.TargetRestrictions} object.
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
* @param sa * @param sa
* a {@link forge.game.spellability.SpellAbility} object. * a {@link forge.game.spellability.SpellAbility} object.
* @param mandatory * @param mandatory
@@ -127,7 +125,7 @@ public class UntapAi extends SpellAbilityAi {
} }
CardCollection list = CardLists.getTargetableCards(targetController.getCardsIn(ZoneType.Battlefield), sa); CardCollection list = CardLists.getTargetableCards(targetController.getCardsIn(ZoneType.Battlefield), sa);
list = CardLists.getValidCards(list, tgt.getValidTgts(), source.getController(), source); list = CardLists.getValidCards(list, tgt.getValidTgts(), source.getController(), source, sa);
if (list.isEmpty()) { if (list.isEmpty()) {
return false; return false;
@@ -137,7 +135,7 @@ public class UntapAi extends SpellAbilityAi {
// filter out enchantments and planeswalkers, their tapped state doesn't // filter out enchantments and planeswalkers, their tapped state doesn't
// matter. // matter.
final String[] tappablePermanents = { "Creature", "Land", "Artifact" }; final String[] tappablePermanents = { "Creature", "Land", "Artifact" };
untapList = CardLists.getValidCards(untapList, tappablePermanents, source.getController(), source); untapList = CardLists.getValidCards(untapList, tappablePermanents, source.getController(), source, sa);
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getHostCard(), sa)) { while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getHostCard(), sa)) {
Card choice = null; Card choice = null;
@@ -199,8 +197,6 @@ public class UntapAi extends SpellAbilityAi {
* untapUnpreferredTargeting. * untapUnpreferredTargeting.
* </p> * </p>
* *
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
* @param sa * @param sa
* a {@link forge.game.spellability.SpellAbility} object. * a {@link forge.game.spellability.SpellAbility} object.
* @param mandatory * @param mandatory
@@ -211,13 +207,14 @@ public class UntapAi extends SpellAbilityAi {
final Card source = sa.getHostCard(); final Card source = sa.getHostCard();
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
CardCollection list = CardLists.getValidCards(sa.getActivatingPlayer().getGame().getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), source.getController(), source); CardCollection list = CardLists.getValidCards(source.getGame().getCardsIn(ZoneType.Battlefield),
tgt.getValidTgts(), source.getController(), source, sa);
list = CardLists.getTargetableCards(list, sa); list = CardLists.getTargetableCards(list, sa);
// filter by enchantments and planeswalkers, their tapped state doesn't // filter by enchantments and planeswalkers, their tapped state doesn't
// matter. // matter.
final String[] tappablePermanents = { "Enchantment", "Planeswalker" }; final String[] tappablePermanents = { "Enchantment", "Planeswalker" };
CardCollection tapList = CardLists.getValidCards(list, tappablePermanents, source.getController(), source); CardCollection tapList = CardLists.getValidCards(list, tappablePermanents, source.getController(), source, sa);
if (untapTargetList(source, tgt, sa, mandatory, tapList)) { if (untapTargetList(source, tgt, sa, mandatory, tapList)) {
return true; return true;

View File

@@ -27,7 +27,7 @@ public class UntapAllAi extends SpellAbilityAi {
if (sa.hasParam("ValidCards")) { if (sa.hasParam("ValidCards")) {
valid = sa.getParam("ValidCards"); valid = sa.getParam("ValidCards");
} }
list = CardLists.getValidCards(list, valid.split(","), source.getController(), source); list = CardLists.getValidCards(list, valid.split(","), source.getController(), source, sa);
return !list.isEmpty(); return !list.isEmpty();
} }
return false; return false;

View File

@@ -132,7 +132,7 @@ public abstract class CardTraitBase extends GameObject implements IHasCardView {
public static boolean matchesValid(final Object o, final String[] valids, final Card srcCard) { public static boolean matchesValid(final Object o, final String[] valids, final Card srcCard) {
if (o instanceof GameEntity) { if (o instanceof GameEntity) {
final GameEntity c = (GameEntity) o; final GameEntity c = (GameEntity) o;
return c.isValid(valids, srcCard.getController(), srcCard); return c.isValid(valids, srcCard.getController(), srcCard, null);
} }
return false; return false;
@@ -240,7 +240,7 @@ public abstract class CardTraitBase extends GameObject implements IHasCardView {
} }
} }
list = CardLists.getValidCards(list, sIsPresent.split(","), this.getHostCard().getController(), this.getHostCard()); list = CardLists.getValidCards(list, sIsPresent.split(","), this.getHostCard().getController(), this.getHostCard(), null);
int right = 1; int right = 1;
final String rightString = presentCompare.substring(2); final String rightString = presentCompare.substring(2);
@@ -281,7 +281,7 @@ public abstract class CardTraitBase extends GameObject implements IHasCardView {
} }
} }
list = CardLists.getValidCards(list, sIsPresent.split(","), this.getHostCard().getController(), this.getHostCard()); list = CardLists.getValidCards(list, sIsPresent.split(","), this.getHostCard().getController(), this.getHostCard(), null);
int right = 1; int right = 1;
final String rightString = presentCompare.substring(2); final String rightString = presentCompare.substring(2);

View File

@@ -19,11 +19,12 @@ public abstract class GameObject {
* the source controller * the source controller
* @param source * @param source
* the source * the source
* @param spellAbility
* @return true, if is valid * @return true, if is valid
*/ */
public boolean isValid(final String[] restrictions, final Player sourceController, final Card source) { public boolean isValid(final String[] restrictions, final Player sourceController, final Card source, SpellAbility spellAbility) {
for (final String restriction : restrictions) { for (final String restriction : restrictions) {
if (this.isValid(restriction, sourceController, source)) { if (this.isValid(restriction, sourceController, source, spellAbility)) {
return true; return true;
} }
} }
@@ -39,9 +40,10 @@ public abstract class GameObject {
* the source controller * the source controller
* @param source * @param source
* the source * the source
* @param spellAbility
* @return true, if is valid * @return true, if is valid
*/ */
public boolean isValid(final String restriction, final Player sourceController, final Card source) { public boolean isValid(final String restriction, final Player sourceController, final Card source, SpellAbility spellAbility) {
return false; return false;
} }
@@ -54,9 +56,10 @@ public abstract class GameObject {
* the source controller * the source controller
* @param source * @param source
* the source * the source
* @param spellAbility
* @return true, if successful * @return true, if successful
*/ */
public boolean hasProperty(final String property, final Player sourceController, final Card source) { public boolean hasProperty(final String property, final Player sourceController, final Card source, SpellAbility spellAbility) {
return false; return false;
} }
} }

View File

@@ -274,17 +274,17 @@ public class AbilityUtils {
} }
else if (defined.startsWith("Valid ")) { else if (defined.startsWith("Valid ")) {
String validDefined = defined.substring("Valid ".length()); String validDefined = defined.substring("Valid ".length());
list = CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), validDefined.split(","), hostCard.getController(), hostCard); list = CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), validDefined.split(","), hostCard.getController(), hostCard, sa);
} }
else if (defined.startsWith("ValidAll ")) { else if (defined.startsWith("ValidAll ")) {
String validDefined = defined.substring("ValidAll ".length()); String validDefined = defined.substring("ValidAll ".length());
list = CardLists.getValidCards(game.getCardsInGame(), validDefined.split(","), hostCard.getController(), hostCard); list = CardLists.getValidCards(game.getCardsInGame(), validDefined.split(","), hostCard.getController(), hostCard, sa);
} }
else if (defined.startsWith("Valid")) { else if (defined.startsWith("Valid")) {
String[] s = defined.split(" "); String[] s = defined.split(" ");
String zone = s[0].substring("Valid".length()); String zone = s[0].substring("Valid".length());
String validDefined = s[1]; String validDefined = s[1];
list = CardLists.getValidCards(game.getCardsIn(ZoneType.smartValueOf(zone)), validDefined.split(","), hostCard.getController(), hostCard); list = CardLists.getValidCards(game.getCardsIn(ZoneType.smartValueOf(zone)), validDefined.split(","), hostCard.getController(), hostCard, sa);
} }
else { else {
return cards; return cards;
@@ -432,7 +432,7 @@ public class AbilityUtils {
else if (hType.startsWith("Property") && ability instanceof SpellAbility) { else if (hType.startsWith("Property") && ability instanceof SpellAbility) {
String defined = hType.split("Property")[1]; String defined = hType.split("Property")[1];
for (Player p : game.getPlayersInTurnOrder()) { for (Player p : game.getPlayersInTurnOrder()) {
if (p.hasProperty(defined, ((SpellAbility)ability).getActivatingPlayer(), ability.getHostCard())) { if (p.hasProperty(defined, ((SpellAbility)ability).getActivatingPlayer(), ability.getHostCard(), (SpellAbility)ability)) {
players.add(p); players.add(p);
} }
} }
@@ -785,7 +785,7 @@ public class AbilityUtils {
String var = sa.getParam("AbilityCount"); String var = sa.getParam("AbilityCount");
valid = valid.replace(var, Integer.toString(calculateAmount(source, var, sa))); valid = valid.replace(var, Integer.toString(calculateAmount(source, var, sa)));
} }
return CardLists.getValidCards(list, valid.split(","), sa.getActivatingPlayer(), source); return CardLists.getValidCards(list, valid.split(","), sa.getActivatingPlayer(), source, sa);
} }
/** /**
@@ -1106,7 +1106,7 @@ public class AbilityUtils {
} }
else { else {
for (Player p : game.getPlayersInTurnOrder()) { for (Player p : game.getPlayersInTurnOrder()) {
if (p.isValid(defined, sa.getActivatingPlayer(), sa.getHostCard())) { if (p.isValid(defined, sa.getActivatingPlayer(), sa.getHostCard(), null)) {
players.add(p); players.add(p);
} }
} }

View File

@@ -142,7 +142,7 @@ public class AnimateAllEffect extends AnimateEffectBase {
list = tgtPlayers.get(0).getCardsIn(ZoneType.Battlefield); list = tgtPlayers.get(0).getCardsIn(ZoneType.Battlefield);
} }
list = CardLists.getValidCards(list, valid.split(","), host.getController(), host); list = CardLists.getValidCards(list, valid.split(","), host.getController(), host, sa);
for (final Card c : list) { for (final Card c : list) {
doAnimate(c, sa, power, toughness, types, removeTypes, finalDesc, doAnimate(c, sa, power, toughness, types, removeTypes, finalDesc,

View File

@@ -84,8 +84,6 @@ public class AttachEffect extends SpellAbilityEffect {
* the card * the card
* @param o * @param o
* the o * the o
* @param af
* the af
*/ */
public static void handleAttachment(final Card card, final Object o, final SpellAbility sa) { public static void handleAttachment(final Card card, final Object o, final SpellAbility sa) {
@@ -126,8 +124,6 @@ public class AttachEffect extends SpellAbilityEffect {
* the card * the card
* @param tgt * @param tgt
* the tgt * the tgt
* @param gainControl
* the gain control
*/ */
public static void handleAura(final Card card, final GameEntity tgt) { public static void handleAura(final Card card, final GameEntity tgt) {
if (card.isEnchanting()) { if (card.isEnchanting()) {
@@ -196,7 +192,7 @@ public class AttachEffect extends SpellAbilityEffect {
final FCollection<Player> players = new FCollection<Player>(); final FCollection<Player> players = new FCollection<Player>();
for (Player player : game.getPlayers()) { for (Player player : game.getPlayers()) {
if (player.isValid(tgt.getValidTgts(), aura.getActivatingPlayer(), source)) { if (player.isValid(tgt.getValidTgts(), aura.getActivatingPlayer(), source, null)) {
players.add(player); players.add(player);
} }
} }
@@ -208,7 +204,7 @@ public class AttachEffect extends SpellAbilityEffect {
} }
else { else {
CardCollectionView list = game.getCardsIn(tgt.getZone()); CardCollectionView list = game.getCardsIn(tgt.getZone());
list = CardLists.getValidCards(list, tgt.getValidTgts(), aura.getActivatingPlayer(), source); list = CardLists.getValidCards(list, tgt.getValidTgts(), aura.getActivatingPlayer(), source, aura);
if (list.isEmpty()) { if (list.isEmpty()) {
return false; return false;
} }

View File

@@ -112,10 +112,10 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
if (null != newTarget) { if (null != newTarget) {
if (sa.hasParam("TargetRestriction")) { if (sa.hasParam("TargetRestriction")) {
if (newTarget.getFirstTargetedCard() != null && newTarget.getFirstTargetedCard(). if (newTarget.getFirstTargetedCard() != null && newTarget.getFirstTargetedCard().
isValid(sa.getParam("TargetRestriction").split(","), activator, sa.getHostCard())) { isValid(sa.getParam("TargetRestriction").split(","), activator, sa.getHostCard(), sa)) {
changingTgtSI.updateTarget(newTarget); changingTgtSI.updateTarget(newTarget);
} else if (newTarget.getFirstTargetedPlayer() != null && newTarget.getFirstTargetedPlayer(). } else if (newTarget.getFirstTargetedPlayer() != null && newTarget.getFirstTargetedPlayer().
isValid(sa.getParam("TargetRestriction").split(","), activator, sa.getHostCard())) { isValid(sa.getParam("TargetRestriction").split(","), activator, sa.getHostCard(), sa)) {
changingTgtSI.updateTarget(newTarget); changingTgtSI.updateTarget(newTarget);
} }
} else { } else {

View File

@@ -118,7 +118,7 @@ public class CopyPermanentEffect extends SpellAbilityEffect {
final PaperCard cp = Aggregates.random(copysource); final PaperCard cp = Aggregates.random(copysource);
Card possibleCard = Card.fromPaperCard(cp, sa.getActivatingPlayer()); // Need to temporarily set the Owner so the Game is set Card possibleCard = Card.fromPaperCard(cp, sa.getActivatingPlayer()); // Need to temporarily set the Owner so the Game is set
if (possibleCard.isValid(valid, hostCard.getController(), hostCard)) { if (possibleCard.isValid(valid, hostCard.getController(), hostCard, sa)) {
choice.add(possibleCard); choice.add(possibleCard);
copysource.remove(cp); copysource.remove(cp);
ncopied -= 1; ncopied -= 1;

View File

@@ -31,7 +31,7 @@ public class CounterEffect extends SpellAbilityEffect {
continue; continue;
} }
if (sa.hasParam("AllValid")) { if (sa.hasParam("AllValid")) {
if (!spell.getHostCard().isValid(sa.getParam("AllValid"), sa.getActivatingPlayer(), sa.getHostCard())) { if (!spell.getHostCard().isValid(sa.getParam("AllValid"), sa.getActivatingPlayer(), sa.getHostCard(), sa)) {
continue; continue;
} }
} }
@@ -76,7 +76,7 @@ public class CounterEffect extends SpellAbilityEffect {
continue; continue;
} }
if (sa.hasParam("AllValid")) { if (sa.hasParam("AllValid")) {
if (!spell.getHostCard().isValid(sa.getParam("AllValid"), sa.getActivatingPlayer(), sa.getHostCard())) { if (!spell.getHostCard().isValid(sa.getParam("AllValid"), sa.getActivatingPlayer(), sa.getHostCard(), sa)) {
continue; continue;
} }
} }
@@ -145,7 +145,6 @@ public class CounterEffect extends SpellAbilityEffect {
* @param si * @param si
* a {@link forge.game.spellability.SpellAbilityStackInstance} * a {@link forge.game.spellability.SpellAbilityStackInstance}
* object. * object.
* @param sa
*/ */
private static void removeFromStack(final SpellAbility tgtSA, private static void removeFromStack(final SpellAbility tgtSA,
final SpellAbility srcSA, final SpellAbilityStackInstance si) { final SpellAbility srcSA, final SpellAbilityStackInstance si) {

View File

@@ -32,7 +32,7 @@ public class DamagePreventAllEffect extends SpellAbilityEffect {
if (!players.equals("")) { if (!players.equals("")) {
for (final Player p : game.getPlayers()) { for (final Player p : game.getPlayers()) {
if (p.isValid(players, source.getController(), source)) { if (p.isValid(players, source.getController(), source, sa)) {
p.addPreventNextDamage(numDam); p.addPreventNextDamage(numDam);
} }
} }

View File

@@ -182,9 +182,9 @@ public class DigEffect extends SpellAbilityEffect {
if (changeValid.contains("ChosenType")) { if (changeValid.contains("ChosenType")) {
changeValid = changeValid.replace("ChosenType", host.getChosenType()); changeValid = changeValid.replace("ChosenType", host.getChosenType());
} }
valid = CardLists.getValidCards(top, changeValid.split(","), host.getController(), host); valid = CardLists.getValidCards(top, changeValid.split(","), host.getController(), host, sa);
if (!andOrValid.equals("")) { if (!andOrValid.equals("")) {
andOrCards = CardLists.getValidCards(top, andOrValid.split(","), host.getController(), host); andOrCards = CardLists.getValidCards(top, andOrValid.split(","), host.getController(), host, sa);
andOrCards.removeAll((Collection<?>)valid); andOrCards.removeAll((Collection<?>)valid);
valid.addAll(andOrCards); valid.addAll(andOrCards);
} }
@@ -275,10 +275,10 @@ public class DigEffect extends SpellAbilityEffect {
valid.remove(chosen); valid.remove(chosen);
if (!andOrValid.equals("")) { if (!andOrValid.equals("")) {
andOrCards.remove(chosen); andOrCards.remove(chosen);
if (!chosen.isValid(andOrValid.split(","), host.getController(), host)) { if (!chosen.isValid(andOrValid.split(","), host.getController(), host, sa)) {
valid = new CardCollection(andOrCards); valid = new CardCollection(andOrCards);
} }
else if (!chosen.isValid(changeValid.split(","), host.getController(), host)) { else if (!chosen.isValid(changeValid.split(","), host.getController(), host, sa)) {
valid.removeAll((Collection<?>)andOrCards); valid.removeAll((Collection<?>)andOrCards);
} }
} }

View File

@@ -124,7 +124,7 @@ public class DigUntilEffect extends SpellAbilityEffect {
for (int i = 0; i < maxToDig; i++) { for (int i = 0; i < maxToDig; i++) {
final Card c = library.get(i); final Card c = library.get(i);
revealed.add(c); revealed.add(c);
if (c.isValid(type, sa.getActivatingPlayer(), host)) { if (c.isValid(type, sa.getActivatingPlayer(), host, sa)) {
found.add(c); found.add(c);
if (remember) { if (remember) {
host.addRemembered(c); host.addRemembered(c);

View File

@@ -210,7 +210,7 @@ public class DiscardEffect extends SpellAbilityEffect {
valid = valid.replace("X", Integer.toString(AbilityUtils.calculateAmount(source, "X", sa))); valid = valid.replace("X", Integer.toString(AbilityUtils.calculateAmount(source, "X", sa)));
} }
List<Card> dPChHand = CardLists.getValidCards(dPHand, valid.split(","), source.getController(), source); List<Card> dPChHand = CardLists.getValidCards(dPHand, valid.split(","), source.getController(), source, sa);
dPChHand = CardLists.filter(dPChHand, Presets.NON_TOKEN); dPChHand = CardLists.filter(dPChHand, Presets.NON_TOKEN);
// Reveal cards that will be discarded? // Reveal cards that will be discarded?
for (final Card c : dPChHand) { for (final Card c : dPChHand) {
@@ -230,7 +230,7 @@ public class DiscardEffect extends SpellAbilityEffect {
} }
final String valid = sa.hasParam("DiscardValid") ? sa.getParam("DiscardValid") : "Card"; final String valid = sa.hasParam("DiscardValid") ? sa.getParam("DiscardValid") : "Card";
String[] dValid = valid.split(","); String[] dValid = valid.split(",");
CardCollection validCards = CardLists.getValidCards(dPHand, dValid, source.getController(), source); CardCollection validCards = CardLists.getValidCards(dPHand, dValid, source.getController(), source, sa);
Player chooser = p; Player chooser = p;
if (mode.equals("RevealYouChoose")) { if (mode.equals("RevealYouChoose")) {
@@ -267,6 +267,5 @@ public class DiscardEffect extends SpellAbilityEffect {
source.addRemembered(c); source.addRemembered(c);
} }
} }
} // discardResolve() } // discardResolve()
} }

View File

@@ -103,7 +103,7 @@ public class PlayEffect extends SpellAbilityEffect {
// Need to temporarily set the Owner so the Game is set // Need to temporarily set the Owner so the Game is set
possibleCard.setOwner(sa.getActivatingPlayer()); possibleCard.setOwner(sa.getActivatingPlayer());
if (possibleCard.isValid(valid, source.getController(), source)) { if (possibleCard.isValid(valid, source.getController(), source, sa)) {
choice.add(possibleCard); choice.add(possibleCard);
copysource.remove(cp); copysource.remove(cp);
ncopied -= 1; ncopied -= 1;

View File

@@ -28,7 +28,7 @@ public class RegenerateAllEffect extends SpellAbilityEffect {
} }
CardCollectionView list = game.getCardsIn(ZoneType.Battlefield); CardCollectionView list = game.getCardsIn(ZoneType.Battlefield);
list = CardLists.getValidCards(list, valid.split(","), hostCard.getController(), hostCard); list = CardLists.getValidCards(list, valid.split(","), hostCard.getController(), hostCard, sa);
for (final Card c : list) { for (final Card c : list) {
final GameCommand untilEOT = new GameCommand() { final GameCommand untilEOT = new GameCommand() {

View File

@@ -60,9 +60,7 @@ public class RepeatEffect extends SpellAbilityEffect {
* checkRepeatConditions. * checkRepeatConditions.
* </p> * </p>
* *
* @param AF * @param sa
* a {@link forge.game.ability.AbilityFactory} object.
* @param SA
* a {@link forge.game.spellability.SpellAbility} object. * a {@link forge.game.spellability.SpellAbility} object.
*/ */
private static boolean checkRepeatConditions(final SpellAbility sa) { private static boolean checkRepeatConditions(final SpellAbility sa) {
@@ -85,7 +83,7 @@ public class RepeatEffect extends SpellAbilityEffect {
else { else {
list = game.getCardsIn(ZoneType.Battlefield); list = game.getCardsIn(ZoneType.Battlefield);
} }
list = CardLists.getValidCards(list, repeatPresent.split(","), sa.getActivatingPlayer(), sa.getHostCard()); list = CardLists.getValidCards(list, repeatPresent.split(","), sa.getActivatingPlayer(), sa.getHostCard(), sa);
int right; int right;
final String rightString = repeatCompare.substring(2); final String rightString = repeatCompare.substring(2);

View File

@@ -43,7 +43,7 @@ public class RestartGameEffect extends SpellAbilityEffect {
List<Card> filteredCards = null; List<Card> filteredCards = null;
if (leaveZone != null) { if (leaveZone != null) {
filteredCards = CardLists.filter(p.getCardsIn(leaveZone), filteredCards = CardLists.filter(p.getCardsIn(leaveZone),
CardPredicates.restriction(leaveRestriction.split(","), p, sa.getHostCard())); CardPredicates.restriction(leaveRestriction.split(","), p, sa.getHostCard(), null));
newLibrary.addAll(filteredCards); newLibrary.addAll(filteredCards);
} }
playerLibraries.put(p, newLibrary); playerLibraries.put(p, newLibrary);

View File

@@ -158,7 +158,7 @@ public class UnattachAllEffect extends SpellAbilityEffect {
String valid = sa.getParam("UnattachValid"); String valid = sa.getParam("UnattachValid");
CardCollectionView unattachList = game.getCardsIn(ZoneType.Battlefield); CardCollectionView unattachList = game.getCardsIn(ZoneType.Battlefield);
unattachList = CardLists.getValidCards(unattachList, valid.split(","), source.getController(), source); unattachList = CardLists.getValidCards(unattachList, valid.split(","), source.getController(), source, sa);
for (final Card c : unattachList) { for (final Card c : unattachList) {
handleUnattachment((GameEntity) o, c); handleUnattachment((GameEntity) o, c);
} }

View File

@@ -43,7 +43,7 @@ public class UntapAllEffect extends SpellAbilityEffect {
} }
list = list2; list = list2;
} }
list = CardLists.getValidCards(list, valid.split(","), card.getController(), card); list = CardLists.getValidCards(list, valid.split(","), card.getController(), card, sa);
boolean remember = sa.hasParam("RememberUntapped"); boolean remember = sa.hasParam("RememberUntapped");
for (Card c : list) { for (Card c : list) {

View File

@@ -2328,7 +2328,7 @@ public class Card extends GameEntity implements Comparable<Card> {
final String parse = getKeywords().get(keywordPosition); final String parse = getKeywords().get(keywordPosition);
final String[] k = parse.split(" ", 2); final String[] k = parse.split(" ", 2);
final String[] restrictions = k[1].split(","); final String[] restrictions = k[1].split(",");
if (c.isValid(restrictions, getController(), this)) { if (c.isValid(restrictions, getController(), this, null)) {
getGame().getGameLog().add(GameLogEntryType.STACK_RESOLVE, "Trying to equip " + c.getName() + " but it can't be equipped."); getGame().getGameLog().add(GameLogEntryType.STACK_RESOLVE, "Trying to equip " + c.getName() + " but it can't be equipped.");
return; return;
} }
@@ -3570,7 +3570,7 @@ public class Card extends GameEntity implements Comparable<Card> {
// Takes one argument like Permanent.Blue+withFlying // Takes one argument like Permanent.Blue+withFlying
@Override @Override
public final boolean isValid(final String restriction, final Player sourceController, final Card source) { public final boolean isValid(final String restriction, final Player sourceController, final Card source, SpellAbility spellAbility) {
if (isImmutable() && !source.isRemembered(this)) { // special case exclusion if (isImmutable() && !source.isRemembered(this)) { // special case exclusion
return false; return false;
} }
@@ -3599,7 +3599,7 @@ public class Card extends GameEntity implements Comparable<Card> {
final String excR = incR[1]; final String excR = incR[1];
final String[] exRs = excR.split("\\+"); // Exclusive Restrictions are ... final String[] exRs = excR.split("\\+"); // Exclusive Restrictions are ...
for (String exR : exRs) { for (String exR : exRs) {
if (!hasProperty(exR, sourceController, source)) { if (!hasProperty(exR, sourceController, source, spellAbility)) {
return testFailed; return testFailed;
} }
} }
@@ -3609,7 +3609,7 @@ public class Card extends GameEntity implements Comparable<Card> {
// Takes arguments like Blue or withFlying // Takes arguments like Blue or withFlying
@Override @Override
public boolean hasProperty(final String property, final Player sourceController, final Card source) { public boolean hasProperty(final String property, final Player sourceController, final Card source, SpellAbility spellAbility) {
final Game game = getGame(); final Game game = getGame();
final Combat combat = game.getCombat(); final Combat combat = game.getCombat();
final Card lki = getGame().getChangeZoneLKIInfo(this); final Card lki = getGame().getChangeZoneLKIInfo(this);
@@ -3850,12 +3850,12 @@ public class Card extends GameEntity implements Comparable<Card> {
} }
} else if (property.startsWith("OwnedBy")) { } else if (property.startsWith("OwnedBy")) {
final String valid = property.substring(8); final String valid = property.substring(8);
if (!getOwner().isValid(valid, sourceController, source)) { if (!getOwner().isValid(valid, sourceController, source, spellAbility)) {
return false; return false;
} }
} else if (property.startsWith("ControlledBy")) { } else if (property.startsWith("ControlledBy")) {
final String valid = property.substring(13); final String valid = property.substring(13);
if (!controller.isValid(valid, sourceController, source)) { if (!controller.isValid(valid, sourceController, source, spellAbility)) {
return false; return false;
} }
} else if (property.startsWith("OwnerDoesntControl")) { } else if (property.startsWith("OwnerDoesntControl")) {
@@ -3918,9 +3918,9 @@ public class Card extends GameEntity implements Comparable<Card> {
return false; return false;
} }
} else { } else {
if ((enchanting == null || !enchanting.isValid(restriction, sourceController, source)) if ((enchanting == null || !enchanting.isValid(restriction, sourceController, source, spellAbility))
&& (equipping == null || !equipping.isValid(restriction, sourceController, source)) && (equipping == null || !equipping.isValid(restriction, sourceController, source, spellAbility))
&& (fortifying == null || !fortifying.isValid(restriction, sourceController, source))) { && (fortifying == null || !fortifying.isValid(restriction, sourceController, source, spellAbility))) {
return false; return false;
} }
} }
@@ -3967,7 +3967,7 @@ public class Card extends GameEntity implements Comparable<Card> {
break; break;
default: // EnchantedBy Aura.Other default: // EnchantedBy Aura.Other
for (final Card aura : getEnchantedBy(false)) { for (final Card aura : getEnchantedBy(false)) {
if (aura.isValid(restriction, sourceController, source)) { if (aura.isValid(restriction, sourceController, source, spellAbility)) {
return true; return true;
} }
} }
@@ -4227,7 +4227,7 @@ public class Card extends GameEntity implements Comparable<Card> {
break; break;
default: default:
for (final Card card : sourceController.getCardsIn(ZoneType.Battlefield)) { for (final Card card : sourceController.getCardsIn(ZoneType.Battlefield)) {
if (card.isValid(restriction, sourceController, source) && sharesColorWith(card)) { if (card.isValid(restriction, sourceController, source, spellAbility) && sharesColorWith(card)) {
return true; return true;
} }
} }
@@ -4254,7 +4254,7 @@ public class Card extends GameEntity implements Comparable<Card> {
} else { } else {
final String restriction = property.split("notSharesColorWith ")[1]; final String restriction = property.split("notSharesColorWith ")[1];
for (final Card card : sourceController.getCardsIn(ZoneType.Battlefield)) { for (final Card card : sourceController.getCardsIn(ZoneType.Battlefield)) {
if (card.isValid(restriction, sourceController, source) && sharesColorWith(card)) { if (card.isValid(restriction, sourceController, source, spellAbility) && sharesColorWith(card)) {
return false; return false;
} }
} }
@@ -4315,7 +4315,7 @@ public class Card extends GameEntity implements Comparable<Card> {
default: default:
boolean shares = false; boolean shares = false;
for (final Card card : sourceController.getCardsIn(ZoneType.Battlefield)) { for (final Card card : sourceController.getCardsIn(ZoneType.Battlefield)) {
if (card.isValid(restriction, sourceController, source) && sharesCreatureTypeWith(card)) { if (card.isValid(restriction, sourceController, source, spellAbility) && sharesCreatureTypeWith(card)) {
shares = true; shares = true;
} }
} }
@@ -4449,6 +4449,16 @@ public class Card extends GameEntity implements Comparable<Card> {
} }
} }
return false; return false;
} else if (restriction.equals("TriggeredCard")) {
if (spellAbility == null) {
System.out.println("Looking at TriggeredCard but no SA?");
} else {
Card triggeredCard = ((Card)spellAbility.getTriggeringObject("Card"));
if (triggeredCard != null && getName().equals(triggeredCard.getName())) {
return true;
}
}
return false;
} }
} }
} else if (property.startsWith("doesNotShareNameWith")) { } else if (property.startsWith("doesNotShareNameWith")) {
@@ -4546,7 +4556,7 @@ public class Card extends GameEntity implements Comparable<Card> {
Player p = null; Player p = null;
if (res.length > 1) { if (res.length > 1) {
for (Player pl : game.getPlayers()) { for (Player pl : game.getPlayers()) {
if (pl.isValid(res[1], sourceController, source)) { if (pl.isValid(res[1], sourceController, source, spellAbility)) {
p = pl; p = pl;
break; break;
} }
@@ -5558,11 +5568,11 @@ public class Card extends GameEntity implements Comparable<Card> {
continue; continue;
} }
if (params.containsKey("ValidSource") if (params.containsKey("ValidSource")
&& !source.isValid(params.get("ValidSource"), ca.getController(), ca)) { && !source.isValid(params.get("ValidSource"), ca.getController(), ca, null)) {
continue; continue;
} }
if (params.containsKey("ValidTarget") if (params.containsKey("ValidTarget")
&& !isValid(params.get("ValidTarget"), ca.getController(), ca)) { && !isValid(params.get("ValidTarget"), ca.getController(), ca, null)) {
continue; continue;
} }
if (params.containsKey("IsCombat")) { if (params.containsKey("IsCombat")) {
@@ -5641,7 +5651,7 @@ public class Card extends GameEntity implements Comparable<Card> {
if (kw.startsWith("PreventAllDamageBy")) { if (kw.startsWith("PreventAllDamageBy")) {
String valid = getKeywords().get(getKeywordPosition("PreventAllDamageBy")); String valid = getKeywords().get(getKeywordPosition("PreventAllDamageBy"));
valid = valid.split(" ", 2)[1]; valid = valid.split(" ", 2)[1];
if (source.isValid(valid, getController(), this)) { if (source.isValid(valid, getController(), this, null)) {
return 0; return 0;
} }
} }
@@ -6156,8 +6166,8 @@ public class Card extends GameEntity implements Comparable<Card> {
final String characteristic = kws[1]; final String characteristic = kws[1];
final String[] characteristics = characteristic.split(","); final String[] characteristics = characteristic.split(",");
final String exception = kws.length > 3 ? kws[3] : null; // check "This effect cannot remove sth" final String exception = kws.length > 3 ? kws[3] : null; // check "This effect cannot remove sth"
if (source.isValid(characteristics, getController(), this) if (source.isValid(characteristics, getController(), this, null)
&& (!checkSBA || exception == null || !source.isValid(exception, getController(), this))) { && (!checkSBA || exception == null || !source.isValid(exception, getController(), this, null))) {
return true; return true;
} }
} else if (kw.equals("Protection from colored spells")) { } else if (kw.equals("Protection from colored spells")) {
@@ -6300,7 +6310,7 @@ public class Card extends GameEntity implements Comparable<Card> {
final String parse = source.getKeywords().get(keywordPosition); final String parse = source.getKeywords().get(keywordPosition);
final String[] k = parse.split(":"); final String[] k = parse.split(":");
final String[] restrictions = k[1].split(","); final String[] restrictions = k[1].split(",");
if (isValid(restrictions, source.getController(), source)) { if (isValid(restrictions, source.getController(), source, null)) {
return false; return false;
} }
} }
@@ -6326,7 +6336,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|| (hasKeyword("CARDNAME can't be enchanted in the future.") && !isEnchantedBy(aura)) || (hasKeyword("CARDNAME can't be enchanted in the future.") && !isEnchantedBy(aura))
|| (hasKeyword("CARDNAME can't be enchanted.") && !aura.getName().equals("Anti-Magic Aura") || (hasKeyword("CARDNAME can't be enchanted.") && !aura.getName().equals("Anti-Magic Aura")
&& !(aura.getName().equals("Consecrate Land") && aura.isInZone(ZoneType.Battlefield))) && !(aura.getName().equals("Consecrate Land") && aura.isInZone(ZoneType.Battlefield)))
|| ((tgt != null) && !isValid(tgt.getValidTgts(), aura.getController(), aura))); || ((tgt != null) && !isValid(tgt.getValidTgts(), aura.getController(), aura, sa)));
} }
public final boolean canBeEquippedBy(final Card equip) { public final boolean canBeEquippedBy(final Card equip) {
@@ -6335,13 +6345,13 @@ public class Card extends GameEntity implements Comparable<Card> {
final String parse = equip.getKeywords().get(keywordPosition); final String parse = equip.getKeywords().get(keywordPosition);
final String[] k = parse.split(" ", 2); final String[] k = parse.split(" ", 2);
final String[] restrictions = k[1].split(","); final String[] restrictions = k[1].split(",");
if (isValid(restrictions, equip.getController(), equip)) { if (isValid(restrictions, equip.getController(), equip, null)) {
return false; return false;
} }
} }
return !(hasProtectionFrom(equip) return !(hasProtectionFrom(equip)
|| hasKeyword("CARDNAME can't be equipped.") || hasKeyword("CARDNAME can't be equipped.")
|| !isValid("Creature", equip.getController(), equip)); || !isValid("Creature", equip.getController(), equip, null));
} }
public FCollectionView<ReplacementEffect> getReplacementEffects() { public FCollectionView<ReplacementEffect> getReplacementEffects() {

View File

@@ -524,7 +524,7 @@ public class CardFactoryUtil {
// Reconfirm the Validity of a TgtValid, or if the Creature is still // Reconfirm the Validity of a TgtValid, or if the Creature is still
// a Creature // a Creature
if (tgt.doesTarget() if (tgt.doesTarget()
&& !target.isValid(tgt.getValidTgts(), ability.getActivatingPlayer(), ability.getHostCard())) { && !target.isValid(tgt.getValidTgts(), ability.getActivatingPlayer(), ability.getHostCard(), ability)) {
return false; return false;
} }
@@ -731,7 +731,7 @@ public class CardFactoryUtil {
int totPlayer = 0; int totPlayer = 0;
String property = sq[0].substring(11); String property = sq[0].substring(11);
for (Player p : players) { for (Player p : players) {
if (p.hasProperty(property, source.getController(), source)) { if (p.hasProperty(property, source.getController(), source, null)) {
totPlayer++; totPlayer++;
} }
} }
@@ -765,7 +765,7 @@ public class CardFactoryUtil {
final List<ZoneType> vZone = ZoneType.listValueOf(lparts[0].split("Valid")[1]); final List<ZoneType> vZone = ZoneType.listValueOf(lparts[0].split("Valid")[1]);
String restrictions = l[0].replace(lparts[0] + " ", ""); String restrictions = l[0].replace(lparts[0] + " ", "");
final String[] rest = restrictions.split(","); final String[] rest = restrictions.split(",");
CardCollection cards = CardLists.getValidCards(game.getCardsIn(vZone), rest, player, source); CardCollection cards = CardLists.getValidCards(game.getCardsIn(vZone), rest, player, source, null);
return doXMath(cards.size(), m, source); return doXMath(cards.size(), m, source);
} }
@@ -773,7 +773,7 @@ public class CardFactoryUtil {
if (l[0].startsWith("Valid ")) { if (l[0].startsWith("Valid ")) {
final String restrictions = l[0].substring(6); final String restrictions = l[0].substring(6);
final String[] rest = restrictions.split(","); final String[] rest = restrictions.split(",");
CardCollection cardsonbattlefield = CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), rest, player, source); CardCollection cardsonbattlefield = CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), rest, player, source, null);
return doXMath(cardsonbattlefield.size(), m, source); return doXMath(cardsonbattlefield.size(), m, source);
} }
@@ -940,7 +940,7 @@ public class CardFactoryUtil {
? game.getCardsIn(ZoneType.listValueOf(lparts[0].substring(5))) ? game.getCardsIn(ZoneType.listValueOf(lparts[0].substring(5)))
: game.getCardsIn(ZoneType.Battlefield); : game.getCardsIn(ZoneType.Battlefield);
CardCollection cards = CardLists.getValidCards(cardsInZones, rest, cc, c); CardCollection cards = CardLists.getValidCards(cardsInZones, rest, cc, c, null);
return doXMath(cards.size(), m, c); return doXMath(cards.size(), m, c);
} }
@@ -951,7 +951,7 @@ public class CardFactoryUtil {
if (l[0].startsWith("GreatestPower_")) { if (l[0].startsWith("GreatestPower_")) {
final String restriction = l[0].substring(14); final String restriction = l[0].substring(14);
final String[] rest = restriction.split(","); final String[] rest = restriction.split(",");
CardCollection list = CardLists.getValidCards(cc.getGame().getCardsIn(ZoneType.Battlefield), rest, cc, c); CardCollection list = CardLists.getValidCards(cc.getGame().getCardsIn(ZoneType.Battlefield), rest, cc, c, null);
int highest = 0; int highest = 0;
for (final Card crd : list) { for (final Card crd : list) {
if (crd.getNetPower() > highest) { if (crd.getNetPower() > highest) {
@@ -964,7 +964,7 @@ public class CardFactoryUtil {
if (l[0].startsWith("GreatestToughness_")) { if (l[0].startsWith("GreatestToughness_")) {
final String restriction = l[0].substring(18); final String restriction = l[0].substring(18);
final String[] rest = restriction.split(","); final String[] rest = restriction.split(",");
CardCollection list = CardLists.getValidCards(cc.getGame().getCardsIn(ZoneType.Battlefield), rest, cc, c); CardCollection list = CardLists.getValidCards(cc.getGame().getCardsIn(ZoneType.Battlefield), rest, cc, c, null);
int highest = 0; int highest = 0;
for (final Card crd : list) { for (final Card crd : list) {
if (crd.getNetToughness() > highest) { if (crd.getNetToughness() > highest) {
@@ -977,7 +977,7 @@ public class CardFactoryUtil {
if (l[0].startsWith("HighestCMC_")) { if (l[0].startsWith("HighestCMC_")) {
final String restriction = l[0].substring(11); final String restriction = l[0].substring(11);
final String[] rest = restriction.split(","); final String[] rest = restriction.split(",");
CardCollection list = CardLists.getValidCards(cc.getGame().getCardsInGame(), rest, cc, c); CardCollection list = CardLists.getValidCards(cc.getGame().getCardsInGame(), rest, cc, c, null);
int highest = 0; int highest = 0;
for (final Card crd : list) { for (final Card crd : list) {
if (crd.isSplitCard()) { if (crd.isSplitCard()) {
@@ -1001,7 +1001,7 @@ public class CardFactoryUtil {
final List<String> crdname = new ArrayList<String>(); final List<String> crdname = new ArrayList<String>();
final String restriction = l[0].substring(19); final String restriction = l[0].substring(19);
final String[] rest = restriction.split(","); final String[] rest = restriction.split(",");
CardCollection list = CardLists.getValidCards(cc.getGame().getCardsInGame(), rest, cc, c); CardCollection list = CardLists.getValidCards(cc.getGame().getCardsInGame(), rest, cc, c, null);
for (final Card card : list) { for (final Card card : list) {
if (!crdname.contains(card.getName())) { if (!crdname.contains(card.getName())) {
crdname.add(card.getName()); crdname.add(card.getName());
@@ -1030,7 +1030,7 @@ public class CardFactoryUtil {
final CounterType counterType = CounterType.valueOf(components[1]); final CounterType counterType = CounterType.valueOf(components[1]);
String restrictions = components[2]; String restrictions = components[2];
final String[] rest = restrictions.split(","); final String[] rest = restrictions.split(",");
CardCollection candidates = CardLists.getValidCards(game.getCardsInGame(), rest, cc, c); CardCollection candidates = CardLists.getValidCards(game.getCardsInGame(), rest, cc, c, null);
int added = 0; int added = 0;
for (final Card counterSource : candidates) { for (final Card counterSource : candidates) {
@@ -1318,7 +1318,7 @@ public class CardFactoryUtil {
if (sq[0].startsWith("Devoured")) { if (sq[0].startsWith("Devoured")) {
final String validDevoured = l[0].split(" ")[1]; final String validDevoured = l[0].split(" ")[1];
CardCollection cl = CardLists.getValidCards(c.getDevoured(), validDevoured.split(","), cc, c); CardCollection cl = CardLists.getValidCards(c.getDevoured(), validDevoured.split(","), cc, c, null);
return doXMath(cl.size(), m, c); return doXMath(cl.size(), m, c);
} }
@@ -1336,7 +1336,7 @@ public class CardFactoryUtil {
if (sq[0].contains("SumPower")) { if (sq[0].contains("SumPower")) {
final String[] restrictions = l[0].split("_"); final String[] restrictions = l[0].split("_");
final String[] rest = restrictions[1].split(","); final String[] rest = restrictions[1].split(",");
CardCollection filteredCards = CardLists.getValidCards(cc.getGame().getCardsIn(ZoneType.Battlefield), rest, cc, c); CardCollection filteredCards = CardLists.getValidCards(cc.getGame().getCardsIn(ZoneType.Battlefield), rest, cc, c, null);
return doXMath(Aggregates.sum(filteredCards, CardPredicates.Accessors.fnGetNetPower), m, c); return doXMath(Aggregates.sum(filteredCards, CardPredicates.Accessors.fnGetNetPower), m, c);
} }
// Count$CardManaCost // Count$CardManaCost
@@ -1359,7 +1359,7 @@ public class CardFactoryUtil {
final String[] restrictions = l[0].split("_"); final String[] restrictions = l[0].split("_");
final String[] rest = restrictions[1].split(","); final String[] rest = restrictions[1].split(",");
CardCollectionView cardsonbattlefield = game.getCardsIn(ZoneType.Battlefield); CardCollectionView cardsonbattlefield = game.getCardsIn(ZoneType.Battlefield);
CardCollection filteredCards = CardLists.getValidCards(cardsonbattlefield, rest, cc, c); CardCollection filteredCards = CardLists.getValidCards(cardsonbattlefield, rest, cc, c, null);
return Aggregates.sum(filteredCards, CardPredicates.Accessors.fnGetCmc); return Aggregates.sum(filteredCards, CardPredicates.Accessors.fnGetCmc);
} }
@@ -1391,7 +1391,7 @@ public class CardFactoryUtil {
final CounterType cType = CounterType.getType(restrictions[1]); final CounterType cType = CounterType.getType(restrictions[1]);
final String[] validFilter = restrictions[2].split(","); final String[] validFilter = restrictions[2].split(",");
CardCollectionView validCards = game.getCardsIn(ZoneType.Battlefield); CardCollectionView validCards = game.getCardsIn(ZoneType.Battlefield);
validCards = CardLists.getValidCards(validCards, validFilter, cc, c); validCards = CardLists.getValidCards(validCards, validFilter, cc, c, null);
int cCount = 0; int cCount = 0;
for (final Card card : validCards) { for (final Card card : validCards) {
cCount += card.getCounters(cType); cCount += card.getCounters(cType);
@@ -2018,7 +2018,7 @@ public class CardFactoryUtil {
final List<String> protectionkw = new ArrayList<String>(); final List<String> protectionkw = new ArrayList<String>();
final List<String> allkw = new ArrayList<String>(); final List<String> allkw = new ArrayList<String>();
cardlist = CardLists.getValidCards(cardlist, restrictions, p, host); cardlist = CardLists.getValidCards(cardlist, restrictions, p, host, null);
for (Card c : cardlist) { for (Card c : cardlist) {
for (String k : c.getKeywords()) { for (String k : c.getKeywords()) {
if (k.endsWith("walk")) { if (k.endsWith("walk")) {

View File

@@ -45,11 +45,9 @@ public class CardLists {
* filterToughness. * filterToughness.
* </p> * </p>
* *
* @param in
* a {@link forge.CardList} object.
* @param atLeastToughness * @param atLeastToughness
* a int. * a int.
* @return a {@link forge.CardList} object. * @return a CardCollection
*/ */
public static CardCollection filterToughness(final Iterable<Card> in, final int atLeastToughness) { public static CardCollection filterToughness(final Iterable<Card> in, final int atLeastToughness) {
return CardLists.filter(in, new Predicate<Card>() { return CardLists.filter(in, new Predicate<Card>() {
@@ -103,7 +101,6 @@ public class CardLists {
* </p> * </p>
* *
* @param list * @param list
* a {@link forge.CardList} object.
*/ */
public static void sortByCmcDesc(final List<Card> list) { public static void sortByCmcDesc(final List<Card> list) {
Collections.sort(list, CmcComparatorInv); Collections.sort(list, CmcComparatorInv);
@@ -115,7 +112,6 @@ public class CardLists {
* </p> * </p>
* *
* @param list * @param list
* a {@link forge.CardList} object.
*/ */
public static void sortByToughnessAsc(final List<Card> list) { public static void sortByToughnessAsc(final List<Card> list) {
Collections.sort(list, ToughnessComparator); Collections.sort(list, ToughnessComparator);
@@ -127,7 +123,6 @@ public class CardLists {
* </p> * </p>
* *
* @param list * @param list
* a {@link forge.CardList} object.
*/ */
public static void sortByPowerAsc(final List<Card> list) { public static void sortByPowerAsc(final List<Card> list) {
Collections.sort(list, PowerComparator); Collections.sort(list, PowerComparator);
@@ -140,7 +135,6 @@ public class CardLists {
* </p> * </p>
* *
* @param list * @param list
* a {@link forge.CardList} object.
*/ */
public static void sortByPowerDesc(final List<Card> list) { public static void sortByPowerDesc(final List<Card> list) {
Collections.sort(list, Collections.reverseOrder(PowerComparator)); Collections.sort(list, Collections.reverseOrder(PowerComparator));
@@ -187,28 +181,28 @@ public class CardLists {
return CardLists.filter(cardList, CardPredicates.isControlledByAnyOf(player)); return CardLists.filter(cardList, CardPredicates.isControlledByAnyOf(player));
} }
public static CardCollection getValidCards(Iterable<Card> cardList, String[] restrictions, Player sourceController, Card source) { public static CardCollection getValidCards(Iterable<Card> cardList, String[] restrictions, Player sourceController, Card source, SpellAbility spellAbility) {
return CardLists.filter(cardList, CardPredicates.restriction(restrictions, sourceController, source)); return CardLists.filter(cardList, CardPredicates.restriction(restrictions, sourceController, source, spellAbility));
} }
public static List<Card> getValidCardsAsList(Iterable<Card> cardList, String[] restrictions, Player sourceController, Card source) { public static List<Card> getValidCardsAsList(Iterable<Card> cardList, String[] restrictions, Player sourceController, Card source) {
return CardLists.filterAsList(cardList, CardPredicates.restriction(restrictions, sourceController, source)); return CardLists.filterAsList(cardList, CardPredicates.restriction(restrictions, sourceController, source, null));
} }
public static int getValidCardCount(Iterable<Card> cardList, String[] restrictions, Player sourceController, Card source) { public static int getValidCardCount(Iterable<Card> cardList, String[] restrictions, Player sourceController, Card source) {
return CardLists.count(cardList, CardPredicates.restriction(restrictions, sourceController, source)); return CardLists.count(cardList, CardPredicates.restriction(restrictions, sourceController, source, null));
} }
public static CardCollection getValidCards(Iterable<Card> cardList, String restriction, Player sourceController, Card source) { public static CardCollection getValidCards(Iterable<Card> cardList, String restriction, Player sourceController, Card source) {
return CardLists.filter(cardList, CardPredicates.restriction(restriction.split(","), sourceController, source)); return CardLists.filter(cardList, CardPredicates.restriction(restriction.split(","), sourceController, source, null));
} }
public static List<Card> getValidCardsAsList(Iterable<Card> cardList, String restriction, Player sourceController, Card source) { public static List<Card> getValidCardsAsList(Iterable<Card> cardList, String restriction, Player sourceController, Card source) {
return CardLists.filterAsList(cardList, CardPredicates.restriction(restriction.split(","), sourceController, source)); return CardLists.filterAsList(cardList, CardPredicates.restriction(restriction.split(","), sourceController, source, null));
} }
public static int getValidCardCount(Iterable<Card> cardList, String restriction, Player sourceController, Card source) { public static int getValidCardCount(Iterable<Card> cardList, String restriction, Player sourceController, Card source) {
return CardLists.count(cardList, CardPredicates.restriction(restriction.split(","), sourceController, source)); return CardLists.count(cardList, CardPredicates.restriction(restriction.split(","), sourceController, source, null));
} }
public static CardCollection getTargetableCards(Iterable<Card> cardList, SpellAbility source) { public static CardCollection getTargetableCards(Iterable<Card> cardList, SpellAbility source) {

View File

@@ -144,11 +144,11 @@ public final class CardPredicates {
}; };
} }
public static final Predicate<Card> restriction(final String[] restrictions, final Player sourceController, final Card source) { public static final Predicate<Card> restriction(final String[] restrictions, final Player sourceController, final Card source, final SpellAbility spellAbility) {
return new Predicate<Card>() { return new Predicate<Card>() {
@Override @Override
public boolean apply(final Card c) { public boolean apply(final Card c) {
return (c != null) && c.isValid(restrictions, sourceController, source); return (c != null) && c.isValid(restrictions, sourceController, source, spellAbility);
} }
}; };
} }

View File

@@ -151,7 +151,6 @@ public final class CardUtil {
* @param from zone coming from * @param from zone coming from
* @param valid a isValid expression * @param valid a isValid expression
* @param src a Card object * @param src a Card object
* @param checkLatestState a boolean, true if the latest state of the card as it left the original zone needs to be checked
* @return a CardCollection that matches the given criteria * @return a CardCollection that matches the given criteria
*/ */
public static CardCollection getThisTurnEntered(final ZoneType to, final ZoneType from, final String valid, final Card src) { public static CardCollection getThisTurnEntered(final ZoneType to, final ZoneType from, final String valid, final Card src) {
@@ -190,7 +189,6 @@ public final class CardUtil {
* @param from zone coming from * @param from zone coming from
* @param valid a isValid expression * @param valid a isValid expression
* @param src a Card object * @param src a Card object
* @param checkLatestState a boolean, true if the latest state of the card as it left the original zone needs to be checked
* @return a CardCollection that matches the given criteria * @return a CardCollection that matches the given criteria
*/ */
public static CardCollection getLastTurnEntered(final ZoneType to, final ZoneType from, final String valid, final Card src) { public static CardCollection getLastTurnEntered(final ZoneType to, final ZoneType from, final String valid, final Card src) {
@@ -307,7 +305,7 @@ public final class CardUtil {
continue; continue;
for(final Card c : game.getColoredCardsInPlay(MagicColor.toLongString(color))) { for(final Card c : game.getColoredCardsInPlay(MagicColor.toLongString(color))) {
if (!res.contains(c) && c.isValid(valid, source.getController(), source) && !c.equals(origin)) { if (!res.contains(c) && c.isValid(valid, source.getController(), source, null) && !c.equals(origin)) {
res.add(c); res.add(c);
} }
} }
@@ -479,7 +477,7 @@ public final class CardUtil {
final List<ZoneType> zone = tgt.getZone(); final List<ZoneType> zone = tgt.getZone();
final boolean canTgtStack = zone.contains(ZoneType.Stack); final boolean canTgtStack = zone.contains(ZoneType.Stack);
List<Card> validCards = CardLists.getValidCards(game.getCardsIn(zone), tgt.getValidTgts(), ability.getActivatingPlayer(), ability.getHostCard()); List<Card> validCards = CardLists.getValidCards(game.getCardsIn(zone), tgt.getValidTgts(), ability.getActivatingPlayer(), ability.getHostCard(), ability);
List<Card> choices = CardLists.getTargetableCards(validCards, ability); List<Card> choices = CardLists.getTargetableCards(validCards, ability);
if (canTgtStack) { if (canTgtStack) {
// Since getTargetableCards doesn't have additional checks if one of the Zones is stack // Since getTargetableCards doesn't have additional checks if one of the Zones is stack

View File

@@ -157,7 +157,6 @@ public class CombatUtil {
* </p> * </p>
* <p> * <p>
* This method doesn't check effects related to other creatures attacking * This method doesn't check effects related to other creatures attacking
* (but see {@link CombatUtil}.{@link #canAttack(Card, GameEntity, Combat)}.
* </p> * </p>
* <p> * <p>
* Note that a creature affected by any attacking restrictions may never be * Note that a creature affected by any attacking restrictions may never be
@@ -234,8 +233,6 @@ public class CombatUtil {
* *
* @param attacker * @param attacker
* a {@link forge.game.card.Card} object. * a {@link forge.game.card.Card} object.
* @param bLast
* a boolean.
*/ */
public static boolean checkPropagandaEffects(final Game game, final Card attacker, final Combat combat) { public static boolean checkPropagandaEffects(final Game game, final Card attacker, final Combat combat) {
final Cost attackCost = getAttackCost(game, attacker, combat.getDefenderByAttacker(attacker)); final Cost attackCost = getAttackCost(game, attacker, combat.getDefenderByAttacker(attacker));
@@ -342,7 +339,6 @@ public class CombatUtil {
* @param combat * @param combat
* a {@link Combat}. * a {@link Combat}.
* @return a {@link Map}. * @return a {@link Map}.
* @see #getRequirementsPerDefender(Card, FCollectionView, Combat, int)
*/ */
public static AttackConstraints getAllRequirements(final Combat combat) { public static AttackConstraints getAllRequirements(final Combat combat) {
return new AttackConstraints(combat); return new AttackConstraints(combat);
@@ -577,7 +573,7 @@ public class CombatUtil {
final String valid = StringUtils.join(walkTypes, ","); final String valid = StringUtils.join(walkTypes, ",");
final CardCollectionView defendingLands = defendingPlayer.getCardsIn(ZoneType.Battlefield); final CardCollectionView defendingLands = defendingPlayer.getCardsIn(ZoneType.Battlefield);
for (final Card c : defendingLands) { for (final Card c : defendingLands) {
if (c.isValid(valid.split(","), defendingPlayer, attacker)) { if (c.isValid(valid.split(","), defendingPlayer, attacker, null)) {
return true; return true;
} }
} }
@@ -946,7 +942,7 @@ public class CombatUtil {
final String parse = attacker.getKeywords().get(keywordPosition).toString(); final String parse = attacker.getKeywords().get(keywordPosition).toString();
final String[] k = parse.split(" ", 2); final String[] k = parse.split(" ", 2);
final String[] restrictions = k[1].split(","); final String[] restrictions = k[1].split(",");
if (blocker.isValid(restrictions, attacker.getController(), attacker)) { if (blocker.isValid(restrictions, attacker.getController(), attacker, null)) {
//Dragon Hunter check //Dragon Hunter check
if (!k[1].contains("withoutReach") || !attacker.getType().hasCreatureType("Dragon") if (!k[1].contains("withoutReach") || !attacker.getType().hasCreatureType("Dragon")
|| !blocker.hasKeyword("CARDNAME can block Dragons as though it had reach.")) { || !blocker.hasKeyword("CARDNAME can block Dragons as though it had reach.")) {
@@ -967,7 +963,7 @@ public class CombatUtil {
final String[] parse0 = parse.split(":"); final String[] parse0 = parse.split(":");
final String[] k = parse0[0].split(" ", 2); final String[] k = parse0[0].split(" ", 2);
final String[] restrictions = k[1].split(","); final String[] restrictions = k[1].split(",");
if (attacker.isValid(restrictions, blocker.getController(), blocker)) { if (attacker.isValid(restrictions, blocker.getController(), blocker, null)) {
return false; return false;
} }
} }

View File

@@ -124,7 +124,7 @@ public class CostDiscard extends CostPartWithList {
} }
if (!type.equals("Random") && !type.contains("X")) { if (!type.equals("Random") && !type.contains("X")) {
// Knollspine Invocation fails to activate without the above conditional // Knollspine Invocation fails to activate without the above conditional
handList = CardLists.getValidCards(handList, type.split(";"), activator, source); handList = CardLists.getValidCards(handList, type.split(";"), activator, source, ability);
} }
if (sameName) { if (sameName) {
for (Card c : handList) { for (Card c : handList) {

View File

@@ -59,7 +59,7 @@ public class CostDraw extends CostPart {
List<Player> res = new ArrayList<Player>(); List<Player> res = new ArrayList<Player>();
String type = this.getType(); String type = this.getType();
for (Player p : payer.getGame().getPlayers()) { for (Player p : payer.getGame().getPlayers()) {
if (p.isValid(type, payer, source) && p.canDraw()) { if (p.isValid(type, payer, source, null) && p.canDraw()) {
res.add(p); res.add(p);
} }
} }

View File

@@ -131,7 +131,7 @@ public class CostExile extends CostPartWithList {
return list.contains(source); return list.contains(source);
} }
list = CardLists.getValidCards(list, type.split(";"), activator, source); list = CardLists.getValidCards(list, type.split(";"), activator, source, ability);
final Integer amount = this.convertAmount(); final Integer amount = this.convertAmount();
if ((amount != null) && (list.size() < amount)) { if ((amount != null) && (list.size() < amount)) {

View File

@@ -85,7 +85,7 @@ public class CostExileFromStack extends CostPart {
CardCollectionView list = activator.getCardsIn(ZoneType.Stack); CardCollectionView list = activator.getCardsIn(ZoneType.Stack);
list = CardLists.getValidCards(list, type.split(";"), activator, source); list = CardLists.getValidCards(list, type.split(";"), activator, source, ability);
final Integer amount = this.convertAmount(); final Integer amount = this.convertAmount();
if ((amount != null) && (list.size() < amount)) { if ((amount != null) && (list.size() < amount)) {

View File

@@ -70,7 +70,7 @@ public class CostExiledMoveToGrave extends CostPartWithList {
CardCollectionView typeList = activator.getGame().getCardsIn(ZoneType.Exile); CardCollectionView typeList = activator.getGame().getCardsIn(ZoneType.Exile);
typeList = CardLists.getValidCards(typeList, getType().split(";"), activator, source); typeList = CardLists.getValidCards(typeList, getType().split(";"), activator, source, ability);
return typeList.size() >= i; return typeList.size() >= i;
} }

View File

@@ -70,7 +70,7 @@ public class CostGainControl extends CostPartWithList {
final Player activator = ability.getActivatingPlayer(); final Player activator = ability.getActivatingPlayer();
final Card source = ability.getHostCard(); final Card source = ability.getHostCard();
CardCollectionView typeList = activator.getGame().getCardsIn(ZoneType.Battlefield); CardCollectionView typeList = activator.getGame().getCardsIn(ZoneType.Battlefield);
typeList = CardLists.getValidCards(typeList, this.getType().split(";"), activator, source); typeList = CardLists.getValidCards(typeList, this.getType().split(";"), activator, source, ability);
Integer amount = this.convertAmount(); Integer amount = this.convertAmount();
if (amount == null) { if (amount == null) {

View File

@@ -65,7 +65,7 @@ public class CostGainLife extends CostPart {
List<Player> res = new ArrayList<Player>(); List<Player> res = new ArrayList<Player>();
for(Player p : payer.getGame().getPlayers()) for(Player p : payer.getGame().getPlayers())
{ {
if(p.isValid(getType(), payer, source)) if(p.isValid(getType(), payer, source, null))
res.add(p); res.add(p);
} }
return res; return res;

View File

@@ -128,7 +128,7 @@ public class CostPutCardToLib extends CostPartWithList {
typeList = activator.getCardsIn(getFrom()); typeList = activator.getCardsIn(getFrom());
} }
typeList = CardLists.getValidCards(typeList, getType().split(";"), activator, source); typeList = CardLists.getValidCards(typeList, getType().split(";"), activator, source, ability);
if (typeList.size() < i) { if (typeList.size() < i) {
return false; return false;

View File

@@ -134,7 +134,8 @@ public class CostPutCounter extends CostPartWithList {
} }
} else { } else {
// 3 Cards have Put a -1/-1 Counter on a Creature you control. // 3 Cards have Put a -1/-1 Counter on a Creature you control.
final List<Card> typeList = CardLists.getValidCards(activator.getGame().getCardsIn(ZoneType.Battlefield), this.getType().split(";"), activator, source); final List<Card> typeList = CardLists.getValidCards(activator.getGame().getCardsIn(ZoneType.Battlefield),
this.getType().split(";"), activator, source, ability);
if (typeList.size() == 0) { if (typeList.size() == 0) {
return false; return false;

View File

@@ -88,7 +88,7 @@ public class CostRemoveAnyCounter extends CostPartWithList {
final Player activator = ability.getActivatingPlayer(); final Player activator = ability.getActivatingPlayer();
final Card source = ability.getHostCard(); final Card source = ability.getHostCard();
CardCollectionView validCards = activator.getCardsIn(ZoneType.Battlefield); CardCollectionView validCards = activator.getCardsIn(ZoneType.Battlefield);
validCards = CardLists.getValidCards(validCards, this.getType().split(";"), activator, source); validCards = CardLists.getValidCards(validCards, this.getType().split(";"), activator, source, ability);
validCards = CardLists.filter(validCards, new Predicate<Card>() { validCards = CardLists.filter(validCards, new Predicate<Card>() {
@Override @Override
public boolean apply(final Card c) { public boolean apply(final Card c) {

View File

@@ -136,7 +136,7 @@ public class CostRemoveCounter extends CostPartWithList {
if (type.equals("OriginalHost")) { if (type.equals("OriginalHost")) {
typeList = Lists.newArrayList(ability.getOriginalHost()); typeList = Lists.newArrayList(ability.getOriginalHost());
} else { } else {
typeList = CardLists.getValidCards(activator.getCardsIn(this.zone), type.split(";"), activator, source); typeList = CardLists.getValidCards(activator.getCardsIn(this.zone), type.split(";"), activator, source, ability);
} }
if (amount != null) { if (amount != null) {
if (this.getTypeDescription().equals("among creatures you control")) { if (this.getTypeDescription().equals("among creatures you control")) {

View File

@@ -91,7 +91,7 @@ public class CostReturn extends CostPartWithList {
boolean needsAnnoucement = ability.hasParam("Announce") && this.getType().contains(ability.getParam("Announce")); boolean needsAnnoucement = ability.hasParam("Announce") && this.getType().contains(ability.getParam("Announce"));
CardCollectionView typeList = activator.getCardsIn(ZoneType.Battlefield); CardCollectionView typeList = activator.getCardsIn(ZoneType.Battlefield);
typeList = CardLists.getValidCards(typeList, this.getType().split(";"), activator, source); typeList = CardLists.getValidCards(typeList, this.getType().split(";"), activator, source, ability);
final Integer amount = this.convertAmount(); final Integer amount = this.convertAmount();
if (!needsAnnoucement && amount != null && typeList.size() < amount) { if (!needsAnnoucement && amount != null && typeList.size() < amount) {

View File

@@ -79,7 +79,7 @@ public class CostReveal extends CostPartWithList {
modifiedHand.remove(source); // can't pay for itself modifiedHand.remove(source); // can't pay for itself
handList = modifiedHand; handList = modifiedHand;
} }
handList = CardLists.getValidCards(handList, type.split(";"), activator, source); handList = CardLists.getValidCards(handList, type.split(";"), activator, source, ability);
if ((amount != null) && (amount > handList.size())) { if ((amount != null) && (amount > handList.size())) {
// not enough cards in hand to pay // not enough cards in hand to pay
return false; return false;

View File

@@ -87,7 +87,7 @@ public class CostSacrifice extends CostPartWithList {
boolean needsAnnoucement = ability.hasParam("Announce") && this.getType().contains(ability.getParam("Announce")); boolean needsAnnoucement = ability.hasParam("Announce") && this.getType().contains(ability.getParam("Announce"));
CardCollectionView typeList = activator.getCardsIn(ZoneType.Battlefield); CardCollectionView typeList = activator.getCardsIn(ZoneType.Battlefield);
typeList = CardLists.getValidCards(typeList, this.getType().split(";"), activator, source); typeList = CardLists.getValidCards(typeList, this.getType().split(";"), activator, source, ability);
final Integer amount = this.convertAmount(); final Integer amount = this.convertAmount();
if (activator.hasKeyword("You can't sacrifice creatures to cast spells or activate abilities.")) { if (activator.hasKeyword("You can't sacrifice creatures to cast spells or activate abilities.")) {

View File

@@ -121,7 +121,7 @@ public class CostTapType extends CostPartWithList {
type = type.replace("+withTotalPowerGE" + totalP, ""); type = type.replace("+withTotalPowerGE" + totalP, "");
} }
CardCollection typeList = CardLists.getValidCards(activator.getCardsIn(ZoneType.Battlefield), type.split(";"), activator, source); CardCollection typeList = CardLists.getValidCards(activator.getCardsIn(ZoneType.Battlefield), type.split(";"), activator, source, ability);
if (!canTapSource) { if (!canTapSource) {
typeList.remove(source); typeList.remove(source);

View File

@@ -74,7 +74,7 @@ public class CostUntapType extends CostPartWithList {
final Player activator = ability.getActivatingPlayer(); final Player activator = ability.getActivatingPlayer();
final Card source = ability.getHostCard(); final Card source = ability.getHostCard();
CardCollection typeList = CardLists.getValidCards(activator.getGame().getCardsIn(ZoneType.Battlefield), getType().split(";"), activator, source); CardCollection typeList = CardLists.getValidCards(activator.getGame().getCardsIn(ZoneType.Battlefield), getType().split(";"), activator, source, ability);
if (!canUntapSource) { if (!canUntapSource) {
typeList.remove(source); typeList.remove(source);

View File

@@ -205,7 +205,7 @@ public class ManaCostAdjustment {
* a StaticAbility * a StaticAbility
* @param sa * @param sa
* the SpellAbility * the SpellAbility
* @param originalCost * @param manaCost
* a ManaCost * a ManaCost
*/ */
private static void applyRaiseCostAbility(final StaticAbility staticAbility, final SpellAbility sa, final ManaCostBeingPaid manaCost) { private static void applyRaiseCostAbility(final StaticAbility staticAbility, final SpellAbility sa, final ManaCostBeingPaid manaCost) {
@@ -217,12 +217,12 @@ public class ManaCostAdjustment {
if (params.containsKey("ValidCard") if (params.containsKey("ValidCard")
&& !card.isValid(params.get("ValidCard").split(","), hostCard.getController(), hostCard)) { && !card.isValid(params.get("ValidCard").split(","), hostCard.getController(), hostCard, sa)) {
return; return;
} }
if (params.containsKey("Activator") && ((activator == null) if (params.containsKey("Activator") && ((activator == null)
|| !activator.isValid(params.get("Activator"), hostCard.getController(), hostCard))) { || !activator.isValid(params.get("Activator"), hostCard.getController(), hostCard, sa))) {
return; return;
} }
@@ -286,7 +286,7 @@ public class ManaCostAdjustment {
} }
boolean targetValid = false; boolean targetValid = false;
for (GameObject target : sa.getTargets().getTargets()) { for (GameObject target : sa.getTargets().getTargets()) {
if (target.isValid(params.get("ValidTarget").split(","), hostCard.getController(), hostCard)) { if (target.isValid(params.get("ValidTarget").split(","), hostCard.getController(), hostCard, sa)) {
targetValid = true; targetValid = true;
} }
} }
@@ -302,7 +302,7 @@ public class ManaCostAdjustment {
boolean targetValid = false; boolean targetValid = false;
for (SpellAbility target : sa.getTargets().getTargetSpells()) { for (SpellAbility target : sa.getTargets().getTargetSpells()) {
Card targetCard = target.getHostCard(); Card targetCard = target.getHostCard();
if (targetCard.isValid(params.get("ValidSpellTarget").split(","), hostCard.getController(), hostCard)) { if (targetCard.isValid(params.get("ValidSpellTarget").split(","), hostCard.getController(), hostCard, sa)) {
targetValid = true; targetValid = true;
} }
} }
@@ -351,7 +351,7 @@ public class ManaCostAdjustment {
* a StaticAbility * a StaticAbility
* @param sa * @param sa
* the SpellAbility * the SpellAbility
* @param originalCost * @param manaCost
* a ManaCost * a ManaCost
*/ */
private static void applyReduceCostAbility(final StaticAbility staticAbility, final SpellAbility sa, final ManaCostBeingPaid manaCost) { private static void applyReduceCostAbility(final StaticAbility staticAbility, final SpellAbility sa, final ManaCostBeingPaid manaCost) {
@@ -367,11 +367,11 @@ public class ManaCostAdjustment {
if (params.containsKey("ValidCard") if (params.containsKey("ValidCard")
&& !card.isValid(params.get("ValidCard").split(","), hostCard.getController(), hostCard)) { && !card.isValid(params.get("ValidCard").split(","), hostCard.getController(), hostCard, sa)) {
return; return;
} }
if (params.containsKey("Activator") && ((activator == null) if (params.containsKey("Activator") && ((activator == null)
|| !activator.isValid(params.get("Activator"), hostCard.getController(), hostCard))) { || !activator.isValid(params.get("Activator"), hostCard.getController(), hostCard, sa))) {
return; return;
} }
if (params.containsKey("Type")) { if (params.containsKey("Type")) {
@@ -433,7 +433,7 @@ public class ManaCostAdjustment {
} }
boolean targetValid = false; boolean targetValid = false;
for (GameObject target : sa.getTargets().getTargets()) { for (GameObject target : sa.getTargets().getTargets()) {
if (target.isValid(params.get("ValidTarget").split(","), hostCard.getController(), hostCard)) { if (target.isValid(params.get("ValidTarget").split(","), hostCard.getController(), hostCard, sa)) {
targetValid = true; targetValid = true;
} }
} }

View File

@@ -151,7 +151,7 @@ public class Untap extends Phase {
if (!Untap.canUntap(c)) { if (!Untap.canUntap(c)) {
return false; return false;
} }
if (c.isValid(restrict, player, null)) { if (c.isValid(restrict, player, null, null)) {
return false; return false;
} }
return true; return true;
@@ -175,7 +175,7 @@ public class Untap extends Phase {
CardCollection restrictUntapped = new CardCollection(); CardCollection restrictUntapped = new CardCollection();
CardCollection cardList = CardLists.filter(untapList, tappedCanUntap); CardCollection cardList = CardLists.filter(untapList, tappedCanUntap);
cardList = CardLists.getValidCards(cardList, restrict, player, null); cardList = CardLists.getValidCards(cardList, restrict, player, null, null);
while (!cardList.isEmpty()) { while (!cardList.isEmpty()) {
Map<String, Integer> remaining = new HashMap<String, Integer>(restrictUntap); Map<String, Integer> remaining = new HashMap<String, Integer>(restrictUntap);
@@ -189,7 +189,7 @@ public class Untap extends Phase {
"Select a card to untap\r\n(Selected:" + restrictUntapped + ")\r\n" + "Remaining cards that can untap: " + remaining); "Select a card to untap\r\n(Selected:" + restrictUntapped + ")\r\n" + "Remaining cards that can untap: " + remaining);
if (chosen != null) { if (chosen != null) {
for (Entry<String, Integer> rest : restrictUntap.entrySet()) { for (Entry<String, Integer> rest : restrictUntap.entrySet()) {
if (chosen.isValid(rest.getKey(), player, null)) { if (chosen.isValid(rest.getKey(), player, null, null)) {
restrictUntap.put(rest.getKey(), rest.getValue().intValue() - 1); restrictUntap.put(rest.getKey(), rest.getValue().intValue() - 1);
} }
} }

View File

@@ -1123,7 +1123,7 @@ public class Player extends GameEntity implements Comparable<Player> {
if (kw.startsWith("Protection:")) { // uses isValid if (kw.startsWith("Protection:")) { // uses isValid
final String characteristic = kw.split(":")[1]; final String characteristic = kw.split(":")[1];
final String[] characteristics = characteristic.split(","); final String[] characteristics = characteristic.split(",");
if (source.isValid(characteristics, this, null)) { if (source.isValid(characteristics, this, null, null)) {
return true; return true;
} }
} }
@@ -1917,7 +1917,7 @@ public class Player extends GameEntity implements Comparable<Player> {
} }
@Override @Override
public final boolean isValid(final String restriction, final Player sourceController, final Card source) { public final boolean isValid(final String restriction, final Player sourceController, final Card source, SpellAbility spellAbility) {
final String[] incR = restriction.split("\\.", 2); final String[] incR = restriction.split("\\.", 2);
if (incR[0].equals("Opponent")) { if (incR[0].equals("Opponent")) {
@@ -1948,7 +1948,7 @@ public class Player extends GameEntity implements Comparable<Player> {
final String[] exR = excR.split("\\+"); // Exclusive Restrictions final String[] exR = excR.split("\\+"); // Exclusive Restrictions
// are ... // are ...
for (int j = 0; j < exR.length; j++) { for (int j = 0; j < exR.length; j++) {
if (!hasProperty(exR[j], sourceController, source)) { if (!hasProperty(exR[j], sourceController, source, spellAbility)) {
return false; return false;
} }
} }
@@ -1957,7 +1957,7 @@ public class Player extends GameEntity implements Comparable<Player> {
} }
@Override @Override
public final boolean hasProperty(final String property, final Player sourceController, final Card source) { public final boolean hasProperty(final String property, final Player sourceController, final Card source, SpellAbility spellAbility) {
if (property.equals("You")) { if (property.equals("You")) {
if (!equals(sourceController)) { if (!equals(sourceController)) {
return false; return false;

View File

@@ -77,12 +77,6 @@ public class AbilityManaPart implements java.io.Serializable {
* *
* @param sourceCard * @param sourceCard
* a {@link forge.game.card.Card} object. * a {@link forge.game.card.Card} object.
* @param parse
* a {@link java.lang.String} object.
* @param produced
* a {@link java.lang.String} object.
* @param num
* a int.
*/ */
public AbilityManaPart(final Card sourceCard, final Map<String, String> params) { public AbilityManaPart(final Card sourceCard, final Map<String, String> params) {
this.sourceCard = sourceCard; this.sourceCard = sourceCard;
@@ -103,7 +97,7 @@ public class AbilityManaPart implements java.io.Serializable {
* <p> * <p>
* produceMana. * produceMana.
* </p> * </p>
* @param ability * @param sa
*/ */
public final void produceMana(SpellAbility sa) { public final void produceMana(SpellAbility sa) {
this.produceMana(this.getOrigProduced(), this.getSourceCard().getController(), sa); this.produceMana(this.getOrigProduced(), this.getSourceCard().getController(), sa);
@@ -197,7 +191,7 @@ public class AbilityManaPart implements java.io.Serializable {
Card source = saBeingPaid.getHostCard(); Card source = saBeingPaid.getHostCard();
if (source == null) return false; if (source == null) return false;
return source.isValid(cannotCounterSpell, sourceCard.getController(), sourceCard); return source.isValid(cannotCounterSpell, sourceCard.getController(), sourceCard, null);
} }
/** /**
@@ -224,7 +218,6 @@ public class AbilityManaPart implements java.io.Serializable {
* <p> * <p>
* getKeywords. * getKeywords.
* </p> * </p>
* @param saBeingPaid
* *
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
@@ -250,7 +243,7 @@ public class AbilityManaPart implements java.io.Serializable {
public void createETBCounters(Card c) { public void createETBCounters(Card c) {
String[] parse = this.addsCounters.split("_"); String[] parse = this.addsCounters.split("_");
// Convert random SVars if there are other cards with this effect // Convert random SVars if there are other cards with this effect
if (c.isValid(parse[0], c.getController(), c)) { if (c.isValid(parse[0], c.getController(), c, null)) {
String abStr = "DB$ PutCounter | Defined$ Self | CounterType$ " + parse[1] String abStr = "DB$ PutCounter | Defined$ Self | CounterType$ " + parse[1]
+ " | ETB$ True | CounterNum$ " + parse[2] + " | SubAbility$ ManaDBETBCounters"; + " | ETB$ True | CounterNum$ " + parse[2] + " | SubAbility$ ManaDBETBCounters";
String dbStr = "DB$ ChangeZone | Hidden$ True | Origin$ All | Destination$ Battlefield" String dbStr = "DB$ ChangeZone | Hidden$ True | Origin$ All | Destination$ Battlefield"
@@ -341,7 +334,7 @@ public class AbilityManaPart implements java.io.Serializable {
if (sa.getHostCard() != null) { if (sa.getHostCard() != null) {
if (sa.getHostCard().isValid(restriction, this.getSourceCard().getController(), this.getSourceCard())) { if (sa.getHostCard().isValid(restriction, this.getSourceCard().getController(), this.getSourceCard(), null)) {
return true; return true;
} }
} }

View File

@@ -212,6 +212,14 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
manaPart = manaPart0; manaPart = manaPart0;
} }
public final String getSvarWithFallback(final String name) {
String var = sVars.get(name);
if (var == null) {
var = hostCard.getSVar(name);
}
return var;
}
public final String getSVar(final String name) { public final String getSVar(final String name) {
String var = sVars.get(name); String var = sVars.get(name);
if (var == null) { if (var == null) {
@@ -397,7 +405,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
paidLists.get(str).add(c); paidLists.get(str).add(c);
} }
public void resetPaidHash() { public void resetPaidHash() {
paidLists = new HashMap<String, CardCollection>(); paidLists.clear();
} }
public Iterable<OptionalCost> getOptionalCosts() { public Iterable<OptionalCost> getOptionalCosts() {
@@ -727,7 +735,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
} }
String[] validTgt = tr.getValidTgts(); String[] validTgt = tr.getValidTgts();
if (entity instanceof GameEntity && !((GameEntity) entity).isValid(validTgt, getActivatingPlayer(), getHostCard())) { if (entity instanceof GameEntity && !((GameEntity) entity).isValid(validTgt, getActivatingPlayer(), getHostCard(), this)) {
return false; return false;
} }
} }
@@ -1098,7 +1106,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
public boolean canTargetSpellAbility(final SpellAbility topSA) { public boolean canTargetSpellAbility(final SpellAbility topSA) {
final TargetRestrictions tgt = getTargetRestrictions(); final TargetRestrictions tgt = getTargetRestrictions();
if (hasParam("TargetType") && !topSA.isValid(getParam("TargetType").split(","), getActivatingPlayer(), getHostCard())) { if (hasParam("TargetType") && !topSA.isValid(getParam("TargetType").split(","), getActivatingPlayer(), getHostCard(), this)) {
return false; return false;
} }
@@ -1115,7 +1123,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
boolean result = false; boolean result = false;
for (final GameObject o : matchTgt.getTargets()) { for (final GameObject o : matchTgt.getTargets()) {
if (o.isValid(splitTargetRestrictions.split(","), getActivatingPlayer(), getHostCard())) { if (o.isValid(splitTargetRestrictions.split(","), getActivatingPlayer(), getHostCard(), this)) {
result = true; result = true;
break; break;
} }
@@ -1131,7 +1139,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
continue; continue;
} }
for (final GameObject o : matchTgt.getTargets()) { for (final GameObject o : matchTgt.getTargets()) {
if (o.isValid(splitTargetRestrictions.split(","), getActivatingPlayer(), getHostCard())) { if (o.isValid(splitTargetRestrictions.split(","), getActivatingPlayer(), getHostCard(), this)) {
result = true; result = true;
break; break;
} }
@@ -1161,12 +1169,12 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
} }
} }
return topSA.getHostCard().isValid(tgt.getValidTgts(), getActivatingPlayer(), getHostCard()); return topSA.getHostCard().isValid(tgt.getValidTgts(), getActivatingPlayer(), getHostCard(), this);
} }
// Takes one argument like Permanent.Blue+withFlying // Takes one argument like Permanent.Blue+withFlying
@Override @Override
public final boolean isValid(final String restriction, final Player sourceController, final Card source) { public final boolean isValid(final String restriction, final Player sourceController, final Card source, SpellAbility spellAbility) {
// Inclusive restrictions are Card types // Inclusive restrictions are Card types
final String[] incR = restriction.split("\\.", 2); final String[] incR = restriction.split("\\.", 2);
@@ -1193,7 +1201,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
final String excR = incR[1]; final String excR = incR[1];
final String[] exR = excR.split("\\+"); // Exclusive Restrictions are ... final String[] exR = excR.split("\\+"); // Exclusive Restrictions are ...
for (int j = 0; j < exR.length; j++) { for (int j = 0; j < exR.length; j++) {
if (!hasProperty(exR[j], sourceController, source)) { if (!hasProperty(exR[j], sourceController, source, spellAbility)) {
return false; return false;
} }
} }
@@ -1203,7 +1211,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
// Takes arguments like Blue or withFlying // Takes arguments like Blue or withFlying
@Override @Override
public boolean hasProperty(final String property, final Player sourceController, final Card source) { public boolean hasProperty(final String property, final Player sourceController, final Card source, SpellAbility spellAbility) {
return true; return true;
} }

View File

@@ -321,7 +321,7 @@ public class SpellAbilityCondition extends SpellAbilityVariables {
list = game.getCardsIn(ZoneType.Battlefield); list = game.getCardsIn(ZoneType.Battlefield);
} }
list = CardLists.getValidCards(list, this.getIsPresent().split(","), sa.getActivatingPlayer(), sa.getHostCard()); list = CardLists.getValidCards(list, this.getIsPresent().split(","), sa.getActivatingPlayer(), sa.getHostCard(), sa);
int right; int right;
final String rightString = this.getPresentCompare().substring(2); final String rightString = this.getPresentCompare().substring(2);
@@ -382,7 +382,7 @@ public class SpellAbilityCondition extends SpellAbilityVariables {
boolean result = false; boolean result = false;
for (final GameObject o : matchTgt.getFirstTargetedSpell().getTargets().getTargets()) { for (final GameObject o : matchTgt.getFirstTargetedSpell().getTargets().getTargets()) {
if (o.isValid(this.getTargetValidTargeting().split(","), sa.getActivatingPlayer(), sa.getHostCard())) { if (o.isValid(this.getTargetValidTargeting().split(","), sa.getActivatingPlayer(), sa.getHostCard(), sa)) {
result = true; result = true;
break; break;
} }

View File

@@ -361,7 +361,7 @@ public class SpellAbilityRestriction extends SpellAbilityVariables {
if (this.getIsPresent() != null) { if (this.getIsPresent() != null) {
CardCollectionView list = game.getCardsIn(this.getPresentZone()); CardCollectionView list = game.getCardsIn(this.getPresentZone());
list = CardLists.getValidCards(list, this.getIsPresent().split(","), activator, c); list = CardLists.getValidCards(list, this.getIsPresent().split(","), activator, c, sa);
int right = 1; int right = 1;
final String rightString = this.getPresentCompare().substring(2); final String rightString = this.getPresentCompare().substring(2);

View File

@@ -114,8 +114,6 @@ public class TargetRestrictions {
* Constructor for Target. * Constructor for Target.
* </p> * </p>
* *
* @param src
* a {@link forge.game.card.Card} object.
* @param prompt * @param prompt
* a {@link java.lang.String} object. * a {@link java.lang.String} object.
* @param valid * @param valid
@@ -475,7 +473,7 @@ public class TargetRestrictions {
return true; return true;
} else { } else {
for (final Card c : game.getCardsIn(this.tgtZone)) { for (final Card c : game.getCardsIn(this.tgtZone)) {
if (!c.isValid(this.validTgts, srcCard.getController(), srcCard)) { if (!c.isValid(this.validTgts, srcCard.getController(), srcCard, sa)) {
continue; continue;
} }
if (isTargeted && !sa.canTarget(c)) { if (isTargeted && !sa.canTarget(c)) {
@@ -552,7 +550,7 @@ public class TargetRestrictions {
final Card srcCard = sa.getHostCard(); // should there be OrginalHost at any moment? final Card srcCard = sa.getHostCard(); // should there be OrginalHost at any moment?
if (this.tgtZone.contains(ZoneType.Stack)) { if (this.tgtZone.contains(ZoneType.Stack)) {
for (final Card c : game.getStackZone().getCards()) { for (final Card c : game.getStackZone().getCards()) {
if (c.isValid(this.validTgts, srcCard.getController(), srcCard) if (c.isValid(this.validTgts, srcCard.getController(), srcCard, sa)
&& (!isTargeted || sa.canTarget(c)) && (!isTargeted || sa.canTarget(c))
&& !sa.getTargets().isTargeting(c)) { && !sa.getTargets().isTargeting(c)) {
candidates.add(c); candidates.add(c);
@@ -560,7 +558,7 @@ public class TargetRestrictions {
} }
} else { } else {
for (final Card c : game.getCardsIn(this.tgtZone)) { for (final Card c : game.getCardsIn(this.tgtZone)) {
if (c.isValid(this.validTgts, srcCard.getController(), srcCard) if (c.isValid(this.validTgts, srcCard.getController(), srcCard, sa)
&& (!isTargeted || sa.canTarget(c)) && (!isTargeted || sa.canTarget(c))
&& !sa.getTargets().isTargeting(c)) { && !sa.getTargets().isTargeting(c)) {
candidates.add(c); candidates.add(c);

View File

@@ -502,7 +502,7 @@ public class StaticAbility extends CardTraitBase {
return false; return false;
} }
final Card topCard = controller.getCardsIn(ZoneType.Library).get(0); final Card topCard = controller.getCardsIn(ZoneType.Library).get(0);
if (!topCard.isValid(this.mapParams.get("TopCardOfLibraryIs").split(","), controller, this.hostCard)) { if (!topCard.isValid(this.mapParams.get("TopCardOfLibraryIs").split(","), controller, this.hostCard, null)) {
return false; return false;
} }
} }
@@ -580,7 +580,7 @@ public class StaticAbility extends CardTraitBase {
} }
/** /**
* @param c the ignoreEffectCards to set * @param cards the ignoreEffectCards to set
*/ */
public void setIgnoreEffectCards(final CardCollectionView cards) { public void setIgnoreEffectCards(final CardCollectionView cards) {
ignoreEffectCards = cards; ignoreEffectCards = cards;

View File

@@ -49,12 +49,12 @@ public class StaticAbilityCantAttackBlock {
final Card hostCard = stAb.getHostCard(); final Card hostCard = stAb.getHostCard();
if (params.containsKey("ValidCard") if (params.containsKey("ValidCard")
&& !card.isValid(params.get("ValidCard").split(","), hostCard.getController(), hostCard)) { && !card.isValid(params.get("ValidCard").split(","), hostCard.getController(), hostCard, null)) {
return false; return false;
} }
if (params.containsKey("Target") if (params.containsKey("Target")
&& !target.isValid(params.get("Target").split(","), hostCard.getController(), hostCard)) { && !target.isValid(params.get("Target").split(","), hostCard.getController(), hostCard, null)) {
return false; return false;
} }
@@ -63,14 +63,14 @@ public class StaticAbilityCantAttackBlock {
if (params.containsKey("UnlessDefenderControls")) { if (params.containsKey("UnlessDefenderControls")) {
String type = params.get("UnlessDefenderControls"); String type = params.get("UnlessDefenderControls");
CardCollectionView list = defender.getCardsIn(ZoneType.Battlefield); CardCollectionView list = defender.getCardsIn(ZoneType.Battlefield);
if (Iterables.any(list, CardPredicates.restriction(type.split(","), hostCard.getController(), hostCard))) { if (Iterables.any(list, CardPredicates.restriction(type.split(","), hostCard.getController(), hostCard, null))) {
return false; return false;
} }
} }
if (params.containsKey("IfDefenderControls")) { if (params.containsKey("IfDefenderControls")) {
String type = params.get("IfDefenderControls"); String type = params.get("IfDefenderControls");
CardCollectionView list = defender.getCardsIn(ZoneType.Battlefield); CardCollectionView list = defender.getCardsIn(ZoneType.Battlefield);
if (!Iterables.any(list, CardPredicates.restriction(type.split(","), hostCard.getController(), hostCard))) { if (!Iterables.any(list, CardPredicates.restriction(type.split(","), hostCard.getController(), hostCard, null))) {
return false; return false;
} }
} }
@@ -81,7 +81,7 @@ public class StaticAbilityCantAttackBlock {
} }
if (params.containsKey("UnlessDefender")) { if (params.containsKey("UnlessDefender")) {
final String type = params.get("UnlessDefender"); final String type = params.get("UnlessDefender");
if (defender.hasProperty(type, hostCard.getController(), hostCard)) { if (defender.hasProperty(type, hostCard.getController(), hostCard, null)) {
return false; return false;
} }
} }
@@ -103,12 +103,12 @@ public class StaticAbilityCantAttackBlock {
final Card hostCard = stAb.getHostCard(); final Card hostCard = stAb.getHostCard();
if (params.containsKey("ValidCard") if (params.containsKey("ValidCard")
&& !card.isValid(params.get("ValidCard").split(","), hostCard.getController(), hostCard)) { && !card.isValid(params.get("ValidCard").split(","), hostCard.getController(), hostCard, null)) {
return null; return null;
} }
if (params.containsKey("Target") if (params.containsKey("Target")
&& !target.isValid(params.get("Target").split(","), hostCard.getController(), hostCard)) { && !target.isValid(params.get("Target").split(","), hostCard.getController(), hostCard, null)) {
return null; return null;
} }
String costString = params.get("Cost"); String costString = params.get("Cost");
@@ -139,12 +139,12 @@ public class StaticAbilityCantAttackBlock {
final Card hostCard = stAb.getHostCard(); final Card hostCard = stAb.getHostCard();
if (params.containsKey("ValidCard") if (params.containsKey("ValidCard")
&& !blocker.isValid(params.get("ValidCard").split(","), hostCard.getController(), hostCard)) { && !blocker.isValid(params.get("ValidCard").split(","), hostCard.getController(), hostCard, null)) {
return null; return null;
} }
if (params.containsKey("Attacker") && attacker != null if (params.containsKey("Attacker") && attacker != null
&& !attacker.isValid(params.get("Attacker").split(","), hostCard.getController(), hostCard)) { && !attacker.isValid(params.get("Attacker").split(","), hostCard.getController(), hostCard, null)) {
return null; return null;
} }
String costString = params.get("Cost"); String costString = params.get("Cost");

View File

@@ -47,12 +47,12 @@ public class StaticAbilityCantBeCast {
final Card hostCard = stAb.getHostCard(); final Card hostCard = stAb.getHostCard();
if (params.containsKey("ValidCard") if (params.containsKey("ValidCard")
&& !card.isValid(params.get("ValidCard").split(","), hostCard.getController(), hostCard)) { && !card.isValid(params.get("ValidCard").split(","), hostCard.getController(), hostCard, null)) {
return false; return false;
} }
if (params.containsKey("Caster") && (activator != null) if (params.containsKey("Caster") && (activator != null)
&& !activator.isValid(params.get("Caster"), hostCard.getController(), hostCard)) { && !activator.isValid(params.get("Caster"), hostCard.getController(), hostCard, null)) {
return false; return false;
} }
@@ -98,7 +98,7 @@ public class StaticAbilityCantBeCast {
final Player activator = spellAbility.getActivatingPlayer(); final Player activator = spellAbility.getActivatingPlayer();
if (params.containsKey("ValidCard") if (params.containsKey("ValidCard")
&& !card.isValid(params.get("ValidCard").split(","), hostCard.getController(), hostCard)) { && !card.isValid(params.get("ValidCard").split(","), hostCard.getController(), hostCard, null)) {
return false; return false;
} }
@@ -107,7 +107,7 @@ public class StaticAbilityCantBeCast {
} }
if (params.containsKey("Activator") && (activator != null) if (params.containsKey("Activator") && (activator != null)
&& !activator.isValid(params.get("Activator"), hostCard.getController(), hostCard)) { && !activator.isValid(params.get("Activator"), hostCard.getController(), hostCard, spellAbility)) {
return false; return false;
} }
@@ -138,12 +138,12 @@ public class StaticAbilityCantBeCast {
final Card hostCard = stAb.getHostCard(); final Card hostCard = stAb.getHostCard();
if (params.containsKey("ValidCard") if (params.containsKey("ValidCard")
&& (card == null || !card.isValid(params.get("ValidCard").split(","), hostCard.getController(), hostCard))) { && (card == null || !card.isValid(params.get("ValidCard").split(","), hostCard.getController(), hostCard, null))) {
return false; return false;
} }
if (params.containsKey("Player") && (player != null) if (params.containsKey("Player") && (player != null)
&& !player.isValid(params.get("Player"), hostCard.getController(), hostCard)) { && !player.isValid(params.get("Player"), hostCard.getController(), hostCard, null)) {
return false; return false;
} }

View File

@@ -62,17 +62,17 @@ public class StaticAbilityCantTarget {
} }
if (params.containsKey("ValidCard") if (params.containsKey("ValidCard")
&& !card.isValid(params.get("ValidCard").split(","), hostCard.getController(), hostCard)) { && !card.isValid(params.get("ValidCard").split(","), hostCard.getController(), hostCard, null)) {
return false; return false;
} }
if (params.containsKey("ValidSource") if (params.containsKey("ValidSource")
&& !source.isValid(params.get("ValidSource").split(","), hostCard.getController(), hostCard)) { && !source.isValid(params.get("ValidSource").split(","), hostCard.getController(), hostCard, null)) {
return false; return false;
} }
if (params.containsKey("Activator") && (activator != null) if (params.containsKey("Activator") && (activator != null)
&& !activator.isValid(params.get("Activator"), hostCard.getController(), hostCard)) { && !activator.isValid(params.get("Activator"), hostCard.getController(), hostCard, spellAbility)) {
return false; return false;
} }

View File

@@ -339,7 +339,7 @@ public final class StaticAbilityContinuous {
} }
CardCollectionView cardsIGainedAbilitiesFrom = game.getCardsIn(validZones); CardCollectionView cardsIGainedAbilitiesFrom = game.getCardsIn(validZones);
cardsIGainedAbilitiesFrom = CardLists.getValidCards(cardsIGainedAbilitiesFrom, valids, hostCard.getController(), hostCard); cardsIGainedAbilitiesFrom = CardLists.getValidCards(cardsIGainedAbilitiesFrom, valids, hostCard.getController(), hostCard, null);
if (cardsIGainedAbilitiesFrom.size() > 0) { if (cardsIGainedAbilitiesFrom.size() > 0) {
addFullAbs = new ArrayList<SpellAbility>(); addFullAbs = new ArrayList<SpellAbility>();
@@ -671,7 +671,7 @@ public final class StaticAbilityContinuous {
final String[] strngs = params.get("Affected").split(","); final String[] strngs = params.get("Affected").split(",");
for (Player p : controller.getGame().getPlayersInTurnOrder()) { for (Player p : controller.getGame().getPlayersInTurnOrder()) {
if (p.isValid(strngs, controller, hostCard)) { if (p.isValid(strngs, controller, hostCard, null)) {
players.add(p); players.add(p);
} }
} }
@@ -712,7 +712,7 @@ public final class StaticAbilityContinuous {
} }
if (params.containsKey("Affected")) { if (params.containsKey("Affected")) {
affectedCards = CardLists.getValidCards(affectedCards, params.get("Affected").split(","), controller, hostCard); affectedCards = CardLists.getValidCards(affectedCards, params.get("Affected").split(","), controller, hostCard, null);
} }
affectedCards.removeAll((List<?>) stAb.getIgnoreEffectCards()); affectedCards.removeAll((List<?>) stAb.getIgnoreEffectCards());
return affectedCards; return affectedCards;

View File

@@ -40,7 +40,7 @@ public class StaticAbilityETBTapped {
final Card hostCard = stAb.getHostCard(); final Card hostCard = stAb.getHostCard();
if (params.containsKey("ValidCard") if (params.containsKey("ValidCard")
&& !card.isValid(params.get("ValidCard").split(","), hostCard.getController(), hostCard)) { && !card.isValid(params.get("ValidCard").split(","), hostCard.getController(), hostCard, null)) {
return false; return false;
} }

View File

@@ -50,12 +50,12 @@ public class StaticAbilityPreventDamage {
int restDamage = damage; int restDamage = damage;
if (params.containsKey("Source") if (params.containsKey("Source")
&& !source.isValid(params.get("Source").split(","), hostCard.getController(), hostCard)) { && !source.isValid(params.get("Source").split(","), hostCard.getController(), hostCard, null)) {
return restDamage; return restDamage;
} }
if (params.containsKey("Target") if (params.containsKey("Target")
&& !target.isValid(params.get("Target").split(","), hostCard.getController(), hostCard)) { && !target.isValid(params.get("Target").split(","), hostCard.getController(), hostCard, null)) {
return restDamage; return restDamage;
} }

View File

@@ -284,7 +284,7 @@ public abstract class Trigger extends TriggerReplacementBase {
} else if ("AttackedPlayerWithMostLife".equals(condition)) { } else if ("AttackedPlayerWithMostLife".equals(condition)) {
GameEntity attacked = (GameEntity) runParams.get("Attacked"); GameEntity attacked = (GameEntity) runParams.get("Attacked");
if (attacked == null || !attacked.isValid("Player.withMostLife", if (attacked == null || !attacked.isValid("Player.withMostLife",
this.getHostCard().getController(), this.getHostCard())) { this.getHostCard().getController(), this.getHostCard(), null)) {
return false; return false;
} }
} }

View File

@@ -54,7 +54,7 @@ public class TriggerAttached extends Trigger {
if (this.mapParams.containsKey("ValidSource")) { if (this.mapParams.containsKey("ValidSource")) {
if (!src.isValid(this.mapParams.get("ValidSource").split(","), this.getHostCard().getController(), if (!src.isValid(this.mapParams.get("ValidSource").split(","), this.getHostCard().getController(),
this.getHostCard())) { this.getHostCard(), null)) {
return false; return false;
} }
} }

View File

@@ -64,7 +64,7 @@ public class TriggerAttacks extends Trigger {
if (this.mapParams.containsKey("Attacked")) { if (this.mapParams.containsKey("Attacked")) {
GameEntity attacked = (GameEntity) runParams2.get("Attacked"); GameEntity attacked = (GameEntity) runParams2.get("Attacked");
if (!attacked.isValid(this.mapParams.get("Attacked").split(",") if (!attacked.isValid(this.mapParams.get("Attacked").split(",")
, this.getHostCard().getController(), this.getHostCard())) { , this.getHostCard().getController(), this.getHostCard(), null)) {
return false; return false;
} }
} }

View File

@@ -55,13 +55,13 @@ public class TriggerChampioned extends Trigger {
if (this.mapParams.containsKey("ValidCard")) { if (this.mapParams.containsKey("ValidCard")) {
if (!championed.isValid(this.mapParams.get("ValidCard").split(","), if (!championed.isValid(this.mapParams.get("ValidCard").split(","),
this.getHostCard().getController(), this.getHostCard())) { this.getHostCard().getController(), this.getHostCard(), null)) {
return false; return false;
} }
} }
if (this.mapParams.containsKey("ValidSource")) { if (this.mapParams.containsKey("ValidSource")) {
if (!source.isValid(this.mapParams.get("ValidSource").split(","), if (!source.isValid(this.mapParams.get("ValidSource").split(","),
this.getHostCard().getController(), this.getHostCard())) { this.getHostCard().getController(), this.getHostCard(), null)) {
return false; return false;
} }
} }

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