From b8e9214a3fe84fffa0a1ce13a100890932c72393 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sun, 12 Sep 2021 08:05:40 -0400 Subject: [PATCH] [MID] Implemented Moonveil Regent --- .../src/mage/cards/m/MoonveilRegent.java | 141 ++++++++++++++++++ .../src/mage/sets/InnistradMidnightHunt.java | 1 + 2 files changed, 142 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/m/MoonveilRegent.java diff --git a/Mage.Sets/src/mage/cards/m/MoonveilRegent.java b/Mage.Sets/src/mage/cards/m/MoonveilRegent.java new file mode 100644 index 00000000000..b0e147769ec --- /dev/null +++ b/Mage.Sets/src/mage/cards/m/MoonveilRegent.java @@ -0,0 +1,141 @@ +package mage.cards.m; + +import mage.MageInt; +import mage.ObjectColor; +import mage.abilities.Ability; +import mage.abilities.common.DiesSourceTriggeredAbility; +import mage.abilities.common.SpellCastControllerTriggeredAbility; +import mage.abilities.costs.common.DiscardHandCost; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.DamageTargetEffect; +import mage.abilities.effects.common.DoIfCostPaid; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.abilities.hint.Hint; +import mage.abilities.keyword.FlyingAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.game.stack.Spell; +import mage.target.common.TargetAnyTarget; + +import java.util.UUID; +import java.util.stream.Collectors; + +/** + * @author TheElk801 + */ +public final class MoonveilRegent extends CardImpl { + + public MoonveilRegent(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{R}"); + + this.subtype.add(SubType.DRAGON); + this.power = new MageInt(4); + this.toughness = new MageInt(4); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + + // Whenever you cast a spell, you may discard your hand. If you do, draw a card for each of that spell's colors. + this.addAbility(new SpellCastControllerTriggeredAbility(new DoIfCostPaid( + new DrawCardSourceControllerEffect(MoonveilRegentSpellValue.instance) + .setText("draw a card for each of that spell's colors"), + new DiscardHandCost() + ), false)); + + // When Moonveil Regent dies, it deals X damage to any target, where X is the number of colors among permanents you control. + Ability ability = new DiesSourceTriggeredAbility(new DamageTargetEffect( + MoonveilRegentColorValue.instance + ).setText("it deals X damage to any target, where X is the number of colors among permanents you control")); + ability.addTarget(new TargetAnyTarget()); + this.addAbility(ability); + } + + private MoonveilRegent(final MoonveilRegent card) { + super(card); + } + + @Override + public MoonveilRegent copy() { + return new MoonveilRegent(this); + } +} + +enum MoonveilRegentSpellValue implements DynamicValue { + instance; + + @Override + public int calculate(Game game, Ability sourceAbility, Effect effect) { + Spell spell = (Spell) effect.getValue("spellCast"); + return spell != null ? spell.getColor(game).getColorCount() : 0; + } + + @Override + public MoonveilRegentSpellValue copy() { + return this; + } + + @Override + public String getMessage() { + return ""; + } +} + +enum MoonveilRegentColorValue implements DynamicValue { + instance; + + @Override + public int calculate(Game game, Ability sourceAbility, Effect effect) { + return getColorUnion(game, sourceAbility).getColorCount(); + } + + static ObjectColor getColorUnion(Game game, Ability ability) { + ObjectColor color = new ObjectColor(); + for (Permanent permanent : game.getBattlefield().getActivePermanents( + StaticFilters.FILTER_CONTROLLED_PERMANENT, ability.getControllerId(), game + )) { + color.addColor(permanent.getColor(game)); + if (color.getColorCount() >= 5) { + break; + } + } + return color; + } + + @Override + public MoonveilRegentColorValue copy() { + return this; + } + + @Override + public String getMessage() { + return ""; + } +} + +enum MoonveilRegentHint implements Hint { + instance; + + @Override + public String getText(Game game, Ability ability) { + ObjectColor color = MoonveilRegentColorValue.getColorUnion(game, ability); + return "Colors among permanents you control: " + color.getColorCount() + ( + color.getColorCount() > 0 + ? color + .getColors() + .stream() + .map(ObjectColor::getDescription) + .collect(Collectors.joining(", ", " (", ")")) : "" + ); + } + + @Override + public MoonveilRegentHint copy() { + return this; + } +} diff --git a/Mage.Sets/src/mage/sets/InnistradMidnightHunt.java b/Mage.Sets/src/mage/sets/InnistradMidnightHunt.java index 285eb059dfc..eca4dda085e 100644 --- a/Mage.Sets/src/mage/sets/InnistradMidnightHunt.java +++ b/Mage.Sets/src/mage/sets/InnistradMidnightHunt.java @@ -193,6 +193,7 @@ public final class InnistradMidnightHunt extends ExpansionSet { cards.add(new SetCardInfo("Mask of Griselbrand", 111, Rarity.RARE, mage.cards.m.MaskOfGriselbrand.class)); cards.add(new SetCardInfo("Might of the Old Ways", 189, Rarity.COMMON, mage.cards.m.MightOfTheOldWays.class)); cards.add(new SetCardInfo("Moonsilver Key", 255, Rarity.UNCOMMON, mage.cards.m.MoonsilverKey.class)); + cards.add(new SetCardInfo("Moonveil Regent", 149, Rarity.MYTHIC, mage.cards.m.MoonveilRegent.class)); cards.add(new SetCardInfo("Morbid Opportunist", 113, Rarity.UNCOMMON, mage.cards.m.MorbidOpportunist.class)); cards.add(new SetCardInfo("Morkrut Behemoth", 114, Rarity.COMMON, mage.cards.m.MorkrutBehemoth.class)); cards.add(new SetCardInfo("Morning Apparition", 28, Rarity.COMMON, mage.cards.m.MorningApparition.class));