refactor more cards using ConditionalInterveningIfTriggeredAbility

This commit is contained in:
theelk801 2025-06-05 12:13:59 -04:00
parent d861f67232
commit d952e3b2ce
26 changed files with 207 additions and 288 deletions

View file

@ -2,14 +2,15 @@ package mage.cards.a;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.triggers.BeginningOfEndStepTriggeredAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
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.dynamicvalue.common.PermanentsOnBattlefieldCount; import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.continuous.GainControlTargetEffect; import mage.abilities.effects.common.continuous.GainControlTargetEffect;
import mage.abilities.hint.Hint;
import mage.abilities.hint.ValueHint; import mage.abilities.hint.ValueHint;
import mage.abilities.triggers.BeginningOfEndStepTriggeredAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.*; import mage.constants.*;
@ -24,12 +25,15 @@ import java.util.UUID;
*/ */
public final class AgentOfTreachery extends CardImpl { public final class AgentOfTreachery extends CardImpl {
private static final FilterPermanent filter = new FilterControlledPermanent(); private static final FilterPermanent filter = new FilterControlledPermanent("you control three or more permanents you don't own");
static { static {
filter.add(TargetController.NOT_YOU.getOwnerPredicate()); filter.add(TargetController.NOT_YOU.getOwnerPredicate());
} }
private static final Condition condition = new PermanentsOnTheBattlefieldCondition(filter, ComparisonType.MORE_THAN, 2);
private static final Hint hint = new ValueHint("Permanents you control but don't own", new PermanentsOnBattlefieldCount(filter));
public AgentOfTreachery(UUID ownerId, CardSetInfo setInfo) { public AgentOfTreachery(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{U}{U}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{U}{U}");
@ -44,12 +48,7 @@ public final class AgentOfTreachery extends CardImpl {
this.addAbility(ability); this.addAbility(ability);
// At the beginning of your end step, if you control three or more permanents you don't own, draw three cards. // At the beginning of your end step, if you control three or more permanents you don't own, draw three cards.
this.addAbility(new ConditionalInterveningIfTriggeredAbility( this.addAbility(new BeginningOfEndStepTriggeredAbility(new DrawCardSourceControllerEffect(3)).withInterveningIf(condition).addHint(hint));
new BeginningOfEndStepTriggeredAbility(
new DrawCardSourceControllerEffect(3)
), new PermanentsOnTheBattlefieldCondition(filter, ComparisonType.MORE_THAN, 2), "At the beginning of your end step, " +
"if you control three or more permanents you don't own, draw three cards."
).addHint(new ValueHint("Permanents you control but don't own", new PermanentsOnBattlefieldCount(filter))));
} }
private AgentOfTreachery(final AgentOfTreachery card) { private AgentOfTreachery(final AgentOfTreachery card) {

View file

@ -1,32 +1,28 @@
package mage.cards.a; package mage.cards.a;
import java.util.UUID;
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.keyword.TrampleAbility; import mage.abilities.keyword.TrampleAbility;
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;
/** /**
*
* @author fireshoes * @author fireshoes
*/ */
public final class AjanisComrade extends CardImpl { public final class AjanisComrade extends CardImpl {
private static final FilterControlledPermanent filter = new FilterControlledPermanent(); private static final Condition condition = new PermanentsOnTheBattlefieldCondition(
new FilterControlledPlaneswalkerPermanent(SubType.AJANI, "you control an Ajani planeswalker")
static { );
filter.add(CardType.PLANESWALKER.getPredicate());
filter.add(SubType.AJANI.getPredicate());
}
public AjanisComrade(UUID ownerId, CardSetInfo setInfo) { public AjanisComrade(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{G}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{G}");
@ -40,10 +36,7 @@ public final class AjanisComrade extends CardImpl {
this.addAbility(TrampleAbility.getInstance()); this.addAbility(TrampleAbility.getInstance());
// At the beginning of combat on your turn, if you control an Ajani planeswalker, put a +1/+1 counter on Ajani's Comrade. // At the beginning of combat on your turn, if you control an Ajani planeswalker, put a +1/+1 counter on Ajani's Comrade.
this.addAbility(new ConditionalInterveningIfTriggeredAbility( this.addAbility(new BeginningOfCombatTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance())).withInterveningIf(condition));
new BeginningOfCombatTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance())),
new PermanentsOnTheBattlefieldCondition(filter),
"At the beginning of combat on your turn, if you control an Ajani planeswalker, put a +1/+1 counter on {this}."));
} }
private AjanisComrade(final AjanisComrade card) { private AjanisComrade(final AjanisComrade card) {

View file

@ -1,51 +1,42 @@
package mage.cards.a; package mage.cards.a;
import java.util.UUID; import mage.abilities.common.DiesCreatureTriggeredAbility;
import mage.MageObject;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.DiscardedByOpponentTriggeredAbility; import mage.abilities.common.DiscardedByOpponentTriggeredAbility;
import mage.abilities.condition.Condition;
import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition; import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition;
import mage.abilities.costs.common.SacrificeSourceCost; import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.effects.common.CreateTokenEffect;
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.SubType; import mage.constants.SubType;
import mage.constants.Zone; import mage.filter.StaticFilters;
import mage.filter.common.FilterControlledPermanent; import mage.filter.common.FilterControlledPermanent;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.game.permanent.token.AvatarToken2; import mage.game.permanent.token.AvatarToken2;
import java.util.UUID;
/** /**
*
* @author TheElk801 * @author TheElk801
*/ */
public final class AjanisLastStand extends CardImpl { public final class AjanisLastStand extends CardImpl {
private static final FilterControlledPermanent filter = new FilterControlledPermanent(); private static final Condition condition = new PermanentsOnTheBattlefieldCondition(
new FilterControlledPermanent(SubType.PLAINS, "you control a Plains")
static { );
filter.add(SubType.PLAINS.getPredicate());
}
public AjanisLastStand(UUID ownerId, CardSetInfo setInfo) { public AjanisLastStand(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}{W}"); super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}{W}");
// Whenever a creature or planeswalker you control dies, you may sacrifice Ajani's Last Stand. If you do, create a 4/4 white Avatar creature token with flying. // Whenever a creature or planeswalker you control dies, you may sacrifice Ajani's Last Stand. If you do, create a 4/4 white Avatar creature token with flying.
this.addAbility(new AjanisLastStandTriggeredAbility()); this.addAbility(new DiesCreatureTriggeredAbility(
new DoIfCostPaid(new CreateTokenEffect(new AvatarToken2()), new SacrificeSourceCost()),
false, StaticFilters.FILTER_CONTROLLED_PERMANENT_CREATURE_OR_PLANESWALKER
));
// When a spell or ability an opponent controls causes you to discard this card, if you control a Plains, create a 4/4 white Avatar creature token with flying. // When a spell or ability an opponent controls causes you to discard this card, if you control a Plains, create a 4/4 white Avatar creature token with flying.
this.addAbility(new ConditionalInterveningIfTriggeredAbility( this.addAbility(new DiscardedByOpponentTriggeredAbility(new CreateTokenEffect(new AvatarToken2())).withInterveningIf(condition));
new DiscardedByOpponentTriggeredAbility(new CreateTokenEffect(new AvatarToken2())),
new PermanentsOnTheBattlefieldCondition(filter),
"When a spell or ability an opponent controls causes you to discard this card, "
+ "if you control a Plains, create a 4/4 white Avatar creature token with flying."
));
} }
private AjanisLastStand(final AjanisLastStand card) { private AjanisLastStand(final AjanisLastStand card) {
@ -57,53 +48,3 @@ public final class AjanisLastStand extends CardImpl {
return new AjanisLastStand(this); return new AjanisLastStand(this);
} }
} }
class AjanisLastStandTriggeredAbility extends TriggeredAbilityImpl {
public AjanisLastStandTriggeredAbility() {
super(Zone.BATTLEFIELD, new DoIfCostPaid(
new CreateTokenEffect(new AvatarToken2()),
new SacrificeSourceCost()
), false);
setLeavesTheBattlefieldTrigger(true);
}
private AjanisLastStandTriggeredAbility(final AjanisLastStandTriggeredAbility ability) {
super(ability);
}
@Override
public AjanisLastStandTriggeredAbility copy() {
return new AjanisLastStandTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.ZONE_CHANGE;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (zEvent.isDiesEvent()) {
if (zEvent.getTarget().isControlledBy(controllerId)
&& (zEvent.getTarget().isCreature(game)
|| zEvent.getTarget().isPlaneswalker(game))) {
return true;
}
}
return false;
}
@Override
public String getRule() {
return "Whenever a creature or planeswalker you control dies, "
+ "you may sacrifice {this}. "
+ "If you do, create a 4/4 white Avatar creature token with flying.";
}
@Override
public boolean isInUseableZone(Game game, MageObject sourceObject, GameEvent event) {
return TriggeredAbilityImpl.isInUseableZoneDiesTrigger(this, sourceObject, event, game);
}
}

View file

@ -7,7 +7,6 @@ import mage.abilities.common.SpellCastControllerTriggeredAbility;
import mage.abilities.condition.Condition; import mage.abilities.condition.Condition;
import mage.abilities.costs.common.SacrificeSourceCost; import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.effects.common.CreateTokenEffect;
@ -52,18 +51,24 @@ public final class AlchemistsTalent extends CardImpl {
// Treasures you control have "{T}, Sacrifice this artifact: Add two mana of any one color." // Treasures you control have "{T}, Sacrifice this artifact: Add two mana of any one color."
Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(2), new TapSourceCost()); Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(2), new TapSourceCost());
ability.addCost(new SacrificeSourceCost().setText("sacrifice this artifact")); ability.addCost(new SacrificeSourceCost().setText("sacrifice this artifact"));
this.addAbility(new SimpleStaticAbility(new GainClassAbilitySourceEffect(new GainAbilityControlledEffect(ability, Duration.WhileOnBattlefield, new FilterPermanent(SubType.TREASURE, "Treasures")), 2))); this.addAbility(new SimpleStaticAbility(new GainClassAbilitySourceEffect(
new GainAbilityControlledEffect(
ability, Duration.WhileOnBattlefield,
new FilterPermanent(SubType.TREASURE, "Treasures")
), 2
)));
// {4}{R}: Level 3 // {4}{R}: Level 3
this.addAbility(new ClassLevelAbility(3, "{4}{R}")); this.addAbility(new ClassLevelAbility(3, "{4}{R}"));
// Whenever you cast a spell, if mana from a Treasure was spent to cast it, this Class deals damage equal to that spell's mana value to each opponent. // Whenever you cast a spell, if mana from a Treasure was spent to cast it, this Class deals damage equal to that spell's mana value to each opponent.
this.addAbility(new SimpleStaticAbility(new GainClassAbilitySourceEffect(new ConditionalInterveningIfTriggeredAbility( this.addAbility(new SimpleStaticAbility(new GainClassAbilitySourceEffect(
new SpellCastControllerTriggeredAbility( new SpellCastControllerTriggeredAbility(
new DamagePlayersEffect(AlchemistsTalentValue.instance, TargetController.OPPONENT), StaticFilters.FILTER_SPELL, false, SetTargetPointer.SPELL new DamagePlayersEffect(AlchemistsTalentValue.instance, TargetController.OPPONENT)
), AlchemistsTalentCondition.instance, "Whenever you cast a spell, if mana from a Treasure " + .setText("{this} deals damage equal to that spell's mana value to each opponent"),
"was spent to cast it, this Class deals damage equal to that spell's mana value to each opponent" StaticFilters.FILTER_SPELL, false, SetTargetPointer.SPELL
), 3))); ).withInterveningIf(AlchemistsTalentCondition.instance), 3
)));
} }
private AlchemistsTalent(final AlchemistsTalent card) { private AlchemistsTalent(final AlchemistsTalent card) {
@ -84,6 +89,11 @@ enum AlchemistsTalentCondition implements Condition {
Spell spell = (Spell) source.getEffects().get(0).getValue("spellCast"); Spell spell = (Spell) source.getEffects().get(0).getValue("spellCast");
return spell != null && ManaPaidSourceWatcher.getTreasurePaid(spell.getSourceId(), game) > 0; return spell != null && ManaPaidSourceWatcher.getTreasurePaid(spell.getSourceId(), game) > 0;
} }
@Override
public String toString() {
return "mana from a Treasure was spent to cast it";
}
} }
enum AlchemistsTalentValue implements DynamicValue { enum AlchemistsTalentValue implements DynamicValue {
@ -111,6 +121,6 @@ enum AlchemistsTalentValue implements DynamicValue {
@Override @Override
public String toString() { public String toString() {
return ""; return "1";
} }
} }

View file

@ -2,11 +2,11 @@ package mage.cards.a;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.TriggeredAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.condition.Condition;
import mage.abilities.condition.common.KickedCostCondition; import mage.abilities.condition.common.KickedCostCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.TapTargetEffect;
import mage.abilities.effects.common.discard.DiscardTargetEffect; import mage.abilities.effects.common.discard.DiscardTargetEffect;
import mage.abilities.keyword.KickerAbility; import mage.abilities.keyword.KickerAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -35,6 +35,9 @@ public final class AnaBattlemage extends CardImpl {
filter.add(TappedPredicate.UNTAPPED); filter.add(TappedPredicate.UNTAPPED);
} }
private static final Condition condition = new KickedCostCondition("{2}{U}");
private static final Condition condition2 = new KickedCostCondition("{1}{B}");
public AnaBattlemage(UUID ownerId, CardSetInfo setInfo) { public AnaBattlemage(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.HUMAN); this.subtype.add(SubType.HUMAN);
@ -46,16 +49,17 @@ public final class AnaBattlemage extends CardImpl {
KickerAbility kickerAbility = new KickerAbility("{2}{U}"); KickerAbility kickerAbility = new KickerAbility("{2}{U}");
kickerAbility.addKickerCost("{1}{B}"); kickerAbility.addKickerCost("{1}{B}");
this.addAbility(kickerAbility); this.addAbility(kickerAbility);
// When Ana Battlemage enters the battlefield, if it was kicked with its {2}{U} kicker, target player discards three cards. // When Ana Battlemage enters the battlefield, if it was kicked with its {2}{U} kicker, target player discards three cards.
TriggeredAbility ability = new EntersBattlefieldTriggeredAbility(new DiscardTargetEffect(3)); Ability ability = new EntersBattlefieldTriggeredAbility(new DiscardTargetEffect(3)).withInterveningIf(condition);
ability.addTarget(new TargetPlayer()); ability.addTarget(new TargetPlayer());
this.addAbility(new ConditionalInterveningIfTriggeredAbility(ability, new KickedCostCondition("{2}{U}"), this.addAbility(ability);
"When {this} enters, if it was kicked with its {2}{U} kicker, target player discards three cards."));
// When Ana Battlemage enters the battlefield, if it was kicked with its {1}{B} kicker, tap target untapped creature and that creature deals damage equal to its power to its controller. // When Ana Battlemage enters the battlefield, if it was kicked with its {1}{B} kicker, tap target untapped creature and that creature deals damage equal to its power to its controller.
ability = new EntersBattlefieldTriggeredAbility(new AnaBattlemageKickerEffect()); ability = new EntersBattlefieldTriggeredAbility(new TapTargetEffect()).withInterveningIf(condition2);
ability.addEffect(new AnaBattlemageEffect());
ability.addTarget(new TargetCreaturePermanent(filter)); ability.addTarget(new TargetCreaturePermanent(filter));
this.addAbility(new ConditionalInterveningIfTriggeredAbility(ability, new KickedCostCondition("{1}{B}"), this.addAbility(ability);
"When {this} enters, if it was kicked with its {1}{B} kicker, tap target untapped creature and that creature deals damage equal to its power to its controller."));
} }
private AnaBattlemage(final AnaBattlemage card) { private AnaBattlemage(final AnaBattlemage card) {
@ -68,34 +72,31 @@ public final class AnaBattlemage extends CardImpl {
} }
} }
class AnaBattlemageKickerEffect extends OneShotEffect { class AnaBattlemageEffect extends OneShotEffect {
AnaBattlemageKickerEffect() { AnaBattlemageEffect() {
super(Outcome.Detriment); super(Outcome.Detriment);
this.staticText = "tap target untapped creature and it deals damage equal to its power to its controller"; this.staticText = "and it deals damage equal to its power to its controller";
} }
private AnaBattlemageKickerEffect(final AnaBattlemageKickerEffect effect) { private AnaBattlemageEffect(final AnaBattlemageEffect effect) {
super(effect); super(effect);
} }
@Override @Override
public AnaBattlemageKickerEffect copy() { public AnaBattlemageEffect copy() {
return new AnaBattlemageKickerEffect(this); return new AnaBattlemageEffect(this);
} }
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
boolean applied = false;
Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source)); Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
if (targetCreature != null) { if (targetCreature == null) {
applied = targetCreature.tap(source, game); return false;
}
Player controller = game.getPlayer(targetCreature.getControllerId()); Player controller = game.getPlayer(targetCreature.getControllerId());
if (controller != null) { return controller != null && controller.damage(
controller.damage(targetCreature.getPower().getValue(), source.getSourceId(), source, game); targetCreature.getPower().getValue(), source.getSourceId(), source, game
applied = true; ) > 0;
}
}
return applied;
} }
} }

