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) {
if (!c.getSVar("NeedsToPlay").isEmpty()) {
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()) {
return false;
}
@@ -697,7 +697,7 @@ public class AiController {
SpellAbility effectExile = AbilityFactory.getAbility(card.getSVar("TrigExile"), card);
final ZoneType origin = ZoneType.listValueOf(effectExile.getParam("Origin")).get(0);
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);
if (sa.getHostCard().getName().equals("Suspension Field")) {
//existing "exile until leaves" enchantments only target opponent's permanents
@@ -794,7 +794,7 @@ public class AiController {
final String needsToPlay = card.getSVar("NeedsToPlay");
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()) {
return AiPlayDecision.MissingNeededCards;
}
@@ -917,7 +917,7 @@ public class AiController {
public CardCollection getCardsToDiscard(final int numDiscard, final String[] uTypes, final SpellAbility sa) {
CardCollection hand = new CardCollection(player.getCardsIn(ZoneType.Hand));
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);
}
@@ -1356,7 +1356,6 @@ public class AiController {
* Ai should run.
*
* @param sa the sa
* @param ai
* @return true, if successful
*/
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>();
for (SpellAbilityStackInstance si :source.getGame().getStack()) {
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);
}
}
@@ -189,7 +189,7 @@ public class AiCostDecision extends CostDecisionMakerBase {
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) {
return null;
@@ -230,7 +230,7 @@ public class AiCostDecision extends CostDecisionMakerBase {
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) {
return null;
@@ -329,7 +329,7 @@ public class AiCostDecision extends CostDecisionMakerBase {
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()) {
// Jotun Grunt
@@ -356,7 +356,8 @@ public class AiCostDecision extends CostDecisionMakerBase {
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;
if (cost.getType().equals("Creature.YouCtrl")) {
@@ -382,7 +383,8 @@ public class AiCostDecision extends CostDecisionMakerBase {
final String sVar = ability.getSVar(amount);
if (sVar.equals("XChoice")) {
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);
c = typeList.size();
source.setSVar("ChosenX", "Number$" + Integer.toString(c));
@@ -467,7 +469,7 @@ public class AiCostDecision extends CostDecisionMakerBase {
return null;
}
hand = CardLists.getValidCards(hand, type.split(";"), player, source);
hand = CardLists.getValidCards(hand, type.split(";"), player, source, ability);
Integer c = cost.convertAmount();
if (c == null) {
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 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>() {
@Override
public boolean apply(final Card crd) {
@@ -539,7 +541,7 @@ public class AiCostDecision extends CostDecisionMakerBase {
if (type.equals("OriginalHost")) {
typeList = new CardCollection(ability.getOriginalHost());
} 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) {
if (card.getCounters(cost.counter) >= c) {
@@ -564,7 +566,8 @@ public class AiCostDecision extends CostDecisionMakerBase {
if (c == null) {
final String sVar = ability.getSVar(amount);
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) {
typeList.remove(source);
}

View File

@@ -278,7 +278,7 @@ public class ComputerUtil {
if (activate != null) {
final String[] prefValid = activate.getSVar("AIPreference").split("\\$");
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) {
CardLists.shuffle(prefList);
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) {
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.")) {
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,
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)) {
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,
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)) {
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) {
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?
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) {
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?
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) {
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)) {
// don't bounce the card we're pumping
typeList.remove(target);
@@ -661,7 +661,7 @@ public class ComputerUtil {
final TargetRestrictions tgt = sa.getTargetRestrictions();
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;
}
} else if (AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa).contains(card)) {
@@ -699,7 +699,7 @@ public class ComputerUtil {
}
final TargetRestrictions tgt = sa.getTargetRestrictions();
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);
}
@@ -768,7 +768,7 @@ public class ComputerUtil {
if (buffedcard.hasSVar("BuffedBy")) {
final String buffedby = buffedcard.getSVar("BuffedBy");
final String[] bffdby = buffedby.split(",");
if (card.isValid(bffdby, buffedcard.getController(), buffedcard)) {
if (card.isValid(bffdby, buffedcard.getController(), buffedcard, sa)) {
return true;
}
}
@@ -797,7 +797,7 @@ public class ComputerUtil {
if (buffedcard.hasSVar("AntiBuffedBy")) {
final String buffedby = buffedcard.getSVar("AntiBuffedBy");
final String[] bffdby = buffedby.split(",");
if (card.isValid(bffdby, buffedcard.getController(), buffedcard)) {
if (card.isValid(bffdby, buffedcard.getController(), buffedcard, sa)) {
return true;
}
}
@@ -884,7 +884,7 @@ public class ComputerUtil {
// not castable for at least one other turn.
return true;
} 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.
return true;
}
@@ -929,7 +929,7 @@ public class ComputerUtil {
if (buffedCard.hasSVar("BuffedBy")) {
final String buffedby = buffedCard.getSVar("BuffedBy");
final String[] bffdby = buffedby.split(",");
if (source.isValid(bffdby, buffedCard.getController(), buffedCard)) {
if (source.isValid(bffdby, buffedCard.getController(), buffedCard, sa)) {
return true;
}
}
@@ -949,7 +949,7 @@ public class ComputerUtil {
if (buffedcard.hasSVar("AntiBuffedBy")) {
final String buffedby = buffedcard.getSVar("AntiBuffedBy");
final String[] bffdby = buffedby.split(",");
if (source.isValid(bffdby, buffedcard.getController(), buffedcard)) {
if (source.isValid(bffdby, buffedcard.getController(), buffedcard, sa)) {
return true;
}
}
@@ -1008,7 +1008,7 @@ public class ComputerUtil {
}
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) {
if (c.getSVar("SacMe").equals("6")) {
return true;
@@ -1150,7 +1150,7 @@ public class ComputerUtil {
objects = AbilityUtils.getDefinedObjects(source, topStack.getParam("Defined"), topStack);
} else if (topStack.hasParam("ValidCards")) {
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 {
return threatened;
}
@@ -1797,13 +1797,13 @@ public class ComputerUtil {
continue;
}
if (trigParams.containsKey("ValidCard")) {
if (!card.isValid(trigParams.get("ValidCard"), source.getController(), source)) {
if (!card.isValid(trigParams.get("ValidCard"), source.getController(), source, sa)) {
continue;
}
}
if (trigParams.containsKey("ValidActivatingPlayer")) {
if (!player.isValid(trigParams.get("ValidActivatingPlayer"), source.getController(), source)) {
if (!player.isValid(trigParams.get("ValidActivatingPlayer"), source.getController(), source, sa)) {
continue;
}
}
@@ -1869,7 +1869,7 @@ public class ComputerUtil {
continue;
}
if (trigParams.containsKey("ValidCard")) {
if (!permanent.isValid(trigParams.get("ValidCard"), source.getController(), source)) {
if (!permanent.isValid(trigParams.get("ValidCard"), source.getController(), source, null)) {
continue;
}
}

View File

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

View File

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

View File

@@ -108,7 +108,7 @@ public class ComputerUtilCost {
if (type.equals("CARDNAME") && source.getAbilityText().contains("Bloodrush")) {
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()) {
continue;
}
@@ -217,7 +217,7 @@ public class ComputerUtilCost {
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) {
return false;
}
@@ -257,7 +257,7 @@ public class ComputerUtilCost {
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) {
return false;
}
@@ -321,8 +321,7 @@ public class ComputerUtilCost {
*
* @param hostCard
* a {@link forge.game.card.Card} object.
* @param costString
* a {@link java.lang.String} object.
* @param cost
* @return a boolean.
*/
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");
if (!StringUtils.isBlank(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)
continue;

View File

@@ -76,14 +76,15 @@ public class AnimateAi extends SpellAbilityAi {
num = (num == null) ? "1" : num;
final int nToSac = AbilityUtils.calculateAmount(topStack.getHostCard(), num, topStack);
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));
ComputerUtilCard.sortByEvaluateCreature(list);
if (!list.isEmpty() && list.size() == nToSac && ComputerUtilCost.canPayCost(sa, aiPlayer)) {
Card animatedCopy = CardFactory.copyCard(source, true);
becomeAnimated(animatedCopy, source.hasSickness(), sa);
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));
if (ComputerUtilCard.evaluateCreature(animatedCopy) < ComputerUtilCard.evaluateCreature(list.get(0))
&& list.contains(animatedCopy)) {
@@ -98,7 +99,7 @@ public class AnimateAi extends SpellAbilityAi {
if (ph.getPlayerTurn().isOpponentOf(aiPlayer) || ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)) {
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) {
if (ComputerUtilCard.doesCreatureAttackAI(aiPlayer, c)) {
sa.getTargets().add(c);
@@ -237,7 +238,7 @@ public class AnimateAi extends SpellAbilityAi {
final TargetRestrictions tgt = sa.getTargetRestrictions();
final Card animateSource = sa.getHostCard();
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);
if (!prefList.isEmpty()){
CardLists.shuffle(prefList);

View File

@@ -81,7 +81,7 @@ public class AttachAi extends SpellAbilityAi {
final SpellAbility effectExile = AbilityFactory.getAbility(source.getSVar("TrigExile"), source);
final ZoneType origin = ZoneType.listValueOf(effectExile.getParam("Origin")).get(0);
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>() {
@Override
public boolean apply(final Card c) {
@@ -283,9 +283,7 @@ public class AttachAi extends SpellAbilityAi {
/**
* Attach to player ai preferences.
*
* @param af
* the af
*
* @param sa
* the sa
* @param mandatory
@@ -695,8 +693,6 @@ public class AttachAi extends SpellAbilityAi {
* the sa
* @param mandatory
* the mandatory
* @param af
* the af
*
* @return true, if successful
*/
@@ -766,9 +762,7 @@ public class AttachAi extends SpellAbilityAi {
/**
* Attach preference.
*
* @param af
* the af
*
* @param sa
* the sa
* @param sa
@@ -1051,7 +1045,7 @@ public class AttachAi extends SpellAbilityAi {
if (tgt == null) {
list = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa);
} 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.
// I believe this is the only case where mandatory will be true, so just
// 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.
*
* @param card
* @param c
* the card
* @param sa 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) {
sa.resetTargets();
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.getNotKeyword(list, "Trample");

View File

@@ -25,7 +25,7 @@ public class BidLifeAi extends SpellAbilityAi {
sa.resetTargets();
if (tgt.canTgtCreature()) {
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()) {
return false;
}

View File

@@ -42,8 +42,6 @@ public class ChangeZoneAi extends SpellAbilityAi {
* </p>
* @param sa
* a {@link forge.game.spellability.SpellAbility} object.
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
*
* @return a boolean.
*/
@@ -81,8 +79,6 @@ public class ChangeZoneAi extends SpellAbilityAi {
* </p>
* @param sa
* a {@link forge.game.spellability.SpellAbility} object.
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
*
* @return a boolean.
*/
@@ -109,8 +105,6 @@ public class ChangeZoneAi extends SpellAbilityAi {
* a {@link forge.game.spellability.SpellAbility} object.
* @param mandatory
* a boolean.
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
*
* @return a boolean.
*/
@@ -144,9 +138,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
* <p>
* changeHiddenOriginCanPlayAI.
* </p>
*
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
*
* @param sa
* a {@link forge.game.spellability.SpellAbility} object.
* @return a boolean.
@@ -349,9 +341,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
* <p>
* changeHiddenOriginPlayDrawbackAI.
* </p>
*
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
*
* @param sa
* a {@link forge.game.spellability.SpellAbility} object.
* @return a boolean.
@@ -379,9 +369,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
* <p>
* changeHiddenTriggerAI.
* </p>
*
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
*
* @param sa
* a {@link forge.game.spellability.SpellAbility} object.
* @param mandatory
@@ -465,7 +453,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
* @param ai
*
* @param list
* a {@link forge.CardList} object.
* a List<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
@@ -560,9 +548,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
* <p>
* changeKnownOriginCanPlayAI.
* </p>
*
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
*
* @param sa
* a {@link forge.game.spellability.SpellAbility} object.
* @return a boolean.
@@ -689,9 +675,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
* <p>
* changeKnownOriginPlayDrawbackAI.
* </p>
*
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
*
* @param sa
* a {@link forge.game.spellability.SpellAbility} object.
* @return a boolean.
@@ -708,9 +692,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
* <p>
* changeKnownPreferredTarget.
* </p>
*
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
*
* @param sa
* a {@link forge.game.spellability.SpellAbility} object.
* @param mandatory
@@ -735,7 +717,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
}
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);
if (sa.hasParam("AITgts")) {
list = CardLists.getValidCards(list, sa.getParam("AITgts"), ai, source);
@@ -753,7 +735,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
@Override
public boolean apply(final Card c) {
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;
}
}
@@ -1114,7 +1096,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
final ZoneType destination = ZoneType.smartValueOf(sa.getParam("Destination"));
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:
if (origin.equals(ZoneType.Battlefield)) {
@@ -1203,9 +1185,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
* <p>
* changeKnownOriginTriggerAI.
* </p>
*
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
*
* @param sa
* a {@link forge.game.spellability.SpellAbility} object.
* @param mandatory

View File

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

View File

@@ -31,7 +31,7 @@ public class ControlExchangeAi extends SpellAbilityAi {
sa.resetTargets();
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
// purpose
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);
} else if (tgt.getMinTargets(sa.getHostCard(), sa) > 1) {
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);
sa.getTargets().add(object2);
}
@@ -69,7 +69,8 @@ public class ControlExchangeAi extends SpellAbilityAi {
}
} else {
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()) {
Card best = ComputerUtilCard.getBestAI(list2);
if (sa.canTarget(best)) {

View File

@@ -119,7 +119,7 @@ public class ControlGainAi extends SpellAbilityAi {
}
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
list = CardLists.filter(list, new Predicate<Card>() {

View File

@@ -57,7 +57,8 @@ public class CopyPermanentAi extends SpellAbilityAi {
if (abTgt != null) {
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.filter(list, new Predicate<Card>() {
@Override

View File

@@ -48,7 +48,7 @@ public class CounterAi extends SpellAbilityAi {
return false;
}
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;
}

View File

@@ -79,12 +79,12 @@ public class CountersMoveAi extends SpellAbilityAi {
} else { // targeted
final Player player = sa.isCurse() ? ai.getOpponent() : ai;
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 there isn't any prefered cards to target, gotta choose
// non-preferred ones
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;
}
// 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)) {
return false;
@@ -365,7 +365,7 @@ public class CountersPutAi extends SpellAbilityAi {
if (abTgt != null) {
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) {
return false;
@@ -454,7 +454,7 @@ public class CountersPutAi extends SpellAbilityAi {
}
} else {
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();
@@ -468,7 +468,7 @@ public class CountersPutAi extends SpellAbilityAi {
if (list.isEmpty() && preferred) {
// 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.getValidCards(list, abTgt.getValidTgts(), source.getController(), source);
list = CardLists.getValidCards(list, abTgt.getValidTgts(), source.getController(), source, sa);
preferred = false;
}
}

View File

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

View File

@@ -186,7 +186,7 @@ public class DamageAllAi extends SpellAbilityAi {
// TODO: X may be something different than X paid
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>() {
@Override

View File

@@ -167,7 +167,7 @@ public class DamageDealAi extends DamageAiBase {
}
final TargetRestrictions tgt = sa.getTargetRestrictions();
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());
if (sa.hasParam("TargetUnique")) {

View File

@@ -102,7 +102,7 @@ public class DamagePreventAi extends SpellAbilityAi {
}
final List<Card> threatenedTargets = new ArrayList<Card>();
// 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);
for (final Card c : targetables) {
@@ -129,7 +129,7 @@ public class DamagePreventAi extends SpellAbilityAi {
} else {
// filter AIs battlefield by what I can target
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);
if (targetables.isEmpty()) {
@@ -171,9 +171,7 @@ public class DamagePreventAi extends SpellAbilityAi {
* <p>
* preventDamageMandatoryTarget.
* </p>
*
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
*
* @param sa
* a {@link forge.game.spellability.SpellAbility} object.
* @param mandatory
@@ -186,7 +184,7 @@ public class DamagePreventAi extends SpellAbilityAi {
// filter AIs battlefield by what I can target
final Game game = ai.getGame();
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);
Card target = null;

View File

@@ -107,9 +107,7 @@ public class DebuffAi extends SpellAbilityAi {
* <p>
* debuffTgtAI.
* </p>
*
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
*
* @param sa
* a {@link forge.game.spellability.SpellAbility} object.
* @param kws
@@ -127,7 +125,7 @@ public class DebuffAi extends SpellAbilityAi {
final TargetRestrictions tgt = sa.getTargetRestrictions();
sa.resetTargets();
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:
// 1. make human creatures lose evasion when they are attacking
@@ -170,14 +168,12 @@ public class DebuffAi extends SpellAbilityAi {
* <p>
* getCurseCreatures.
* </p>
*
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
*
* @param sa
* a {@link forge.game.spellability.SpellAbility} object.
* @param kws
* 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) {
final Player opp = ai.getOpponent();
@@ -198,9 +194,7 @@ public class DebuffAi extends SpellAbilityAi {
* <p>
* debuffMandatoryTarget.
* </p>
*
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
*
* @param sa
* a {@link forge.game.spellability.SpellAbility} object.
* @param mandatory
@@ -209,7 +203,8 @@ public class DebuffAi extends SpellAbilityAi {
*/
private boolean debuffMandatoryTarget(final Player ai, final SpellAbility sa, final boolean mandatory) {
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)) {
sa.resetTargets();

View File

@@ -246,7 +246,7 @@ public class DestroyAi extends SpellAbilityAi {
sa.resetTargets();
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)) {
return false;

View File

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

View File

@@ -42,7 +42,7 @@ public class DigUntilAi extends SpellAbilityAi {
} else {
if (sa.hasParam("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;
}
}

View File

@@ -74,7 +74,7 @@ public class EffectAi extends SpellAbilityAi {
}
} else {
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);
Card target = ComputerUtilCard.getBestCreatureAI(list);
if (target == null) {

View File

@@ -62,7 +62,7 @@ public class MustBlockAi extends SpellAbilityAi {
if (abTgt != null) {
List<Card> list = CardLists.filter(ai.getOpponent().getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES);
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>() {
@Override
public boolean apply(final Card c) {

View File

@@ -107,7 +107,7 @@ public class PhasesAi extends SpellAbilityAi {
final TargetRestrictions tgt = sa.getTargetRestrictions();
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;
}

View File

@@ -63,7 +63,7 @@ public class PlayAi extends SpellAbilityAi {
final TargetRestrictions tgt = sa.getTargetRestrictions();
if (tgt != null) {
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()) {
return false;
}
@@ -85,8 +85,6 @@ public class PlayAi extends SpellAbilityAi {
* a {@link forge.game.spellability.SpellAbility} object.
* @param mandatory
* a boolean.
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
*
* @return a boolean.
*/

View File

@@ -31,7 +31,7 @@ public class PowerExchangeAi extends SpellAbilityAi {
sa.resetTargets();
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
// purpose
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);
}
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);
Collections.reverse(list2);
c2 = list2.isEmpty() ? null : list2.get(0);

View File

@@ -99,10 +99,7 @@ public class ProtectAi extends SpellAbilityAi {
* <p>
* getProtectCreatures.
* </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) {
final List<String> gains = ProtectEffect.getProtectionList(sa);
@@ -252,7 +249,7 @@ public class ProtectAi extends SpellAbilityAi {
sa.resetTargets();
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 the cost is tapping, don't activate before declare
@@ -306,7 +303,7 @@ public class ProtectAi extends SpellAbilityAi {
final Game game = ai.getGame();
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)) {
sa.resetTargets();

View File

@@ -240,7 +240,7 @@ public class PumpAi extends PumpAiBase {
CardCollection list;
if (sa.hasParam("AILogic")) {
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);
CardLists.sortByPowerDesc(list);
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 the cost is tapping, don't activate before declare
// attack/block
@@ -359,7 +359,7 @@ public class PumpAi extends PumpAiBase {
final Game game = ai.getGame();
final TargetRestrictions tgt = sa.getTargetRestrictions();
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);
if (list.size() < tgt.getMinTargets(sa.getHostCard(), sa)) {

View File

@@ -115,7 +115,7 @@ public class RegenerateAi extends SpellAbilityAi {
} else {
sa.resetTargets();
// 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);
if (targetables.size() == 0) {
@@ -184,7 +184,7 @@ public class RegenerateAi extends SpellAbilityAi {
sa.resetTargets();
// filter AIs battlefield by what I can target
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);
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);
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));
if (list.size() == 0) {

View File

@@ -72,7 +72,7 @@ public class SacrificeAi extends SpellAbilityAi {
final int amount = AbilityUtils.calculateAmount(sa.getHostCard(), num, sa);
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) {
if (c.hasSVar("SacMe") && Integer.parseInt(c.getSVar("SacMe")) > 3) {
return false;
@@ -126,7 +126,7 @@ public class SacrificeAi extends SpellAbilityAi {
}
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
// (or X for X) trades for special decks
@@ -135,7 +135,7 @@ public class SacrificeAi extends SpellAbilityAi {
}
} else if (defined.equals("You")) {
List<Card> computerList =
CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), valid.split(","), sa.getActivatingPlayer(), sa.getHostCard());
CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), valid.split(","), sa.getActivatingPlayer(), sa.getHostCard(), sa);
for (Card c : computerList) {
if (c.hasSVar("SacMe") || ComputerUtilCard.evaluateCreature(c) <= 135) {
return true;

View File

@@ -38,9 +38,9 @@ public class SacrificeAllAi extends SpellAbilityAi {
}
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 =
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) {
// AI currently disabled for some costs

View File

@@ -29,12 +29,11 @@ public abstract class TapAiBase extends SpellAbilityAi {
* tapTargetList.
* </p>
*
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
* @param sa
* a {@link forge.game.spellability.SpellAbility} object.
* @param tapList
* a {@link forge.CardList} object.
* a CardCollection object.
* @param mandatory
* a boolean.
* @return a boolean.
@@ -105,8 +104,6 @@ public abstract class TapAiBase extends SpellAbilityAi {
* a {@link forge.game.card.Card} object.
* @param tgt
* a {@link forge.game.spellability.TargetRestrictions} object.
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
* @param sa
* a {@link forge.game.spellability.SpellAbility} object.
* @param mandatory
@@ -117,7 +114,7 @@ public abstract class TapAiBase extends SpellAbilityAi {
final Player opp = ai.getOpponent();
final Game game = ai.getGame();
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.filter(tapList, Presets.UNTAPPED);
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
if (tapList.isEmpty() && ComputerUtil.activateForCost(sa, ai)) {
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.filter(tapList, new Predicate<Card>() {
@Override
@@ -252,9 +249,7 @@ public abstract class TapAiBase extends SpellAbilityAi {
* <p>
* tapUnpreferredTargeting.
* </p>
*
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
*
* @param sa
* a {@link forge.game.spellability.SpellAbility} object.
* @param mandatory
@@ -266,7 +261,7 @@ public abstract class TapAiBase extends SpellAbilityAi {
final TargetRestrictions tgt = sa.getTargetRestrictions();
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);
// 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.
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)) {
return true;

View File

@@ -181,7 +181,7 @@ public class TokenAi extends SpellAbilityAi {
} else {
//Flash Foliage
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);
CardCollection betterList = CardLists.filter(list, new Predicate<Card>() {
@Override
@@ -233,14 +233,14 @@ public class TokenAi extends SpellAbilityAi {
num = (num == null) ? "1" : num;
final int nToSac = AbilityUtils.calculateAmount(topStack.getHostCard(), num, topStack);
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));
if (!list.isEmpty() && nTokens > 0 && list.size() == nToSac) { //only care about saving single creature for now
ComputerUtilCard.sortByEvaluateCreature(list);
Card token = spawnToken(ai, sa);
if (token != null) {
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));
if (ComputerUtilCard.evaluateCreature(token) < ComputerUtilCard.evaluateCreature(list.get(0))
&& list.contains(token)) {

View File

@@ -109,8 +109,6 @@ public class UntapAi extends SpellAbilityAi {
*
* @param tgt
* a {@link forge.game.spellability.TargetRestrictions} object.
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
* @param sa
* a {@link forge.game.spellability.SpellAbility} object.
* @param mandatory
@@ -127,7 +125,7 @@ public class UntapAi extends SpellAbilityAi {
}
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()) {
return false;
@@ -137,7 +135,7 @@ public class UntapAi extends SpellAbilityAi {
// filter out enchantments and planeswalkers, their tapped state doesn't
// matter.
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)) {
Card choice = null;
@@ -198,9 +196,7 @@ public class UntapAi extends SpellAbilityAi {
* <p>
* untapUnpreferredTargeting.
* </p>
*
* @param af
* a {@link forge.game.ability.AbilityFactory} object.
*
* @param sa
* a {@link forge.game.spellability.SpellAbility} object.
* @param mandatory
@@ -211,13 +207,14 @@ public class UntapAi extends SpellAbilityAi {
final Card source = sa.getHostCard();
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);
// filter by enchantments and planeswalkers, their tapped state doesn't
// matter.
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)) {
return true;

View File

@@ -27,7 +27,7 @@ public class UntapAllAi extends SpellAbilityAi {
if (sa.hasParam("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 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) {
if (o instanceof GameEntity) {
final GameEntity c = (GameEntity) o;
return c.isValid(valids, srcCard.getController(), srcCard);
return c.isValid(valids, srcCard.getController(), srcCard, null);
}
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;
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;
final String rightString = presentCompare.substring(2);

View File

@@ -19,11 +19,12 @@ public abstract class GameObject {
* the source controller
* @param source
* the source
* @param spellAbility
* @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) {
if (this.isValid(restriction, sourceController, source)) {
if (this.isValid(restriction, sourceController, source, spellAbility)) {
return true;
}
}
@@ -39,9 +40,10 @@ public abstract class GameObject {
* the source controller
* @param source
* the source
* @param spellAbility
* @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;
}
@@ -54,9 +56,10 @@ public abstract class GameObject {
* the source controller
* @param source
* the source
* @param spellAbility
* @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;
}
}

View File

@@ -274,17 +274,17 @@ public class AbilityUtils {
}
else if (defined.startsWith("Valid ")) {
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 ")) {
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")) {
String[] s = defined.split(" ");
String zone = s[0].substring("Valid".length());
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 {
return cards;
@@ -432,7 +432,7 @@ public class AbilityUtils {
else if (hType.startsWith("Property") && ability instanceof SpellAbility) {
String defined = hType.split("Property")[1];
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);
}
}
@@ -785,7 +785,7 @@ public class AbilityUtils {
String var = sa.getParam("AbilityCount");
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 {
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);
}
}

View File

@@ -142,7 +142,7 @@ public class AnimateAllEffect extends AnimateEffectBase {
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) {
doAnimate(c, sa, power, toughness, types, removeTypes, finalDesc,

View File

@@ -84,8 +84,6 @@ public class AttachEffect extends SpellAbilityEffect {
* the card
* @param o
* the o
* @param af
* the af
*/
public static void handleAttachment(final Card card, final Object o, final SpellAbility sa) {
@@ -126,8 +124,6 @@ public class AttachEffect extends SpellAbilityEffect {
* the card
* @param tgt
* the tgt
* @param gainControl
* the gain control
*/
public static void handleAura(final Card card, final GameEntity tgt) {
if (card.isEnchanting()) {
@@ -196,7 +192,7 @@ public class AttachEffect extends SpellAbilityEffect {
final FCollection<Player> players = new FCollection<Player>();
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);
}
}
@@ -208,7 +204,7 @@ public class AttachEffect extends SpellAbilityEffect {
}
else {
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()) {
return false;
}

View File

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

View File

@@ -118,7 +118,7 @@ public class CopyPermanentEffect extends SpellAbilityEffect {
final PaperCard cp = Aggregates.random(copysource);
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);
copysource.remove(cp);
ncopied -= 1;

View File

@@ -31,7 +31,7 @@ public class CounterEffect extends SpellAbilityEffect {
continue;
}
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;
}
}
@@ -76,7 +76,7 @@ public class CounterEffect extends SpellAbilityEffect {
continue;
}
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;
}
}
@@ -145,7 +145,6 @@ public class CounterEffect extends SpellAbilityEffect {
* @param si
* a {@link forge.game.spellability.SpellAbilityStackInstance}
* object.
* @param sa
*/
private static void removeFromStack(final SpellAbility tgtSA,
final SpellAbility srcSA, final SpellAbilityStackInstance si) {

View File

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

View File

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

View File

@@ -124,7 +124,7 @@ public class DigUntilEffect extends SpellAbilityEffect {
for (int i = 0; i < maxToDig; i++) {
final Card c = library.get(i);
revealed.add(c);
if (c.isValid(type, sa.getActivatingPlayer(), host)) {
if (c.isValid(type, sa.getActivatingPlayer(), host, sa)) {
found.add(c);
if (remember) {
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)));
}
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);
// Reveal cards that will be discarded?
for (final Card c : dPChHand) {
@@ -230,7 +230,7 @@ public class DiscardEffect extends SpellAbilityEffect {
}
final String valid = sa.hasParam("DiscardValid") ? sa.getParam("DiscardValid") : "Card";
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;
if (mode.equals("RevealYouChoose")) {
@@ -267,6 +267,5 @@ public class DiscardEffect extends SpellAbilityEffect {
source.addRemembered(c);
}
}
} // discardResolve()
}

View File

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

View File

@@ -28,7 +28,7 @@ public class RegenerateAllEffect extends SpellAbilityEffect {
}
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) {
final GameCommand untilEOT = new GameCommand() {

View File

@@ -59,10 +59,8 @@ public class RepeatEffect extends SpellAbilityEffect {
* <p>
* checkRepeatConditions.
* </p>
*
* @param AF
* a {@link forge.game.ability.AbilityFactory} object.
* @param SA
*
* @param sa
* a {@link forge.game.spellability.SpellAbility} object.
*/
private static boolean checkRepeatConditions(final SpellAbility sa) {
@@ -85,7 +83,7 @@ public class RepeatEffect extends SpellAbilityEffect {
else {
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;
final String rightString = repeatCompare.substring(2);

View File

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

View File

@@ -158,7 +158,7 @@ public class UnattachAllEffect extends SpellAbilityEffect {
String valid = sa.getParam("UnattachValid");
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) {
handleUnattachment((GameEntity) o, c);
}

View File

@@ -43,7 +43,7 @@ public class UntapAllEffect extends SpellAbilityEffect {
}
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");
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[] k = parse.split(" ", 2);
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.");
return;
}
@@ -3570,7 +3570,7 @@ public class Card extends GameEntity implements Comparable<Card> {
// Takes one argument like Permanent.Blue+withFlying
@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
return false;
}
@@ -3599,7 +3599,7 @@ public class Card extends GameEntity implements Comparable<Card> {
final String excR = incR[1];
final String[] exRs = excR.split("\\+"); // Exclusive Restrictions are ...
for (String exR : exRs) {
if (!hasProperty(exR, sourceController, source)) {
if (!hasProperty(exR, sourceController, source, spellAbility)) {
return testFailed;
}
}
@@ -3609,7 +3609,7 @@ public class Card extends GameEntity implements Comparable<Card> {
// Takes arguments like Blue or withFlying
@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 Combat combat = game.getCombat();
final Card lki = getGame().getChangeZoneLKIInfo(this);
@@ -3850,12 +3850,12 @@ public class Card extends GameEntity implements Comparable<Card> {
}
} else if (property.startsWith("OwnedBy")) {
final String valid = property.substring(8);
if (!getOwner().isValid(valid, sourceController, source)) {
if (!getOwner().isValid(valid, sourceController, source, spellAbility)) {
return false;
}
} else if (property.startsWith("ControlledBy")) {
final String valid = property.substring(13);
if (!controller.isValid(valid, sourceController, source)) {
if (!controller.isValid(valid, sourceController, source, spellAbility)) {
return false;
}
} else if (property.startsWith("OwnerDoesntControl")) {
@@ -3918,9 +3918,9 @@ public class Card extends GameEntity implements Comparable<Card> {
return false;
}
} else {
if ((enchanting == null || !enchanting.isValid(restriction, sourceController, source))
&& (equipping == null || !equipping.isValid(restriction, sourceController, source))
&& (fortifying == null || !fortifying.isValid(restriction, sourceController, source))) {
if ((enchanting == null || !enchanting.isValid(restriction, sourceController, source, spellAbility))
&& (equipping == null || !equipping.isValid(restriction, sourceController, source, spellAbility))
&& (fortifying == null || !fortifying.isValid(restriction, sourceController, source, spellAbility))) {
return false;
}
}
@@ -3967,7 +3967,7 @@ public class Card extends GameEntity implements Comparable<Card> {
break;
default: // EnchantedBy Aura.Other
for (final Card aura : getEnchantedBy(false)) {
if (aura.isValid(restriction, sourceController, source)) {
if (aura.isValid(restriction, sourceController, source, spellAbility)) {
return true;
}
}
@@ -4227,7 +4227,7 @@ public class Card extends GameEntity implements Comparable<Card> {
break;
default:
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;
}
}
@@ -4254,7 +4254,7 @@ public class Card extends GameEntity implements Comparable<Card> {
} else {
final String restriction = property.split("notSharesColorWith ")[1];
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;
}
}
@@ -4315,7 +4315,7 @@ public class Card extends GameEntity implements Comparable<Card> {
default:
boolean shares = false;
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;
}
}
@@ -4449,6 +4449,16 @@ public class Card extends GameEntity implements Comparable<Card> {
}
}
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")) {
@@ -4546,7 +4556,7 @@ public class Card extends GameEntity implements Comparable<Card> {
Player p = null;
if (res.length > 1) {
for (Player pl : game.getPlayers()) {
if (pl.isValid(res[1], sourceController, source)) {
if (pl.isValid(res[1], sourceController, source, spellAbility)) {
p = pl;
break;
}
@@ -5558,11 +5568,11 @@ public class Card extends GameEntity implements Comparable<Card> {
continue;
}
if (params.containsKey("ValidSource")
&& !source.isValid(params.get("ValidSource"), ca.getController(), ca)) {
&& !source.isValid(params.get("ValidSource"), ca.getController(), ca, null)) {
continue;
}
if (params.containsKey("ValidTarget")
&& !isValid(params.get("ValidTarget"), ca.getController(), ca)) {
&& !isValid(params.get("ValidTarget"), ca.getController(), ca, null)) {
continue;
}
if (params.containsKey("IsCombat")) {
@@ -5641,7 +5651,7 @@ public class Card extends GameEntity implements Comparable<Card> {
if (kw.startsWith("PreventAllDamageBy")) {
String valid = getKeywords().get(getKeywordPosition("PreventAllDamageBy"));
valid = valid.split(" ", 2)[1];
if (source.isValid(valid, getController(), this)) {
if (source.isValid(valid, getController(), this, null)) {
return 0;
}
}
@@ -6156,8 +6166,8 @@ public class Card extends GameEntity implements Comparable<Card> {
final String characteristic = kws[1];
final String[] characteristics = characteristic.split(",");
final String exception = kws.length > 3 ? kws[3] : null; // check "This effect cannot remove sth"
if (source.isValid(characteristics, getController(), this)
&& (!checkSBA || exception == null || !source.isValid(exception, getController(), this))) {
if (source.isValid(characteristics, getController(), this, null)
&& (!checkSBA || exception == null || !source.isValid(exception, getController(), this, null))) {
return true;
}
} 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[] k = parse.split(":");
final String[] restrictions = k[1].split(",");
if (isValid(restrictions, source.getController(), source)) {
if (isValid(restrictions, source.getController(), source, null)) {
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.") && !aura.getName().equals("Anti-Magic Aura")
&& !(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) {
@@ -6335,13 +6345,13 @@ public class Card extends GameEntity implements Comparable<Card> {
final String parse = equip.getKeywords().get(keywordPosition);
final String[] k = parse.split(" ", 2);
final String[] restrictions = k[1].split(",");
if (isValid(restrictions, equip.getController(), equip)) {
if (isValid(restrictions, equip.getController(), equip, null)) {
return false;
}
}
return !(hasProtectionFrom(equip)
|| hasKeyword("CARDNAME can't be equipped.")
|| !isValid("Creature", equip.getController(), equip));
|| !isValid("Creature", equip.getController(), equip, null));
}
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
// a Creature
if (tgt.doesTarget()
&& !target.isValid(tgt.getValidTgts(), ability.getActivatingPlayer(), ability.getHostCard())) {
&& !target.isValid(tgt.getValidTgts(), ability.getActivatingPlayer(), ability.getHostCard(), ability)) {
return false;
}
@@ -731,7 +731,7 @@ public class CardFactoryUtil {
int totPlayer = 0;
String property = sq[0].substring(11);
for (Player p : players) {
if (p.hasProperty(property, source.getController(), source)) {
if (p.hasProperty(property, source.getController(), source, null)) {
totPlayer++;
}
}
@@ -765,7 +765,7 @@ public class CardFactoryUtil {
final List<ZoneType> vZone = ZoneType.listValueOf(lparts[0].split("Valid")[1]);
String restrictions = l[0].replace(lparts[0] + " ", "");
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);
}
@@ -773,7 +773,7 @@ public class CardFactoryUtil {
if (l[0].startsWith("Valid ")) {
final String restrictions = l[0].substring(6);
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);
}
@@ -940,7 +940,7 @@ public class CardFactoryUtil {
? game.getCardsIn(ZoneType.listValueOf(lparts[0].substring(5)))
: 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);
}
@@ -951,7 +951,7 @@ public class CardFactoryUtil {
if (l[0].startsWith("GreatestPower_")) {
final String restriction = l[0].substring(14);
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;
for (final Card crd : list) {
if (crd.getNetPower() > highest) {
@@ -964,7 +964,7 @@ public class CardFactoryUtil {
if (l[0].startsWith("GreatestToughness_")) {
final String restriction = l[0].substring(18);
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;
for (final Card crd : list) {
if (crd.getNetToughness() > highest) {
@@ -977,7 +977,7 @@ public class CardFactoryUtil {
if (l[0].startsWith("HighestCMC_")) {
final String restriction = l[0].substring(11);
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;
for (final Card crd : list) {
if (crd.isSplitCard()) {
@@ -1001,7 +1001,7 @@ public class CardFactoryUtil {
final List<String> crdname = new ArrayList<String>();
final String restriction = l[0].substring(19);
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) {
if (!crdname.contains(card.getName())) {
crdname.add(card.getName());
@@ -1030,7 +1030,7 @@ public class CardFactoryUtil {
final CounterType counterType = CounterType.valueOf(components[1]);
String restrictions = components[2];
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;
for (final Card counterSource : candidates) {
@@ -1318,7 +1318,7 @@ public class CardFactoryUtil {
if (sq[0].startsWith("Devoured")) {
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);
}
@@ -1336,7 +1336,7 @@ public class CardFactoryUtil {
if (sq[0].contains("SumPower")) {
final String[] restrictions = l[0].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);
}
// Count$CardManaCost
@@ -1359,7 +1359,7 @@ public class CardFactoryUtil {
final String[] restrictions = l[0].split("_");
final String[] rest = restrictions[1].split(",");
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);
}
@@ -1391,7 +1391,7 @@ public class CardFactoryUtil {
final CounterType cType = CounterType.getType(restrictions[1]);
final String[] validFilter = restrictions[2].split(",");
CardCollectionView validCards = game.getCardsIn(ZoneType.Battlefield);
validCards = CardLists.getValidCards(validCards, validFilter, cc, c);
validCards = CardLists.getValidCards(validCards, validFilter, cc, c, null);
int cCount = 0;
for (final Card card : validCards) {
cCount += card.getCounters(cType);
@@ -2018,7 +2018,7 @@ public class CardFactoryUtil {
final List<String> protectionkw = 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 (String k : c.getKeywords()) {
if (k.endsWith("walk")) {

View File

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

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

View File

@@ -124,7 +124,7 @@ public class CostDiscard extends CostPartWithList {
}
if (!type.equals("Random") && !type.contains("X")) {
// 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) {
for (Card c : handList) {

View File

@@ -59,7 +59,7 @@ public class CostDraw extends CostPart {
List<Player> res = new ArrayList<Player>();
String type = this.getType();
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);
}
}

View File

@@ -131,7 +131,7 @@ public class CostExile extends CostPartWithList {
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();
if ((amount != null) && (list.size() < amount)) {

View File

@@ -85,7 +85,7 @@ public class CostExileFromStack extends CostPart {
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();
if ((amount != null) && (list.size() < amount)) {

View File

@@ -70,7 +70,7 @@ public class CostExiledMoveToGrave extends CostPartWithList {
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;
}

View File

@@ -70,7 +70,7 @@ public class CostGainControl extends CostPartWithList {
final Player activator = ability.getActivatingPlayer();
final Card source = ability.getHostCard();
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();
if (amount == null) {

View File

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

View File

@@ -128,7 +128,7 @@ public class CostPutCardToLib extends CostPartWithList {
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) {
return false;

View File

@@ -134,7 +134,8 @@ public class CostPutCounter extends CostPartWithList {
}
} else {
// 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) {
return false;

View File

@@ -88,7 +88,7 @@ public class CostRemoveAnyCounter extends CostPartWithList {
final Player activator = ability.getActivatingPlayer();
final Card source = ability.getHostCard();
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>() {
@Override
public boolean apply(final Card c) {

View File

@@ -136,7 +136,7 @@ public class CostRemoveCounter extends CostPartWithList {
if (type.equals("OriginalHost")) {
typeList = Lists.newArrayList(ability.getOriginalHost());
} 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 (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"));
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();
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
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())) {
// not enough cards in hand to pay
return false;

View File

@@ -87,7 +87,7 @@ public class CostSacrifice extends CostPartWithList {
boolean needsAnnoucement = ability.hasParam("Announce") && this.getType().contains(ability.getParam("Announce"));
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();
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, "");
}
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) {
typeList.remove(source);

View File

@@ -74,7 +74,7 @@ public class CostUntapType extends CostPartWithList {
final Player activator = ability.getActivatingPlayer();
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) {
typeList.remove(source);

View File

@@ -205,7 +205,7 @@ public class ManaCostAdjustment {
* a StaticAbility
* @param sa
* the SpellAbility
* @param originalCost
* @param manaCost
* a 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")
&& !card.isValid(params.get("ValidCard").split(","), hostCard.getController(), hostCard)) {
&& !card.isValid(params.get("ValidCard").split(","), hostCard.getController(), hostCard, sa)) {
return;
}
if (params.containsKey("Activator") && ((activator == null)
|| !activator.isValid(params.get("Activator"), hostCard.getController(), hostCard))) {
|| !activator.isValid(params.get("Activator"), hostCard.getController(), hostCard, sa))) {
return;
}
@@ -286,7 +286,7 @@ public class ManaCostAdjustment {
}
boolean targetValid = false;
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;
}
}
@@ -302,7 +302,7 @@ public class ManaCostAdjustment {
boolean targetValid = false;
for (SpellAbility target : sa.getTargets().getTargetSpells()) {
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;
}
}
@@ -351,7 +351,7 @@ public class ManaCostAdjustment {
* a StaticAbility
* @param sa
* the SpellAbility
* @param originalCost
* @param manaCost
* a 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")
&& !card.isValid(params.get("ValidCard").split(","), hostCard.getController(), hostCard)) {
&& !card.isValid(params.get("ValidCard").split(","), hostCard.getController(), hostCard, sa)) {
return;
}
if (params.containsKey("Activator") && ((activator == null)
|| !activator.isValid(params.get("Activator"), hostCard.getController(), hostCard))) {
|| !activator.isValid(params.get("Activator"), hostCard.getController(), hostCard, sa))) {
return;
}
if (params.containsKey("Type")) {
@@ -433,7 +433,7 @@ public class ManaCostAdjustment {
}
boolean targetValid = false;
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;
}
}

View File

@@ -151,7 +151,7 @@ public class Untap extends Phase {
if (!Untap.canUntap(c)) {
return false;
}
if (c.isValid(restrict, player, null)) {
if (c.isValid(restrict, player, null, null)) {
return false;
}
return true;
@@ -175,7 +175,7 @@ public class Untap extends Phase {
CardCollection restrictUntapped = new CardCollection();
CardCollection cardList = CardLists.filter(untapList, tappedCanUntap);
cardList = CardLists.getValidCards(cardList, restrict, player, null);
cardList = CardLists.getValidCards(cardList, restrict, player, null, null);
while (!cardList.isEmpty()) {
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);
if (chosen != null) {
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);
}
}

View File

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

View File

@@ -77,12 +77,6 @@ public class AbilityManaPart implements java.io.Serializable {
*
* @param sourceCard
* 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) {
this.sourceCard = sourceCard;
@@ -103,7 +97,7 @@ public class AbilityManaPart implements java.io.Serializable {
* <p>
* produceMana.
* </p>
* @param ability
* @param sa
*/
public final void produceMana(SpellAbility sa) {
this.produceMana(this.getOrigProduced(), this.getSourceCard().getController(), sa);
@@ -197,7 +191,7 @@ public class AbilityManaPart implements java.io.Serializable {
Card source = saBeingPaid.getHostCard();
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>
* getKeywords.
* </p>
* @param saBeingPaid
*
* @return a {@link java.lang.String} object.
*/
@@ -250,7 +243,7 @@ public class AbilityManaPart implements java.io.Serializable {
public void createETBCounters(Card c) {
String[] parse = this.addsCounters.split("_");
// 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]
+ " | ETB$ True | CounterNum$ " + parse[2] + " | SubAbility$ ManaDBETBCounters";
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().isValid(restriction, this.getSourceCard().getController(), this.getSourceCard())) {
if (sa.getHostCard().isValid(restriction, this.getSourceCard().getController(), this.getSourceCard(), null)) {
return true;
}
}

View File

@@ -212,6 +212,14 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
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) {
String var = sVars.get(name);
if (var == null) {
@@ -397,7 +405,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
paidLists.get(str).add(c);
}
public void resetPaidHash() {
paidLists = new HashMap<String, CardCollection>();
paidLists.clear();
}
public Iterable<OptionalCost> getOptionalCosts() {
@@ -727,7 +735,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
}
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;
}
}
@@ -1098,7 +1106,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
public boolean canTargetSpellAbility(final SpellAbility topSA) {
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;
}
@@ -1115,7 +1123,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
boolean result = false;
for (final GameObject o : matchTgt.getTargets()) {
if (o.isValid(splitTargetRestrictions.split(","), getActivatingPlayer(), getHostCard())) {
if (o.isValid(splitTargetRestrictions.split(","), getActivatingPlayer(), getHostCard(), this)) {
result = true;
break;
}
@@ -1131,7 +1139,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
continue;
}
for (final GameObject o : matchTgt.getTargets()) {
if (o.isValid(splitTargetRestrictions.split(","), getActivatingPlayer(), getHostCard())) {
if (o.isValid(splitTargetRestrictions.split(","), getActivatingPlayer(), getHostCard(), this)) {
result = true;
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
@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
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[] exR = excR.split("\\+"); // Exclusive Restrictions are ...
for (int j = 0; j < exR.length; j++) {
if (!hasProperty(exR[j], sourceController, source)) {
if (!hasProperty(exR[j], sourceController, source, spellAbility)) {
return false;
}
}
@@ -1203,7 +1211,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
// Takes arguments like Blue or withFlying
@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;
}

View File

@@ -321,7 +321,7 @@ public class SpellAbilityCondition extends SpellAbilityVariables {
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;
final String rightString = this.getPresentCompare().substring(2);
@@ -382,7 +382,7 @@ public class SpellAbilityCondition extends SpellAbilityVariables {
boolean result = false;
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;
break;
}

View File

@@ -361,7 +361,7 @@ public class SpellAbilityRestriction extends SpellAbilityVariables {
if (this.getIsPresent() != null) {
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;
final String rightString = this.getPresentCompare().substring(2);

View File

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

View File

@@ -502,7 +502,7 @@ public class StaticAbility extends CardTraitBase {
return false;
}
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;
}
}
@@ -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) {
ignoreEffectCards = cards;

View File

@@ -49,12 +49,12 @@ public class StaticAbilityCantAttackBlock {
final Card hostCard = stAb.getHostCard();
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;
}
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;
}
@@ -63,14 +63,14 @@ public class StaticAbilityCantAttackBlock {
if (params.containsKey("UnlessDefenderControls")) {
String type = params.get("UnlessDefenderControls");
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;
}
}
if (params.containsKey("IfDefenderControls")) {
String type = params.get("IfDefenderControls");
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;
}
}
@@ -81,7 +81,7 @@ public class StaticAbilityCantAttackBlock {
}
if (params.containsKey("UnlessDefender")) {
final String type = params.get("UnlessDefender");
if (defender.hasProperty(type, hostCard.getController(), hostCard)) {
if (defender.hasProperty(type, hostCard.getController(), hostCard, null)) {
return false;
}
}
@@ -103,12 +103,12 @@ public class StaticAbilityCantAttackBlock {
final Card hostCard = stAb.getHostCard();
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;
}
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;
}
String costString = params.get("Cost");
@@ -139,12 +139,12 @@ public class StaticAbilityCantAttackBlock {
final Card hostCard = stAb.getHostCard();
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;
}
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;
}
String costString = params.get("Cost");

View File

@@ -47,12 +47,12 @@ public class StaticAbilityCantBeCast {
final Card hostCard = stAb.getHostCard();
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;
}
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;
}
@@ -98,7 +98,7 @@ public class StaticAbilityCantBeCast {
final Player activator = spellAbility.getActivatingPlayer();
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;
}
@@ -107,7 +107,7 @@ public class StaticAbilityCantBeCast {
}
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;
}
@@ -138,12 +138,12 @@ public class StaticAbilityCantBeCast {
final Card hostCard = stAb.getHostCard();
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;
}
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;
}

View File

@@ -62,17 +62,17 @@ public class StaticAbilityCantTarget {
}
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;
}
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;
}
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;
}

View File

@@ -339,7 +339,7 @@ public final class StaticAbilityContinuous {
}
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) {
addFullAbs = new ArrayList<SpellAbility>();
@@ -671,7 +671,7 @@ public final class StaticAbilityContinuous {
final String[] strngs = params.get("Affected").split(",");
for (Player p : controller.getGame().getPlayersInTurnOrder()) {
if (p.isValid(strngs, controller, hostCard)) {
if (p.isValid(strngs, controller, hostCard, null)) {
players.add(p);
}
}
@@ -712,7 +712,7 @@ public final class StaticAbilityContinuous {
}
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());
return affectedCards;

View File

@@ -40,7 +40,7 @@ public class StaticAbilityETBTapped {
final Card hostCard = stAb.getHostCard();
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;
}

View File

@@ -50,12 +50,12 @@ public class StaticAbilityPreventDamage {
int restDamage = damage;
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;
}
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;
}

View File

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

View File

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

View File

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

View File

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

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