From f9f69e0ffcec07bb6898b79c348fad4822b6ab12 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Thu, 9 Apr 2020 21:26:38 -0400 Subject: [PATCH] Implemented Heartless Act --- Mage.Sets/src/mage/cards/h/HeartlessAct.java | 135 ++++++++++++++++++ .../src/mage/sets/IkoriaLairOfBehemoths.java | 1 + 2 files changed, 136 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/h/HeartlessAct.java diff --git a/Mage.Sets/src/mage/cards/h/HeartlessAct.java b/Mage.Sets/src/mage/cards/h/HeartlessAct.java new file mode 100644 index 0000000000..f5d4f24495 --- /dev/null +++ b/Mage.Sets/src/mage/cards/h/HeartlessAct.java @@ -0,0 +1,135 @@ +package mage.cards.h; + +import mage.abilities.Ability; +import mage.abilities.Mode; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.DestroyTargetEffect; +import mage.abilities.effects.common.continuous.BoostSourceEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.permanent.CounterAnyPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetPermanent; +import mage.target.common.TargetCreaturePermanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class HeartlessAct extends CardImpl { + + private static final FilterPermanent filter + = new FilterCreaturePermanent("creature with no counters on it"); + + static { + filter.add(Predicates.not(CounterAnyPredicate.instance)); + } + + public HeartlessAct(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{B}"); + + // Choose one — + // • Destroy target creature with no counters on it. + this.getSpellAbility().addEffect(new DestroyTargetEffect()); + this.getSpellAbility().addTarget(new TargetPermanent(filter)); + + // • Remove up to three counters from target creature. + Mode mode = new Mode(new HeartlessActEffect()); + mode.addTarget(new TargetCreaturePermanent()); + this.getSpellAbility().addMode(mode); + } + + private HeartlessAct(final HeartlessAct card) { + super(card); + } + + @Override + public HeartlessAct copy() { + return new HeartlessAct(this); + } +} + +class HeartlessActEffect extends OneShotEffect { + + HeartlessActEffect() { + super(Outcome.Benefit); + staticText = ""; + } + + private HeartlessActEffect(final HeartlessActEffect effect) { + super(effect); + } + + @Override + public HeartlessActEffect copy() { + return new HeartlessActEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null) { + return false; + } + Permanent permanent = game.getPermanent(source.getFirstTarget()); + if (permanent != null) { + int toRemove = 3; + int removed = 0; + String[] counterNames = permanent.getCounters(game).keySet().toArray(new String[0]); + for (String counterName : counterNames) { + if (controller.chooseUse(Outcome.Neutral, "Do you want to remove " + counterName + " counters?", source, game)) { + if (permanent.getCounters(game).get(counterName).getCount() == 1 || toRemove == 1) { + permanent.removeCounters(counterName, 1, game); + removed++; + } else { + int amount = controller.getAmount(1, Math.min(permanent.getCounters(game).get(counterName).getCount(), toRemove - removed), "How many?", game); + if (amount > 0) { + removed += amount; + permanent.removeCounters(counterName, amount, game); + } + } + } + if (removed >= toRemove) { + break; + } + } + game.addEffect(new BoostSourceEffect(removed, 0, Duration.EndOfTurn), source); + return true; + } + Player player = game.getPlayer(source.getFirstTarget()); + if (player == null) { + return false; + } + int toRemove = 3; + int removed = 0; + String[] counterNames = player.getCounters().keySet().toArray(new String[0]); + for (String counterName : counterNames) { + if (controller.chooseUse(Outcome.Neutral, "Do you want to remove " + counterName + " counters?", source, game)) { + if (player.getCounters().get(counterName).getCount() == 1 || toRemove == 1) { + player.removeCounters(counterName, 1, source, game); + removed++; + } else { + int amount = controller.getAmount(1, Math.min(player.getCounters().get(counterName).getCount(), toRemove - removed), "How many?", game); + if (amount > 0) { + removed += amount; + player.removeCounters(counterName, amount, source, game); + } + } + } + if (removed >= toRemove) { + break; + } + } + game.addEffect(new BoostSourceEffect(removed, 0, Duration.EndOfTurn), source); + return true; + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/IkoriaLairOfBehemoths.java b/Mage.Sets/src/mage/sets/IkoriaLairOfBehemoths.java index 94cd81d2c4..02507eca69 100644 --- a/Mage.Sets/src/mage/sets/IkoriaLairOfBehemoths.java +++ b/Mage.Sets/src/mage/sets/IkoriaLairOfBehemoths.java @@ -119,6 +119,7 @@ public final class IkoriaLairOfBehemoths extends ExpansionSet { cards.add(new SetCardInfo("Glowstone Recluse", 156, Rarity.UNCOMMON, mage.cards.g.GlowstoneRecluse.class)); cards.add(new SetCardInfo("Go for Blood", 122, Rarity.COMMON, mage.cards.g.GoForBlood.class)); cards.add(new SetCardInfo("Grimdancer", 90, Rarity.UNCOMMON, mage.cards.g.Grimdancer.class)); + cards.add(new SetCardInfo("Heartless Act", 91, Rarity.UNCOMMON, mage.cards.h.HeartlessAct.class)); cards.add(new SetCardInfo("Helica Glider", 15, Rarity.COMMON, mage.cards.h.HelicaGlider.class)); cards.add(new SetCardInfo("Hornbash Mentor", 159, Rarity.UNCOMMON, mage.cards.h.HornbashMentor.class)); cards.add(new SetCardInfo("Huntmaster Liger", 16, Rarity.UNCOMMON, mage.cards.h.HuntmasterLiger.class));