View file

@ -3,13 +3,12 @@ package mage.cards.a;
import mage.MageInt; import mage.MageInt;
import mage.MageObjectReference; import mage.MageObjectReference;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.triggers.BeginningOfEndStepTriggeredAbility;
import mage.abilities.common.DealsDamageToAPlayerAllTriggeredAbility; import mage.abilities.common.DealsDamageToAPlayerAllTriggeredAbility;
import mage.abilities.condition.common.MoreThanStartingLifeTotalCondition; import mage.abilities.condition.common.MoreThanStartingLifeTotalCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.DoubleStrikeAbility; import mage.abilities.keyword.DoubleStrikeAbility;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
import mage.abilities.triggers.BeginningOfEndStepTriggeredAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.*; import mage.constants.*;
@ -47,13 +46,8 @@ public final class AngelOfDestiny extends CardImpl {
)); ));
// At the beginning of your end step, if you have at least 15 life more than your starting life total, each player Angel of Destiny attacked this turn loses the game. // At the beginning of your end step, if you have at least 15 life more than your starting life total, each player Angel of Destiny attacked this turn loses the game.
this.addAbility(new ConditionalInterveningIfTriggeredAbility( this.addAbility(new BeginningOfEndStepTriggeredAbility(new AngelOfDestinyLoseEffect())
new BeginningOfEndStepTriggeredAbility( .withInterveningIf(MoreThanStartingLifeTotalCondition.FIFTEEN), new AngelOfDestinyWatcher());
new AngelOfDestinyLoseEffect()
), MoreThanStartingLifeTotalCondition.FIFTEEN, "At the beginning of your end step, " +
"if you have at least 15 life more than your starting life total, " +
"each player {this} attacked this turn loses the game."
), new AngelOfDestinyWatcher());
} }
private AngelOfDestiny(final AngelOfDestiny card) { private AngelOfDestiny(final AngelOfDestiny card) {
@ -101,6 +95,7 @@ class AngelOfDestinyLoseEffect extends OneShotEffect {
AngelOfDestinyLoseEffect() { AngelOfDestinyLoseEffect() {
super(Outcome.Benefit); super(Outcome.Benefit);
staticText = "each player {this} attacked this turn loses the game";
} }
private AngelOfDestinyLoseEffect(final AngelOfDestinyLoseEffect effect) { private AngelOfDestinyLoseEffect(final AngelOfDestinyLoseEffect effect) {

View file

@ -6,7 +6,6 @@ import mage.abilities.Ability;
import mage.abilities.common.AttacksTriggeredAbility; import mage.abilities.common.AttacksTriggeredAbility;
import mage.abilities.common.EntersBattlefieldThisOrAnotherTriggeredAbility; import mage.abilities.common.EntersBattlefieldThisOrAnotherTriggeredAbility;
import mage.abilities.condition.Condition; import mage.abilities.condition.Condition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
@ -48,11 +47,8 @@ public final class AngelicSellSword extends CardImpl {
)); ));
// Whenever Angelic Sell-Sword attacks, if its power is 6 or greater, draw a card. // Whenever Angelic Sell-Sword attacks, if its power is 6 or greater, draw a card.
this.addAbility(new ConditionalInterveningIfTriggeredAbility( this.addAbility(new AttacksTriggeredAbility(new DrawCardSourceControllerEffect(1))
new AttacksTriggeredAbility(new DrawCardSourceControllerEffect(1)), .withInterveningIf(AngelicSellSwordCondition.instance));
AngelicSellSwordCondition.instance, "Whenever {this} attacks, " +
"if its power is 6 or greater, draw a card."
));
} }
private AngelicSellSword(final AngelicSellSword card) { private AngelicSellSword(final AngelicSellSword card) {
@ -76,4 +72,9 @@ enum AngelicSellSwordCondition implements Condition {
.map(MageInt::getValue) .map(MageInt::getValue)
.orElse(0) >= 6; .orElse(0) >= 6;
} }
@Override
public String toString() {
return "its power is 6 or greater";
}
} }

