diff --git a/src/main/java/forge/card/ability/AbilityFactory.java b/src/main/java/forge/card/ability/AbilityFactory.java index f88c55da505..94381dcb387 100644 --- a/src/main/java/forge/card/ability/AbilityFactory.java +++ b/src/main/java/forge/card/ability/AbilityFactory.java @@ -225,13 +225,6 @@ public final class AbilityFactory { abTgt.setZone(ZoneType.listValueOf(mapParams.get("TgtZone"))); } - // Target Type mostly for Counter: Spell,Activated,Triggered,Ability - // (or any combination of) - // Ability = both activated and triggered abilities - if (mapParams.containsKey("TargetType")) { - abTgt.setTargetSpellAbilityType(mapParams.get("TargetType")); - } - // TargetValidTargeting most for Counter: e.g. target spell that // targets X. if (mapParams.containsKey("TargetValidTargeting")) { diff --git a/src/main/java/forge/card/spellability/SpellAbility.java b/src/main/java/forge/card/spellability/SpellAbility.java index fc5988f50f5..39652d8c338 100644 --- a/src/main/java/forge/card/spellability/SpellAbility.java +++ b/src/main/java/forge/card/spellability/SpellAbility.java @@ -1560,7 +1560,7 @@ public abstract class SpellAbility extends GameObject implements ISpellAbility { boolean result = false; for (final GameObject o : matchTgt.getTargets()) { - if (matchesValid(o, splitTargetRestrictions.split(","))) { + if (o.isValid(splitTargetRestrictions.split(","), this.getActivatingPlayer(), this.getSourceCard())) { result = true; break; } @@ -1588,24 +1588,6 @@ public abstract class SpellAbility extends GameObject implements ISpellAbility { return topSA.getSourceCard().isValid(tgt.getValidTgts(), this.getActivatingPlayer(), this.getSourceCard()); } - - private boolean matchesValid(final GameObject o, final String[] valids) { - final Card srcCard = this.getSourceCard(); - final Player activatingPlayer = this.getActivatingPlayer(); - if (o instanceof Card) { - final Card c = (Card) o; - return c.isValid(valids, activatingPlayer, srcCard); - } - - if (o instanceof Player) { - Player p = (Player) o; - if (p.isValid(valids, activatingPlayer, srcCard)) { - return true; - } - } - - return false; - } // Takes one argument like Permanent.Blue+withFlying /** @@ -1630,14 +1612,14 @@ public abstract class SpellAbility extends GameObject implements ISpellAbility { if (incR[0].equals("Spell")) { if (!this.isSpell()) return false; - } - else if (incR[0].equals("Triggered")) { + } else if (incR[0].equals("Triggered")) { if (!this.isTrigger()) return false; - } - else if (incR[0].equals("Activated")) { + } else if (incR[0].equals("Activated")) { if (!(this instanceof AbilityActivated)) return false; + } else { //not a spell/ability type + return false; } if (incR.length > 1) { diff --git a/src/main/java/forge/card/spellability/TargetRestrictions.java b/src/main/java/forge/card/spellability/TargetRestrictions.java index 7b8fcab579a..05813461540 100644 --- a/src/main/java/forge/card/spellability/TargetRestrictions.java +++ b/src/main/java/forge/card/spellability/TargetRestrictions.java @@ -52,9 +52,6 @@ public class TargetRestrictions { private String uiPrompt = ""; private List tgtZone = Arrays.asList(ZoneType.Battlefield); - //SpellAbility Restrictions - // Comma-separated - private String targetSpellAbilityType = null; // The target SA of this SA must be targeting a Valid X private String saValidTargeting = null; @@ -96,7 +93,6 @@ public class TargetRestrictions { this.minTargets = target.getMinTargets(); this.maxTargets = target.getMaxTargets(); this.tgtZone = target.getZone(); - this.targetSpellAbilityType = target.getTargetSpellAbilityType(); this.saValidTargeting = target.getSAValidTargeting(); this.dividedAsYouChoose = target.isDividedAsYouChoose(); this.uniqueTargets = target.isUniqueTargets(); @@ -306,29 +302,6 @@ public class TargetRestrictions { return this.tgtZone; } - /** - *

- * Setter for the field targetSpellAbilityType. - *

- * - * @param tgtSAType - * a {@link java.lang.String} object. - */ - public final void setTargetSpellAbilityType(final String tgtSAType) { - this.targetSpellAbilityType = tgtSAType; - } - - /** - *

- * Getter for the field targetSpellAbilityType. - *

- * - * @return a {@link java.lang.String} object. - */ - public final String getTargetSpellAbilityType() { - return this.targetSpellAbilityType; - } - /** *

* setSAValidTargeting. diff --git a/src/main/java/forge/game/ai/ComputerUtil.java b/src/main/java/forge/game/ai/ComputerUtil.java index 96d7dcff3ba..4585789281b 100644 --- a/src/main/java/forge/game/ai/ComputerUtil.java +++ b/src/main/java/forge/game/ai/ComputerUtil.java @@ -204,8 +204,9 @@ public class ComputerUtil { // And lastly give some bonus points to least restrictive TargetType // (Spell,Ability,Triggered) - final String tgtType = tgt.getTargetSpellAbilityType(); - restrict -= (5 * tgtType.split(",").length); + final String tgtType = sa.getParam("TargetType"); + if (tgtType != null) + restrict -= (5 * tgtType.split(",").length); return restrict; }