remove the SimpleTriggeredAbility class and rewrite old cards using it

This commit is contained in:
Ingmar Goudt 2021-05-13 21:48:58 +02:00
parent b640646cab
commit 895430b554
5 changed files with 6 additions and 80 deletions

View file

@ -3,14 +3,12 @@ package mage.cards.c;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.common.SimpleTriggeredAbility; import mage.abilities.effects.common.DiscardCardPlayerTriggeredAbility;
import mage.abilities.effects.common.GainLifeEffect; import mage.abilities.effects.common.GainLifeEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType; import mage.constants.SubType;
import mage.constants.Zone;
import mage.game.events.GameEvent.EventType;
/** /**
* *
@ -27,8 +25,7 @@ public final class Confessor extends CardImpl {
this.toughness = new MageInt(1); this.toughness = new MageInt(1);
// Whenever a player discards a card, you may gain 1 life. // Whenever a player discards a card, you may gain 1 life.
this.addAbility(new SimpleTriggeredAbility( this.addAbility(new DiscardCardPlayerTriggeredAbility(new GainLifeEffect(1), true));
Zone.BATTLEFIELD, EventType.DISCARDED_CARD, new GainLifeEffect(1), "Whenever a player discards a card, ", false, true));
} }
private Confessor(final Confessor card) { private Confessor(final Confessor card) {

View file

@ -3,15 +3,13 @@ package mage.cards.s;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleTriggeredAbility; import mage.abilities.common.GainLifeControllerTriggeredAbility;
import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.DoIfCostPaid; import mage.abilities.effects.common.DoIfCostPaid;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Zone;
import mage.game.events.GameEvent;
import mage.target.common.TargetAnyTarget; import mage.target.common.TargetAnyTarget;
/** /**
@ -25,7 +23,7 @@ public final class SearingMeditation extends CardImpl {
// Whenever you gain life, you may pay {2}. If you do, Searing Meditation deals 2 damage to any target. // Whenever you gain life, you may pay {2}. If you do, Searing Meditation deals 2 damage to any target.
Ability ability = new SimpleTriggeredAbility(Zone.BATTLEFIELD, GameEvent.EventType.GAINED_LIFE, new DoIfCostPaid(new DamageTargetEffect(2), new GenericManaCost(2)), "Whenever you gain life, ", true); Ability ability = new GainLifeControllerTriggeredAbility(new DoIfCostPaid(new DamageTargetEffect(2), new GenericManaCost(2)), false, true);
ability.addTarget(new TargetAnyTarget()); ability.addTarget(new TargetAnyTarget());
this.addAbility(ability); this.addAbility(ability);
} }

View file

@ -2,15 +2,13 @@
package mage.cards.s; package mage.cards.s;
import java.util.UUID; import java.util.UUID;
import mage.abilities.common.SimpleTriggeredAbility;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.DiscardCardPlayerTriggeredAbility;
import mage.abilities.effects.common.DoIfCostPaid; import mage.abilities.effects.common.DoIfCostPaid;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Zone;
import mage.game.events.GameEvent;
import mage.game.permanent.token.SpiritWhiteToken; import mage.game.permanent.token.SpiritWhiteToken;
/** /**
@ -23,10 +21,7 @@ public final class SpiritCairn extends CardImpl {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{W}"); super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{W}");
// Whenever a player discards a card, you may pay {W}. If you do, create a 1/1 white Spirit creature token with flying. // Whenever a player discards a card, you may pay {W}. If you do, create a 1/1 white Spirit creature token with flying.
this.addAbility(new SimpleTriggeredAbility(Zone.BATTLEFIELD, GameEvent.EventType.DISCARDED_CARD, this.addAbility(new DiscardCardPlayerTriggeredAbility(new DoIfCostPaid(new CreateTokenEffect(new SpiritWhiteToken()), new ManaCostsImpl("{W}")),false));
new DoIfCostPaid(new CreateTokenEffect(new SpiritWhiteToken()), new ManaCostsImpl("{W}")),
"Whenever a player discards a card, ",
false, false));
} }
private SpiritCairn(final SpiritCairn card) { private SpiritCairn(final SpiritCairn card) {

View file

@ -94,7 +94,6 @@ public class LandfallTest extends CardTestPlayerBase {
* Fang. It only dealt 1 damage to me, where it should've dealt 3, because * Fang. It only dealt 1 damage to me, where it should've dealt 3, because
* my opponent had played a land. * my opponent had played a land.
*/ */
@Ignore
@Test @Test
public void testSearingBlaze() { public void testSearingBlaze() {
// Searing Blaze deals 1 damage to target player and 1 damage to target creature that player controls. // Searing Blaze deals 1 damage to target player and 1 damage to target creature that player controls.

View file

@ -1,63 +0,0 @@
package mage.abilities.common;
import mage.constants.Zone;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class SimpleTriggeredAbility extends TriggeredAbilityImpl {
private EventType eventType;
private boolean onlyController;
private String prefix;
public SimpleTriggeredAbility(Zone zone, EventType eventType, Effect effect, String prefix) {
this(zone, eventType, effect, prefix, false);
}
public SimpleTriggeredAbility(Zone zone, EventType eventType, Effect effect, String prefix, boolean onlyController) {
this(zone, eventType, effect, prefix, onlyController, false);
}
public SimpleTriggeredAbility(Zone zone, EventType eventType, Effect effect, String prefix, boolean onlyController, boolean optional) {
super(zone, effect, optional);
this.eventType = eventType;
this.onlyController = onlyController;
this.prefix = prefix;
}
public SimpleTriggeredAbility(final SimpleTriggeredAbility ability) {
super(ability);
this.eventType = ability.eventType;
this.onlyController = ability.onlyController;
this.prefix = ability.prefix;
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == eventType;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return !onlyController || event.getPlayerId().equals(this.controllerId);
}
@Override
public SimpleTriggeredAbility copy() {
return new SimpleTriggeredAbility(this);
}
@Override
public String getRule() {
return prefix + super.getRule();
}
}