From 1b5ad66ae58fcd8831c751504aeb6c673789c32c Mon Sep 17 00:00:00 2001 From: Daniel Bomar Date: Tue, 14 Sep 2021 18:17:22 -0500 Subject: [PATCH] [MID] Implemented Light Up the Night --- .../src/mage/cards/l/LightUpTheNight.java | 89 +++++++++++++++++++ .../src/mage/sets/InnistradMidnightHunt.java | 1 + .../RemoveVariableCountersTargetCost.java | 21 ++++- 3 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 Mage.Sets/src/mage/cards/l/LightUpTheNight.java diff --git a/Mage.Sets/src/mage/cards/l/LightUpTheNight.java b/Mage.Sets/src/mage/cards/l/LightUpTheNight.java new file mode 100644 index 0000000000..29fb8a01c0 --- /dev/null +++ b/Mage.Sets/src/mage/cards/l/LightUpTheNight.java @@ -0,0 +1,89 @@ +package mage.cards.l; + +import java.util.UUID; + +import mage.abilities.Ability; +import mage.abilities.costs.common.RemoveVariableCountersTargetCost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.dynamicvalue.common.GetXValue; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.keyword.FlashbackAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.counters.CounterType; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.common.TargetAnyTarget; + +/** + * + * @author weirddan455 + */ +public final class LightUpTheNight extends CardImpl { + + public LightUpTheNight(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{R}"); + + // Light Up the Night deals X damage to any target. It deals X plus 1 damage instead if that target is a creature or planeswalker. + this.getSpellAbility().addEffect(new LightUpTheNightEffect()); + this.getSpellAbility().addTarget(new TargetAnyTarget()); + + // Flashback—{3}{R}, Remove X loyalty counters from among planeswalkers you control. If you cast this spell this way, X can't be 0. + Ability ability = new FlashbackAbility(this, new ManaCostsImpl<>("{3}{R}")); + ability.addCost(new RemoveVariableCountersTargetCost( + StaticFilters.FILTER_CONTROLLED_PERMANENT_PLANESWALKER, CounterType.LOYALTY, "X", 1, + "Remove X loyalty counters from among planeswalkers you control. If you cast this spell this way, X can't be 0" + )); + this.addAbility(ability); + } + + private LightUpTheNight(final LightUpTheNight card) { + super(card); + } + + @Override + public LightUpTheNight copy() { + return new LightUpTheNight(this); + } +} + +class LightUpTheNightEffect extends OneShotEffect { + + public LightUpTheNightEffect() { + super(Outcome.Damage); + staticText = "{this} deals X damage to any target. It deals X plus 1 damage instead if that target is a creature or planeswalker"; + } + + private LightUpTheNightEffect(final LightUpTheNightEffect effect) { + super(effect); + } + + @Override + public LightUpTheNightEffect copy() { + return new LightUpTheNightEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + // Normal cast + int damage = source.getManaCostsToPay().getX(); + // Flashback cast + damage += GetXValue.instance.calculate(game, source, this); + UUID targetId = source.getFirstTarget(); + Player player = game.getPlayer(targetId); + if (player != null) { + player.damage(damage, source.getSourceId(), source, game); + return true; + } + Permanent permanent = game.getPermanent(targetId); + if (permanent != null) { + permanent.damage(damage + 1, source.getSourceId(), source, game); + return true; + } + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/InnistradMidnightHunt.java b/Mage.Sets/src/mage/sets/InnistradMidnightHunt.java index 8b186f6fc2..4280787eb0 100644 --- a/Mage.Sets/src/mage/sets/InnistradMidnightHunt.java +++ b/Mage.Sets/src/mage/sets/InnistradMidnightHunt.java @@ -187,6 +187,7 @@ public final class InnistradMidnightHunt extends ExpansionSet { cards.add(new SetCardInfo("Larder Zombie", 58, Rarity.COMMON, mage.cards.l.LarderZombie.class)); cards.add(new SetCardInfo("Lier, Disciple of the Drowned", 59, Rarity.MYTHIC, mage.cards.l.LierDiscipleOfTheDrowned.class)); cards.add(new SetCardInfo("Liesa, Forgotten Archangel", 232, Rarity.RARE, mage.cards.l.LiesaForgottenArchangel.class)); + cards.add(new SetCardInfo("Light Up the Night", 146, Rarity.RARE, mage.cards.l.LightUpTheNight.class)); cards.add(new SetCardInfo("Locked in the Cemetery", 60, Rarity.COMMON, mage.cards.l.LockedInTheCemetery.class)); cards.add(new SetCardInfo("Lord of the Ulvenwald", 231, Rarity.UNCOMMON, mage.cards.l.LordOfTheUlvenwald.class)); cards.add(new SetCardInfo("Loyal Gryff", 26, Rarity.UNCOMMON, mage.cards.l.LoyalGryff.class)); diff --git a/Mage/src/main/java/mage/abilities/costs/common/RemoveVariableCountersTargetCost.java b/Mage/src/main/java/mage/abilities/costs/common/RemoveVariableCountersTargetCost.java index 0b017a680e..2bf8e091e1 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/RemoveVariableCountersTargetCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/RemoveVariableCountersTargetCost.java @@ -31,16 +31,25 @@ public class RemoveVariableCountersTargetCost extends VariableCostImpl { } public RemoveVariableCountersTargetCost(FilterPermanent filter, CounterType counterTypeToRemove, String xText, int minValue) { + this(filter, counterTypeToRemove, xText, minValue, null); + } + + public RemoveVariableCountersTargetCost(FilterPermanent filter, CounterType counterTypeToRemove, String xText, int minValue, String text) { super(VariableCostType.NORMAL, xText, new StringBuilder(counterTypeToRemove != null ? counterTypeToRemove.getName() + ' ' : "").append("counters to remove").toString()); this.filter = filter; this.counterTypeToRemove = counterTypeToRemove; - this.text = setText(); + if (text != null && !text.isEmpty()) { + this.text = text; + } else { + this.text = setText(); + } this.minValue = minValue; } public RemoveVariableCountersTargetCost(final RemoveVariableCountersTargetCost cost) { super(cost); this.filter = cost.filter; + this.counterTypeToRemove = cost.counterTypeToRemove; this.minValue = cost.minValue; } @@ -63,6 +72,16 @@ public class RemoveVariableCountersTargetCost extends VariableCostImpl { return new RemoveVariableCountersTargetCost(this); } + @Override + public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { + return getMaxValue(source, game) >= minValue; + } + + @Override + public int getMinValue(Ability source, Game game) { + return minValue; + } + @Override public int getMaxValue(Ability source, Game game) { int maxValue = 0;