View file

@ -1,35 +1,34 @@
package mage.cards.a; package mage.cards.a;
import mage.MageInt; import mage.MageInt;
import mage.abilities.TriggeredAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
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.GainLifeEffect; import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
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.filter.FilterPermanent;
import mage.filter.common.FilterControlledPermanent; import mage.filter.common.FilterControlledPermanent;
import mage.filter.predicate.mageobject.AnotherPredicate; import mage.filter.predicate.mageobject.AnotherPredicate;
import java.util.UUID; import java.util.UUID;
/** /**
*
* @author escplan9 (Derek Monturo - dmontur1 at gmail dot com) * @author escplan9 (Derek Monturo - dmontur1 at gmail dot com)
*/ */
public final class ApothecaryGeist extends CardImpl { public final class ApothecaryGeist extends CardImpl {
private static final FilterControlledPermanent filter = new FilterControlledPermanent("another Elf"); private static final FilterPermanent filter = new FilterControlledPermanent(SubType.SPIRIT, "you control another Spirit");
static { static {
filter.add(AnotherPredicate.instance); filter.add(AnotherPredicate.instance);
filter.add(SubType.SPIRIT.getPredicate());
} }
private static final Condition condition = new PermanentsOnTheBattlefieldCondition(filter);
public ApothecaryGeist(UUID ownerId, CardSetInfo setInfo) { public ApothecaryGeist(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{W}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{W}");
this.subtype.add(SubType.SPIRIT); this.subtype.add(SubType.SPIRIT);
@ -40,11 +39,7 @@ public final class ApothecaryGeist extends CardImpl {
this.addAbility(FlyingAbility.getInstance()); this.addAbility(FlyingAbility.getInstance());
// When Apothecary Geist enters the battlefield, if you control another Spirit, you gain 3 life. // When Apothecary Geist enters the battlefield, if you control another Spirit, you gain 3 life.
TriggeredAbility triggeredAbility = new EntersBattlefieldTriggeredAbility(new GainLifeEffect(3)); this.addAbility(new EntersBattlefieldTriggeredAbility(new GainLifeEffect(3)).withInterveningIf(condition));
this.addAbility(new ConditionalInterveningIfTriggeredAbility(
triggeredAbility,
new PermanentsOnTheBattlefieldCondition(filter),
"When {this} enters, if you control another Spirit, you gain 3 life."));
} }
private ApothecaryGeist(final ApothecaryGeist card) { private ApothecaryGeist(final ApothecaryGeist card) {

View file

@ -4,7 +4,6 @@ import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.condition.common.CastFromEverywhereSourceCondition; import mage.abilities.condition.common.CastFromEverywhereSourceCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.ExileTargetCardCopyAndCastEffect; import mage.abilities.effects.common.ExileTargetCardCopyAndCastEffect;
import mage.abilities.keyword.PrototypeAbility; import mage.abilities.keyword.PrototypeAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -42,12 +41,11 @@ public final class ArcaneProxy extends CardImpl {
this.addAbility(new PrototypeAbility(this, "{1}{U}{U}", 2, 1)); this.addAbility(new PrototypeAbility(this, "{1}{U}{U}", 2, 1));
// When Arcane Proxy enters the battlefield, if you cast it, exile target instant or sorcery card with mana value less than or equal to Arcane Proxy's power from your graveyard. Copy that card. You may cast the copy without paying its mana cost. // When Arcane Proxy enters the battlefield, if you cast it, exile target instant or sorcery card with mana value less than or equal to Arcane Proxy's power from your graveyard. Copy that card. You may cast the copy without paying its mana cost.
Ability ability = new ConditionalInterveningIfTriggeredAbility( Ability ability = new EntersBattlefieldTriggeredAbility(
new EntersBattlefieldTriggeredAbility(new ExileTargetCardCopyAndCastEffect(true)), new ExileTargetCardCopyAndCastEffect(true)
CastFromEverywhereSourceCondition.instance, "When {this} enters, " + .setText("exile target instant or sorcery card with mana value less than or equal to {this}'s " +
"if you cast it, exile target instant or sorcery card with mana value less than or equal to {this}'s " + "power from your graveyard. Copy that card. You may cast the copy without paying its mana cost")
"power from your graveyard. Copy that card. You may cast the copy without paying its mana cost." ).withInterveningIf(CastFromEverywhereSourceCondition.instance);
);
ability.addTarget(new TargetCardInYourGraveyard(filter)); ability.addTarget(new TargetCardInYourGraveyard(filter));
this.addAbility(ability); this.addAbility(ability);
} }

View file

@ -1,10 +1,9 @@
package mage.cards.a; package mage.cards.a;
import mage.MageInt; import mage.MageInt;
import mage.abilities.TriggeredAbility; import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.condition.common.KickedCondition; import mage.abilities.condition.common.KickedCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.KickerAbility; import mage.abilities.keyword.KickerAbility;
@ -40,19 +39,19 @@ public final class ArchangelOfWrath extends CardImpl {
// Lifelink // Lifelink
this.addAbility(LifelinkAbility.getInstance()); this.addAbility(LifelinkAbility.getInstance());
TriggeredAbility triggeredAbility = new EntersBattlefieldTriggeredAbility(new DamageTargetEffect(2));
triggeredAbility.addTarget(new TargetAnyTarget());
// When Archangel of Wrath enters the battlefield, if it was kicked, it deals 2 damage to any target. // When Archangel of Wrath enters the battlefield, if it was kicked, it deals 2 damage to any target.
this.addAbility(new ConditionalInterveningIfTriggeredAbility( Ability ability = new EntersBattlefieldTriggeredAbility(
triggeredAbility, KickedCondition.ONCE, "When {this} enters, " + new DamageTargetEffect(2, "it")
"if it was kicked, it deals 2 damage to any target." ).withInterveningIf(KickedCondition.ONCE);
)); ability.addTarget(new TargetAnyTarget());
this.addAbility(ability);
// When Archangel of Wrath enters the battlefield, if it was kicked twice, it deals 2 damage to any target. // When Archangel of Wrath enters the battlefield, if it was kicked twice, it deals 2 damage to any target.
this.addAbility(new ConditionalInterveningIfTriggeredAbility( ability = new EntersBattlefieldTriggeredAbility(
triggeredAbility.copy(), KickedCondition.TWICE, "When {this} enters, " + new DamageTargetEffect(2, "it")
"if it was kicked twice, it deals 2 damage to any target." ).withInterveningIf(KickedCondition.TWICE);
)); ability.addTarget(new TargetAnyTarget());
this.addAbility(ability);
} }
private ArchangelOfWrath(final ArchangelOfWrath card) { private ArchangelOfWrath(final ArchangelOfWrath card) {

View file

@ -1,12 +1,13 @@
package mage.cards.a; package mage.cards.a;
import mage.MageInt; import mage.MageInt;
import mage.abilities.triggers.BeginningOfEndStepTriggeredAbility; import mage.abilities.Ability;
import mage.abilities.common.DealsDamageToAPlayerAllTriggeredAbility; import mage.abilities.common.DealsDamageToAPlayerAllTriggeredAbility;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility; import mage.abilities.condition.Condition;
import mage.abilities.effects.common.BecomesMonarchSourceEffect; import mage.abilities.effects.common.BecomesMonarchSourceEffect;
import mage.abilities.effects.common.DrawCardTargetEffect; import mage.abilities.effects.common.DrawCardTargetEffect;
import mage.abilities.hint.common.MonarchHint; import mage.abilities.hint.common.MonarchHint;
import mage.abilities.triggers.BeginningOfEndStepTriggeredAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
@ -15,6 +16,7 @@ import mage.constants.SubType;
import mage.constants.TargetController; import mage.constants.TargetController;
import mage.filter.FilterPermanent; import mage.filter.FilterPermanent;
import mage.filter.predicate.mageobject.CommanderPredicate; import mage.filter.predicate.mageobject.CommanderPredicate;
import mage.game.Game;
import java.util.UUID; import java.util.UUID;
@ -39,13 +41,11 @@ public final class ArchivistOfGondor extends CardImpl {
this.toughness = new MageInt(3); this.toughness = new MageInt(3);
// When your commander deals combat damage to a player, if there is no monarch, you become the monarch. // When your commander deals combat damage to a player, if there is no monarch, you become the monarch.
this.addAbility(new ConditionalInterveningIfTriggeredAbility( this.addAbility(new DealsDamageToAPlayerAllTriggeredAbility(
new DealsDamageToAPlayerAllTriggeredAbility(
new BecomesMonarchSourceEffect(), filter, false, new BecomesMonarchSourceEffect(), filter, false,
SetTargetPointer.NONE, true SetTargetPointer.NONE, true
), (game, source) -> game.getMonarchId() == null, "When your commander " + ).setTriggerPhrase("When your commander deals combat damage to a player, ")
"deals combat damage to a player, if there is no monarch, you become the monarch." .withInterveningIf(ArchivistOfGondorCondition.instance).addHint(MonarchHint.instance));
).addHint(MonarchHint.instance));
// At the beginning of the monarch's end step, that player draws a card. // At the beginning of the monarch's end step, that player draws a card.
this.addAbility(new BeginningOfEndStepTriggeredAbility( this.addAbility(new BeginningOfEndStepTriggeredAbility(
@ -62,3 +62,17 @@ public final class ArchivistOfGondor extends CardImpl {
return new ArchivistOfGondor(this); return new ArchivistOfGondor(this);
} }
} }
enum ArchivistOfGondorCondition implements Condition {
instance;
@Override
public boolean apply(Game game, Ability source) {
return game.getMonarchId() == null;
}
@Override
public String toString() {
return "there is no monarch";
}
}

View file

@ -1,12 +1,11 @@
package mage.cards.a; package mage.cards.a;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.triggers.BeginningOfEndStepTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.Condition; import mage.abilities.condition.Condition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.triggers.BeginningOfEndStepTriggeredAbility;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
@ -30,12 +29,9 @@ public final class ArchmageAscension extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{U}"); super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{U}");
// At the beginning of each end step, if you drew two or more cards this turn, you may put a quest counter on Archmage Ascension. // At the beginning of each end step, if you drew two or more cards this turn, you may put a quest counter on Archmage Ascension.
this.addAbility(new ConditionalInterveningIfTriggeredAbility( this.addAbility(new BeginningOfEndStepTriggeredAbility(
new BeginningOfEndStepTriggeredAbility( TargetController.EACH_PLAYER, new AddCountersSourceEffect(CounterType.QUEST.createInstance()),
TargetController.EACH_PLAYER, new AddCountersSourceEffect(CounterType.QUEST.createInstance(1)), true, ArchmageAscensionCondition.instance
true
), ArchmageAscensionCondition.instance, "At the beginning of each end step, " +
"if you drew two or more cards this turn, you may put a quest counter on {this}."
), new CardsAmountDrawnThisTurnWatcher()); ), new CardsAmountDrawnThisTurnWatcher());
// As long as Archmage Ascension has six or more quest counters on it, if you would draw a card, // As long as Archmage Ascension has six or more quest counters on it, if you would draw a card,
@ -61,6 +57,11 @@ enum ArchmageAscensionCondition implements Condition {
CardsAmountDrawnThisTurnWatcher watcher = game.getState().getWatcher(CardsAmountDrawnThisTurnWatcher.class); CardsAmountDrawnThisTurnWatcher watcher = game.getState().getWatcher(CardsAmountDrawnThisTurnWatcher.class);
return watcher != null && watcher.getAmountCardsDrawn(source.getControllerId()) >= 2; return watcher != null && watcher.getAmountCardsDrawn(source.getControllerId()) >= 2;
} }
@Override
public String toString() {
return "you drew two or more cards this turn";
}
} }
class ArchmageAscensionReplacementEffect extends ReplacementEffectImpl { class ArchmageAscensionReplacementEffect extends ReplacementEffectImpl {

View file

@ -2,19 +2,20 @@ package mage.cards.a;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.triggers.BeginningOfCombatTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.common.FullPartyCondition; import mage.abilities.condition.common.FullPartyCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.dynamicvalue.common.PartyCount; import mage.abilities.dynamicvalue.common.PartyCount;
import mage.abilities.effects.common.continuous.BoostTargetEffect; import mage.abilities.effects.common.continuous.BoostTargetEffect;
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect; import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
import mage.abilities.effects.common.continuous.SetBasePowerSourceEffect; import mage.abilities.effects.common.continuous.SetBasePowerSourceEffect;
import mage.abilities.hint.common.PartyCountHint; import mage.abilities.hint.common.PartyCountHint;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
import mage.abilities.triggers.BeginningOfCombatTriggeredAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.*; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
import java.util.UUID; import java.util.UUID;
@ -35,19 +36,16 @@ public final class ArchpriestOfIona extends CardImpl {
// Archpriest of Iona's power is equal to the number of creatures in your party. // Archpriest of Iona's power is equal to the number of creatures in your party.
this.addAbility(new SimpleStaticAbility( this.addAbility(new SimpleStaticAbility(
Zone.ALL, Zone.ALL,
new SetBasePowerSourceEffect( new SetBasePowerSourceEffect(PartyCount.instance)
PartyCount.instance .setText("{this}'s power is equal to the number of creatures in your party. " + PartyCount.getReminder())
).setText("{this}'s power is equal to the number of creatures in your party. " + PartyCount.getReminder())
).addHint(PartyCountHint.instance)); ).addHint(PartyCountHint.instance));
// At the beginning of combat on your turn, if you have a full party, target creature gets +1/+1 and gains flying until end of turn. // At the beginning of combat on your turn, if you have a full party, target creature gets +1/+1 and gains flying until end of turn.
Ability ability = new ConditionalInterveningIfTriggeredAbility( Ability ability = new BeginningOfCombatTriggeredAbility(
new BeginningOfCombatTriggeredAbility( new BoostTargetEffect(1, 1).setText("target creature gets +1/+1")
new BoostTargetEffect(1, 1, Duration.EndOfTurn) ).withInterveningIf(FullPartyCondition.instance);
), FullPartyCondition.instance, "At the beginning of combat on your turn, " + ability.addEffect(new GainAbilityTargetEffect(FlyingAbility.getInstance())
"if you have a full party, target creature gets +1/+1 and gains flying until end of turn." .setText("and gains flying until end of turn"));
);
ability.addEffect(new GainAbilityTargetEffect(FlyingAbility.getInstance(), Duration.EndOfTurn));
ability.addTarget(new TargetCreaturePermanent()); ability.addTarget(new TargetCreaturePermanent());
this.addAbility(ability); this.addAbility(ability);
} }

View file

@ -4,7 +4,6 @@ import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.condition.common.OpponentsLostLifeCondition; import mage.abilities.condition.common.OpponentsLostLifeCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.GainLifeEffect; import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.effects.common.LoseLifeOpponentsEffect; import mage.abilities.effects.common.LoseLifeOpponentsEffect;
import mage.abilities.hint.common.OpponentsLostLifeHint; import mage.abilities.hint.common.OpponentsLostLifeHint;
@ -29,13 +28,10 @@ public final class ArrogantOutlaw extends CardImpl {
this.toughness = new MageInt(2); this.toughness = new MageInt(2);
// When Arrogant Outlaw enters the battlefield, if an opponent lost life this turn, each opponent loses 2 life and you gain 2 life. // When Arrogant Outlaw enters the battlefield, if an opponent lost life this turn, each opponent loses 2 life and you gain 2 life.
Ability ability = new ConditionalInterveningIfTriggeredAbility( Ability ability = new EntersBattlefieldTriggeredAbility(
new EntersBattlefieldTriggeredAbility(
new LoseLifeOpponentsEffect(2), false new LoseLifeOpponentsEffect(2), false
), OpponentsLostLifeCondition.instance, "When {this} enters, " + ).withInterveningIf(OpponentsLostLifeCondition.instance);
"if an opponent lost life this turn, each opponent loses 2 life and you gain 2 life." ability.addEffect(new GainLifeEffect(2).concatBy("and"));
);
ability.addEffect(new GainLifeEffect(2));
this.addAbility(ability.addHint(OpponentsLostLifeHint.instance)); this.addAbility(ability.addHint(OpponentsLostLifeHint.instance));
} }

View file

@ -1,13 +1,11 @@
package mage.cards.a; package mage.cards.a;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.AttacksTriggeredAbility; import mage.abilities.common.AttacksTriggeredAbility;
import mage.abilities.common.BecomesBlockedSourceTriggeredAbility; import mage.abilities.common.BecomesBlockedSourceTriggeredAbility;
import mage.abilities.condition.common.HateCondition; import mage.abilities.condition.common.HateCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.dynamicvalue.common.BlockingCreatureCount; import mage.abilities.dynamicvalue.common.BlockingCreatureCount;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.common.combat.BlocksIfAbleTargetEffect; import mage.abilities.effects.common.combat.BlocksIfAbleTargetEffect;
@ -15,13 +13,12 @@ import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.abilities.keyword.DoubleStrikeAbility; import mage.abilities.keyword.DoubleStrikeAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.*;
import mage.constants.Duration;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
import mage.watchers.common.LifeLossOtherFromCombatWatcher; import mage.watchers.common.LifeLossOtherFromCombatWatcher;
import java.util.UUID;
/** /**
* @author Styxo * @author Styxo
*/ */
@ -43,10 +40,8 @@ public final class AsajjVentress extends CardImpl {
this.addAbility(new BecomesBlockedSourceTriggeredAbility(effect, false)); this.addAbility(new BecomesBlockedSourceTriggeredAbility(effect, false));
// <i>Hate</i> &mdash; Whenever Asajj Ventress attacks, if an opponent lost life from a source other than combat damage this turn, target creature blocks this turn if able. // <i>Hate</i> &mdash; Whenever Asajj Ventress attacks, if an opponent lost life from a source other than combat damage this turn, target creature blocks this turn if able.
Ability ability = new ConditionalInterveningIfTriggeredAbility( Ability ability = new AttacksTriggeredAbility(new BlocksIfAbleTargetEffect(Duration.EndOfTurn), false)
new AttacksTriggeredAbility(new BlocksIfAbleTargetEffect(Duration.EndOfTurn), false), .withInterveningIf(HateCondition.instance).setAbilityWord(AbilityWord.HATE);
HateCondition.instance,
"<i>Hate</i> &mdash; Whenever Asajj Ventress attacks, if an opponent lost life from a source other than combat damage this turn, target creature blocks this turn if able");
ability.addTarget(new TargetCreaturePermanent()); ability.addTarget(new TargetCreaturePermanent());
this.addAbility(ability, new LifeLossOtherFromCombatWatcher()); this.addAbility(ability, new LifeLossOtherFromCombatWatcher());
} }

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.common.CelebrationCondition; import mage.abilities.condition.common.CelebrationCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.keyword.HasteAbility; import mage.abilities.keyword.HasteAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -36,11 +35,8 @@ public final class AshPartyCrasher extends CardImpl {
this.addAbility(HasteAbility.getInstance()); this.addAbility(HasteAbility.getInstance());
// Celebration -- Whenever Ash, Party Crasher attacks, if two or more nonland permanents entered the battlefield under your control this turn, put a +1/+1 counter on Ash. // Celebration -- Whenever Ash, Party Crasher attacks, if two or more nonland permanents entered the battlefield under your control this turn, put a +1/+1 counter on Ash.
Ability ability = new ConditionalInterveningIfTriggeredAbility( Ability ability = new AttacksTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance(1)), false)
new AttacksTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance(1)), false), .withInterveningIf(CelebrationCondition.instance);
CelebrationCondition.instance, "Whenever {this} attacks, if two or more nonland permanents " +
"entered the battlefield under your control this turn, put a +1/+1 counter on {this}."
);
ability.setAbilityWord(AbilityWord.CELEBRATION); ability.setAbilityWord(AbilityWord.CELEBRATION);
ability.addHint(CelebrationCondition.getHint()); ability.addHint(CelebrationCondition.getHint());
this.addAbility(ability, new PermanentsEnteredBattlefieldWatcher()); this.addAbility(ability, new PermanentsEnteredBattlefieldWatcher());

