mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
Fixed predicate refactor at #5161;
* Interdict, Ouphe Vandals - fixed that it catch triggered + activated, but must only activated;
This commit is contained in:
parent
a94dbe1c9d
commit
3da2f98eac
10 changed files with 36 additions and 61 deletions
|
@ -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());
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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("<br><br>Draw a card"));
|
||||
|
|
|
@ -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<StackObject> {
|
||||
|
||||
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() {
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Ability> {
|
||||
public class ArtifactSourcePredicate implements Predicate<StackObject> {
|
||||
|
||||
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
|
||||
|
|
|
@ -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<StackObject> {
|
||||
|
||||
@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)";
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue