From f38251c80984d12c597d1bd8d68fe668fa01dcdd Mon Sep 17 00:00:00 2001 From: theelk801 Date: Sun, 18 Jun 2023 12:34:38 -0400 Subject: [PATCH] [LTR] Implement Palantir of Orthanc --- .../src/mage/cards/p/PalantirOfOrthanc.java | 101 ++++++++++++++++++ .../TheLordOfTheRingsTalesOfMiddleEarth.java | 1 + .../main/java/mage/counters/CounterType.java | 1 + 3 files changed, 103 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/p/PalantirOfOrthanc.java diff --git a/Mage.Sets/src/mage/cards/p/PalantirOfOrthanc.java b/Mage.Sets/src/mage/cards/p/PalantirOfOrthanc.java new file mode 100644 index 00000000000..b17017e15b9 --- /dev/null +++ b/Mage.Sets/src/mage/cards/p/PalantirOfOrthanc.java @@ -0,0 +1,101 @@ +package mage.cards.p; + +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfEndStepTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.abilities.effects.keyword.ScryEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SuperType; +import mage.constants.TargetController; +import mage.counters.CounterType; +import mage.game.Game; +import mage.players.Player; +import mage.target.common.TargetOpponent; + +import java.util.Objects; +import java.util.Optional; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class PalantirOfOrthanc extends CardImpl { + + public PalantirOfOrthanc(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}"); + + this.supertype.add(SuperType.LEGENDARY); + + // At the beginning of your end step, put an influence counter on Palantir of Orthanc and scry 2. Then target opponent may have you draw a card. If that player doesn't, you mill X cards, where X is the number of influence counters on Palantir of Orthanc, and that player loses life equal to the total mana value of those cards. + Ability ability = new BeginningOfEndStepTriggeredAbility( + new AddCountersSourceEffect(CounterType.INFLUENCE.createInstance()), + TargetController.YOU, false + ); + ability.addEffect(new ScryEffect(2, false).concatBy("and")); + ability.addEffect(new PalantirOfOrthancEffect()); + ability.addTarget(new TargetOpponent()); + this.addAbility(ability); + } + + private PalantirOfOrthanc(final PalantirOfOrthanc card) { + super(card); + } + + @Override + public PalantirOfOrthanc copy() { + return new PalantirOfOrthanc(this); + } +} + +class PalantirOfOrthancEffect extends OneShotEffect { + + PalantirOfOrthancEffect() { + super(Outcome.Benefit); + staticText = "Then target opponent may have you draw a card. If that player doesn't, " + + "you mill X cards, where X is the number of influence counters on {this}, " + + "and that player loses life equal to the total mana value of those cards."; + } + + private PalantirOfOrthancEffect(final PalantirOfOrthancEffect effect) { + super(effect); + } + + @Override + public PalantirOfOrthancEffect copy() { + return new PalantirOfOrthancEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + Player opponent = game.getPlayer(getTargetPointer().getFirst(game, source)); + if (controller == null || opponent == null) { + return false; + } + if (opponent.chooseUse(outcome, "Have " + controller.getName() + " draw a card?", source, game)) { + return controller.drawCards(1, source, game) > 0; + } + int counters = Optional + .ofNullable(source.getSourcePermanentOrLKI(game)) + .filter(Objects::nonNull) + .map(permanent -> permanent.getCounters(game)) + .map(c -> c.getCount(CounterType.INFLUENCE)) + .orElse(0); + if (counters < 1) { + return false; + } + int total = controller + .millCards(counters, source, game) + .getCards(game) + .stream() + .mapToInt(MageObject::getManaValue) + .sum(); + opponent.loseLife(total, game, source, false); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java b/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java index 275b9717f7f..91dbb92e7a1 100644 --- a/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java +++ b/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java @@ -164,6 +164,7 @@ public final class TheLordOfTheRingsTalesOfMiddleEarth extends ExpansionSet { cards.add(new SetCardInfo("Olog-hai Crusher", 140, Rarity.COMMON, mage.cards.o.OlogHaiCrusher.class)); cards.add(new SetCardInfo("One Ring to Rule Them All", 102, Rarity.RARE, mage.cards.o.OneRingToRuleThemAll.class)); cards.add(new SetCardInfo("Orcish Medicine", 104, Rarity.COMMON, mage.cards.o.OrcishMedicine.class)); + cards.add(new SetCardInfo("Palantir of Orthanc", 247, Rarity.MYTHIC, mage.cards.p.PalantirOfOrthanc.class)); cards.add(new SetCardInfo("Pelargir Survivor", 64, Rarity.COMMON, mage.cards.p.PelargirSurvivor.class)); cards.add(new SetCardInfo("Peregrin Took", 181, Rarity.UNCOMMON, mage.cards.p.PeregrinTook.class)); cards.add(new SetCardInfo("Pippin's Bravery", 182, Rarity.COMMON, mage.cards.p.PippinsBravery.class)); diff --git a/Mage/src/main/java/mage/counters/CounterType.java b/Mage/src/main/java/mage/counters/CounterType.java index 3734852e370..50e6ef9344f 100644 --- a/Mage/src/main/java/mage/counters/CounterType.java +++ b/Mage/src/main/java/mage/counters/CounterType.java @@ -100,6 +100,7 @@ public enum CounterType { INCARNATION("incarnation"), INDESTRUCTIBLE("indestructible"), INFECTION("infection"), + INFLUENCE("influence"), INGENUITY("ingenuity"), INTEL("intel"), INTERVENTION("intervention"),