From c745bce734d717b2343b7efbd94862228c8e8248 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Mon, 5 Sep 2022 20:24:46 -0400 Subject: [PATCH] [DMU] Implemented Shanna, Purifying Blade --- .../src/mage/cards/k/KarnLivingLegacy.java | 2 +- .../mage/cards/s/ShannaPurifyingBlade.java | 85 +++++++++++++++++++ Mage.Sets/src/mage/sets/DominariaUnited.java | 1 + .../common/ControllerGotLifeCount.java | 8 +- Mage/src/main/java/mage/util/ManaUtil.java | 18 ++-- 5 files changed, 99 insertions(+), 15 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/s/ShannaPurifyingBlade.java diff --git a/Mage.Sets/src/mage/cards/k/KarnLivingLegacy.java b/Mage.Sets/src/mage/cards/k/KarnLivingLegacy.java index da1e14d79f..1c33ffe83b 100644 --- a/Mage.Sets/src/mage/cards/k/KarnLivingLegacy.java +++ b/Mage.Sets/src/mage/cards/k/KarnLivingLegacy.java @@ -74,7 +74,7 @@ class KarnLivingLegacyEffect extends OneShotEffect { return false; } int amount = ManaUtil.playerPaysXGenericMana( - true, "Karn, Living Legacy", player, source, game + false, "Karn, Living Legacy", player, source, game ); if (amount < 1) { return false; diff --git a/Mage.Sets/src/mage/cards/s/ShannaPurifyingBlade.java b/Mage.Sets/src/mage/cards/s/ShannaPurifyingBlade.java new file mode 100644 index 0000000000..2fc65c9a51 --- /dev/null +++ b/Mage.Sets/src/mage/cards/s/ShannaPurifyingBlade.java @@ -0,0 +1,85 @@ +package mage.cards.s; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfEndStepTriggeredAbility; +import mage.abilities.dynamicvalue.common.ControllerGotLifeCount; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.keyword.LifelinkAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.game.Game; +import mage.players.Player; +import mage.util.ManaUtil; +import mage.watchers.common.PlayerGainedLifeWatcher; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class ShannaPurifyingBlade extends CardImpl { + + public ShannaPurifyingBlade(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{G}{W}{U}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.HUMAN); + this.subtype.add(SubType.WARRIOR); + this.power = new MageInt(3); + this.toughness = new MageInt(3); + + // Lifelink + this.addAbility(LifelinkAbility.getInstance()); + + // At the beginning of your end step, you may pay {X}. If you do, draw X cards. X can't be greater than the amount of life you gained this turn. + this.addAbility(new BeginningOfEndStepTriggeredAbility( + new ShannaPurifyingBladeEffect(), TargetController.YOU, false + ).addHint(ControllerGotLifeCount.getHint()), new PlayerGainedLifeWatcher()); + } + + private ShannaPurifyingBlade(final ShannaPurifyingBlade card) { + super(card); + } + + @Override + public ShannaPurifyingBlade copy() { + return new ShannaPurifyingBlade(this); + } +} + +class ShannaPurifyingBladeEffect extends OneShotEffect { + + ShannaPurifyingBladeEffect() { + super(Outcome.Benefit); + staticText = "you may pay {X}. If you do, draw X cards. " + + "X can't be greater than the amount of life you gained this turn"; + } + + private ShannaPurifyingBladeEffect(final ShannaPurifyingBladeEffect effect) { + super(effect); + } + + @Override + public ShannaPurifyingBladeEffect copy() { + return new ShannaPurifyingBladeEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + int lifeGained = ControllerGotLifeCount.instance.calculate(game, source, this); + if (lifeGained < 1) { + return false; + } + int count = ManaUtil.playerPaysXGenericMana( + true, "Shanna, Purifying Blade", + player, source, game, lifeGained + ); + return count > 0 && player.drawCards(count, source, game) > 0; + } +} diff --git a/Mage.Sets/src/mage/sets/DominariaUnited.java b/Mage.Sets/src/mage/sets/DominariaUnited.java index 1e7e7b0ef3..d94df07e09 100644 --- a/Mage.Sets/src/mage/sets/DominariaUnited.java +++ b/Mage.Sets/src/mage/sets/DominariaUnited.java @@ -202,6 +202,7 @@ public final class DominariaUnited extends ExpansionSet { cards.add(new SetCardInfo("Shadow Prophecy", 105, Rarity.COMMON, mage.cards.s.ShadowProphecy.class)); cards.add(new SetCardInfo("Shadow-Rite Priest", 106, Rarity.RARE, mage.cards.s.ShadowRitePriest.class)); cards.add(new SetCardInfo("Shalai's Acolyte", 33, Rarity.UNCOMMON, mage.cards.s.ShalaisAcolyte.class)); + cards.add(new SetCardInfo("Shanna, Purifying Blade", 218, Rarity.MYTHIC, mage.cards.s.ShannaPurifyingBlade.class)); cards.add(new SetCardInfo("Sheoldred's Restoration", 108, Rarity.UNCOMMON, mage.cards.s.SheoldredsRestoration.class)); cards.add(new SetCardInfo("Sheoldred, the Apocalypse", 107, Rarity.MYTHIC, mage.cards.s.SheoldredTheApocalypse.class)); cards.add(new SetCardInfo("Shield-Wall Sentinel", 238, Rarity.COMMON, mage.cards.s.ShieldWallSentinel.class)); diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/ControllerGotLifeCount.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/ControllerGotLifeCount.java index 06b2426874..d354ac7a19 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/ControllerGotLifeCount.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/ControllerGotLifeCount.java @@ -8,8 +8,6 @@ import mage.abilities.hint.ValueHint; import mage.game.Game; import mage.watchers.common.PlayerGainedLifeWatcher; -import java.util.UUID; - /** * Amount of life the controller got this turn. * @@ -22,13 +20,9 @@ public enum ControllerGotLifeCount implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - return this.calculate(game, sourceAbility.getControllerId()); - } - - public int calculate(Game game, UUID controllerId) { PlayerGainedLifeWatcher watcher = game.getState().getWatcher(PlayerGainedLifeWatcher.class); if (watcher != null) { - return watcher.getLifeGained(controllerId); + return watcher.getLifeGained(sourceAbility.getControllerId()); } return 0; } diff --git a/Mage/src/main/java/mage/util/ManaUtil.java b/Mage/src/main/java/mage/util/ManaUtil.java index 3d7e6fe55b..bb524f1adb 100644 --- a/Mage/src/main/java/mage/util/ManaUtil.java +++ b/Mage/src/main/java/mage/util/ManaUtil.java @@ -450,13 +450,13 @@ public final class ManaUtil { /** * Converts a collection of mana symbols into a single condensed string e.g: - * {1}{1}{1}{1}{1}{W} = {5}{W} - * {2}{B}{2}{B}{2}{B} = {6}{B}{B}{B} - * {1}{2}{R}{U}{1}{1} = {5}{R}{U} - * {B}{G}{R} = {B}{G}{R} + * {1}{1}{1}{1}{1}{W} = {5}{W} + * {2}{B}{2}{B}{2}{B} = {6}{B}{B}{B} + * {1}{2}{R}{U}{1}{1} = {5}{R}{U} + * {B}{G}{R} = {B}{G}{R} * - * @param rawCost the uncondensed version of the mana String. - * @return the condensed version of the mana String. + * @param rawCost the uncondensed version of the mana String. + * @return the condensed version of the mana String. */ public static String condenseManaCostString(String rawCost) { int total = 0; @@ -674,6 +674,10 @@ public final class ManaUtil { } public static int playerPaysXGenericMana(boolean payAsX, String restoreContextName, Player player, Ability source, Game game) { + return playerPaysXGenericMana(payAsX, restoreContextName, player, source, game, Integer.MAX_VALUE); + } + + public static int playerPaysXGenericMana(boolean payAsX, String restoreContextName, Player player, Ability source, Game game, int maxValue) { // payAsX - if your cost is X value (some mana can be used for X cost only) // false: "you may pay any amount of mana" // true: "counter that spell unless that player pays {X}" @@ -684,7 +688,7 @@ public final class ManaUtil { int bookmark = game.bookmarkState(); player.resetStoredBookmark(game); - wantToPay = player.announceXMana(0, Integer.MAX_VALUE, "How much mana will you pay?", game, source); + wantToPay = player.announceXMana(0, maxValue, "Choose how much mana to pay", game, source); if (wantToPay > 0) { Cost cost = ManaUtil.createManaCost(wantToPay, payAsX); payed = cost.pay(source, game, source, player.getId(), false, null);