I have a fever and the only prescription is more refactoring ConditionalInterveningIfTriggeredAbility

This commit is contained in:
theelk801 2025-06-10 14:40:43 -04:00
parent cc2d234d58
commit 15d4ca2edc
44 changed files with 456 additions and 653 deletions

View file

@ -1,12 +1,11 @@
package mage.cards.h;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.condition.Condition;
import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.PutOnLibraryTargetEffect;
import mage.abilities.effects.common.discard.DiscardTargetEffect;
import mage.cards.CardImpl;
@ -14,30 +13,28 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.ComparisonType;
import mage.constants.SubType;
import mage.filter.common.FilterLandPermanent;
import mage.filter.common.FilterControlledPermanent;
import mage.target.TargetPlayer;
import mage.target.common.TargetCardInYourGraveyard;
import java.util.UUID;
/**
*
* @author jeffwadsworth
*
*/
public final class HagHedgeMage extends CardImpl {
private static final FilterLandPermanent filter = new FilterLandPermanent();
private static final FilterLandPermanent filter2 = new FilterLandPermanent();
static {
filter.add(SubType.SWAMP.getPredicate());
filter2.add(SubType.FOREST.getPredicate());
}
private static final String rule = "When {this} enters, if you control two or more Swamps, you may have target player discard a card.";
private static final String rule2 = "When {this} enters, if you control two or more Forests, you may put target card from your graveyard on top of your library.";
private static final Condition condition = new PermanentsOnTheBattlefieldCondition(
new FilterControlledPermanent(SubType.SWAMP, "you control two or more Swamps"),
ComparisonType.MORE_THAN, 1
);
private static final Condition condition2 = new PermanentsOnTheBattlefieldCondition(
new FilterControlledPermanent(SubType.FOREST, "you control two or more Forests"),
ComparisonType.MORE_THAN, 1
);
public HagHedgeMage(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{B/G}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{B/G}");
this.subtype.add(SubType.HAG);
this.subtype.add(SubType.SHAMAN);
@ -45,12 +42,12 @@ public final class HagHedgeMage extends CardImpl {
this.toughness = new MageInt(2);
// When Hag Hedge-Mage enters the battlefield, if you control two or more Swamps, you may have target player discard a card.
Ability ability = new ConditionalInterveningIfTriggeredAbility(new EntersBattlefieldTriggeredAbility(new DiscardTargetEffect(1), true), new PermanentsOnTheBattlefieldCondition(filter, ComparisonType.MORE_THAN, 1), rule);
Ability ability = new EntersBattlefieldTriggeredAbility(new DiscardTargetEffect(1), true).withInterveningIf(condition);
ability.addTarget(new TargetPlayer());
this.addAbility(ability);
// When Hag Hedge-Mage enters the battlefield, if you control two or more Forests, you may put target card from your graveyard on top of your library.
Ability ability2 = new ConditionalInterveningIfTriggeredAbility(new EntersBattlefieldTriggeredAbility(new PutOnLibraryTargetEffect(true), true), new PermanentsOnTheBattlefieldCondition(filter2, ComparisonType.MORE_THAN, 1), rule2);
Ability ability2 = new EntersBattlefieldTriggeredAbility(new PutOnLibraryTargetEffect(true), true).withInterveningIf(condition2);
ability2.addTarget(new TargetCardInYourGraveyard());
this.addAbility(ability2);
}

View file

@ -1,27 +1,30 @@
package mage.cards.h;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.triggers.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.condition.Condition;
import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.TransformSourceEffect;
import mage.abilities.hint.common.CreaturesYouControlHint;
import mage.abilities.keyword.TransformAbility;
import mage.abilities.triggers.BeginningOfUpkeepTriggeredAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.ComparisonType;
import mage.constants.SubType;
import mage.filter.common.FilterControlledCreaturePermanent;
import java.util.UUID;
/**
* @author fireshoes
*/
public final class HanweirMilitiaCaptain extends CardImpl {
private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("if you control four or more creatures");
private static final Condition condition = new PermanentsOnTheBattlefieldCondition(
new FilterControlledCreaturePermanent("you control four or more creatures"),
ComparisonType.MORE_THAN, 3
);
public HanweirMilitiaCaptain(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{W}");
@ -34,10 +37,8 @@ public final class HanweirMilitiaCaptain extends CardImpl {
// At the beginning of your upkeep, if you control four or more creatures, transform Hanweir Militia Captain.
this.addAbility(new TransformAbility());
this.addAbility(new ConditionalInterveningIfTriggeredAbility(
new BeginningOfUpkeepTriggeredAbility(new TransformSourceEffect()),
new PermanentsOnTheBattlefieldCondition(filter, ComparisonType.MORE_THAN, 3),
"At the beginning of your upkeep, if you control four or more creatures, transform {this}"));
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new TransformSourceEffect())
.withInterveningIf(condition).addHint(CreaturesYouControlHint.instance));
}
private HanweirMilitiaCaptain(final HanweirMilitiaCaptain card) {

View file

@ -1,14 +1,12 @@
package mage.cards.h;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.triggers.BeginningOfEndStepTriggeredAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.condition.Condition;
import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.IndestructibleAbility;
import mage.abilities.triggers.BeginningOfEndStepTriggeredAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
@ -25,12 +23,26 @@ import mage.players.Player;
import mage.target.TargetPermanent;
import mage.util.RandomUtil;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
/**
*
* @author LevelX2
*/
public final class HaphazardBombardment extends CardImpl {
private static final FilterPermanent filter = new FilterPermanent("if two or more permanents you don't control have an aim counter on them");
static {
filter.add(TargetController.NOT_YOU.getControllerPredicate());
filter.add(CounterType.AIM.getPredicate());
}
private static final Condition condition = new PermanentsOnTheBattlefieldCondition(filter, ComparisonType.MORE_THAN, 1);
public HaphazardBombardment(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{5}{R}");
@ -38,12 +50,7 @@ public final class HaphazardBombardment extends CardImpl {
this.addAbility(new EntersBattlefieldTriggeredAbility(new HaphazardBombardmentEffect(), false));
// At the beginning of your end step, if two or more permanents you don't control have an aim counter on them, destroy one of those permanents at random.
FilterPermanent filter = new FilterPermanent("if two or more permanents you don't control have an aim counter on them");
filter.add(TargetController.NOT_YOU.getControllerPredicate());
filter.add(CounterType.AIM.getPredicate());
this.addAbility(new ConditionalInterveningIfTriggeredAbility(new BeginningOfEndStepTriggeredAbility(new HaphazardBombardmentEndOfTurnEffect()),
new PermanentsOnTheBattlefieldCondition(filter, ComparisonType.MORE_THAN, 1, false),
"At the beginning of your end step, if two or more permanents you don't control have an aim counter on them, destroy one of those permanents at random"));
this.addAbility(new BeginningOfEndStepTriggeredAbility(new HaphazardBombardmentEndOfTurnEffect()).withInterveningIf(condition));
}
private HaphazardBombardment(final HaphazardBombardment card) {
@ -58,6 +65,13 @@ public final class HaphazardBombardment extends CardImpl {
class HaphazardBombardmentEffect extends OneShotEffect {
private static final FilterPermanent filter = new FilterPermanent("nonenchantment permanents you don't control");
static {
filter.add(Predicates.not(CardType.ENCHANTMENT.getPredicate()));
filter.add(TargetController.NOT_YOU.getControllerPredicate());
}
HaphazardBombardmentEffect() {
super(Outcome.Benefit);
this.staticText = "choose four nonenchantment permanents you don't control and put an aim counter on each of them";
@ -75,34 +89,43 @@ class HaphazardBombardmentEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
FilterPermanent filter = new FilterPermanent("nonenchantment permanents you don't control");
filter.add(Predicates.not(CardType.ENCHANTMENT.getPredicate()));
filter.add(TargetController.OPPONENT.getControllerPredicate());
List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game);
if (permanents.size() > 4) {
permanents.clear();
TargetPermanent target = new TargetPermanent(4, 4, filter, true);
controller.chooseTarget(outcome, target, source, game);
for (UUID targetId : target.getTargets()) {
Permanent permanent = game.getPermanent(targetId);
if (permanent != null) {
permanents.add(permanent);
}
}
}
for (Permanent permanent : permanents) {
permanent.addCounters(CounterType.AIM.createInstance(), source.getControllerId(), source, game);
}
return true;
if (controller == null) {
return false;
}
return false;
List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game);
if (permanents.size() > 4) {
permanents.clear();
TargetPermanent target = new TargetPermanent(4, 4, filter, true);
controller.chooseTarget(outcome, target, source, game);
permanents.addAll(
target.getTargets()
.stream()
.map(game::getPermanent)
.filter(Objects::nonNull)
.collect(Collectors.toList())
);
}
for (Permanent permanent : permanents) {
permanent.addCounters(CounterType.AIM.createInstance(), source.getControllerId(), source, game);
}
return true;
}
}
class HaphazardBombardmentEndOfTurnEffect extends OneShotEffect {
private static final FilterPermanent filter = new FilterPermanent();
static {
filter.add(TargetController.NOT_YOU.getControllerPredicate());
filter.add(CounterType.AIM.getPredicate());
// 4/27/2018 If one or more of the permanents with aim counters on them have indestructible,
// select the permanent destroyed at random from among the permanents with aim counters
// that don't have indestructible.
filter.add(Predicates.not(new AbilityPredicate(IndestructibleAbility.class)));
}
HaphazardBombardmentEndOfTurnEffect() {
super(Outcome.Benefit);
this.staticText = "destroy one of those permanents at random";
@ -119,21 +142,12 @@ class HaphazardBombardmentEndOfTurnEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
// 4/27/2018 If one or more of the permanents with aim counters on them have indestructible,
// select the permanent destroyed at random from among the permanents with aim counters
// that don't have indestructible.
FilterPermanent filter = new FilterPermanent("if two or more permanents you don't control have an aim counter on them");
filter.add(TargetController.NOT_YOU.getControllerPredicate());
filter.add(CounterType.AIM.getPredicate());
filter.add(Predicates.not(new AbilityPredicate(IndestructibleAbility.class)));
List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game);
if (!permanents.isEmpty()) {
Permanent permanent = permanents.get(RandomUtil.nextInt(permanents.size()));
if (permanent != null) {
permanent.destroy(source, game, false);
}
}
return true;
return Optional.ofNullable(
game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)
)
.filter(p -> !p.isEmpty())
.map(RandomUtil::randomFromCollection)
.filter(permanent -> permanent.destroy(source, game))
.isPresent();
}
}

View file

@ -2,14 +2,13 @@ package mage.cards.h;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.triggers.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.condition.Condition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.WinGameSourceControllerEffect;
import mage.abilities.hint.Hint;
import mage.abilities.hint.HintUtils;
import mage.abilities.triggers.BeginningOfUpkeepTriggeredAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
@ -18,7 +17,6 @@ import mage.game.Game;
import mage.players.Player;
import java.util.*;
import java.util.List;
/**
* @author TheElk801
@ -32,17 +30,11 @@ public final class HappilyEverAfter extends CardImpl {
this.addAbility(new EntersBattlefieldTriggeredAbility(new HappilyEverAfterEffect()));
// At the beginning of your upkeep, if there are five colors among permanents you control, there are six or more card types among permanents you control and/or cards in your graveyard, and your life total is greater than or equal to your starting life total, you win the game.
this.addAbility(new ConditionalInterveningIfTriggeredAbility(
new BeginningOfUpkeepTriggeredAbility(
new WinGameSourceControllerEffect(), false
), HappilyEverAfterCondition.instance, "At the beginning of your upkeep, " +
"if there are five colors among permanents you control, there are six or more card types " +
"among permanents you control and/or cards in your graveyard, and your life total is " +
"greater than or equal to your starting life total, you win the game.")
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new WinGameSourceControllerEffect())
.withInterveningIf(HappilyEverAfterCondition.instance)
.addHint(HappilyEverAfterColorHint.instance)
.addHint(HappilyEverAfterCardTypeHint.instance)
.addHint(HappilyEverAfterLifeHint.instance)
);
.addHint(HappilyEverAfterLifeHint.instance));
}
private HappilyEverAfter(final HappilyEverAfter card) {
@ -122,6 +114,13 @@ enum HappilyEverAfterCondition implements Condition {
.forEach(cardTypeEnumSet::add);
return cardTypeEnumSet.size() >= 6;
}
@Override
public String toString() {
return "there are five colors among permanents you control, " +
"there are six or more card types among permanents you control and/or cards in your graveyard, " +
"and your life total is greater than or equal to your starting life total";
}
}
enum HappilyEverAfterColorHint implements Hint {

View file

@ -1,11 +1,10 @@
package mage.cards.h;
import mage.MageInt;
import mage.abilities.triggers.BeginningOfCombatTriggeredAbility;
import mage.abilities.condition.common.CovenCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect;
import mage.abilities.hint.common.CovenHint;
import mage.abilities.triggers.BeginningOfCombatTriggeredAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
@ -19,7 +18,7 @@ import java.util.UUID;
*/
public final class HarvesttideSentry extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent();
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures with power 2 or less");
static {
filter.add(new PowerPredicate(ComparisonType.FEWER_THAN, 3));
@ -34,13 +33,9 @@ public final class HarvesttideSentry extends CardImpl {
this.toughness = new MageInt(1);
// Coven At the beginning of combat on your turn, if you control three or more creatures with different powers, Harvesttide Sentry can't be blocked by creatures with power 2 or less this turn.
this.addAbility(new ConditionalInterveningIfTriggeredAbility(
new BeginningOfCombatTriggeredAbility(
new CantBeBlockedByCreaturesSourceEffect(filter, Duration.EndOfTurn)
), CovenCondition.instance, "At the beginning of combat on your turn, " +
"if you control three or more creatures with different powers, " +
"{this} can't be blocked by creatures with power 2 or less this turn."
).addHint(CovenHint.instance).setAbilityWord(AbilityWord.COVEN));
this.addAbility(new BeginningOfCombatTriggeredAbility(
new CantBeBlockedByCreaturesSourceEffect(filter, Duration.EndOfTurn)
).withInterveningIf(CovenCondition.instance).addHint(CovenHint.instance).setAbilityWord(AbilityWord.COVEN));
}
private HarvesttideSentry(final HarvesttideSentry card) {

View file

@ -3,11 +3,11 @@ package mage.cards.h;
import mage.MageInt;
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
import mage.abilities.condition.common.HellbentCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.discard.DiscardTargetEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AbilityWord;
import mage.constants.CardType;
import mage.constants.SubType;
@ -29,12 +29,9 @@ public final class HeadlessSpecter extends CardImpl {
this.addAbility(FlyingAbility.getInstance());
// Hellbent Whenever Headless Specter deals combat damage to a player, if you have no cards in hand, that player discards a card at random.
this.addAbility(new ConditionalInterveningIfTriggeredAbility(
new DealsCombatDamageToAPlayerTriggeredAbility(
new DiscardTargetEffect(1, true), false, true
), HellbentCondition.instance, "<i>Hellbent</i> &mdash; Whenever {this} deals combat damage " +
"to a player, if you have no cards in hand, that player discards a card at random."
));
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(
new DiscardTargetEffect(1, true), false, true
).withInterveningIf(HellbentCondition.instance).setAbilityWord(AbilityWord.HELLBENT));
}
private HeadlessSpecter(final HeadlessSpecter card) {

View file

@ -1,11 +1,9 @@
package mage.cards.h;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.condition.common.KickedCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.KickerAbility;
@ -15,14 +13,15 @@ import mage.constants.CardType;
import mage.constants.SubType;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
/**
*
* @author North
*/
public final class HeartstabberMosquito extends CardImpl {
public HeartstabberMosquito(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{B}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{B}");
this.subtype.add(SubType.INSECT);
this.power = new MageInt(2);
@ -31,14 +30,13 @@ public final class HeartstabberMosquito extends CardImpl {
// Kicker {2}{B} (You may pay an additional {2}{B} as you cast this spell.)
this.addAbility(new KickerAbility("{2}{B}"));
// Flying
this.addAbility(FlyingAbility.getInstance());
// When Heartstabber Mosquito enters the battlefield, if it was kicked, destroy target creature.
EntersBattlefieldTriggeredAbility ability = new EntersBattlefieldTriggeredAbility(new DestroyTargetEffect(), false);
Ability ability = new EntersBattlefieldTriggeredAbility(new DestroyTargetEffect(), false).withInterveningIf(KickedCondition.ONCE);
ability.addTarget(new TargetCreaturePermanent());
this.addAbility(new ConditionalInterveningIfTriggeredAbility(ability, KickedCondition.ONCE, "When {this} enters, if it was kicked, destroy target creature."));
this.addAbility(ability);
}
private HeartstabberMosquito(final HeartstabberMosquito card) {

View file

@ -1,15 +1,14 @@
package mage.cards.h;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.AttacksTriggeredAbility;
import mage.abilities.condition.common.FerociousCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.abilities.hint.common.FerociousHint;
import mage.abilities.keyword.DeathtouchAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AbilityWord;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.SubType;
@ -31,15 +30,11 @@ public final class HeirOfTheWilds extends CardImpl {
// Deathtouch
this.addAbility(DeathtouchAbility.getInstance());
// <em>Ferocious</em> - Whenever Heir of the Wilds attacks, if you control a creature with power 4 or greater, Heir of the Wilds gets +1/+1 until end of turn.
Ability ability = new ConditionalInterveningIfTriggeredAbility(
new AttacksTriggeredAbility(new BoostSourceEffect(1, 1, Duration.EndOfTurn), false),
FerociousCondition.instance,
"<i>Ferocious</i> &mdash; Whenever {this} attacks, if you control a creature with power 4 or greater, {this} gets +1/+1 until end of turn."
);
ability.addHint(FerociousHint.instance);
this.addAbility(ability);
// <em>Ferocious</em> - Whenever Heir of the Wilds attacks, if you control a creature with power 4 or greater, Heir of the Wilds gets +1/+1 until end of turn.
this.addAbility(new AttacksTriggeredAbility(
new BoostSourceEffect(1, 1, Duration.EndOfTurn), false
).withInterveningIf(FerociousCondition.instance).addHint(FerociousHint.instance).setAbilityWord(AbilityWord.FEROCIOUS));
}
private HeirOfTheWilds(final HeirOfTheWilds card) {

View file

@ -1,13 +1,11 @@
package mage.cards.h;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.triggers.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.condition.common.CardsInHandCondition;
import mage.abilities.condition.Condition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.condition.common.CardsInHandCondition;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.triggers.BeginningOfUpkeepTriggeredAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
@ -15,14 +13,17 @@ import mage.constants.ComparisonType;
import mage.constants.SubType;
import mage.constants.TargetController;
import java.util.UUID;
/**
*
* @author North
*/
public final class HellfireMongrel extends CardImpl {
private static final Condition condition = new CardsInHandCondition(ComparisonType.FEWER_THAN, 3, TargetController.ACTIVE);
public HellfireMongrel(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{R}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{R}");
this.subtype.add(SubType.ELEMENTAL);
this.subtype.add(SubType.DOG);
@ -30,11 +31,11 @@ public final class HellfireMongrel extends CardImpl {
this.toughness = new MageInt(2);
// At the beginning of each opponent's upkeep, if that player has two or fewer cards in hand, Hellfire Mongrel deals 2 damage to that player.
this.addAbility(new ConditionalInterveningIfTriggeredAbility(
new BeginningOfUpkeepTriggeredAbility(TargetController.OPPONENT, new DamageTargetEffect(2), false),
(Condition)new CardsInHandCondition(ComparisonType.FEWER_THAN, 3, TargetController.ACTIVE),
"At the beginning of each opponent's upkeep, if that player has two or fewer cards in hand, {this} deals 2 damage to that player."
));
this.addAbility(new BeginningOfUpkeepTriggeredAbility(
TargetController.OPPONENT,
new DamageTargetEffect(2, true, "that player"),
false
).withInterveningIf(condition));
}
private HellfireMongrel(final HellfireMongrel card) {

View file

@ -2,17 +2,15 @@
package mage.cards.h;
import mage.MageInt;
import mage.abilities.TriggeredAbility;
import mage.abilities.triggers.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
import mage.abilities.condition.Condition;
import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.common.WinGameSourceControllerEffect;
import mage.abilities.effects.common.continuous.GainControlAllControlledTargetEffect;
import mage.abilities.hint.ValueHint;
import mage.abilities.hint.common.ArtifactYouControlHint;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.TrampleAbility;
import mage.abilities.triggers.BeginningOfUpkeepTriggeredAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
@ -28,6 +26,10 @@ import java.util.UUID;
*/
public final class HellkiteTyrant extends CardImpl {
private static final Condition condition = new PermanentsOnTheBattlefieldCondition(
new FilterArtifactPermanent("you control twenty or more artifacts"), ComparisonType.MORE_THAN, 19
);
public HellkiteTyrant(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{R}{R}");
this.subtype.add(SubType.DRAGON);
@ -37,8 +39,10 @@ public final class HellkiteTyrant extends CardImpl {
// Flying
this.addAbility(FlyingAbility.getInstance());
// Trample
this.addAbility(TrampleAbility.getInstance());
// Whenever Hellkite Tyrant deals combat damage to a player, gain control of all artifacts that player controls.
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(
new GainControlAllControlledTargetEffect(StaticFilters.FILTER_PERMANENT_ARTIFACTS)
@ -46,12 +50,8 @@ public final class HellkiteTyrant extends CardImpl {
false, true));
// At the beginning of your upkeep, if you control twenty or more artifacts, you win the game.
TriggeredAbility ability = new BeginningOfUpkeepTriggeredAbility(new WinGameSourceControllerEffect());
this.addAbility(new ConditionalInterveningIfTriggeredAbility(
ability,
new PermanentsOnTheBattlefieldCondition(new FilterArtifactPermanent(), ComparisonType.MORE_THAN, 19),
"At the beginning of your upkeep, if you control twenty or more artifacts, you win the game."
).addHint(new ValueHint("Artifacts you control", new PermanentsOnBattlefieldCount(StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT))));
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new WinGameSourceControllerEffect())
.withInterveningIf(condition).addHint(ArtifactYouControlHint.instance));
}
private HellkiteTyrant(final HellkiteTyrant card) {

View file

@ -4,7 +4,6 @@ import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.condition.common.CastFromEverywhereSourceCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect;
import mage.abilities.keyword.CyclingAbility;
import mage.abilities.keyword.FlyingAbility;
@ -43,11 +42,8 @@ public final class HeraldOfTheForgotten extends CardImpl {
this.addAbility(FlyingAbility.getInstance());
// When Herald of the Forgotten enters the battlefield, if you cast it, return any number of target permanent cards with cycling abilities from your graveyard to the battlefield.
Ability ability = new ConditionalInterveningIfTriggeredAbility(
new EntersBattlefieldTriggeredAbility(new ReturnFromGraveyardToBattlefieldTargetEffect()),
CastFromEverywhereSourceCondition.instance, "When {this} enters, if you cast it, " +
"return any number of target permanent cards with cycling abilities from your graveyard to the battlefield."
);
Ability ability = new EntersBattlefieldTriggeredAbility(new ReturnFromGraveyardToBattlefieldTargetEffect())
.withInterveningIf(CastFromEverywhereSourceCondition.instance);
ability.addTarget(new TargetCardInYourGraveyard(0, Integer.MAX_VALUE, filter));
this.addAbility(ability);
}

View file

@ -5,7 +5,6 @@ import mage.abilities.common.AttacksAttachedTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.common.FirstCombatPhaseCondition;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.AdditionalCombatPhaseEffect;
import mage.abilities.effects.common.UntapAllEffect;
import mage.abilities.effects.common.continuous.BoostEquippedEffect;
@ -16,7 +15,6 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.StaticFilters;
import java.util.UUID;
@ -38,12 +36,8 @@ public final class HexplateWallbreaker extends CardImpl {
// Whenever equipped creature attacks, if it's the first combat phase of the turn, untap
// each attacking creature. After this phase, there is an additional combat phase.
Ability ability = new ConditionalInterveningIfTriggeredAbility(
new AttacksAttachedTriggeredAbility(new UntapAllEffect(StaticFilters.FILTER_ATTACKING_CREATURES)),
FirstCombatPhaseCondition.instance,
"Whenever equipped creature attacks, if it's the first combat phase of the turn, untap " +
"each attacking creature. After this phase, there is an additional combat phase"
);
Ability ability = new AttacksAttachedTriggeredAbility(new UntapAllEffect(StaticFilters.FILTER_ATTACKING_CREATURE)
.setText("untap each attacking creature")).withInterveningIf(FirstCombatPhaseCondition.instance);
ability.addEffect(new AdditionalCombatPhaseEffect());
this.addAbility(ability);

View file

@ -1,44 +1,34 @@
package mage.cards.h;
import mage.MageInt;
import mage.abilities.TriggeredAbility;
import mage.abilities.common.SpellCastOpponentTriggeredAbility;
import mage.abilities.condition.Condition;
import mage.abilities.condition.common.SourceMatchesFilterCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.continuous.BecomesCreatureSourceEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.filter.FilterSpell;
import mage.constants.SubType;
import mage.filter.StaticFilters;
import mage.game.permanent.token.TokenImpl;
import java.util.UUID;
/**
*
* @author LoneFox
*
*/
public final class HiddenAncients extends CardImpl {
private static final FilterSpell filter = new FilterSpell("enchantment spell");
static {
filter.add(CardType.ENCHANTMENT.getPredicate());
}
private static final Condition condition = new SourceMatchesFilterCondition("{this} is an enchantment", StaticFilters.FILTER_PERMANENT_ENCHANTMENT);
public HiddenAncients(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{G}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{G}");
// When an opponent casts an enchantment spell, if Hidden Ancients is an enchantment, Hidden Ancients becomes a 5/5 Treefolk creature.
TriggeredAbility ability = new SpellCastOpponentTriggeredAbility(new BecomesCreatureSourceEffect(new HiddenAncientsTreefolkToken(), null, Duration.WhileOnBattlefield),
filter, false);
this.addAbility(new ConditionalInterveningIfTriggeredAbility(ability, new SourceMatchesFilterCondition(StaticFilters.FILTER_PERMANENT_ENCHANTMENT),
"When an opponent casts an enchantment spell, if {this} is an enchantment, {this} becomes a 5/5 Treefolk creature."));
this.addAbility(new SpellCastOpponentTriggeredAbility(new BecomesCreatureSourceEffect(
new HiddenAncientsTreefolkToken(), null, Duration.WhileOnBattlefield
), StaticFilters.FILTER_SPELL_AN_ENCHANTMENT, false).withInterveningIf(condition).setTriggerPhrase("When an opponent casts an enchantment spell, "));
}
private HiddenAncients(final HiddenAncients card) {
@ -60,6 +50,7 @@ class HiddenAncientsTreefolkToken extends TokenImpl {
power = new MageInt(5);
toughness = new MageInt(5);
}
private HiddenAncientsTreefolkToken(final HiddenAncientsTreefolkToken token) {
super(token);
}

View file

@ -1,17 +1,15 @@
package mage.cards.h;
import mage.MageInt;
import mage.abilities.TriggeredAbility;
import mage.abilities.common.SpellCastOpponentTriggeredAbility;
import mage.abilities.condition.Condition;
import mage.abilities.condition.common.SourceMatchesFilterCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.continuous.BecomesCreatureSourceEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.SubType;
import mage.filter.FilterSpell;
import mage.filter.StaticFilters;
import mage.game.permanent.token.TokenImpl;
@ -19,26 +17,25 @@ import mage.game.permanent.token.TokenImpl;
import java.util.UUID;
/**
*
* @author LoneFox
*
*/
public final class HiddenGibbons extends CardImpl {
private static final FilterSpell filter = new FilterSpell("instant spell");
private static final FilterSpell filter = new FilterSpell("an instant spell");
static {
filter.add(CardType.INSTANT.getPredicate());
}
private static final Condition condition = new SourceMatchesFilterCondition("{this} is an enchantment", StaticFilters.FILTER_PERMANENT_ENCHANTMENT);
public HiddenGibbons(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{G}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{G}");
// When an opponent casts an instant spell, if Hidden Gibbons is an enchantment, Hidden Gibbons becomes a 4/4 Ape creature.
TriggeredAbility ability = new SpellCastOpponentTriggeredAbility(new BecomesCreatureSourceEffect(new HiddenGibbonsApe(), null, Duration.WhileOnBattlefield),
filter, false);
this.addAbility(new ConditionalInterveningIfTriggeredAbility(ability, new SourceMatchesFilterCondition(StaticFilters.FILTER_PERMANENT_ENCHANTMENT),
"When an opponent casts an instant spell, if {this} is an enchantment, {this} becomes a 4/4 Ape creature."));
this.addAbility(new SpellCastOpponentTriggeredAbility(
new BecomesCreatureSourceEffect(new HiddenGibbonsApe(), null, Duration.WhileOnBattlefield), filter, false
).withInterveningIf(condition).setTriggerPhrase("When an opponent casts an instant spell, "));
}
private HiddenGibbons(final HiddenGibbons card) {
@ -60,6 +57,7 @@ class HiddenGibbonsApe extends TokenImpl {
power = new MageInt(4);
toughness = new MageInt(4);
}
private HiddenGibbonsApe(final HiddenGibbonsApe token) {
super(token);
}

View file

@ -1,10 +1,9 @@
package mage.cards.h;
import mage.MageInt;
import mage.abilities.TriggeredAbility;
import mage.abilities.common.SpellCastOpponentTriggeredAbility;
import mage.abilities.condition.Condition;
import mage.abilities.condition.common.SourceMatchesFilterCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.continuous.BecomesCreatureSourceEffect;
import mage.abilities.keyword.TrampleAbility;
import mage.cards.CardImpl;
@ -12,33 +11,25 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.SubType;
import mage.filter.FilterSpell;
import mage.filter.StaticFilters;
import mage.game.permanent.token.TokenImpl;
import java.util.UUID;
/**
*
* @author LoneFox
*
*/
public final class HiddenGuerrillas extends CardImpl {
private static final FilterSpell filter = new FilterSpell("an artifact spell");
static {
filter.add(CardType.ARTIFACT.getPredicate());
}
private static final Condition condition = new SourceMatchesFilterCondition("{this} is an enchantment", StaticFilters.FILTER_PERMANENT_ENCHANTMENT);
public HiddenGuerrillas(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{G}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{G}");
// When an opponent casts an artifact spell, if Hidden Guerrillas is an enchantment, Hidden Guerrillas becomes a 5/3 Soldier creature with trample.
TriggeredAbility ability = new SpellCastOpponentTriggeredAbility(new BecomesCreatureSourceEffect(new HiddenGuerrillasSoldier(), null, Duration.WhileOnBattlefield),
filter, false);
this.addAbility(new ConditionalInterveningIfTriggeredAbility(ability, new SourceMatchesFilterCondition(StaticFilters.FILTER_PERMANENT_ENCHANTMENT),
"When an opponent casts an artifact spell, if {this} is an enchantment, {this} becomes a 5/3 Soldier creature with trample."));
this.addAbility(new SpellCastOpponentTriggeredAbility(new BecomesCreatureSourceEffect(
new HiddenGuerrillasSoldier(), null, Duration.WhileOnBattlefield
), StaticFilters.FILTER_SPELL_AN_ARTIFACT, false).withInterveningIf(condition).setTriggerPhrase("When an opponent casts an artifact spell, "));
}
private HiddenGuerrillas(final HiddenGuerrillas card) {
@ -61,6 +52,7 @@ class HiddenGuerrillasSoldier extends TokenImpl {
toughness = new MageInt(3);
this.addAbility(TrampleAbility.getInstance());
}
private HiddenGuerrillasSoldier(final HiddenGuerrillasSoldier token) {
super(token);
}

View file

@ -1,11 +1,7 @@
package mage.cards.h;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.condition.common.SourceMatchesFilterCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.continuous.BecomesCreatureSourceEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -13,14 +9,15 @@ import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.TokenImpl;
import java.util.Optional;
import java.util.UUID;
/**
*
* @author TheElk801
*/
public final class HiddenHerd extends CardImpl {
@ -29,11 +26,7 @@ public final class HiddenHerd extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{G}");
// When an opponent plays a nonbasic land, if Hidden Herd is an enchantment, Hidden Herd becomes a 3/3 Beast creature.
this.addAbility(new ConditionalInterveningIfTriggeredAbility(
new HiddenHerdAbility(),
new SourceMatchesFilterCondition(StaticFilters.FILTER_PERMANENT_ENCHANTMENT),
"When an opponent plays a nonbasic land, if {this} is an enchantment, {this} becomes a 3/3 Beast creature."
));
this.addAbility(new HiddenHerdAbility());
}
private HiddenHerd(final HiddenHerd card) {
@ -72,6 +65,14 @@ class HiddenHerdAbility extends TriggeredAbilityImpl {
return game.getOpponents(controllerId).contains(event.getPlayerId()) && !land.isBasic(game);
}
@Override
public boolean checkInterveningIfClause(Game game) {
return Optional
.ofNullable(getSourcePermanentIfItStillExists(game))
.filter(permanent -> permanent.isEnchantment(game))
.isPresent();
}
@Override
public String getRule() {
return "When an opponent plays a nonbasic land, if {this} is an enchantment, {this} becomes a 3/3 Beast creature.";
@ -87,6 +88,7 @@ class HiddenHerdBeast extends TokenImpl {
power = new MageInt(3);
toughness = new MageInt(3);
}
private HiddenHerdBeast(final HiddenHerdBeast token) {
super(token);
}

View file

@ -2,18 +2,17 @@
package mage.cards.h;
import mage.MageInt;
import mage.abilities.TriggeredAbility;
import mage.abilities.common.SpellCastOpponentTriggeredAbility;
import mage.abilities.condition.Condition;
import mage.abilities.condition.common.SourceMatchesFilterCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.continuous.BecomesCreatureSourceEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.ReachAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.SubType;
import mage.filter.StaticFilters;
import mage.filter.common.FilterCreatureSpell;
import mage.filter.predicate.mageobject.AbilityPredicate;
@ -22,9 +21,7 @@ import mage.game.permanent.token.TokenImpl;
import java.util.UUID;
/**
*
* @author LoneFox
*
*/
public final class HiddenSpider extends CardImpl {
@ -34,14 +31,15 @@ public final class HiddenSpider extends CardImpl {
filter.add(new AbilityPredicate(FlyingAbility.class));
}
private static final Condition condition = new SourceMatchesFilterCondition("{this} is an enchantment", StaticFilters.FILTER_PERMANENT_ENCHANTMENT);
public HiddenSpider(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{G}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{G}");
// When an opponent casts a creature spell with flying, if Hidden Spider is an enchantment, Hidden Spider becomes a 3/5 Spider creature with reach.
TriggeredAbility ability = new SpellCastOpponentTriggeredAbility(new BecomesCreatureSourceEffect(new HiddenSpiderToken(), null, Duration.WhileOnBattlefield),
filter, false);
this.addAbility(new ConditionalInterveningIfTriggeredAbility(ability, new SourceMatchesFilterCondition(StaticFilters.FILTER_PERMANENT_ENCHANTMENT),
"When an opponent casts a creature spell with flying, if {this} is an enchantment, {this} becomes a 3/5 Spider creature with reach."));
this.addAbility(new SpellCastOpponentTriggeredAbility(new BecomesCreatureSourceEffect(
new HiddenSpiderToken(), null, Duration.WhileOnBattlefield
), filter, false).withInterveningIf(condition).setTriggerPhrase("When an opponent casts a creature spell with flying, "));
}
private HiddenSpider(final HiddenSpider card) {
@ -64,6 +62,7 @@ class HiddenSpiderToken extends TokenImpl {
toughness = new MageInt(5);
this.addAbility(ReachAbility.getInstance());
}
private HiddenSpiderToken(final HiddenSpiderToken token) {
super(token);
}

View file

@ -1,13 +1,10 @@
package mage.cards.h;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.TriggeredAbility;
import mage.abilities.common.ControllerPlaysLandTriggeredAbility;
import mage.abilities.common.OpponentPlaysLandTriggeredAbility;
import mage.abilities.condition.Condition;
import mage.abilities.condition.common.SourceMatchesFilterCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continuous.BecomesCreatureSourceEffect;
import mage.abilities.effects.common.continuous.BecomesEnchantmentSourceEffect;
import mage.cards.CardImpl;
@ -19,27 +16,31 @@ import mage.constants.Zone;
import mage.filter.StaticFilters;
import mage.game.permanent.token.TokenImpl;
import java.util.UUID;
/**
*
* @author jeffwadsworth
*/
public final class HiddenStag extends CardImpl {
private static final Condition condition = new SourceMatchesFilterCondition("{this} is an enchantment", StaticFilters.FILTER_PERMANENT_ENCHANTMENT);
private static final Condition condition2 = new SourceMatchesFilterCondition("{this} is a creature", StaticFilters.FILTER_PERMANENT_CREATURE);
public HiddenStag(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{G}");
// Whenever an opponent plays a land, if Hidden Stag is an enchantment, Hidden Stag becomes a 3/2 Elk Beast creature.
Effect effect = new BecomesCreatureSourceEffect(new ElkBeastToken(), null, Duration.WhileOnBattlefield);
TriggeredAbility ability = new OpponentPlaysLandTriggeredAbility(Zone.BATTLEFIELD, effect, false);
this.addAbility(new ConditionalInterveningIfTriggeredAbility(ability, new SourceMatchesFilterCondition(StaticFilters.FILTER_PERMANENT_ENCHANTMENT),
"Whenever an opponent plays a land, if Hidden Stag is an enchantment, Hidden Stag becomes a 3/2 Elk Beast creature."));
this.addAbility(new OpponentPlaysLandTriggeredAbility(
Zone.BATTLEFIELD,
new BecomesCreatureSourceEffect(
new ElkBeastToken(), null, Duration.WhileOnBattlefield
), false
).withInterveningIf(condition));
// Whenever you play a land, if Hidden Stag is a creature, Hidden Stag becomes an enchantment.
Effect effect2 = new BecomesEnchantmentSourceEffect();
TriggeredAbility ability2 = new ControllerPlaysLandTriggeredAbility(Zone.BATTLEFIELD, effect2, false);
this.addAbility(new ConditionalInterveningIfTriggeredAbility(ability2, new SourceMatchesFilterCondition(StaticFilters.FILTER_PERMANENT_CREATURE),
"Whenever you play a land, if Hidden Stag is a creature, Hidden Stag becomes an enchantment."));
this.addAbility(new ControllerPlaysLandTriggeredAbility(
Zone.BATTLEFIELD, new BecomesEnchantmentSourceEffect(), false
).withInterveningIf(condition2));
}
private HiddenStag(final HiddenStag card) {

View file

@ -4,7 +4,6 @@ import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.condition.common.BargainedCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.effects.common.LoseLifeOpponentsEffect;
import mage.abilities.keyword.BargainAbility;
@ -36,12 +35,9 @@ public final class HighFaeNegotiator extends CardImpl {
this.addAbility(FlyingAbility.getInstance());
// When High Fae Negotiator enters the battlefield, if it was bargained, each opponent loses 3 life and you gain 3 life.
Ability ability = new ConditionalInterveningIfTriggeredAbility(
new EntersBattlefieldTriggeredAbility(new LoseLifeOpponentsEffect(3)),
BargainedCondition.instance, "When {this} enters, " +
"if it was bargained, each opponent loses 3 life and you gain 3 life."
);
ability.addEffect(new GainLifeEffect(3));
Ability ability = new EntersBattlefieldTriggeredAbility(new LoseLifeOpponentsEffect(3))
.withInterveningIf(BargainedCondition.instance);
ability.addEffect(new GainLifeEffect(3).concatBy("and"));
this.addAbility(ability);
}

View file

@ -4,14 +4,12 @@ import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.condition.common.TreasureSpentToCastCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.watchers.common.ManaPaidSourceWatcher;
import java.util.UUID;
@ -29,11 +27,8 @@ public final class HiredHexblade extends CardImpl {
this.toughness = new MageInt(2);
// When Hired Hexblade enters the battlefield, if mana from a Treasure was spent to cast it, you draw a card and you lose 1 life.
Ability ability = new ConditionalInterveningIfTriggeredAbility(
new EntersBattlefieldTriggeredAbility(new DrawCardSourceControllerEffect(1)),
TreasureSpentToCastCondition.instance, "When {this} enters, " +
"if mana from a Treasure was spent to cast it, you draw a card and you lose 1 life."
);
Ability ability = new EntersBattlefieldTriggeredAbility(new DrawCardSourceControllerEffect(1))
.withInterveningIf(TreasureSpentToCastCondition.instance);
ability.addEffect(new LoseLifeSourceControllerEffect(1));
this.addAbility(ability);
}

View file

@ -4,13 +4,11 @@ import mage.MageInt;
import mage.abilities.common.AttacksTriggeredAbility;
import mage.abilities.condition.Condition;
import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledPlaneswalkerPermanent;
import java.util.UUID;
@ -20,8 +18,9 @@ import java.util.UUID;
*/
public final class HistorianOfZhalfir extends CardImpl {
private static final FilterPermanent filter = new FilterControlledPlaneswalkerPermanent(SubType.TEFERI);
private static final Condition condition = new PermanentsOnTheBattlefieldCondition(filter);
private static final Condition condition = new PermanentsOnTheBattlefieldCondition(
new FilterControlledPlaneswalkerPermanent(SubType.TEFERI, "you control a Teferi planeswalker")
);
public HistorianOfZhalfir(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{U}{U}");
@ -32,10 +31,7 @@ public final class HistorianOfZhalfir extends CardImpl {
this.toughness = new MageInt(3);
// Whenever Historian of Zhalfir attacks, if you control a Teferi planeswalker, draw a card.
this.addAbility(new ConditionalInterveningIfTriggeredAbility(
new AttacksTriggeredAbility(new DrawCardSourceControllerEffect(1), false),
condition, "Whenever {this} attacks, if you control a Teferi planeswalker, draw a card."
));
this.addAbility(new AttacksTriggeredAbility(new DrawCardSourceControllerEffect(1), false).withInterveningIf(condition));
}
private HistorianOfZhalfir(final HistorianOfZhalfir card) {

View file

@ -1,33 +1,32 @@
package mage.cards.h;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.Condition;
import mage.abilities.condition.common.AttachedToMatchesFilterCondition;
import mage.abilities.decorator.ConditionalContinuousEffect;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.dynamicvalue.common.GreatestAmongPermanentsValue;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.continuous.BoostEnchantedEffect;
import mage.constants.ComparisonType;
import mage.constants.SubType;
import mage.abilities.effects.common.AttachEffect;
import mage.constants.Outcome;
import mage.filter.StaticFilters;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.PowerPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.TargetPermanent;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.TargetPermanent;
import java.util.Optional;
import java.util.UUID;
/**
*
* @author weirddan455
*/
public final class HistoriansWisdom extends CardImpl {
@ -46,17 +45,13 @@ public final class HistoriansWisdom extends CardImpl {
this.addAbility(new EnchantAbility(auraTarget));
// When Historian's Wisdom enters the battlefield, if enchanted permanent is a creature with the greatest power among creatures on the battlefield, draw a card.
this.addAbility(new ConditionalInterveningIfTriggeredAbility(
new EntersBattlefieldTriggeredAbility(new DrawCardSourceControllerEffect(1)),
HistoriansWisdomCondition.instance,
"When {this} enters, if enchanted permanent is a creature with the greatest power among creatures on the battlefield, draw a card."
));
this.addAbility(new EntersBattlefieldTriggeredAbility(new DrawCardSourceControllerEffect(1))
.withInterveningIf(HistoriansWisdomCondition.instance).addHint(GreatestAmongPermanentsValue.POWER_ALL_CREATURES.getHint()));
// As long as enchanted permanent is a creature, it gets +2/+1.
this.addAbility(new SimpleStaticAbility(new ConditionalContinuousEffect(
new BoostEnchantedEffect(2, 1),
creatureCondition,
"As long as enchanted permanent is a creature, it gets +2/+1"
new BoostEnchantedEffect(2, 1), creatureCondition,
"as long as enchanted permanent is a creature, it gets +2/+1"
)));
}
@ -75,21 +70,19 @@ enum HistoriansWisdomCondition implements Condition {
@Override
public boolean apply(Game game, Ability source) {
//game.applyEffects(); // Make sure +2/+1 buff gets applied first
// TODO: not appropriate to call here - investigate where in the engine to apply effects to solve bug
Permanent enchantment = source.getSourcePermanentIfItStillExists(game);
if (enchantment == null) {
return false;
}
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
if (creature == null) {
return false;
}
if (!creature.isCreature(game)) {
return false;
}
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new PowerPredicate(ComparisonType.MORE_THAN, creature.getPower().getValue()));
return game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game).isEmpty();
return Optional
.ofNullable(source.getSourcePermanentIfItStillExists(game))
.map(Permanent::getAttachedTo)
.map(game::getPermanent)
.filter(permanent -> permanent.isCreature(game))
.map(MageObject::getPower)
.map(MageInt::getValue)
.filter(x -> x >= GreatestAmongPermanentsValue.POWER_ALL_CREATURES.calculate(game, source, null))
.isPresent();
}
@Override
public String toString() {
return "enchanted permanent is a creature with the greatest power among creatures on the battlefield";
}
}

View file

@ -3,7 +3,6 @@ package mage.cards.h;
import mage.MageInt;
import mage.abilities.common.DealsDamageToYouAllTriggeredAbility;
import mage.abilities.condition.common.SourceEnteredThisTurnCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.ExileUntilSourceLeavesEffect;
import mage.abilities.keyword.FlashAbility;
import mage.cards.CardImpl;
@ -16,13 +15,12 @@ import mage.filter.StaticFilters;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class HixusPrisonWarden extends CardImpl {
public HixusPrisonWarden(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{W}{W}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{W}{W}");
this.supertype.add(SuperType.LEGENDARY);
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.SOLDIER);
@ -33,11 +31,9 @@ public final class HixusPrisonWarden extends CardImpl {
this.addAbility(FlashAbility.getInstance());
// Whenever a creature deals combat damage to you, if Hixus, Prison Warden entered the battlefield this turn, exile that creature until Hixus leaves the battlefield.
this.addAbility(new ConditionalInterveningIfTriggeredAbility(new DealsDamageToYouAllTriggeredAbility(
this.addAbility(new DealsDamageToYouAllTriggeredAbility(
StaticFilters.FILTER_PERMANENT_CREATURE, new ExileUntilSourceLeavesEffect(), true
).setTriggerPhrase("Whenever a creature deals combat damage to you, if {this} entered the battlefield this turn, "),
SourceEnteredThisTurnCondition.DID, null
));
).withInterveningIf(SourceEnteredThisTurnCondition.DID));
}
private HixusPrisonWarden(final HixusPrisonWarden card) {

View file

@ -1,35 +1,27 @@
package mage.cards.h;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbility;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.triggers.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.condition.Condition;
import mage.abilities.condition.common.CardsInHandCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.condition.common.HellbentCondition;
import mage.abilities.effects.common.LoseLifeOpponentsEffect;
import mage.abilities.effects.common.LoseLifeTargetEffect;
import mage.abilities.triggers.BeginningOfUpkeepTriggeredAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.ComparisonType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
import mage.constants.SubType;
import mage.constants.TargetController;
import java.util.UUID;
/**
*
* @author jeffwadsworth
*/
public final class HollowbornBarghest extends CardImpl {
private static final String rule = "At the beginning of your upkeep, if you have no cards in hand, each opponent loses 2 life.";
private static final Condition condition = new CardsInHandCondition(ComparisonType.EQUAL_TO, 0, TargetController.ACTIVE);
public HollowbornBarghest(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{B}{B}");
@ -40,17 +32,13 @@ public final class HollowbornBarghest extends CardImpl {
this.toughness = new MageInt(6);
// At the beginning of your upkeep, if you have no cards in hand, each opponent loses 2 life.
Condition condition = new CardsInHandCondition(ComparisonType.EQUAL_TO, 0);
TriggeredAbility ability = new BeginningOfUpkeepTriggeredAbility(
new HollowbornBarghestEffect()
);
this.addAbility(new ConditionalInterveningIfTriggeredAbility(
ability,
condition,
rule));
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new LoseLifeOpponentsEffect(2))
.withInterveningIf(HellbentCondition.instance));
// At the beginning of each opponent's upkeep, if that player has no cards in hand, they lose 2 life.
this.addAbility(new HollowbornBarghestTriggeredAbility());
this.addAbility(new BeginningOfUpkeepTriggeredAbility(
TargetController.OPPONENT, new LoseLifeTargetEffect(2).setText("they lose 2 life"), false
).withInterveningIf(condition));
}
private HollowbornBarghest(final HollowbornBarghest card) {
@ -62,70 +50,3 @@ public final class HollowbornBarghest extends CardImpl {
return new HollowbornBarghest(this);
}
}
class HollowbornBarghestEffect extends OneShotEffect {
HollowbornBarghestEffect() {
super(Outcome.Benefit);
staticText = "Each opponent loses 2 life";
}
private HollowbornBarghestEffect(final HollowbornBarghestEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
for (UUID opponentId : game.getOpponents(source.getControllerId())) {
Player opponent = game.getPlayer(opponentId);
if (opponent != null) {
game.getPlayer(opponentId).loseLife(2, game, source, false);
}
}
return true;
}
@Override
public HollowbornBarghestEffect copy() {
return new HollowbornBarghestEffect(this);
}
}
class HollowbornBarghestTriggeredAbility extends TriggeredAbilityImpl {
public HollowbornBarghestTriggeredAbility() {
super(Zone.BATTLEFIELD, new LoseLifeTargetEffect(2));
}
private HollowbornBarghestTriggeredAbility(final HollowbornBarghestTriggeredAbility ability) {
super(ability);
}
@Override
public HollowbornBarghestTriggeredAbility copy() {
return new HollowbornBarghestTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.UPKEEP_STEP_PRE
&& game.getOpponents(controllerId).contains(event.getPlayerId());
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Player opponent = game.getPlayer(event.getPlayerId());
if (opponent != null
&& opponent.getHand().isEmpty()) {
this.getEffects().get(0).setTargetPointer(new FixedTarget(opponent.getId()));
return true;
}
return false;
}
@Override
public String getRule() {
return "At the beginning of each opponent's upkeep, if that player has no cards in hand, they lose 2 life.";
}
}

View file

@ -1,12 +1,8 @@
package mage.cards.h;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.TriggeredAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.condition.common.MorbidCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.hint.common.MorbidHint;
import mage.cards.CardImpl;
@ -14,24 +10,23 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import java.util.UUID;
/**
*
* @author nantuko
*/
public final class HollowhengeScavenger extends CardImpl {
private static final String staticText = "<i>Morbid</i> &mdash; When {this} enters, if a creature died this turn, you gain 5 life.";
public HollowhengeScavenger(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{G}{G}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}{G}");
this.color.setGreen(true);
this.subtype.add(SubType.ELEMENTAL);
this.power = new MageInt(4);
this.toughness = new MageInt(5);
// <i>Morbid</i> &mdash; When Hollowhenge Scavenger enters the battlefield, if a creature died this turn, you gain 5 life.
TriggeredAbility ability = new EntersBattlefieldTriggeredAbility(new GainLifeEffect(5));
this.addAbility(new ConditionalInterveningIfTriggeredAbility(ability, MorbidCondition.instance, staticText).addHint(MorbidHint.instance));
this.addAbility(new EntersBattlefieldTriggeredAbility(new GainLifeEffect(5))
.withInterveningIf(MorbidCondition.instance).addHint(MorbidHint.instance));
}
private HollowhengeScavenger(final HollowhengeScavenger card) {

View file

@ -4,7 +4,7 @@ import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.Condition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.condition.common.AttachedToMatchesFilterCondition;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.UntapAttachedEffect;
import mage.abilities.effects.common.continuous.BoostEnchantedEffect;
@ -14,9 +14,12 @@ import mage.abilities.keyword.FlashAbility;
import mage.abilities.keyword.VigilanceAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.constants.AttachmentType;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.filter.FilterPermanent;
import mage.filter.predicate.Predicates;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;
@ -27,6 +30,17 @@ import java.util.UUID;
*/
public final class HowlOfTheHunt extends CardImpl {
private static final FilterPermanent filter = new FilterPermanent("enchanted creature is a Wolf or Werewolf");
static {
filter.add(Predicates.or(
SubType.WOLF.getPredicate(),
SubType.WEREWOLF.getPredicate()
));
}
private static final Condition condition = new AttachedToMatchesFilterCondition(filter);
public HowlOfTheHunt(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{G}");
@ -39,20 +53,17 @@ public final class HowlOfTheHunt extends CardImpl {
TargetPermanent auraTarget = new TargetCreaturePermanent();
this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
Ability ability = new EnchantAbility(auraTarget);
this.addAbility(ability);
this.addAbility(new EnchantAbility(auraTarget));
// When Howl of the Hunt enters the battlefield, if enchanted creature is a Wolf or Werewolf, untap that creature.
this.addAbility(new ConditionalInterveningIfTriggeredAbility(
new EntersBattlefieldTriggeredAbility(new UntapAttachedEffect()),
HowlOfTheHuntCondition.instance, "When {this} enters, " +
"if enchanted creature is a Wolf or Werewolf, untap that creature."
));
this.addAbility(new EntersBattlefieldTriggeredAbility(
new UntapAttachedEffect().setText("untap that creature")
).withInterveningIf(condition));
// Enchanted creature gets +2/+2 and has vigilance.
ability = new SimpleStaticAbility(new BoostEnchantedEffect(2, 2));
Ability ability = new SimpleStaticAbility(new BoostEnchantedEffect(2, 2));
ability.addEffect(new GainAbilityAttachedEffect(
VigilanceAbility.getInstance(), AttachmentType.AURA, Duration.WhileOnBattlefield
VigilanceAbility.getInstance(), AttachmentType.AURA
).setText("and has vigilance"));
this.addAbility(ability);
}
@ -66,22 +77,3 @@ public final class HowlOfTheHunt extends CardImpl {
return new HowlOfTheHunt(this);
}
}
enum HowlOfTheHuntCondition implements Condition {
instance;
@Override
public boolean apply(Game game, Ability source) {
Permanent enchantment = source.getSourcePermanentIfItStillExists(game);
if (enchantment == null) {
return false;
}
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
return creature != null && creature.hasSubtype(SubType.WOLF, game) || creature.hasSubtype(SubType.WEREWOLF, game);
}
@Override
public String toString() {
return "";
}
}

View file

@ -5,7 +5,6 @@ import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.LeavesBattlefieldTriggeredAbility;
import mage.abilities.condition.common.CastFromHandSourcePermanentCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ReturnFromExileForSourceEffect;
import mage.abilities.keyword.FlyingAbility;
@ -39,11 +38,8 @@ public final class Hypnox extends CardImpl {
this.addAbility(FlyingAbility.getInstance());
// When Hypnox enters the battlefield, if you cast it from your hand, exile all cards from target opponent's hand.
Ability ability = new ConditionalInterveningIfTriggeredAbility(
new EntersBattlefieldTriggeredAbility(new HypnoxExileEffect()),
CastFromHandSourcePermanentCondition.instance, "When {this} enters, " +
"if you cast it from your hand, exile all cards from target opponent's hand."
);
Ability ability = new EntersBattlefieldTriggeredAbility(new HypnoxExileEffect())
.withInterveningIf(CastFromHandSourcePermanentCondition.instance);
ability.addTarget(new TargetOpponent());
this.addAbility(ability, new CastFromHandWatcher());
@ -66,7 +62,7 @@ class HypnoxExileEffect extends OneShotEffect {
HypnoxExileEffect() {
super(Outcome.Exile);
staticText = "Exile all cards from target opponent's hand";
staticText = "exile all cards from target opponent's hand";
}
private HypnoxExileEffect(final HypnoxExileEffect effect) {

View file

@ -1,11 +1,10 @@
package mage.cards.i;
import mage.MageInt;
import mage.abilities.TriggeredAbility;
import mage.abilities.Ability;
import mage.abilities.common.AttacksTriggeredAbility;
import mage.abilities.condition.Condition;
import mage.abilities.condition.common.SourceMatchesFilterCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.dynamicvalue.common.SourcePermanentPowerValue;
import mage.abilities.effects.common.DamageControllerEffect;
import mage.abilities.effects.common.DamageTargetEffect;
@ -25,7 +24,7 @@ import java.util.UUID;
*/
public final class IanTheReckless extends CardImpl {
private static final FilterPermanent filter = new FilterPermanent();
private static final FilterPermanent filter = new FilterPermanent("it's modified");
static {
filter.add(ModifiedPredicate.instance);
@ -43,12 +42,11 @@ public final class IanTheReckless extends CardImpl {
this.toughness = new MageInt(1);
// Whenever Ian the Reckless attacks, if it's modified, you may have it deal damage equal to its power to you and any target.
TriggeredAbility ability = new AttacksTriggeredAbility(new DamageControllerEffect(
SourcePermanentPowerValue.NOT_NEGATIVE).setText("have it deal damage equal to its power to you"), true);
Ability ability = new AttacksTriggeredAbility(new DamageControllerEffect(SourcePermanentPowerValue.NOT_NEGATIVE)
.setText("have it deal damage equal to its power to you"), true).withInterveningIf(condition);
ability.addEffect(new DamageTargetEffect(SourcePermanentPowerValue.NOT_NEGATIVE).setText("and any target"));
ability.addTarget(new TargetAnyTarget());
this.addAbility(new ConditionalInterveningIfTriggeredAbility(ability, condition,
"Whenever {this} attacks, if it's modified, you may have it deal damage equal to its power to you and any target."));
this.addAbility(ability);
}
private IanTheReckless(final IanTheReckless card) {

View file

@ -1,35 +1,33 @@
package mage.cards.i;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.TriggeredAbility;
import mage.abilities.triggers.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.condition.common.CardsInHandCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.condition.Condition;
import mage.abilities.condition.InvertCondition;
import mage.abilities.condition.common.HellbentCondition;
import mage.abilities.effects.common.ReturnToHandSourceEffect;
import mage.abilities.triggers.BeginningOfUpkeepTriggeredAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.ComparisonType;
import java.util.UUID;
/**
*
* @author LoneFox
*/
public final class ImaginaryPet extends CardImpl {
private static final Condition condition = new InvertCondition(HellbentCondition.instance, "you have a card in hand");
public ImaginaryPet(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{U}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{U}");
this.subtype.add(SubType.ILLUSION);
this.power = new MageInt(4);
this.toughness = new MageInt(4);
// At the beginning of your upkeep, if you have a card in hand, return Imaginary Pet to its owner's hand.
TriggeredAbility ability = new BeginningOfUpkeepTriggeredAbility(new ReturnToHandSourceEffect(true));
this.addAbility(new ConditionalInterveningIfTriggeredAbility(ability, new CardsInHandCondition(ComparisonType.MORE_THAN, 0),
"At the beginning of your upkeep, if you have a card in hand, return {this} to its owner's hand."));
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new ReturnToHandSourceEffect(true)).withInterveningIf(condition));
}
private ImaginaryPet(final ImaginaryPet card) {

View file

@ -1,36 +1,37 @@
package mage.cards.i;
import mage.abilities.TriggeredAbility;
import mage.abilities.triggers.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.DestroyAllEffect;
import mage.abilities.effects.common.SacrificeSourceEffect;
import mage.abilities.triggers.BeginningOfUpkeepTriggeredAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.ComparisonType;
import mage.filter.StaticFilters;
import mage.filter.common.FilterLandPermanent;
import java.util.UUID;
/**
*
* @author Plopman
*/
public final class ImpendingDisaster extends CardImpl {
private static final Condition condition = new PermanentsOnTheBattlefieldCondition(StaticFilters.FILTER_LAND, ComparisonType.OR_GREATER, 7, false);
private static final Condition condition = new PermanentsOnTheBattlefieldCondition(
new FilterLandPermanent("there are seven or more lands on the battlefield"),
ComparisonType.OR_GREATER, 7, false
);
public ImpendingDisaster(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{R}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{R}");
// At the beginning of your upkeep, if there are seven or more lands on the battlefield, sacrifice Impending Disaster and destroy all lands.
TriggeredAbility ability = new BeginningOfUpkeepTriggeredAbility(new SacrificeSourceEffect());
ability.addEffect(new DestroyAllEffect(StaticFilters.FILTER_LANDS));
this.addAbility(new ConditionalInterveningIfTriggeredAbility(ability, condition,
"At the beginning of your upkeep, if there are seven or more lands on the battlefield, sacrifice {this} and destroy all lands"));
Ability ability = new BeginningOfUpkeepTriggeredAbility(new SacrificeSourceEffect()).withInterveningIf(condition);
ability.addEffect(new DestroyAllEffect(StaticFilters.FILTER_LANDS).concatBy("and"));
this.addAbility(ability);
}
private ImpendingDisaster(final ImpendingDisaster card) {

View file

@ -2,15 +2,14 @@ package mage.cards.i;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.Condition;
import mage.abilities.condition.common.SourceMatchesFilterCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.InfoEffect;
import mage.abilities.effects.common.continuous.GainAbilityControllerEffect;
import mage.abilities.keyword.HexproofAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Zone;
import mage.filter.FilterPermanent;
import mage.filter.predicate.permanent.TokenPredicate;
@ -21,23 +20,22 @@ import java.util.UUID;
*/
public final class ImperialMask extends CardImpl {
private static final FilterPermanent filter = new FilterPermanent();
private static final FilterPermanent filter = new FilterPermanent("it's not a token");
static {
filter.add(TokenPredicate.FALSE);
}
private static final Condition condition = new SourceMatchesFilterCondition(filter);
public ImperialMask(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{4}{W}");
// When Imperial Mask enters the battlefield, if it's not a token, each of your teammates puts a token that's a copy of Imperial Mask onto the battlefield.
// No implementation of teammates currently, so no effect needed
this.addAbility(new ConditionalInterveningIfTriggeredAbility(
new EntersBattlefieldTriggeredAbility(new InfoEffect(""), false),
new SourceMatchesFilterCondition(filter),
"When {this} enters, if it's not a token, "
+ "each of your teammates creates a token that's a copy of {this}"
));
this.addAbility(new EntersBattlefieldTriggeredAbility(new InfoEffect(
"each of your teammates creates a token that's a copy of {this}"
), false).withInterveningIf(condition));
// You have hexproof.
this.addAbility(new SimpleStaticAbility(new GainAbilityControllerEffect(HexproofAbility.getInstance())));

View file

@ -1,31 +1,20 @@
package mage.cards.i;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.common.EntersBattlefieldControlledTriggeredAbility;
import mage.abilities.common.EntersBattlefieldAllTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
import mage.abilities.condition.common.SourceOnBattlefieldOrCommandZoneCondition;
import mage.abilities.costs.common.TapTargetCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DoIfCostPaid;
import mage.abilities.effects.common.ExileTargetEffect;
import mage.abilities.effects.common.LoseLifeTargetEffect;
import mage.abilities.effects.common.CreateTokenCopyTargetEffect;
import mage.abilities.effects.common.DoIfCostPaid;
import mage.abilities.effects.common.LoseLifeTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AbilityWord;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SetTargetPointer;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.constants.Zone;
import mage.constants.*;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledPermanent;
import mage.filter.predicate.mageobject.AnotherPredicate;
import mage.filter.predicate.permanent.TappedPredicate;
@ -34,22 +23,20 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.TargetPlayer;
import mage.target.common.TargetControlledPermanent;
import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
/**
*
* @author TheElk801
*/
public final class InallaArchmageRitualist extends CardImpl {
private static final FilterControlledPermanent filter = new FilterControlledPermanent("another nontoken Wizard");
private static final FilterControlledPermanent filter2 = new FilterControlledPermanent("untapped Wizards you control");
private static final FilterPermanent filter = new FilterControlledPermanent(SubType.WIZARD, "another nontoken Wizard you control");
private static final FilterControlledPermanent filter2 = new FilterControlledPermanent(SubType.WIZARD, "untapped Wizards you control");
static {
filter.add(SubType.WIZARD.getPredicate());
filter.add(TokenPredicate.FALSE);
filter.add(AnotherPredicate.instance);
filter2.add(SubType.WIZARD.getPredicate());
filter2.add(TappedPredicate.UNTAPPED);
}
@ -63,20 +50,19 @@ public final class InallaArchmageRitualist extends CardImpl {
this.toughness = new MageInt(5);
// Eminence - Whenever another nontoken Wizard you control enters, if Inalla, Archmage Ritualist is in the command zone or on the battlefield, you may pay {1}. If you do, create a token that's a copy of that Wizard. The token gains haste. Exile it at the beginning of the next end step.
Ability ability = new ConditionalInterveningIfTriggeredAbility(
new EntersBattlefieldControlledTriggeredAbility(Zone.ALL, new DoIfCostPaid(
new InallaArchmageRitualistEffect(), new ManaCostsImpl<>("{1}"), "Pay {1} to create a token copy?"),
filter, false, SetTargetPointer.PERMANENT),
SourceOnBattlefieldOrCommandZoneCondition.instance,
"Whenever another nontoken Wizard you control enters, "
+ "if {this} is in the command zone or on the battlefield, "
+ "you may pay {1}. If you do, create a token that's a copy of that Wizard. "
+ "The token gains haste. Exile it at the beginning of the next end step");
ability.setAbilityWord(AbilityWord.EMINENCE);
this.addAbility(ability);
this.addAbility(new EntersBattlefieldAllTriggeredAbility(
Zone.ALL,
new DoIfCostPaid(
new InallaArchmageRitualistEffect(), new GenericManaCost(1),
"Pay {1} to create a token copy?"
), filter, false, SetTargetPointer.PERMANENT
).withInterveningIf(SourceOnBattlefieldOrCommandZoneCondition.instance).setAbilityWord(AbilityWord.EMINENCE));
// Tap five untapped Wizards you control: Target player loses 7 life.
ability = new SimpleActivatedAbility(new LoseLifeTargetEffect(7), new TapTargetCost(new TargetControlledPermanent(5, 5, filter2, true)));
Ability ability = new SimpleActivatedAbility(
new LoseLifeTargetEffect(7),
new TapTargetCost(new TargetControlledPermanent(5, filter2))
);
ability.addTarget(new TargetPlayer());
this.addAbility(ability);
}
@ -95,7 +81,7 @@ class InallaArchmageRitualistEffect extends OneShotEffect {
InallaArchmageRitualistEffect() {
super(Outcome.PutCreatureInPlay);
this.staticText = "create a token that's a copy of that Wizard. That token gains haste. Exile it at the beginning of the next end step";
this.staticText = "create a token that's a copy of that Wizard. The token gains haste. Exile it at the beginning of the next end step";
}
private InallaArchmageRitualistEffect(final InallaArchmageRitualistEffect effect) {
@ -109,21 +95,14 @@ class InallaArchmageRitualistEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
if (permanent != null) {
CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(null, null, true);
effect.setTargetPointer(this.getTargetPointer().copy());
if (effect.apply(game, source)) {
for (Permanent tokenPermanent : effect.getAddedPermanents()) {
ExileTargetEffect exileEffect = new ExileTargetEffect();
exileEffect.setTargetPointer(new FixedTarget(tokenPermanent, game));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
game.addDelayedTriggeredAbility(delayedAbility, source);
}
return true;
}
Permanent permanent = (Permanent) getValue("permanentEnteringBattlefield");
if (permanent == null) {
return false;
}
return false;
CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(null, null, true);
effect.setSavedPermanent(permanent);
effect.apply(game, source);
effect.exileTokensCreatedAtNextEndStep(game, source);
return true;
}
}

View file

@ -1,14 +1,11 @@
package mage.cards.i;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.DiesSourceTriggeredAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.condition.common.CastFromHandSourcePermanentCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ExileSourceEffect;
@ -29,8 +26,9 @@ import mage.target.common.TargetCardInYourGraveyard;
import mage.target.targetpointer.FixedTarget;
import mage.watchers.common.CastFromHandWatcher;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class InameAsOne extends CardImpl {
@ -42,18 +40,16 @@ public final class InameAsOne extends CardImpl {
}
public InameAsOne(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{8}{B}{B}{G}{G}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{8}{B}{B}{G}{G}");
this.supertype.add(SuperType.LEGENDARY);
this.subtype.add(SubType.SPIRIT);
this.power = new MageInt(8);
this.toughness = new MageInt(8);
// When Iname as One enters the battlefield, if you cast it from your hand, you may search your library for a Spirit permanent card, put it onto the battlefield, then shuffle your library.
this.addAbility(new ConditionalInterveningIfTriggeredAbility(
new EntersBattlefieldTriggeredAbility(new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(0, 1, filter)), true),
CastFromHandSourcePermanentCondition.instance,
"When {this} enters, if you cast it from your hand, you may search your library for a Spirit permanent card, put it onto the battlefield, then shuffle."),
new CastFromHandWatcher());
this.addAbility(new EntersBattlefieldTriggeredAbility(
new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(filter)), true
).withInterveningIf(CastFromHandSourcePermanentCondition.instance), new CastFromHandWatcher());
// When Iname as One dies, you may exile it. If you do, return target Spirit permanent card from your graveyard to the battlefield.
Ability ability = new DiesSourceTriggeredAbility(new InameAsOneEffect(), false);

View file

@ -1,19 +1,18 @@
package mage.cards.i;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.AttacksTriggeredAbility;
import mage.abilities.condition.common.CorruptedCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.continuous.BoostControlledEffect;
import mage.constants.AbilityWord;
import mage.constants.Duration;
import mage.constants.SubType;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AbilityWord;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.SubType;
import java.util.UUID;
/**
* @author TheElk801
@ -32,11 +31,9 @@ public final class IncisorGlider extends CardImpl {
this.addAbility(FlyingAbility.getInstance());
// Corrupted -- Whenever Incisor Glider attacks, if an opponent has three or more poison counters, creatures you control get +1/+1 until end of turn.
this.addAbility(new ConditionalInterveningIfTriggeredAbility(
new AttacksTriggeredAbility(new BoostControlledEffect(1, 1, Duration.EndOfTurn)),
CorruptedCondition.instance, "Whenever {this} attacks, if an opponent has three or " +
"more poison counters, creatures you control get +1/+1 until end of turn."
).setAbilityWord(AbilityWord.CORRUPTED).addHint(CorruptedCondition.getHint()));
this.addAbility(new AttacksTriggeredAbility(
new BoostControlledEffect(1, 1, Duration.EndOfTurn)
).withInterveningIf(CorruptedCondition.instance).setAbilityWord(AbilityWord.CORRUPTED).addHint(CorruptedCondition.getHint()));
}
private IncisorGlider(final IncisorGlider card) {

View file

@ -1,15 +1,14 @@
package mage.cards.i;
import mage.MageInt;
import mage.abilities.triggers.BeginningOfEndStepTriggeredAbility;
import mage.abilities.condition.Condition;
import mage.abilities.condition.common.YouGainedLifeCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.LoseLifeOpponentsEffect;
import mage.abilities.hint.ConditionHint;
import mage.abilities.hint.Hint;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.LifelinkAbility;
import mage.abilities.triggers.BeginningOfEndStepTriggeredAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
@ -25,7 +24,7 @@ import java.util.UUID;
public final class IndulgingPatrician extends CardImpl {
private static final Condition condition = new YouGainedLifeCondition(ComparisonType.MORE_THAN, 2);
private static final Hint hint = new ConditionHint(condition, "You gained 3 or more life this turn");
private static final Hint hint = new ConditionHint(condition);
public IndulgingPatrician(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{W}{B}");
@ -42,12 +41,8 @@ public final class IndulgingPatrician extends CardImpl {
this.addAbility(LifelinkAbility.getInstance());
// At the beginning of your end step, if you gained 3 or more life this turn, each opponent loses 3 life.
this.addAbility(new ConditionalInterveningIfTriggeredAbility(
new BeginningOfEndStepTriggeredAbility(
new LoseLifeOpponentsEffect(3)
), condition, "At the beginning of your end step, " +
"if you gained 3 or more life this turn, each opponent loses 3 life."
).addHint(hint), new PlayerGainedLifeWatcher());
this.addAbility(new BeginningOfEndStepTriggeredAbility(new LoseLifeOpponentsEffect(3))
.withInterveningIf(condition).addHint(hint), new PlayerGainedLifeWatcher());
}
private IndulgingPatrician(final IndulgingPatrician card) {

View file

@ -1,19 +1,19 @@
package mage.cards.i;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.AttacksTriggeredAbility;
import mage.abilities.condition.common.DeliriumCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.dynamicvalue.common.CardTypesInGraveyardCount;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AbilityWord;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.game.permanent.token.InexorableBlobOozeToken;
import java.util.UUID;
/**
* @author fireshoes
*/
@ -27,11 +27,9 @@ public final class InexorableBlob extends CardImpl {
// <i>Delirium</i> &mdash; Whenever Inexorable Blob attacks, if there are four or more card types among cards
// in your graveyard, create a 3/3 green Ooze creature token thats tapped and attacking.
this.addAbility(new ConditionalInterveningIfTriggeredAbility(new AttacksTriggeredAbility(new CreateTokenEffect(new InexorableBlobOozeToken(), 1, true, true), false),
DeliriumCondition.instance,
"<i>Delirium</i> &mdash; Whenever {this} attacks, if there are four or more card types among cards in your graveyard, " +
"create a 3/3 green Ooze creature token that's tapped and attacking.")
.addHint(CardTypesInGraveyardCount.YOU.getHint()));
this.addAbility(new AttacksTriggeredAbility(new CreateTokenEffect(
new InexorableBlobOozeToken(), 1, true, true
)).withInterveningIf(DeliriumCondition.instance).setAbilityWord(AbilityWord.DELIRIUM).addHint(CardTypesInGraveyardCount.YOU.getHint()));
}
private InexorableBlob(final InexorableBlob card) {

View file

@ -4,7 +4,6 @@ import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.DiesSourceTriggeredAbility;
import mage.abilities.condition.Condition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldWithCounterTargetEffect;
import mage.abilities.effects.common.continuous.AddCardSubTypeTargetEffect;
@ -22,26 +21,21 @@ import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author ciaccona007
*/
public final class InfernalVessel extends CardImpl {
public InfernalVessel(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{B}");
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.CLERIC);
this.power = new MageInt(2);
this.toughness = new MageInt(1);
// When this creature dies, if it wasn't a Demon, return it to the battlefield under its owner's control with two +1/+1 counters on it. It's a Demon in addition to its other types.
this.addAbility(new ConditionalInterveningIfTriggeredAbility(
new DiesSourceTriggeredAbility(new InfernalVesselReturnEffect()),
InfernalVesselCondition.instance,
"When this creature dies, if it wasn't a Demon, return it to the battlefield under its owner's control "
+ "with two +1/+1 counters on it. It's a Demon in addition to its other types"
));
this.addAbility(new DiesSourceTriggeredAbility(new InfernalVesselReturnEffect())
.withInterveningIf(InfernalVesselCondition.instance));
}
private InfernalVessel(final InfernalVessel card) {
@ -59,8 +53,15 @@ enum InfernalVesselCondition implements Condition {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = (Permanent) source.getEffects().get(0).getValue("permanentLeftBattlefield");
return permanent != null && !permanent.hasSubtype(SubType.DEMON, game);
return CardUtil
.getEffectValueFromAbility(source, "permanentLeftBattlefield", Permanent.class)
.filter(permanent -> !permanent.hasSubtype(SubType.DEMON, game))
.isPresent();
}
@Override
public String toString() {
return "it wasn't a Demon";
}
}
@ -68,6 +69,7 @@ class InfernalVesselReturnEffect extends OneShotEffect {
InfernalVesselReturnEffect() {
super(Outcome.PutCreatureInPlay);
staticText = "return it to the battlefield under its owner's control with two +1/+1 counters on it. It's a Demon in addition to its other types";
}
private InfernalVesselReturnEffect(final InfernalVesselReturnEffect effect) {

View file

@ -1,25 +1,24 @@
package mage.cards.i;
import java.util.UUID;
import mage.MageInt;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.triggers.BeginningOfEndStepTriggeredAbility;
import mage.abilities.condition.Condition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.ShuffleIntoLibrarySourceEffect;
import mage.constants.SubType;
import mage.abilities.keyword.TrampleAbility;
import mage.abilities.triggers.BeginningOfEndStepTriggeredAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.TargetController;
import mage.game.Game;
import mage.watchers.common.AttackedThisTurnWatcher;
import mage.watchers.common.BlockedThisTurnWatcher;
import java.util.UUID;
/**
*
* @author TheElk801
*/
public final class InfernoHellion extends CardImpl {
@ -35,18 +34,10 @@ public final class InfernoHellion extends CardImpl {
this.addAbility(TrampleAbility.getInstance());
// At the beginning of each end step, if Inferno Hellion attacked or blocked this turn, its owner shuffles it into their library.
Ability ability = new ConditionalInterveningIfTriggeredAbility(
new BeginningOfEndStepTriggeredAbility(
TargetController.ANY, new ShuffleIntoLibrarySourceEffect(),
false
),
InfernoHellionCondition.instance,
"At the beginning of each end step, "
+ "if {this} attacked or blocked this turn, "
+ "its owner shuffles it into their library."
);
ability.addWatcher(new BlockedThisTurnWatcher());
this.addAbility(ability);
this.addAbility(new BeginningOfEndStepTriggeredAbility(
TargetController.ANY, new ShuffleIntoLibrarySourceEffect(),
false, InfernoHellionCondition.instance
), new BlockedThisTurnWatcher());
}
private InfernoHellion(final InfernoHellion card) {
@ -60,7 +51,6 @@ public final class InfernoHellion extends CardImpl {
}
enum InfernoHellionCondition implements Condition {
instance;
@Override
@ -74,4 +64,9 @@ enum InfernoHellionCondition implements Condition {
return watcherAttacked.getAttackedThisTurnCreatures().contains(mor)
|| watcherBlocked.getBlockedThisTurnCreatures().contains(mor);
}
@Override
public String toString() {
return "{this} attacked or blocked this turn";
}
}

View file

@ -1,16 +1,15 @@
package mage.cards.i;
import mage.MageInt;
import mage.abilities.triggers.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.condition.Condition;
import mage.abilities.condition.common.SourceHasCounterCondition;
import mage.abilities.costs.common.RemoveCountersSourceCost;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.DoIfCostPaid;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.EntersBattlefieldWithXCountersEffect;
import mage.abilities.keyword.SkulkAbility;
import mage.abilities.triggers.BeginningOfUpkeepTriggeredAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
@ -41,15 +40,10 @@ public final class IngeniousProdigy extends CardImpl {
this.addAbility(new EntersBattlefieldAbility(new EntersBattlefieldWithXCountersEffect(CounterType.P1P1.createInstance())));
// At the beginning of your upkeep, if Ingenious Prodigy has one or more +1/+1 counters on it, you may remove a +1/+1 counter from it. If you do, draw a card.
this.addAbility(new ConditionalInterveningIfTriggeredAbility(
new BeginningOfUpkeepTriggeredAbility(
new DoIfCostPaid(
new DrawCardSourceControllerEffect(1),
new RemoveCountersSourceCost(CounterType.P1P1.createInstance())
), false
), condition, "At the beginning of your upkeep, if {this} has one or more " +
"+1/+1 counters on it, you may remove a +1/+1 counter from it. If you do, draw a card."
));
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new DoIfCostPaid(
new DrawCardSourceControllerEffect(1),
new RemoveCountersSourceCost(CounterType.P1P1.createInstance()).setText("remove a +1/+1 counter from it")
)).withInterveningIf(condition));
}
private IngeniousProdigy(final IngeniousProdigy card) {

View file

@ -1,23 +1,21 @@
package mage.cards.i;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbility;
import mage.abilities.triggers.BeginningOfEndStepTriggeredAbility;
import mage.abilities.condition.common.HateCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.triggers.BeginningOfEndStepTriggeredAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AbilityWord;
import mage.constants.CardType;
import mage.constants.TargetController;
import mage.game.permanent.token.RoyalGuardToken;
import mage.watchers.common.LifeLossOtherFromCombatWatcher;
import java.util.UUID;
/**
*
* @author Styxo
*/
public final class IronFistOfTheEmpire extends CardImpl {
@ -26,13 +24,11 @@ public final class IronFistOfTheEmpire extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{U}{B}{R}");
// <i>Hate</i> &mdash; At the beggining of each end step, if opponent lost life from a source other than combat damage this turn, you gain 2 life and create a 2/2 red Soldier creature token with first strike name Royal Guard.
TriggeredAbility triggeredAbility = new BeginningOfEndStepTriggeredAbility(TargetController.ANY, new GainLifeEffect(2), false);
triggeredAbility.addEffect(new CreateTokenEffect(new RoyalGuardToken()));
Ability ability = new ConditionalInterveningIfTriggeredAbility(
triggeredAbility,
HateCondition.instance,
"<i>Hate</i> &mdash; At the beggining of each end step, if opponent lost life from a source other than combat damage this turn, you gain 1 life and create a 2/2 red Soldier creature token with first strike named Royal Guard.");
this.addAbility(ability, new LifeLossOtherFromCombatWatcher());
Ability ability = new BeginningOfEndStepTriggeredAbility(
TargetController.ANY, new GainLifeEffect(2), false
).withInterveningIf(HateCondition.instance);
ability.addEffect(new CreateTokenEffect(new RoyalGuardToken()).concatBy("and"));
this.addAbility(ability.setAbilityWord(AbilityWord.HATE), new LifeLossOtherFromCombatWatcher());
}
private IronFistOfTheEmpire(final IronFistOfTheEmpire card) {

View file

@ -6,15 +6,17 @@ import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.condition.common.DeliriumCondition;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.CardTypesInGraveyardCount;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.LoseLifeTargetEffect;
import mage.abilities.hint.Hint;
import mage.abilities.hint.ValueHint;
import mage.abilities.keyword.ReachAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AbilityWord;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.SuperType;
@ -29,7 +31,10 @@ import java.util.UUID;
*/
public final class IshkanahGrafwidow extends CardImpl {
private static final FilterControlledPermanent filter = new FilterControlledPermanent(SubType.SPIDER, "Spider you control");
private static final DynamicValue xValue = new PermanentsOnBattlefieldCount(
new FilterControlledPermanent(SubType.SPIDER, "Spider you control")
);
private static final Hint hint = new ValueHint("Spiders you control", xValue);
public IshkanahGrafwidow(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{G}");
@ -43,20 +48,16 @@ public final class IshkanahGrafwidow extends CardImpl {
// <i>Delirium</i> &mdash When Ishkanah, Grafwidow enters the battlefield, if there are four or more card types among cards in your graveyard,
// create three 1/2 green Spider creature tokens with reach.
Ability ability = new ConditionalInterveningIfTriggeredAbility(
new EntersBattlefieldTriggeredAbility(new CreateTokenEffect(new SpiderToken(), 3), false),
DeliriumCondition.instance,
"<i>Delirium</i> &mdash; When {this} enters, if there are four or more card types among cards in your graveyard, "
+ "create three 1/2 green Spider creature tokens with reach.");
ability.addHint(CardTypesInGraveyardCount.YOU.getHint());
this.addAbility(ability);
this.addAbility(new EntersBattlefieldTriggeredAbility(
new CreateTokenEffect(new SpiderToken(), 3), false
).withInterveningIf(DeliriumCondition.instance)
.setAbilityWord(AbilityWord.DELIRIUM)
.addHint(CardTypesInGraveyardCount.YOU.getHint()));
// {5}{B}: Target opponent loses 1 life for each Spider you control.
PermanentsOnBattlefieldCount count = new PermanentsOnBattlefieldCount(filter);
ability = new SimpleActivatedAbility(new LoseLifeTargetEffect(count), new ManaCostsImpl<>("{6}{B}"));
Ability ability = new SimpleActivatedAbility(new LoseLifeTargetEffect(xValue), new ManaCostsImpl<>("{6}{B}"));
ability.addTarget(new TargetOpponent());
ability.addHint(new ValueHint("Spiders you control", count));
this.addAbility(ability);
this.addAbility(ability.addHint(hint));
}
private IshkanahGrafwidow(final IshkanahGrafwidow card) {

View file

@ -1,31 +1,28 @@
package mage.cards.i;
import java.util.UUID;
import mage.abilities.TriggeredAbility;
import mage.abilities.triggers.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.condition.Condition;
import mage.abilities.condition.common.CardsInHandCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.triggers.BeginningOfUpkeepTriggeredAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.ComparisonType;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class IvoryCraneNetsuke extends CardImpl {
private static final Condition condition = new CardsInHandCondition(ComparisonType.MORE_THAN, 6);
public IvoryCraneNetsuke(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{2}");
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}");
// At the beginning of your upkeep, if you have seven or more cards in hand, you gain 4 life.
TriggeredAbility ability = new BeginningOfUpkeepTriggeredAbility(new GainLifeEffect(4));
CardsInHandCondition condition = new CardsInHandCondition(ComparisonType.MORE_THAN, 6);
this.addAbility(new ConditionalInterveningIfTriggeredAbility(ability, condition, "At the beginning of your upkeep, if you have seven or more cards in hand, you gain 4 life."));
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new GainLifeEffect(4)).withInterveningIf(condition));
}
private IvoryCraneNetsuke(final IvoryCraneNetsuke card) {

View file

@ -19,4 +19,9 @@ public enum TreasureSpentToCastCondition implements Condition {
}
return ManaPaidSourceWatcher.getTreasurePaid(source.getSourceId(), game) > 0;
}
@Override
public String toString() {
return "mana from a Treasure was spent to cast it";
}
}

View file

@ -7,6 +7,7 @@ import mage.abilities.hint.Hint;
import mage.abilities.hint.ValueHint;
import mage.filter.FilterPermanent;
import mage.filter.StaticFilters;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -25,6 +26,8 @@ public class GreatestAmongPermanentsValue implements DynamicValue {
= new GreatestAmongPermanentsValue(Quality.Power, StaticFilters.FILTER_CONTROLLED_CREATURES);
public static final GreatestAmongPermanentsValue POWER_OTHER_CONTROLLED_CREATURES
= new GreatestAmongPermanentsValue(Quality.Power, StaticFilters.FILTER_OTHER_CONTROLLED_CREATURES);
public static final GreatestAmongPermanentsValue POWER_ALL_CREATURES
= new GreatestAmongPermanentsValue(Quality.Power, new FilterCreaturePermanent("creatures on the battlefield"));
public static final GreatestAmongPermanentsValue TOUGHNESS_CONTROLLED_CREATURES
= new GreatestAmongPermanentsValue(Quality.Toughness, StaticFilters.FILTER_CONTROLLED_CREATURES);
public static final GreatestAmongPermanentsValue TOUGHNESS_OTHER_CONTROLLED_CREATURES
@ -114,4 +117,4 @@ public class GreatestAmongPermanentsValue implements DynamicValue {
public Hint getHint() {
return new ValueHint("Greatest " + quality.text + " among " + filter.getMessage(), this);
}
}
}