From f20cbd934f5f84ec63085b685eef57cf3506bbed Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sat, 5 Feb 2022 14:38:05 -0500 Subject: [PATCH] [NEO] Implemented Dragonspark Reactor --- .../src/mage/cards/d/DragonsparkReactor.java | 56 +++++++++++++++++++ .../src/mage/sets/KamigawaNeonDynasty.java | 1 + .../common/CountersSourceCount.java | 21 +++---- 3 files changed, 64 insertions(+), 14 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/d/DragonsparkReactor.java diff --git a/Mage.Sets/src/mage/cards/d/DragonsparkReactor.java b/Mage.Sets/src/mage/cards/d/DragonsparkReactor.java new file mode 100644 index 00000000000..177e921035d --- /dev/null +++ b/Mage.Sets/src/mage/cards/d/DragonsparkReactor.java @@ -0,0 +1,56 @@ +package mage.cards.d; + +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldThisOrAnotherTriggeredAbility; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.common.SacrificeSourceCost; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.dynamicvalue.common.CountersSourceCount; +import mage.abilities.effects.common.DamageTargetEffect; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.counters.CounterType; +import mage.filter.StaticFilters; +import mage.target.TargetPlayer; +import mage.target.common.TargetCreaturePermanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class DragonsparkReactor extends CardImpl { + + private static final DynamicValue xValue = new CountersSourceCount(CounterType.CHARGE); + + public DragonsparkReactor(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{1}{R}"); + + // Whenever Dragonspark Reactor or another artifact enters the battlefield under your control, put a charge counter on Dragonspark Reactor. + this.addAbility(new EntersBattlefieldThisOrAnotherTriggeredAbility( + new AddCountersSourceEffect(CounterType.P1P1.createInstance()), + StaticFilters.FILTER_PERMANENT_ARTIFACT, false, true + )); + + // {4}, Sacrifice Dragonspark Reactor: It deals damage equal to the number of charge counters on it to target player and that much damage to up to one target creature. + Ability ability = new SimpleActivatedAbility( + new DamageTargetEffect(xValue, "it"), new GenericManaCost(4) + ); + ability.addCost(new SacrificeSourceCost()); + ability.addTarget(new TargetPlayer()); + ability.addTarget(new TargetCreaturePermanent(0, 1)); + this.addAbility(ability); + } + + private DragonsparkReactor(final DragonsparkReactor card) { + super(card); + } + + @Override + public DragonsparkReactor copy() { + return new DragonsparkReactor(this); + } +} diff --git a/Mage.Sets/src/mage/sets/KamigawaNeonDynasty.java b/Mage.Sets/src/mage/sets/KamigawaNeonDynasty.java index 8b80080d5a6..3faa95cc789 100644 --- a/Mage.Sets/src/mage/sets/KamigawaNeonDynasty.java +++ b/Mage.Sets/src/mage/sets/KamigawaNeonDynasty.java @@ -73,6 +73,7 @@ public final class KamigawaNeonDynasty extends ExpansionSet { cards.add(new SetCardInfo("Dokuchi Shadow-Walker", 94, Rarity.COMMON, mage.cards.d.DokuchiShadowWalker.class)); 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("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)); diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/CountersSourceCount.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/CountersSourceCount.java index f33a28a140b..d974ff9c622 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/CountersSourceCount.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/CountersSourceCount.java @@ -9,27 +9,20 @@ import mage.game.permanent.Permanent; public class CountersSourceCount implements DynamicValue { - private final String counterName; + private final CounterType counterType; - public CountersSourceCount(CounterType counter) { - this.counterName = counter.getName(); - } - - public CountersSourceCount(String counterName) { - this.counterName = counterName; + public CountersSourceCount(CounterType counterType) { + this.counterType = counterType; } public CountersSourceCount(final CountersSourceCount countersCount) { - this.counterName = countersCount.counterName; + this.counterType = countersCount.counterType; } @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - Permanent permanent = game.getPermanentOrLKIBattlefield(sourceAbility.getSourceId()); - if (permanent != null) { - return permanent.getCounters(game).getCount(counterName); - } - return 0; + Permanent permanent = sourceAbility.getSourcePermanentOrLKI(game); + return permanent != null ? permanent.getCounters(game).getCount(counterType) : 0; } @Override @@ -44,6 +37,6 @@ public class CountersSourceCount implements DynamicValue { @Override public String getMessage() { - return counterName + " counter on {this}"; + return counterType + " counter on {this}"; } }