From e741a453bf82d7f2424b917f2b694b5e434adc6e Mon Sep 17 00:00:00 2001 From: Susucre <34709007+Susucre@users.noreply.github.com> Date: Thu, 11 Apr 2024 19:16:36 +0200 Subject: [PATCH] [PIP] Implement Nuclear Fallout --- .../src/mage/cards/n/NuclearFallout.java | 46 +++++++++++++++++++ Mage.Sets/src/mage/sets/Fallout.java | 1 + .../counter/AddCountersPlayersEffect.java | 29 +++++++++++- 3 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 Mage.Sets/src/mage/cards/n/NuclearFallout.java diff --git a/Mage.Sets/src/mage/cards/n/NuclearFallout.java b/Mage.Sets/src/mage/cards/n/NuclearFallout.java new file mode 100644 index 00000000000..d51984dfffb --- /dev/null +++ b/Mage.Sets/src/mage/cards/n/NuclearFallout.java @@ -0,0 +1,46 @@ +package mage.cards.n; + +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.dynamicvalue.MultipliedValue; +import mage.abilities.dynamicvalue.common.ManacostVariableValue; +import mage.abilities.effects.common.continuous.BoostAllEffect; +import mage.abilities.effects.common.counter.AddCountersPlayersEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.TargetController; +import mage.counters.CounterType; +import mage.filter.StaticFilters; + +import java.util.UUID; + +/** + * @author Susucr + */ +public final class NuclearFallout extends CardImpl { + + private static final DynamicValue xValue = new MultipliedValue(ManacostVariableValue.REGULAR, 2); + + public NuclearFallout(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{B}{B}"); + + // Each creature gets twice -X/-X until end of turn. Each player gets X rad counters. + this.getSpellAbility().addEffect(new BoostAllEffect( + xValue, xValue, Duration.EndOfTurn, StaticFilters.FILTER_PERMANENT_ALL_CREATURES, false, + "Each creature gets twice -X/-X until end of turn" + )); + this.getSpellAbility().addEffect( + new AddCountersPlayersEffect(CounterType.RAD.createInstance(), ManacostVariableValue.REGULAR, TargetController.ANY) + ); + } + + private NuclearFallout(final NuclearFallout card) { + super(card); + } + + @Override + public NuclearFallout copy() { + return new NuclearFallout(this); + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/Fallout.java b/Mage.Sets/src/mage/sets/Fallout.java index 71ba4f44264..82c2b29b074 100644 --- a/Mage.Sets/src/mage/sets/Fallout.java +++ b/Mage.Sets/src/mage/sets/Fallout.java @@ -208,6 +208,7 @@ public final class Fallout extends ExpansionSet { cards.add(new SetCardInfo("Nick Valentine, Private Eye", 906, Rarity.RARE, mage.cards.n.NickValentinePrivateEye.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Nightkin Ambusher", 112, Rarity.UNCOMMON, mage.cards.n.NightkinAmbusher.class)); cards.add(new SetCardInfo("Nomad Outpost", 277, Rarity.UNCOMMON, mage.cards.n.NomadOutpost.class)); + cards.add(new SetCardInfo("Nuclear Fallout", 47, Rarity.RARE, mage.cards.n.NuclearFallout.class)); cards.add(new SetCardInfo("Nuka-Cola Vending Machine", 137, Rarity.UNCOMMON, mage.cards.n.NukaColaVendingMachine.class)); cards.add(new SetCardInfo("One with the Machine", 179, Rarity.RARE, mage.cards.o.OneWithTheMachine.class)); cards.add(new SetCardInfo("Open the Vaults", 168, Rarity.RARE, mage.cards.o.OpenTheVaults.class)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/counter/AddCountersPlayersEffect.java b/Mage/src/main/java/mage/abilities/effects/common/counter/AddCountersPlayersEffect.java index 51ec854d7a3..2d8916e9473 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/counter/AddCountersPlayersEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/counter/AddCountersPlayersEffect.java @@ -1,6 +1,8 @@ package mage.abilities.effects.common.counter; import mage.abilities.Ability; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.dynamicvalue.common.StaticValue; import mage.abilities.effects.OneShotEffect; import mage.constants.Outcome; import mage.constants.TargetController; @@ -8,6 +10,7 @@ import mage.counters.Counter; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; +import mage.util.CardUtil; import java.util.*; @@ -17,11 +20,17 @@ import java.util.*; public class AddCountersPlayersEffect extends OneShotEffect { private final Counter counter; + private final DynamicValue amount; private final TargetController targetController; public AddCountersPlayersEffect(Counter counter, TargetController targetController) { + this(counter, StaticValue.get(0), targetController); + } + + public AddCountersPlayersEffect(Counter counter, DynamicValue amount, TargetController targetController) { super(Outcome.Benefit); this.counter = counter; + this.amount = amount; this.targetController = targetController; staticText = makeText(); } @@ -29,6 +38,7 @@ public class AddCountersPlayersEffect extends OneShotEffect { private AddCountersPlayersEffect(final AddCountersPlayersEffect effect) { super(effect); this.counter = effect.counter; + this.amount = effect.amount; this.targetController = effect.targetController; } @@ -62,10 +72,27 @@ public class AddCountersPlayersEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { + Counter newCounter = counter.copy(); + int calculated = amount.calculate(game, source, this); + if (!(amount instanceof StaticValue) || calculated > 0) { + // If dynamic, or static and set to a > 0 value, we use that instead of the counter's internal amount. + newCounter.remove(newCounter.getCount()); + newCounter.add(calculated); + } else { + // StaticValue 0 -- the default counter has the amount, so no adjustment. + } + + if (newCounter.getCount() <= 0) { + return false; // no need to iterate on targets, no counters will be put on them + } for (UUID playerId : getPlayers(game, source)) { + Counter newCounterForPlayer = newCounter.copy(); Player player = game.getPlayer(playerId); if (player != null) { - player.addCounters(counter, source.getControllerId(), source, game); + player.addCounters(newCounterForPlayer, source.getControllerId(), source, game); + game.informPlayers(player.getLogName() + " gets " + + newCounterForPlayer.getCount() + ' ' + newCounterForPlayer.getName() + " counters" + + CardUtil.getSourceLogName(game, source)); } } return true;