diff --git a/Mage.Sets/src/mage/cards/z/ZimoneMysteryUnraveler.java b/Mage.Sets/src/mage/cards/z/ZimoneMysteryUnraveler.java new file mode 100644 index 00000000000..ac66eb07011 --- /dev/null +++ b/Mage.Sets/src/mage/cards/z/ZimoneMysteryUnraveler.java @@ -0,0 +1,89 @@ +package mage.cards.z; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.LandfallAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.IfAbilityHasResolvedXTimesEffect; +import mage.abilities.effects.keyword.ManifestDreadEffect; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.constants.SuperType; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.filter.common.FilterControlledPermanent; +import mage.filter.predicate.card.FaceDownPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.common.TargetControlledPermanent; +import mage.watchers.common.AbilityResolvedWatcher; + +/** + * + * @author Grath + */ +public final class ZimoneMysteryUnraveler extends CardImpl { + + public ZimoneMysteryUnraveler(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{G}{U}"); + + this.supertype.add(SuperType.LEGENDARY); + this.subtype.add(SubType.HUMAN); + this.subtype.add(SubType.WIZARD); + this.power = new MageInt(3); + this.toughness = new MageInt(3); + + // Landfall -- Whenever a land you control enters, manifest dread if this is the first time this ability has resolved this turn. Otherwise, you may turn a permanent you control face up. + Ability ability = new LandfallAbility(new IfAbilityHasResolvedXTimesEffect( + Outcome.Benefit, 1, new ManifestDreadEffect() + ).setText("manifest dread if this is the first time this ability has resolved this turn."), false); + ability.addEffect(new IfAbilityHasResolvedXTimesEffect(Outcome.Benefit, 2, true, new ZimoneMysteryUnravelerEffect())); + this.addAbility(ability, new AbilityResolvedWatcher()); + } + + private ZimoneMysteryUnraveler(final ZimoneMysteryUnraveler card) { + super(card); + } + + @Override + public ZimoneMysteryUnraveler copy() { + return new ZimoneMysteryUnraveler(this); + } +} + +class ZimoneMysteryUnravelerEffect extends OneShotEffect { + + public ZimoneMysteryUnravelerEffect() { + super(Outcome.Benefit); + this.staticText = "you may turn a permanent you control face up"; + } + + protected ZimoneMysteryUnravelerEffect(final ZimoneMysteryUnravelerEffect effect) { + super(effect); + } + + @Override + public ZimoneMysteryUnravelerEffect copy() { + return new ZimoneMysteryUnravelerEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + FilterControlledPermanent filter = new FilterControlledPermanent("a permanent you control"); + filter.add(FaceDownPredicate.instance); + if (controller != null) { + TargetControlledPermanent target = new TargetControlledPermanent(filter); + if (controller.chooseUse(Outcome.Benefit, "Turn a permanent you control face up?", source, game) && controller.choose(Outcome.BoostCreature, target, source, game)) { + Permanent permanent = game.getPermanent(target.getFirstTarget()); + if (permanent != null) { + return permanent.turnFaceUp(source, game, source.getControllerId()); + } + } + } + return false; + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/DuskmournHouseOfHorrorCommander.java b/Mage.Sets/src/mage/sets/DuskmournHouseOfHorrorCommander.java index 9cae2f3ee12..0c83af0054a 100644 --- a/Mage.Sets/src/mage/sets/DuskmournHouseOfHorrorCommander.java +++ b/Mage.Sets/src/mage/sets/DuskmournHouseOfHorrorCommander.java @@ -292,5 +292,6 @@ public final class DuskmournHouseOfHorrorCommander extends ExpansionSet { cards.add(new SetCardInfo("Yavimaya Coast", 327, Rarity.RARE, mage.cards.y.YavimayaCoast.class)); cards.add(new SetCardInfo("Yavimaya Elder", 208, Rarity.COMMON, mage.cards.y.YavimayaElder.class)); cards.add(new SetCardInfo("Yedora, Grave Gardener", 209, Rarity.UNCOMMON, mage.cards.y.YedoraGraveGardener.class)); + cards.add(new SetCardInfo("Zimone, Mystery Unraveler", 8, Rarity.MYTHIC, mage.cards.z.ZimoneMysteryUnraveler.class)); } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/IfAbilityHasResolvedXTimesEffect.java b/Mage/src/main/java/mage/abilities/effects/common/IfAbilityHasResolvedXTimesEffect.java index dd89bb9ad8f..40f0d879b58 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/IfAbilityHasResolvedXTimesEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/IfAbilityHasResolvedXTimesEffect.java @@ -18,21 +18,28 @@ public class IfAbilityHasResolvedXTimesEffect extends OneShotEffect { private final int resolutionNumber; private final Effects effects; + private final boolean orMore; public IfAbilityHasResolvedXTimesEffect(int resolutionNumber, Effect effect) { this(effect.getOutcome(), resolutionNumber, effect); } public IfAbilityHasResolvedXTimesEffect(Outcome outcome, int resolutionNumber, Effect... effects) { + this(outcome, resolutionNumber, false, effects); + } + + public IfAbilityHasResolvedXTimesEffect(Outcome outcome, int resolutionNumber, boolean orMore, Effect... effects) { super(outcome); this.resolutionNumber = resolutionNumber; this.effects = new Effects(effects); + this.orMore = orMore; } private IfAbilityHasResolvedXTimesEffect(final IfAbilityHasResolvedXTimesEffect effect) { super(effect); this.resolutionNumber = effect.resolutionNumber; this.effects = effect.effects.copy(); + this.orMore = effect.orMore; } @Override @@ -42,7 +49,8 @@ public class IfAbilityHasResolvedXTimesEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - if (AbilityResolvedWatcher.getResolutionCount(game, source) != resolutionNumber) { + int resolutionCount = AbilityResolvedWatcher.getResolutionCount(game, source); + if (resolutionCount < resolutionNumber || (!orMore && resolutionCount > resolutionNumber)) { return false; } boolean result = false; @@ -62,6 +70,9 @@ public class IfAbilityHasResolvedXTimesEffect extends OneShotEffect { if (staticText != null && !staticText.isEmpty()) { return staticText; } + if (orMore) { + return "otherwise, " + effects.getText(mode); + } return "if this is the " + CardUtil.numberToOrdinalText(resolutionNumber) + " time this ability has resolved this turn, " + effects.getText(mode); }