diff --git a/Mage.Sets/src/mage/cards/a/AyeshaTanaka.java b/Mage.Sets/src/mage/cards/a/AyeshaTanaka.java index 6703c45108..cf8165cc37 100644 --- a/Mage.Sets/src/mage/cards/a/AyeshaTanaka.java +++ b/Mage.Sets/src/mage/cards/a/AyeshaTanaka.java @@ -16,6 +16,7 @@ import mage.constants.SubType; import mage.constants.SuperType; import mage.constants.Zone; import mage.filter.FilterAbility; +import mage.filter.FilterStackObject; import mage.filter.predicate.ability.ArtifactSourcePredicate; import mage.target.common.TargetActivatedAbility; @@ -25,7 +26,7 @@ import mage.target.common.TargetActivatedAbility; */ public final class AyeshaTanaka extends CardImpl { - private final static FilterAbility filter = new FilterAbility("activated ability from an artifact source"); + private final static FilterStackObject filter = new FilterStackObject("activated ability from an artifact source"); static { filter.add(new ArtifactSourcePredicate()); diff --git a/Mage.Sets/src/mage/cards/b/BrownOuphe.java b/Mage.Sets/src/mage/cards/b/BrownOuphe.java index 747c19d320..b7ba3b157a 100644 --- a/Mage.Sets/src/mage/cards/b/BrownOuphe.java +++ b/Mage.Sets/src/mage/cards/b/BrownOuphe.java @@ -14,6 +14,7 @@ import mage.constants.CardType; import mage.constants.SubType; import mage.constants.Zone; import mage.filter.FilterAbility; +import mage.filter.FilterStackObject; import mage.filter.predicate.ability.ArtifactSourcePredicate; import mage.target.common.TargetActivatedAbility; @@ -23,7 +24,7 @@ import mage.target.common.TargetActivatedAbility; */ public final class BrownOuphe extends CardImpl { - private final static FilterAbility filter = new FilterAbility("activated ability from an artifact source"); + private final static FilterStackObject filter = new FilterStackObject("activated ability from an artifact source"); static { filter.add(new ArtifactSourcePredicate()); diff --git a/Mage.Sets/src/mage/cards/i/Interdict.java b/Mage.Sets/src/mage/cards/i/Interdict.java index 9a8e87f664..0e590cd6d3 100644 --- a/Mage.Sets/src/mage/cards/i/Interdict.java +++ b/Mage.Sets/src/mage/cards/i/Interdict.java @@ -19,6 +19,7 @@ import mage.game.Game; import mage.game.permanent.Permanent; import mage.game.stack.StackAbility; import mage.game.stack.StackObject; +import mage.target.common.TargetActivatedAbility; import mage.target.common.TargetActivatedOrTriggeredAbility; import mage.target.targetpointer.FixedTarget; @@ -39,7 +40,7 @@ public final class Interdict extends CardImpl { // Counter target activated ability from an artifact, creature, enchantment, or land. That permanent's activated abilities can't be activated this turn. this.getSpellAbility().addEffect(new InterdictCounterEffect()); - this.getSpellAbility().addTarget(new TargetActivatedOrTriggeredAbility(filter)); + this.getSpellAbility().addTarget(new TargetActivatedAbility(filter)); // Draw a card. this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(1).setText("

Draw a card")); diff --git a/Mage.Sets/src/mage/cards/o/OupheVandals.java b/Mage.Sets/src/mage/cards/o/OupheVandals.java index 24a84e0354..d484706759 100644 --- a/Mage.Sets/src/mage/cards/o/OupheVandals.java +++ b/Mage.Sets/src/mage/cards/o/OupheVandals.java @@ -18,10 +18,12 @@ import mage.constants.Outcome; import mage.constants.Zone; import mage.filter.FilterStackObject; import mage.filter.predicate.Predicate; +import mage.filter.predicate.ability.ArtifactSourcePredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.game.stack.StackAbility; import mage.game.stack.StackObject; +import mage.target.common.TargetActivatedAbility; import mage.target.common.TargetActivatedOrTriggeredAbility; /** @@ -47,7 +49,7 @@ public final class OupheVandals extends CardImpl { // {G}, Sacrifice Ouphe Vandals: Counter target activated ability from an artifact source and destroy that artifact if it's on the battlefield. Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new OupheVandalsEffect(), new ManaCostsImpl<>("{G}")); ability.addCost(new SacrificeSourceCost()); - ability.addTarget(new TargetActivatedOrTriggeredAbility(filter)); + ability.addTarget(new TargetActivatedAbility(filter)); this.addAbility(ability); } @@ -61,26 +63,6 @@ public final class OupheVandals extends CardImpl { } } -class ArtifactSourcePredicate implements Predicate { - - public ArtifactSourcePredicate() { - } - - @Override - public boolean apply(StackObject input, Game game) { - if (input instanceof StackAbility) { - StackAbility ability = (StackAbility) input; - return ability.getSourceObject(game).isArtifact() && ability.getAbilityType() == AbilityType.ACTIVATED; - } - return false; - } - - @Override - public String toString() { - return "Source(Artifact)"; - } -} - class OupheVandalsEffect extends OneShotEffect { public OupheVandalsEffect() { diff --git a/Mage.Sets/src/mage/cards/r/Reroute.java b/Mage.Sets/src/mage/cards/r/Reroute.java index a9154c8da3..609112ba64 100644 --- a/Mage.Sets/src/mage/cards/r/Reroute.java +++ b/Mage.Sets/src/mage/cards/r/Reroute.java @@ -8,6 +8,7 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.filter.FilterAbility; +import mage.filter.FilterStackObject; import mage.filter.predicate.mageobject.NumberOfTargetsPredicate; import mage.target.common.TargetActivatedAbility; @@ -17,7 +18,7 @@ import mage.target.common.TargetActivatedAbility; */ public final class Reroute extends CardImpl { - private static final FilterAbility filter = new FilterAbility("activated ability with a single target"); + private static final FilterStackObject filter = new FilterStackObject("activated ability with a single target"); static { filter.add(new NumberOfTargetsPredicate(1)); diff --git a/Mage.Sets/src/mage/cards/r/Rust.java b/Mage.Sets/src/mage/cards/r/Rust.java index 7e3bf39efd..1e88687beb 100644 --- a/Mage.Sets/src/mage/cards/r/Rust.java +++ b/Mage.Sets/src/mage/cards/r/Rust.java @@ -7,6 +7,7 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.filter.FilterAbility; +import mage.filter.FilterStackObject; import mage.filter.predicate.ability.ArtifactSourcePredicate; import mage.target.common.TargetActivatedAbility; @@ -16,7 +17,7 @@ import mage.target.common.TargetActivatedAbility; */ public final class Rust extends CardImpl { - private final static FilterAbility filter = new FilterAbility("activated ability from an artifact source"); + private final static FilterStackObject filter = new FilterStackObject("activated ability from an artifact source"); static { filter.add(new ArtifactSourcePredicate()); diff --git a/Mage.Sets/src/mage/cards/t/TawnosUrzasApprentice.java b/Mage.Sets/src/mage/cards/t/TawnosUrzasApprentice.java index 4b80eb69af..e4db5140e7 100644 --- a/Mage.Sets/src/mage/cards/t/TawnosUrzasApprentice.java +++ b/Mage.Sets/src/mage/cards/t/TawnosUrzasApprentice.java @@ -17,7 +17,7 @@ import mage.constants.Outcome; import mage.constants.TargetController; import mage.constants.Zone; import mage.filter.FilterStackObject; -import mage.filter.predicate.other.StackObjectWithArtifactSourcePredicate; +import mage.filter.predicate.ability.ArtifactSourcePredicate; import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; import mage.game.permanent.Permanent; @@ -34,7 +34,7 @@ public final class TawnosUrzasApprentice extends CardImpl { private final static FilterStackObject filter = new FilterStackObject("activated or triggered ability you control from an artifact source"); static { - filter.add(new StackObjectWithArtifactSourcePredicate()); + filter.add(new ArtifactSourcePredicate()); filter.add(new ControllerPredicate(TargetController.YOU)); } diff --git a/Mage/src/main/java/mage/filter/predicate/ability/ArtifactSourcePredicate.java b/Mage/src/main/java/mage/filter/predicate/ability/ArtifactSourcePredicate.java index 9b5d4c6b67..4759412ebd 100644 --- a/Mage/src/main/java/mage/filter/predicate/ability/ArtifactSourcePredicate.java +++ b/Mage/src/main/java/mage/filter/predicate/ability/ArtifactSourcePredicate.java @@ -3,19 +3,28 @@ package mage.filter.predicate.ability; import mage.MageObject; import mage.abilities.Ability; +import mage.constants.AbilityType; import mage.filter.predicate.Predicate; import mage.game.Game; +import mage.game.stack.StackAbility; +import mage.game.stack.StackObject; /** * * @author LevelX2 */ -public class ArtifactSourcePredicate implements Predicate { +public class ArtifactSourcePredicate implements Predicate { + + public ArtifactSourcePredicate() { + } @Override - public boolean apply(Ability input, Game game) { - MageObject sourceObject = input.getSourceObject(game); - return sourceObject != null && sourceObject.isArtifact(); + public boolean apply(StackObject input, Game game) { + if (input instanceof StackAbility) { + StackAbility ability = (StackAbility) input; + return ability.getSourceObject(game).isArtifact() && ability.getAbilityType() == AbilityType.ACTIVATED; + } + return false; } @Override diff --git a/Mage/src/main/java/mage/filter/predicate/other/StackObjectWithArtifactSourcePredicate.java b/Mage/src/main/java/mage/filter/predicate/other/StackObjectWithArtifactSourcePredicate.java deleted file mode 100644 index bacccb3e80..0000000000 --- a/Mage/src/main/java/mage/filter/predicate/other/StackObjectWithArtifactSourcePredicate.java +++ /dev/null @@ -1,24 +0,0 @@ - -package mage.filter.predicate.other; - -import mage.MageObject; -import mage.filter.predicate.Predicate; -import mage.game.Game; -import mage.game.stack.StackObject; - -/** - * - */ -public class StackObjectWithArtifactSourcePredicate implements Predicate { - - @Override - public boolean apply(StackObject input, Game game) { - MageObject sourceObject = game.getObject(input.getSourceId()); - return sourceObject != null && sourceObject.isArtifact(); - } - - @Override - public String toString() { - return "Source(Artifact)"; - } -} diff --git a/Mage/src/main/java/mage/target/common/TargetActivatedAbility.java b/Mage/src/main/java/mage/target/common/TargetActivatedAbility.java index 22d16d8f34..64bbbe3611 100644 --- a/Mage/src/main/java/mage/target/common/TargetActivatedAbility.java +++ b/Mage/src/main/java/mage/target/common/TargetActivatedAbility.java @@ -10,6 +10,7 @@ import mage.constants.AbilityType; import mage.constants.Zone; import mage.filter.Filter; import mage.filter.FilterAbility; +import mage.filter.FilterStackObject; import mage.game.Game; import mage.game.stack.StackAbility; import mage.game.stack.StackObject; @@ -21,13 +22,13 @@ import mage.target.TargetObject; */ public class TargetActivatedAbility extends TargetObject { - protected final FilterAbility filter; + protected final FilterStackObject filter; public TargetActivatedAbility() { - this(new FilterAbility("activated ability")); + this(new FilterStackObject("activated ability")); } - public TargetActivatedAbility(FilterAbility filter) { + public TargetActivatedAbility(FilterStackObject filter) { this.minNumberOfTargets = 1; this.maxNumberOfTargets = 1; this.zone = Zone.STACK; @@ -46,8 +47,10 @@ public class TargetActivatedAbility extends TargetObject { return false; } StackObject stackObject = game.getStack().getStackObject(id); - return stackObject != null && stackObject.getStackAbility() != null && stackObject.getStackAbility().getAbilityType() == AbilityType.ACTIVATED - && filter.match(((ActivatedAbility) stackObject.getStackAbility()), game); + return stackObject != null + && stackObject.getStackAbility() != null + && stackObject.getStackAbility().getAbilityType() == AbilityType.ACTIVATED + && filter.match(stackObject, source.getSourceId(), source.getControllerId(), game); } @Override