View file

@ -2,14 +2,13 @@ package mage.cards.a;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.triggers.BeginningOfUpkeepTriggeredAbility; import mage.abilities.condition.Condition;
import mage.abilities.condition.common.CardsInHandCondition; import mage.abilities.condition.common.CardsInHandCondition;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect; import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.abilities.keyword.MadnessAbility; import mage.abilities.keyword.MadnessAbility;
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;
@ -24,6 +23,8 @@ import java.util.UUID;
*/ */
public final class AsylumVisitor extends CardImpl { public final class AsylumVisitor extends CardImpl {
private static final Condition condition = new CardsInHandCondition(ComparisonType.EQUAL_TO, 0, TargetController.ACTIVE);
public AsylumVisitor(UUID ownerId, CardSetInfo setInfo) { public AsylumVisitor(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{B}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{B}");
this.subtype.add(SubType.VAMPIRE); this.subtype.add(SubType.VAMPIRE);
@ -32,12 +33,10 @@ public final class AsylumVisitor extends CardImpl {
this.toughness = new MageInt(1); this.toughness = new MageInt(1);
// At the beginning of each player's upkeep, if that player has no cards in hand, you draw a card and you lose 1 life. // At the beginning of each player's upkeep, if that player has no cards in hand, you draw a card and you lose 1 life.
Ability ability = new ConditionalInterveningIfTriggeredAbility( Ability ability = new BeginningOfUpkeepTriggeredAbility(
new BeginningOfUpkeepTriggeredAbility(TargetController.ANY, new DrawCardSourceControllerEffect(1, true), false), TargetController.ANY, new DrawCardSourceControllerEffect(1, true), false
new CardsInHandCondition(ComparisonType.EQUAL_TO, 0, TargetController.ACTIVE), ).withInterveningIf(condition);
"At the beginning of each player's upkeep, if that player has no cards in hand, you draw a card and you lose 1 life."); ability.addEffect(new LoseLifeSourceControllerEffect(1).concatBy("and"));
Effect effect = new LoseLifeSourceControllerEffect(1);
ability.addEffect(effect);
this.addAbility(ability); this.addAbility(ability);
// Madness {1}{B} // Madness {1}{B}

View file

@ -2,32 +2,26 @@ package mage.cards.a;
import mage.MageInt; import mage.MageInt;
import mage.abilities.common.DiesSourceTriggeredAbility; import mage.abilities.common.DiesSourceTriggeredAbility;
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.dynamicvalue.common.SourcePermanentPowerValue; import mage.abilities.dynamicvalue.common.SourcePermanentPowerValue;
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.TargetController; import mage.filter.common.FilterControlledPlaneswalkerPermanent;
import mage.filter.FilterPermanent;
import java.util.UUID; import java.util.UUID;
/** /**
*
* @author TheElk801 * @author TheElk801
*/ */
public final class AttendantOfVraska extends CardImpl { public final class AttendantOfVraska extends CardImpl {
private static final FilterPermanent filter = new FilterPermanent("a Vraska planeswalker"); private static final Condition condition = new PermanentsOnTheBattlefieldCondition(
new FilterControlledPlaneswalkerPermanent(SubType.VRASKA, "you control a Vraska planeswalker")
static { );
filter.add(TargetController.YOU.getControllerPredicate());
filter.add(CardType.PLANESWALKER.getPredicate());
filter.add(SubType.VRASKA.getPredicate());
}
public AttendantOfVraska(UUID ownerId, CardSetInfo setInfo) { public AttendantOfVraska(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{B}{G}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{B}{G}");
@ -38,13 +32,8 @@ public final class AttendantOfVraska extends CardImpl {
this.toughness = new MageInt(3); this.toughness = new MageInt(3);
// When Attendant of Vraska dies, if you control a Vraska planeswalker, you gain life equal to Attendant of Vraska's power. // When Attendant of Vraska dies, if you control a Vraska planeswalker, you gain life equal to Attendant of Vraska's power.
this.addAbility(new ConditionalInterveningIfTriggeredAbility( this.addAbility(new DiesSourceTriggeredAbility(new GainLifeEffect(SourcePermanentPowerValue.NOT_NEGATIVE)
new DiesSourceTriggeredAbility(new GainLifeEffect( .setText("you gain life equal to {this}'s power"), false).withInterveningIf(condition));
SourcePermanentPowerValue.NOT_NEGATIVE
), false), new PermanentsOnTheBattlefieldCondition(filter),
"When {this} dies, if you control a Vraska planeswalker, "
+ "you gain life equal to {this}'s power."
));
} }
private AttendantOfVraska(final AttendantOfVraska card) { private AttendantOfVraska(final AttendantOfVraska card) {

View file

@ -1,33 +1,35 @@
package mage.cards.a; package mage.cards.a;
import java.util.UUID;
import mage.MageInt; 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.common.PermanentsOnTheBattlefieldCondition; import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.TapTargetEffect; import mage.abilities.effects.common.TapTargetEffect;
import mage.constants.SubType;
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.filter.FilterPermanent;
import mage.filter.common.FilterTeamPermanent; import mage.filter.common.FilterTeamPermanent;
import mage.filter.predicate.mageobject.AnotherPredicate; import mage.filter.predicate.mageobject.AnotherPredicate;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
/** /**
*
* @author TheElk801 * @author TheElk801
*/ */
public final class AuroraChampion extends CardImpl { public final class AuroraChampion extends CardImpl {
private static final FilterTeamPermanent filter = new FilterTeamPermanent(SubType.WARRIOR, "another Warrior"); private static final FilterPermanent filter = new FilterTeamPermanent(SubType.WARRIOR, "your team controls another Warrior");
static { static {
filter.add(AnotherPredicate.instance); filter.add(AnotherPredicate.instance);
} }
private static final Condition condition = new PermanentsOnTheBattlefieldCondition(filter, false);
public AuroraChampion(UUID ownerId, CardSetInfo setInfo) { public AuroraChampion(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{W}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{W}");
@ -37,11 +39,7 @@ public final class AuroraChampion extends CardImpl {
this.toughness = new MageInt(2); this.toughness = new MageInt(2);
// Whenever Aurora Champion attacks, if your team controls another Warrior, tap target creature. // Whenever Aurora Champion attacks, if your team controls another Warrior, tap target creature.
Ability ability = new ConditionalInterveningIfTriggeredAbility( Ability ability = new AttacksTriggeredAbility(new TapTargetEffect(), false).withInterveningIf(condition);
new AttacksTriggeredAbility(new TapTargetEffect(), false),
new PermanentsOnTheBattlefieldCondition(filter),
"Whenever {this} attacks, if your team controls another Warrior, tap target creature."
);
ability.addTarget(new TargetCreaturePermanent()); ability.addTarget(new TargetCreaturePermanent());
this.addAbility(ability); this.addAbility(ability);
} }

View file

@ -26,7 +26,7 @@ public final class MangarasBlessing extends CardImpl {
// When a spell or ability an opponent controls causes you to discard Mangara's Blessing, // When a spell or ability an opponent controls causes you to discard Mangara's Blessing,
// you gain 2 life, and you return Mangara's Blessing from your graveyard to your hand at the beginning of the next end step. // you gain 2 life, and you return Mangara's Blessing from your graveyard to your hand at the beginning of the next end step.
Ability ability = new DiscardedByOpponentTriggeredAbility(new GainLifeEffect(2), true); Ability ability = new DiscardedByOpponentTriggeredAbility(new GainLifeEffect(2));
Effect graveyardReturnNextEndEffect = new CreateDelayedTriggeredAbilityEffect( Effect graveyardReturnNextEndEffect = new CreateDelayedTriggeredAbilityEffect(
new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnSourceFromGraveyardToHandEffect())); new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnSourceFromGraveyardToHandEffect()));

View file

@ -10,7 +10,6 @@ import mage.abilities.effects.common.CreateTokenEffect;
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.permanent.token.GnomeToken; import mage.game.permanent.token.GnomeToken;
/** /**
@ -23,7 +22,7 @@ public final class Metrognome extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}"); super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}");
// When a spell or ability an opponent controls causes you to discard Metrognome, create four 1/1 colorless Gnome artifact creature tokens. // When a spell or ability an opponent controls causes you to discard Metrognome, create four 1/1 colorless Gnome artifact creature tokens.
this.addAbility(new DiscardedByOpponentTriggeredAbility(new CreateTokenEffect(new GnomeToken(), 4), true)); this.addAbility(new DiscardedByOpponentTriggeredAbility(new CreateTokenEffect(new GnomeToken(), 4)));
// {4}, {tap}: Create a 1/1 colorless Gnome artifact creature token. // {4}, {tap}: Create a 1/1 colorless Gnome artifact creature token.
Ability ability = new SimpleActivatedAbility(new CreateTokenEffect(new GnomeToken()), new ManaCostsImpl<>("{4}")); Ability ability = new SimpleActivatedAbility(new CreateTokenEffect(new GnomeToken()), new ManaCostsImpl<>("{4}"));

View file

@ -31,7 +31,7 @@ public final class Quagnoth extends CardImpl {
// When a spell or ability an opponent controls causes you to discard Quagnoth, return it to your hand. // When a spell or ability an opponent controls causes you to discard Quagnoth, return it to your hand.
this.addAbility(new DiscardedByOpponentTriggeredAbility(new ReturnToHandSourceEffect() this.addAbility(new DiscardedByOpponentTriggeredAbility(new ReturnToHandSourceEffect()
.setText("return it to your hand"), true)); .setText("return it to your hand")));
} }
private Quagnoth(final Quagnoth card) { private Quagnoth(final Quagnoth card) {

View file

@ -32,7 +32,7 @@ public final class SandGolem extends CardImpl {
new ReturnSourceFromGraveyardToBattlefieldWithCounterEffect(CounterType.P1P1.createInstance(), false))); new ReturnSourceFromGraveyardToBattlefieldWithCounterEffect(CounterType.P1P1.createInstance(), false)));
effect.setText("return {this} from your graveyard to the battlefield with a +1/+1 counter on it at the beginning of the next end step"); effect.setText("return {this} from your graveyard to the battlefield with a +1/+1 counter on it at the beginning of the next end step");
this.addAbility(new DiscardedByOpponentTriggeredAbility(effect, true)); this.addAbility(new DiscardedByOpponentTriggeredAbility(effect));
} }
private SandGolem(final SandGolem card) { private SandGolem(final SandGolem card) {

View file

@ -13,13 +13,8 @@ import mage.game.stack.StackObject;
public class DiscardedByOpponentTriggeredAbility extends TriggeredAbilityImpl { public class DiscardedByOpponentTriggeredAbility extends TriggeredAbilityImpl {
public DiscardedByOpponentTriggeredAbility(Effect effect) { public DiscardedByOpponentTriggeredAbility(Effect effect) {
this(effect, false);
}
public DiscardedByOpponentTriggeredAbility(Effect effect, boolean textCardName) {
super(Zone.GRAVEYARD, effect, false); super(Zone.GRAVEYARD, effect, false);
setTriggerPhrase("When a spell or ability an opponent controls causes you to discard " setTriggerPhrase("When a spell or ability an opponent controls causes you to discard this card");
+ (textCardName ? "{this}, " : "this card, "));
} }
protected DiscardedByOpponentTriggeredAbility(final DiscardedByOpponentTriggeredAbility ability) { protected DiscardedByOpponentTriggeredAbility(final DiscardedByOpponentTriggeredAbility ability) {
@ -38,12 +33,10 @@ public class DiscardedByOpponentTriggeredAbility extends TriggeredAbilityImpl {
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
if (getSourceId().equals(event.getTargetId())) { if (!getSourceId().equals(event.getTargetId())) {
StackObject stackObject = game.getStack().getStackObject(event.getSourceId());
if (stackObject != null) {
return game.getOpponents(this.getControllerId()).contains(stackObject.getControllerId());
}
}
return false; return false;
} }
StackObject stackObject = game.getStack().getStackObject(event.getSourceId());
return stackObject != null && game.getOpponents(this.getControllerId()).contains(stackObject.getControllerId());
}
} }

View file

@ -8,7 +8,6 @@ import mage.game.Game;
/** /**
* @author TheElk801 * @author TheElk801
*/ */
public enum FullPartyCondition implements Condition { public enum FullPartyCondition implements Condition {
instance; instance;
@ -16,4 +15,9 @@ public enum FullPartyCondition implements Condition {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
return PartyCount.instance.calculate(game, source, null) >= 4; return PartyCount.instance.calculate(game, source, null) >= 4;
} }
@Override
public String toString() {
return "you have a full party";
}
} }

View file

@ -12,7 +12,7 @@ import mage.game.Game;
*/ */
public class KickedCostCondition implements Condition { public class KickedCostCondition implements Condition {
protected String kickerCostText; protected final String kickerCostText;
public KickedCostCondition(String kickerCostText) { public KickedCostCondition(String kickerCostText) {
this.kickerCostText = kickerCostText; this.kickerCostText = kickerCostText;
@ -22,4 +22,9 @@ public class KickedCostCondition implements Condition {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
return KickerAbility.getKickedCounterStrict(game, source, kickerCostText) > 0; return KickerAbility.getKickedCounterStrict(game, source, kickerCostText) > 0;
} }
@Override
public String toString() {
return "it was kicked with its " + kickerCostText + " kicker";
}
} }