1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-04-03 01:08:59 -09:00

* Fixed Stifle rule text and some other minor things related to TragetActivatedAbility.

This commit is contained in:
LevelX2 2018-02-24 01:00:23 +01:00
parent cdbe1b0ad9
commit 9a95e49ac9
7 changed files with 80 additions and 93 deletions

View file

@ -37,16 +37,13 @@ import mage.abilities.effects.common.CounterUnlessPaysEffect;
import mage.abilities.keyword.BandingAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AbilityType;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.constants.Zone;
import mage.filter.FilterStackObject;
import mage.filter.predicate.Predicate;
import mage.game.Game;
import mage.game.stack.StackAbility;
import mage.target.common.TargetActivatedOrTriggeredAbility;
import mage.filter.FilterAbility;
import mage.filter.predicate.ability.ArtifactSourcePredicate;
import mage.target.common.TargetActivatedAbility;
/**
*
@ -54,26 +51,26 @@ import mage.target.common.TargetActivatedOrTriggeredAbility;
*/
public class AyeshaTanaka extends CardImpl {
private final static FilterStackObject filter = new FilterStackObject("activated ability from an artifact source");
private final static FilterAbility filter = new FilterAbility("activated ability from an artifact source");
static {
filter.add(new ArtifactSourcePredicate());
}
public AyeshaTanaka(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{W}{W}{U}{U}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{W}{W}{U}{U}");
addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.ARTIFICER);
this.power = new MageInt(2);
this.toughness = new MageInt(2);
// Banding
this.addAbility(BandingAbility.getInstance());
// {T}: Counter target activated ability from an artifact source unless that ability's controller pays {W}.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new CounterUnlessPaysEffect(new ManaCostsImpl("{W}")), new TapSourceCost());
ability.addTarget(new TargetActivatedOrTriggeredAbility(filter));
ability.addTarget(new TargetActivatedAbility(filter));
this.addAbility(ability);
}
@ -86,22 +83,3 @@ public class AyeshaTanaka extends CardImpl {
return new AyeshaTanaka(this);
}
}
class ArtifactSourcePredicate implements Predicate<Ability> {
public ArtifactSourcePredicate() {
}
@Override
public boolean apply(Ability input, Game game) {
if (input instanceof StackAbility) {
return input.getSourceObject(game).isArtifact() && input.getAbilityType() == AbilityType.ACTIVATED;
}
return false;
}
@Override
public String toString() {
return "Source(Artifact)";
}
}

View file

