refactor some instances of ConditionalInterveningIfTriggeredAbility

This commit is contained in:
theelk801 2025-06-04 14:56:12 -04:00
parent 5fcd99ba44
commit d05d3bbc97
10 changed files with 85 additions and 102 deletions

View file

@ -1,36 +1,35 @@
package mage.cards.a; package mage.cards.a;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.triggers.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.condition.common.ControlsCreatureGreatestToughnessCondition; import mage.abilities.condition.common.ControlsCreatureGreatestToughnessCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility; import mage.abilities.decorator.ConditionalOneShotEffect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.triggers.BeginningOfUpkeepTriggeredAbility;
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 java.util.UUID;
/** /**
*
* @author LevelX2 * @author LevelX2
*/ */
public final class AbzanBeastmaster extends CardImpl { public final class AbzanBeastmaster extends CardImpl {
public AbzanBeastmaster(UUID ownerId, CardSetInfo setInfo) { public AbzanBeastmaster(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{G}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{G}");
this.subtype.add(SubType.DOG); this.subtype.add(SubType.DOG);
this.subtype.add(SubType.SHAMAN); this.subtype.add(SubType.SHAMAN);
this.power = new MageInt(2); this.power = new MageInt(2);
this.toughness = new MageInt(1); this.toughness = new MageInt(1);
// At the beginning of your upkeep, draw a card if you control the creature with the greatest toughness or tied for the greatest toughness. // At the beginning of your upkeep, draw a card if you control the creature with the greatest toughness or tied for the greatest toughness.
this.addAbility(new ConditionalInterveningIfTriggeredAbility( this.addAbility(new BeginningOfUpkeepTriggeredAbility(new ConditionalOneShotEffect(
new BeginningOfUpkeepTriggeredAbility(new DrawCardSourceControllerEffect(1)), new DrawCardSourceControllerEffect(1), ControlsCreatureGreatestToughnessCondition.instance,
ControlsCreatureGreatestToughnessCondition.instance, "draw a card if you control the creature with the greatest toughness or tied for the greatest toughness"
"At the beginning of your upkeep, draw a card if you control the creature with the greatest toughness or tied for the greatest toughness." )));
));
} }
private AbzanBeastmaster(final AbzanBeastmaster card) { private AbzanBeastmaster(final AbzanBeastmaster card) {

View file

@ -4,7 +4,6 @@ import mage.MageInt;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.condition.Condition; import mage.abilities.condition.Condition;
import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition; import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.LookLibraryAndPickControllerEffect; import mage.abilities.effects.common.LookLibraryAndPickControllerEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
@ -25,7 +24,7 @@ import java.util.UUID;
*/ */
public final class AcclaimedContender extends CardImpl { public final class AcclaimedContender extends CardImpl {
private static final FilterPermanent filter = new FilterControlledPermanent(SubType.KNIGHT); private static final FilterPermanent filter = new FilterControlledPermanent(SubType.KNIGHT, "you control another Knight");
private static final FilterCard filter2 private static final FilterCard filter2
= new FilterCard("a Knight, Aura, Equipment, or legendary artifact card"); = new FilterCard("a Knight, Aura, Equipment, or legendary artifact card");
@ -53,14 +52,9 @@ public final class AcclaimedContender extends CardImpl {
this.toughness = new MageInt(3); this.toughness = new MageInt(3);
// When Acclaimed Contender enters the battlefield, if you control another Knight, look at the top five cards of your library. You may reveal a Knight, Aura, Equipment, or legendary artifact card from among them and put it into your hand. Put the rest on the bottom of your library in a random order. // When Acclaimed Contender enters the battlefield, if you control another Knight, look at the top five cards of your library. You may reveal a Knight, Aura, Equipment, or legendary artifact card from among them and put it into your hand. Put the rest on the bottom of your library in a random order.
this.addAbility(new ConditionalInterveningIfTriggeredAbility( this.addAbility(new EntersBattlefieldTriggeredAbility(new LookLibraryAndPickControllerEffect(
new EntersBattlefieldTriggeredAbility(new LookLibraryAndPickControllerEffect(
5, 1, filter2, PutCards.HAND, PutCards.BOTTOM_RANDOM 5, 1, filter2, PutCards.HAND, PutCards.BOTTOM_RANDOM
)), condition, "When {this} enters, " + )).withInterveningIf(condition));
"if you control another Knight, look at the top five cards of your library. " +
"You may reveal a Knight, Aura, Equipment, or legendary artifact card from among them " +
"and put it into your hand. Put the rest on the bottom of your library in a random order."
));
} }
private AcclaimedContender(final AcclaimedContender card) { private AcclaimedContender(final AcclaimedContender card) {

View file

@ -6,7 +6,6 @@ import mage.abilities.common.AttacksTriggeredAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.condition.Condition; import mage.abilities.condition.Condition;
import mage.abilities.condition.common.CompletedDungeonCondition; import mage.abilities.condition.common.CompletedDungeonCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ReturnToHandSourceEffect; import mage.abilities.effects.common.ReturnToHandSourceEffect;
import mage.abilities.effects.keyword.VentureIntoTheDungeonEffect; import mage.abilities.effects.keyword.VentureIntoTheDungeonEffect;
@ -22,8 +21,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.game.permanent.token.ZombieToken; import mage.game.permanent.token.ZombieToken;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetPermanent;
import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.common.TargetSacrifice; import mage.target.common.TargetSacrifice;
import mage.watchers.common.CompletedDungeonWatcher; import mage.watchers.common.CompletedDungeonWatcher;
@ -44,13 +41,9 @@ public final class AcererakTheArchlich extends CardImpl {
this.toughness = new MageInt(5); this.toughness = new MageInt(5);
// When Acererak the Archlich enters the battlefield, if you have not completed Tomb of Annihilation, return Acererak the Archlich to its owner's hand and venture into the dungeon. // When Acererak the Archlich enters the battlefield, if you have not completed Tomb of Annihilation, return Acererak the Archlich to its owner's hand and venture into the dungeon.
Ability ability = new ConditionalInterveningIfTriggeredAbility( Ability ability = new EntersBattlefieldTriggeredAbility(new ReturnToHandSourceEffect(true))
new EntersBattlefieldTriggeredAbility(new ReturnToHandSourceEffect(true)), .withInterveningIf(AcererakTheArchlichCondition.instance);
AcererakTheArchlichCondition.instance, "When {this} enters, " + ability.addEffect(new VentureIntoTheDungeonEffect().concatBy("and"));
"if you haven't completed Tomb of Annihilation, return {this} " +
"to its owner's hand and venture into the dungeon."
);
ability.addEffect(new VentureIntoTheDungeonEffect());
ability.addHint(CurrentDungeonHint.instance); ability.addHint(CurrentDungeonHint.instance);
ability.addHint(CompletedDungeonCondition.getHint()); ability.addHint(CompletedDungeonCondition.getHint());
this.addAbility(ability, new CompletedDungeonWatcher()); this.addAbility(ability, new CompletedDungeonWatcher());
@ -78,6 +71,11 @@ enum AcererakTheArchlichCondition implements Condition {
source.getControllerId(), game source.getControllerId(), game
).contains("Tomb of Annihilation"); ).contains("Tomb of Annihilation");
} }
@Override
public String toString() {
return "you haven't completed Tomb of Annihilation";
}
} }
class AcererakTheArchlichEffect extends OneShotEffect { class AcererakTheArchlichEffect extends OneShotEffect {

View file

@ -1,31 +1,30 @@
package mage.cards.a; package mage.cards.a;
import mage.MageInt; import mage.MageInt;
import mage.abilities.triggers.BeginningOfCombatTriggeredAbility; import mage.abilities.condition.Condition;
import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition; import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.hint.ConditionHint;
import mage.abilities.hint.Hint;
import mage.abilities.triggers.BeginningOfCombatTriggeredAbility;
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.counters.CounterType; import mage.counters.CounterType;
import mage.filter.common.FilterControlledPermanent; import mage.filter.common.FilterControlledPlaneswalkerPermanent;
import java.util.UUID; import java.util.UUID;
/** /**
*
* @author htrajan * @author htrajan
*/ */
public final class AdherentOfHope extends CardImpl { public final class AdherentOfHope extends CardImpl {
private static final FilterControlledPermanent filter = new FilterControlledPermanent(); private static final Condition condition = new PermanentsOnTheBattlefieldCondition(
new FilterControlledPlaneswalkerPermanent(SubType.BASRI, "you control a Basri planeswalker")
static { );
filter.add(CardType.PLANESWALKER.getPredicate()); private static final Hint hint = new ConditionHint(condition);
filter.add(SubType.BASRI.getPredicate());
}
public AdherentOfHope(UUID ownerId, CardSetInfo setInfo) { public AdherentOfHope(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{W}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{W}");
@ -36,10 +35,7 @@ public final class AdherentOfHope extends CardImpl {
this.toughness = new MageInt(1); this.toughness = new MageInt(1);
// At the beginning of combat on your turn, if you control a Basri planeswalker, put a +1/+1 counter on Adherent of Hope. // At the beginning of combat on your turn, if you control a Basri planeswalker, put a +1/+1 counter on Adherent of Hope.
this.addAbility(new ConditionalInterveningIfTriggeredAbility( this.addAbility(new BeginningOfCombatTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance())).withInterveningIf(condition).addHint(hint));
new BeginningOfCombatTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance())),
new PermanentsOnTheBattlefieldCondition(filter),
"At the beginning of combat on your turn, if you control a Basri planeswalker, put a +1/+1 counter on {this}."));
} }
private AdherentOfHope(final AdherentOfHope card) { private AdherentOfHope(final AdherentOfHope card) {

View file

@ -1,36 +1,34 @@
package mage.cards.a; package mage.cards.a;
import java.util.*;
import mage.MageInt; import mage.MageInt;
import mage.MageObjectReference; import mage.MageObjectReference;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.AttacksTriggeredAbility; import mage.abilities.common.AttacksTriggeredAbility;
import mage.abilities.condition.Condition; import mage.abilities.condition.Condition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.continuous.AddCardSubTypeSourceEffect; import mage.abilities.effects.common.continuous.AddCardSubTypeSourceEffect;
import mage.abilities.hint.ConditionHint; import mage.abilities.hint.ConditionHint;
import mage.abilities.hint.Hint; import mage.abilities.hint.Hint;
import mage.constants.*;
import mage.abilities.keyword.IslandwalkAbility;
import mage.abilities.keyword.CrewAbility; import mage.abilities.keyword.CrewAbility;
import mage.abilities.keyword.IslandwalkAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.watchers.Watcher; import mage.watchers.Watcher;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/** /**
*
* @author Grath * @author Grath
*/ */
public final class Adrestia extends CardImpl { public final class Adrestia extends CardImpl {
private static final Condition condition = AdrestiaCondition.instance;
public Adrestia(UUID ownerId, CardSetInfo setInfo) { public Adrestia(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}"); super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}");
@ -44,16 +42,14 @@ public final class Adrestia extends CardImpl {
this.addAbility(new IslandwalkAbility()); this.addAbility(new IslandwalkAbility());
// Whenever Adrestia attacks, if an Assassin crewed it this turn, draw a card. Adrestia becomes an Assassin in addition to its other types until end of turn. // Whenever Adrestia attacks, if an Assassin crewed it this turn, draw a card. Adrestia becomes an Assassin in addition to its other types until end of turn.
Ability ability = new ConditionalInterveningIfTriggeredAbility( Ability ability = new AttacksTriggeredAbility(new DrawCardSourceControllerEffect(1), false)
new AttacksTriggeredAbility(new DrawCardSourceControllerEffect(1), false), .withInterveningIf(AdrestiaCondition.instance);
condition, "Whenever {this} attacks, if an Assassin crewed it this turn, draw a card. {this} becomes an Assassin in addition to its other types until end of turn.");
ability.addEffect(new AddCardSubTypeSourceEffect(Duration.EndOfTurn, true, SubType.ASSASSIN)); ability.addEffect(new AddCardSubTypeSourceEffect(Duration.EndOfTurn, true, SubType.ASSASSIN));
ability.addHint(AdrestiaCondition.getHint()); ability.addHint(AdrestiaCondition.getHint());
this.addAbility(ability, new AdrestiaWatcher()); this.addAbility(ability, new AdrestiaWatcher());
// Crew 1 // Crew 1
this.addAbility(new CrewAbility(1)); this.addAbility(new CrewAbility(1));
} }
private Adrestia(final Adrestia card) { private Adrestia(final Adrestia card) {
@ -68,13 +64,18 @@ public final class Adrestia extends CardImpl {
enum AdrestiaCondition implements Condition { enum AdrestiaCondition implements Condition {
instance; instance;
private static final Hint hint = new ConditionHint(instance, "an Assassin crewed it this turn"); private static final Hint hint = new ConditionHint(instance);
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
return AdrestiaWatcher.checkIfAssassinCrewed(source.getSourcePermanentOrLKI(game), game); return AdrestiaWatcher.checkIfAssassinCrewed(source.getSourcePermanentOrLKI(game), game);
} }
@Override
public String toString() {
return "an Assassin crewed it this turn";
}
public static Hint getHint() { public static Hint getHint() {
return hint; return hint;
} }
@ -97,8 +98,7 @@ class AdrestiaWatcher extends Watcher {
if (crewer != null) { if (crewer != null) {
if (!crewMap.containsKey(vehicle)) { if (!crewMap.containsKey(vehicle)) {
crewMap.put(vehicle, filter.match(crewer, game)); crewMap.put(vehicle, filter.match(crewer, game));
} } else {
else {
crewMap.put(vehicle, crewMap.get(vehicle) || filter.match(crewer, game)); crewMap.put(vehicle, crewMap.get(vehicle) || filter.match(crewer, game));
} }
} }

View file

@ -4,7 +4,6 @@ import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.AttacksTriggeredAbility; import mage.abilities.common.AttacksTriggeredAbility;
import mage.abilities.condition.Condition; import mage.abilities.condition.Condition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect; import mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect;
import mage.abilities.hint.Hint; import mage.abilities.hint.Hint;
import mage.abilities.hint.common.LandsYouControlHint; import mage.abilities.hint.common.LandsYouControlHint;
@ -46,13 +45,10 @@ public final class AerialSurveyor extends CardImpl {
this.addAbility(FlyingAbility.getInstance()); this.addAbility(FlyingAbility.getInstance());
// Whenever Aerial Surveyor attacks, if defending player controls more lands than you, search your library for a basic Plains card, put it onto the battlefield tapped, then shuffle. // Whenever Aerial Surveyor attacks, if defending player controls more lands than you, search your library for a basic Plains card, put it onto the battlefield tapped, then shuffle.
this.addAbility(new ConditionalInterveningIfTriggeredAbility( this.addAbility(new AttacksTriggeredAbility(new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(filter), true))
new AttacksTriggeredAbility( .withInterveningIf(AerialSurveyorCondition.instance)
new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(filter), true) .addHint(LandsYouControlHint.instance)
), AerialSurveyorCondition.instance, "Whenever {this} attacks, if defending player " + .addHint(AerialSurveyorHint.instance));
"controls more lands than you, search your library for a basic Plains card, " +
"put it onto the battlefield tapped, then shuffle."
).addHint(LandsYouControlHint.instance).addHint(AerialSurveyorHint.instance));
// Crew 2 // Crew 2
this.addAbility(new CrewAbility(2)); this.addAbility(new CrewAbility(2));
@ -85,6 +81,11 @@ enum AerialSurveyorCondition implements Condition {
source.getControllerId(), source, game source.getControllerId(), source, game
); );
} }
@Override
public String toString() {
return "";
}
} }
enum AerialSurveyorHint implements Hint { enum AerialSurveyorHint implements Hint {

View file

@ -3,7 +3,6 @@ package mage.game.command.emblems;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.OneOrMoreCombatDamagePlayerTriggeredAbility; import mage.abilities.common.OneOrMoreCombatDamagePlayerTriggeredAbility;
import mage.abilities.condition.Condition; import mage.abilities.condition.Condition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome; import mage.constants.Outcome;
@ -25,13 +24,9 @@ public final class LolthSpiderQueenEmblem extends Emblem {
// 8: You get an emblem with "Whenever an opponent is dealt combat damage by one or more creatures you control, if that player lost less than 8 life this turn, they lose life equal to the difference." // 8: You get an emblem with "Whenever an opponent is dealt combat damage by one or more creatures you control, if that player lost less than 8 life this turn, they lose life equal to the difference."
public LolthSpiderQueenEmblem() { public LolthSpiderQueenEmblem() {
super("Emblem Lolth"); super("Emblem Lolth");
this.getAbilities().add(new ConditionalInterveningIfTriggeredAbility( this.getAbilities().add(new OneOrMoreCombatDamagePlayerTriggeredAbility(
new OneOrMoreCombatDamagePlayerTriggeredAbility(
Zone.COMMAND, new LolthSpiderQueenEmblemEffect(), StaticFilters.FILTER_PERMANENT_CREATURES, SetTargetPointer.PLAYER, false Zone.COMMAND, new LolthSpiderQueenEmblemEffect(), StaticFilters.FILTER_PERMANENT_CREATURES, SetTargetPointer.PLAYER, false
), LolthSpiderQueenEmblemCondition.instance, "Whenever an opponent " + ).withInterveningIf(LolthSpiderQueenEmblemCondition.instance).setTriggerPhrase("Whenever an opponent is dealt combat damage by one or more creatures you control, "));
"is dealt combat damage by one or more creatures you control, " +
"if that player lost less than 8 life this turn, they lose life equal to the difference."
));
} }
private LolthSpiderQueenEmblem(final LolthSpiderQueenEmblem card) { private LolthSpiderQueenEmblem(final LolthSpiderQueenEmblem card) {
@ -61,12 +56,18 @@ enum LolthSpiderQueenEmblemCondition implements Condition {
PlayerLostLifeWatcher watcher = game.getState().getWatcher(PlayerLostLifeWatcher.class); PlayerLostLifeWatcher watcher = game.getState().getWatcher(PlayerLostLifeWatcher.class);
return player != null && watcher != null && watcher.getLifeLost(player.getId()) < 8; return player != null && watcher != null && watcher.getLifeLost(player.getId()) < 8;
} }
@Override
public String toString() {
return "that player lost less than 8 life this turn";
}
} }
class LolthSpiderQueenEmblemEffect extends OneShotEffect { class LolthSpiderQueenEmblemEffect extends OneShotEffect {
LolthSpiderQueenEmblemEffect() { LolthSpiderQueenEmblemEffect() {
super(Outcome.Benefit); super(Outcome.Benefit);
staticText = "they lose life equal to the difference";
} }
private LolthSpiderQueenEmblemEffect(final LolthSpiderQueenEmblemEffect effect) { private LolthSpiderQueenEmblemEffect(final LolthSpiderQueenEmblemEffect effect) {

View file

@ -1,10 +1,9 @@
package mage.game.command.emblems; package mage.game.command.emblems;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.triggers.BeginningOfFirstMainTriggeredAbility;
import mage.abilities.condition.Condition; import mage.abilities.condition.Condition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.triggers.BeginningOfFirstMainTriggeredAbility;
import mage.cards.Cards; import mage.cards.Cards;
import mage.cards.FrameStyle; import mage.cards.FrameStyle;
import mage.cards.repository.TokenInfo; import mage.cards.repository.TokenInfo;
@ -31,12 +30,9 @@ public class RadiationEmblem extends Emblem {
super("Radiation"); super("Radiation");
this.frameStyle = FrameStyle.M15_NORMAL; this.frameStyle = FrameStyle.M15_NORMAL;
this.getAbilities().add(new ConditionalInterveningIfTriggeredAbility( this.getAbilities().add(new BeginningOfFirstMainTriggeredAbility(
new BeginningOfFirstMainTriggeredAbility(Zone.ALL, TargetController.YOU, new RadiationEffect(), false), Zone.ALL, TargetController.YOU, new RadiationEffect(), false
RadiationCondition.instance, ).withInterveningIf(RadiationCondition.instance).setTriggerPhrase("At the beginning of each player's precombat main phase, "));
"At the beginning of your precombat main phase, if you have any rad counters, "
+ "mill that many cards. For each nonland card milled this way, you lose 1 life and a rad counter."
));
TokenInfo foundInfo = TokenRepository.instance.findPreferredTokenInfoForXmage(TokenRepository.XMAGE_IMAGE_NAME_RADIATION, null); TokenInfo foundInfo = TokenRepository.instance.findPreferredTokenInfoForXmage(TokenRepository.XMAGE_IMAGE_NAME_RADIATION, null);
if (foundInfo != null) { if (foundInfo != null) {
@ -69,6 +65,11 @@ enum RadiationCondition implements Condition {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
return player != null && player.getCountersCount(CounterType.RAD) > 0; return player != null && player.getCountersCount(CounterType.RAD) > 0;
} }
@Override
public String toString() {
return "that player has one or more rad counters";
}
} }
/** /**

View file

@ -1,12 +1,11 @@
package mage.game.permanent.token; package mage.game.permanent.token;
import mage.MageInt; import mage.MageInt;
import mage.abilities.triggers.BeginningOfCombatTriggeredAbility;
import mage.abilities.condition.common.WasCardExiledThisTurnCondition; import mage.abilities.condition.common.WasCardExiledThisTurnCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.hint.ConditionHint; import mage.abilities.hint.ConditionHint;
import mage.abilities.hint.Hint; import mage.abilities.hint.Hint;
import mage.abilities.triggers.BeginningOfCombatTriggeredAbility;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType; import mage.constants.SubType;
import mage.counters.CounterType; import mage.counters.CounterType;
@ -22,21 +21,16 @@ public final class AshiokWickedManipulatorNightmareToken extends TokenImpl {
* /!\ You need to add CardsExiledThisTurnWatcher to any card using this token * /!\ You need to add CardsExiledThisTurnWatcher to any card using this token
*/ */
public AshiokWickedManipulatorNightmareToken() { public AshiokWickedManipulatorNightmareToken() {
super("Nightmare Token", "1/1 black Nightmare creature tokens with \"At the beginning of combat on your turn, if a card was put into exile this turn, put a +1/+1 counter on this creature.\""); super("Nightmare Token", "1/1 black Nightmare creature token with \"At the beginning of combat on your turn, if a card was put into exile this turn, put a +1/+1 counter on this token.\"");
cardType.add(CardType.CREATURE); cardType.add(CardType.CREATURE);
color.setBlack(true); color.setBlack(true);
subtype.add(SubType.NIGHTMARE); subtype.add(SubType.NIGHTMARE);
power = new MageInt(1); power = new MageInt(1);
toughness = new MageInt(1); toughness = new MageInt(1);
this.addAbility(new ConditionalInterveningIfTriggeredAbility( this.addAbility(new BeginningOfCombatTriggeredAbility(
new BeginningOfCombatTriggeredAbility(
new AddCountersSourceEffect(CounterType.P1P1.createInstance()) new AddCountersSourceEffect(CounterType.P1P1.createInstance())
), ).withInterveningIf(WasCardExiledThisTurnCondition.instance).addHint(hint));
WasCardExiledThisTurnCondition.instance,
"At the beginning of combat on your turn, if a card was put into exile "
+ "this turn, put a +1/+1 counter on this creature."
).addHint(hint));
} }
private AshiokWickedManipulatorNightmareToken(final AshiokWickedManipulatorNightmareToken token) { private AshiokWickedManipulatorNightmareToken(final AshiokWickedManipulatorNightmareToken token) {

View file

@ -5,7 +5,6 @@ import mage.abilities.common.AttacksTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.Condition; import mage.abilities.condition.Condition;
import mage.abilities.condition.common.SourceMatchesFilterCondition; import mage.abilities.condition.common.SourceMatchesFilterCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect; import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect;
@ -23,7 +22,7 @@ import mage.target.common.TargetCreaturePermanent;
*/ */
public final class YoungHeroRoleToken extends TokenImpl { public final class YoungHeroRoleToken extends TokenImpl {
private static final FilterPermanent filter = new FilterCreaturePermanent(); private static final FilterPermanent filter = new FilterCreaturePermanent("its toughness is 3 or less");
static { static {
filter.add(new ToughnessPredicate(ComparisonType.FEWER_THAN, 4)); filter.add(new ToughnessPredicate(ComparisonType.FEWER_THAN, 4));
@ -45,10 +44,10 @@ public final class YoungHeroRoleToken extends TokenImpl {
// Enchanted creature has "Whenever this creature attacks, if its toughness is 3 or less, put a +1/+1 counter on it." // Enchanted creature has "Whenever this creature attacks, if its toughness is 3 or less, put a +1/+1 counter on it."
this.addAbility(new SimpleStaticAbility(new GainAbilityAttachedEffect( this.addAbility(new SimpleStaticAbility(new GainAbilityAttachedEffect(
new ConditionalInterveningIfTriggeredAbility( new AttacksTriggeredAbility(
new AttacksTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance())), new AddCountersSourceEffect(CounterType.P1P1.createInstance())
condition, "Whenever this creature attacks, if its toughness is 3 or less, put a +1/+1 counter on it." .setText("put a +1/+1 counter on it")
), AttachmentType.AURA ).withInterveningIf(condition), AttachmentType.AURA
))); )));
} }