From c07e6be92b420f79a00d6d62d73d4860d941e85e Mon Sep 17 00:00:00 2001 From: theelk801 Date: Sun, 6 Aug 2023 13:13:15 -0400 Subject: [PATCH] [WOE] Implement Talion, the Kindly Lord --- .../src/mage/cards/t/TalionTheKindlyLord.java | 122 ++++++++++++++++++ Mage.Sets/src/mage/sets/WildsOfEldraine.java | 1 + 2 files changed, 123 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/t/TalionTheKindlyLord.java diff --git a/Mage.Sets/src/mage/cards/t/TalionTheKindlyLord.java b/Mage.Sets/src/mage/cards/t/TalionTheKindlyLord.java new file mode 100644 index 00000000000..af8f6434ca3 --- /dev/null +++ b/Mage.Sets/src/mage/cards/t/TalionTheKindlyLord.java @@ -0,0 +1,122 @@ +package mage.cards.t; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.AsEntersBattlefieldAbility; +import mage.abilities.common.SpellCastOpponentTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.abilities.effects.common.LoseLifeTargetControllerEffect; +import mage.abilities.keyword.FlyingAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.filter.FilterSpell; +import mage.filter.predicate.ObjectSourcePlayer; +import mage.filter.predicate.ObjectSourcePlayerPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.game.stack.StackObject; +import mage.players.Player; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class TalionTheKindlyLord extends CardImpl { + + private static final FilterSpell filter + = new FilterSpell("a spell with mana value, power, or toughness equal to the chosen number"); + + static { + filter.add(TalionTheKindlyLordPredicate.instance); + } + + public TalionTheKindlyLord(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{U}{B}"); + + this.supertype.add(SuperType.LEGENDARY); + this.subtype.add(SubType.FAERIE); + this.subtype.add(SubType.NOBLE); + this.power = new MageInt(3); + this.toughness = new MageInt(4); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + + // As Talion, the Kindly Lord enters the battlefield, choose a number between 1 and 10. + this.addAbility(new AsEntersBattlefieldAbility(new TalionTheKindlyLordEffect())); + + // Whenever an opponent casts a spell with mana value, power, or toughness equal to the chosen number, that player loses 2 life and you draw a card. + Ability ability = new SpellCastOpponentTriggeredAbility( + Zone.BATTLEFIELD, new LoseLifeTargetControllerEffect(2) + .setText("that player loses 2 life"), + filter, false, SetTargetPointer.PLAYER + ); + ability.addEffect(new DrawCardSourceControllerEffect(1).concatBy("and")); + this.addAbility(ability); + } + + private TalionTheKindlyLord(final TalionTheKindlyLord card) { + super(card); + } + + @Override + public TalionTheKindlyLord copy() { + return new TalionTheKindlyLord(this); + } +} + +enum TalionTheKindlyLordPredicate implements ObjectSourcePlayerPredicate { + instance; + + @Override + public boolean apply(ObjectSourcePlayer input, Game game) { + Object obj = game.getState().getValue( + "chosenNumber_" + input.getSource().getSourceId() + + '_' + input.getSource().getSourceObjectZoneChangeCounter() + ); + if (obj == null) { + return false; + } + int value = (Integer) obj; + return input.getObject().getManaValue() == value + || input.getObject().getPower().getValue() == value + || input.getObject().getToughness().getValue() == value; + } +} + +class TalionTheKindlyLordEffect extends OneShotEffect { + + TalionTheKindlyLordEffect() { + super(Outcome.Benefit); + staticText = "choose a number between 1 and 10"; + } + + private TalionTheKindlyLordEffect(final TalionTheKindlyLordEffect effect) { + super(effect); + } + + @Override + public TalionTheKindlyLordEffect copy() { + return new TalionTheKindlyLordEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null) { + return true; + } + int numberChoice = controller.getAmount(1, 10, "Choose a number.", game); + game.getState().setValue("chosenNumber_" + source.getSourceId() + + '_' + source.getSourceObjectZoneChangeCounter(), numberChoice); + Permanent permanent = game.getPermanentEntering(source.getSourceId()); + if (permanent != null) { + permanent.addInfo("chosen players", "Chosen Number: " + numberChoice + "", game); + game.informPlayers(permanent.getLogName() + ", chosen number: " + numberChoice); + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/WildsOfEldraine.java b/Mage.Sets/src/mage/sets/WildsOfEldraine.java index da77253d5ac..5b600642355 100644 --- a/Mage.Sets/src/mage/sets/WildsOfEldraine.java +++ b/Mage.Sets/src/mage/sets/WildsOfEldraine.java @@ -29,6 +29,7 @@ public final class WildsOfEldraine extends ExpansionSet { cards.add(new SetCardInfo("Restless Fortress", 259, Rarity.RARE, mage.cards.r.RestlessFortress.class)); cards.add(new SetCardInfo("Sleight of Hand", 67, Rarity.COMMON, mage.cards.s.SleightOfHand.class)); cards.add(new SetCardInfo("Swamp", 264, Rarity.LAND, mage.cards.basiclands.Swamp.class, NON_FULL_USE_VARIOUS)); + cards.add(new SetCardInfo("Talion, the Kindly Lord", 215, Rarity.MYTHIC, mage.cards.t.TalionTheKindlyLord.class)); cards.add(new SetCardInfo("Tough Cookie", 193, Rarity.UNCOMMON, mage.cards.t.ToughCookie.class)); }