@ -27,6 +27,7 @@
*/
package mage.cards.b;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
@ -35,17 +36,12 @@ import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.CounterTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AbilityType;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.FilterStackObject;
import mage.filter.predicate.Predicate;
import mage.game.Game;
import mage.game.stack.StackAbility;
import mage.target.common.TargetActivatedOrTriggeredAbility;
import java.util.UUID;
import mage.filter.FilterAbility;
import mage.filter.predicate.ability.ArtifactSourcePredicate;
import mage.target.common.TargetActivatedAbility;
/**
*
@ -53,7 +49,7 @@ import java.util.UUID;
*/
public class BrownOuphe extends CardImpl {
private final static FilterStackObject filter = new FilterStackObject("activated ability from an artifact source");
private final static FilterAbility filter = new FilterAbility("activated ability from an artifact source");
static {
filter.add(new ArtifactSourcePredicate());
@ -69,7 +65,7 @@ public class BrownOuphe extends CardImpl {
// {1}{G}, {tap}: Counter target activated ability from an artifact source.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new CounterTargetEffect(), new ManaCostsImpl<>("{1}{G}"));
ability.addCost(new TapSourceCost());
ability.addTarget(new TargetActivatedOrTriggeredAbility(filter));
ability.addTarget(new TargetActivatedAbility(filter));
this.addAbility(ability);
}
@ -82,22 +78,3 @@ public class BrownOuphe extends CardImpl {
return new BrownOuphe(this);
}
}
class ArtifactSourcePredicate implements Predicate<Ability> {
public ArtifactSourcePredicate() {
}
@Override
public boolean apply(Ability input, Game game) {
if (input instanceof StackAbility) {
return input.getSourceObject(game).isArtifact() && input.getAbilityType() == AbilityType.ACTIVATED;
}
return false;
}
@Override
public String toString() {
return "Source(Artifact)";
}
}

View file

@ -28,6 +28,7 @@
package mage.cards.i;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.RestrictionEffect;
@ -88,7 +89,7 @@ class InterdictPredicate implements Predicate<Ability> {
@Override
public boolean apply(Ability input, Game game) {
if (input instanceof StackAbility && input.getAbilityType() == AbilityType.ACTIVATED) {
Permanent sourceObject = game.getPermanentOrLKIBattlefield(input.getSourceId());
MageObject sourceObject = input.getSourceObject(game);
if (sourceObject != null) {
return (sourceObject.isArtifact()
|| sourceObject.isEnchantment()
@ -120,9 +121,12 @@ class InterdictCounterEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
StackObject stackObject = game.getStack().getStackObject(source.getFirstTarget());
if (stackObject != null && game.getStack().counter(source.getFirstTarget(), source.getSourceId(), game)) {
InterdictCantActivateEffect effect = new InterdictCantActivateEffect();
effect.setTargetPointer(new FixedTarget(stackObject.getSourceId()));
game.getContinuousEffects().addEffect(effect, source);
Permanent sourcePermanent = stackObject.getStackAbility().getSourcePermanentIfItStillExists(game);
if (sourcePermanent != null) {
InterdictCantActivateEffect effect = new InterdictCantActivateEffect();
effect.setTargetPointer(new FixedTarget(sourcePermanent, game));
game.getContinuousEffects().addEffect(effect, source);
}
return true;
}
return false;
@ -143,7 +147,7 @@ class InterdictCantActivateEffect extends RestrictionEffect {
@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
return getTargetPointer().getFirst(game, source).equals(permanent.getId());
return permanent.getId().equals(getTargetPointer().getFirst(game, source));
}
@Override

View file

@ -28,17 +28,13 @@
package mage.cards.r;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.common.CounterTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AbilityType;
import mage.constants.CardType;
import mage.filter.FilterStackObject;
import mage.filter.predicate.Predicate;
import mage.game.Game;
import mage.game.stack.StackAbility;
import mage.target.common.TargetActivatedOrTriggeredAbility;
import mage.filter.FilterAbility;
import mage.filter.predicate.ability.ArtifactSourcePredicate;
import mage.target.common.TargetActivatedAbility;
/**
*
@ -46,7 +42,7 @@ import mage.target.common.TargetActivatedOrTriggeredAbility;
*/
public class Rust extends CardImpl {
private final static FilterStackObject filter = new FilterStackObject("activated ability from an artifact source");
private final static FilterAbility filter = new FilterAbility("activated ability from an artifact source");
static {
filter.add(new ArtifactSourcePredicate());
@ -57,7 +53,7 @@ public class Rust extends CardImpl {
// Counter target activated ability from an artifact source.
this.getSpellAbility().addEffect(new CounterTargetEffect());
this.getSpellAbility().addTarget(new TargetActivatedOrTriggeredAbility(filter));
this.getSpellAbility().addTarget(new TargetActivatedAbility(filter));
}
public Rust(final Rust card) {
@ -69,22 +65,3 @@ public class Rust extends CardImpl {
return new Rust(this);
}
}
class ArtifactSourcePredicate implements Predicate<Ability> {
public ArtifactSourcePredicate() {
}
@Override
public boolean apply(Ability input, Game game) {
if (input instanceof StackAbility) {
return input.getSourceObject(game).isArtifact() && input.getAbilityType() == AbilityType.ACTIVATED;
}
return false;
}
@Override
public String toString() {
return "Source(Artifact)";
}
}

View file

@ -0,0 +1,51 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.filter.predicate.ability;
import mage.MageObject;
import mage.abilities.Ability;
import mage.filter.predicate.Predicate;
import mage.game.Game;
/**
*
* @author LevelX2
*/
public class ArtifactSourcePredicate implements Predicate<Ability> {
@Override
public boolean apply(Ability input, Game game) {
MageObject sourceObject = input.getSourceObject(game);
return sourceObject != null && sourceObject.isArtifact();
}
@Override
public String toString() {
return "Source(Artifact)";
}
}

View file

@ -57,7 +57,7 @@ public class TargetActivatedAbility extends TargetObject {
this.minNumberOfTargets = 1;
this.maxNumberOfTargets = 1;
this.zone = Zone.STACK;
this.targetName = "activated ability";
this.targetName = filter.getMessage();
this.filter = filter;
}

View file

@ -44,7 +44,7 @@ public class TargetActivatedOrTriggeredAbility extends TargetObject {
protected final FilterStackObject filter;
public TargetActivatedOrTriggeredAbility() {
this(new FilterStackObject());
this(new FilterStackObject("activated or triggered ability"));
}
public TargetActivatedOrTriggeredAbility(FilterStackObject filter) {