From 93d5fd7404cc868de2af0eaec9e53a87dcd3a010 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sat, 5 Feb 2022 22:56:53 -0500 Subject: [PATCH] [NEO] Implemented Dramatist's Puppet --- .../src/mage/cards/d/DramatistsPuppet.java | 94 +++++++++++++++++++ Mage.Sets/src/mage/cards/q/QuarryHauler.java | 58 ++++++------ .../src/mage/sets/KamigawaNeonDynasty.java | 1 + 3 files changed, 122 insertions(+), 31 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/d/DramatistsPuppet.java diff --git a/Mage.Sets/src/mage/cards/d/DramatistsPuppet.java b/Mage.Sets/src/mage/cards/d/DramatistsPuppet.java new file mode 100644 index 0000000000..fa9f33f85e --- /dev/null +++ b/Mage.Sets/src/mage/cards/d/DramatistsPuppet.java @@ -0,0 +1,94 @@ +package mage.cards.d; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.counters.Counter; +import mage.counters.CounterType; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetPermanent; + +import java.util.List; +import java.util.UUID; +import java.util.stream.Collectors; + +/** + * @author TheElk801 + */ +public final class DramatistsPuppet extends CardImpl { + + public DramatistsPuppet(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{4}"); + + this.subtype.add(SubType.CONSTRUCT); + this.power = new MageInt(2); + this.toughness = new MageInt(4); + + // When Dramatist's Puppet enters the battlefield, for each kind of counter on target permanent, put another counter of that kind on it or remove one from it. + Ability ability = new EntersBattlefieldTriggeredAbility(new DramatistsPuppetEffect()); + ability.addTarget(new TargetPermanent()); + this.addAbility(ability); + } + + private DramatistsPuppet(final DramatistsPuppet card) { + super(card); + } + + @Override + public DramatistsPuppet copy() { + return new DramatistsPuppet(this); + } +} + +class DramatistsPuppetEffect extends OneShotEffect { + + DramatistsPuppetEffect() { + super(Outcome.Benefit); + this.staticText = "for each kind of counter on target permanent, " + + "put another counter of that kind on it or remove one from it"; + } + + private DramatistsPuppetEffect(final DramatistsPuppetEffect effect) { + super(effect); + } + + @Override + public DramatistsPuppetEffect copy() { + return new DramatistsPuppetEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); + if (controller == null || permanent == null) { + return false; + } + List counterNames = permanent + .getCounters(game) + .values() + .stream() + .map(Counter::getName) + .collect(Collectors.toList()); + for (String counterName : counterNames) { + Counter newCounter = CounterType.findByName(counterName).createInstance(); + if (controller.chooseUse( + Outcome.BoostCreature, "Add or remove a " + counterName + " counter?", + null, "Add", "Remove", source, game + )) { + permanent.addCounters(newCounter, source.getControllerId(), source, game); + } else { + permanent.removeCounters(newCounter, source, game); + } + } + return true; + } +} diff --git a/Mage.Sets/src/mage/cards/q/QuarryHauler.java b/Mage.Sets/src/mage/cards/q/QuarryHauler.java index 8de39c379f..52837ab730 100644 --- a/Mage.Sets/src/mage/cards/q/QuarryHauler.java +++ b/Mage.Sets/src/mage/cards/q/QuarryHauler.java @@ -1,7 +1,6 @@ package mage.cards.q; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldTriggeredAbility; @@ -9,18 +8,20 @@ import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.SubType; import mage.constants.Outcome; +import mage.constants.SubType; import mage.counters.Counter; import mage.counters.CounterType; -import mage.counters.Counters; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.TargetPermanent; +import java.util.List; +import java.util.UUID; +import java.util.stream.Collectors; + /** - * * @author Styxo */ public final class QuarryHauler extends CardImpl { @@ -52,7 +53,8 @@ class QuarryHaulerEffect extends OneShotEffect { public QuarryHaulerEffect() { super(Outcome.BoostCreature); - this.staticText = "for each kind of counter on target permanent, put another counter of that kind on it or remove one from it"; + this.staticText = "for each kind of counter on target permanent, " + + "put another counter of that kind on it or remove one from it"; } @@ -69,33 +71,27 @@ class QuarryHaulerEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); - if (controller != null) { - if (permanent != null) { - Counters counters = permanent.getCounters(game).copy(); - CounterType counterType; - for (Counter counter : counters.values()) { - if (controller.chooseUse(Outcome.BoostCreature, "Choose whether to add or remove a " + counter.getName() + " counter", null, "Add", "Remove", source, game)) { - counterType = CounterType.findByName(counter.getName()); - Counter counterToAdd; - if (counterType != null) { - counterToAdd = counterType.createInstance(); - } else { - counterToAdd = new Counter(counter.getName()); - } - permanent.addCounters(counterToAdd, source.getControllerId(), source, game); - } else { - counterType = CounterType.findByName(counter.getName()); - if (counterType != null) { - permanent.removeCounters(counterType.createInstance(), source, game); - } else { - permanent.removeCounters(counter.getName(), 1, source, game); - } - } - } - } - return true; + if (controller == null || permanent == null) { + return false; } - return false; + List counterNames = permanent + .getCounters(game) + .values() + .stream() + .map(Counter::getName) + .collect(Collectors.toList()); + for (String counterName : counterNames) { + Counter newCounter = CounterType.findByName(counterName).createInstance(); + if (controller.chooseUse( + Outcome.BoostCreature, "Add or remove a " + counterName + " counter?", + null, "Add", "Remove", source, game + )) { + permanent.addCounters(newCounter, source.getControllerId(), source, game); + } else { + permanent.removeCounters(newCounter, source, game); + } + } + return true; } } diff --git a/Mage.Sets/src/mage/sets/KamigawaNeonDynasty.java b/Mage.Sets/src/mage/sets/KamigawaNeonDynasty.java index d58761bae7..dbcc3435aa 100644 --- a/Mage.Sets/src/mage/sets/KamigawaNeonDynasty.java +++ b/Mage.Sets/src/mage/sets/KamigawaNeonDynasty.java @@ -76,6 +76,7 @@ public final class KamigawaNeonDynasty extends ExpansionSet { cards.add(new SetCardInfo("Dokuchi Silencer", 95, Rarity.UNCOMMON, mage.cards.d.DokuchiSilencer.class)); cards.add(new SetCardInfo("Dragonfly Suit", 9, Rarity.COMMON, mage.cards.d.DragonflySuit.class)); cards.add(new SetCardInfo("Dragonspark Reactor", 137, Rarity.UNCOMMON, mage.cards.d.DragonsparkReactor.class)); + cards.add(new SetCardInfo("Dramatist's Puppet", 244, Rarity.COMMON, mage.cards.d.DramatistsPuppet.class)); cards.add(new SetCardInfo("Echo of Death's Wail", 124, Rarity.RARE, mage.cards.e.EchoOfDeathsWail.class)); cards.add(new SetCardInfo("Ecologist's Terrarium", 246, Rarity.COMMON, mage.cards.e.EcologistsTerrarium.class)); cards.add(new SetCardInfo("Eiganjo Exemplar", 10, Rarity.COMMON, mage.cards.e.EiganjoExemplar.class));