From d6efb5d7cd6ef727b9ca72b672255e6ce215af2a Mon Sep 17 00:00:00 2001 From: Susucre <34709007+Susucre@users.noreply.github.com> Date: Wed, 3 Apr 2024 23:04:45 +0200 Subject: [PATCH] [OTJ] Implement Thunder Salvo --- Mage.Sets/src/mage/cards/t/ThunderSalvo.java | 75 +++++++++++++++++++ .../mage/sets/OutlawsOfThunderJunction.java | 1 + 2 files changed, 76 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/t/ThunderSalvo.java diff --git a/Mage.Sets/src/mage/cards/t/ThunderSalvo.java b/Mage.Sets/src/mage/cards/t/ThunderSalvo.java new file mode 100644 index 00000000000..c1bd2856545 --- /dev/null +++ b/Mage.Sets/src/mage/cards/t/ThunderSalvo.java @@ -0,0 +1,75 @@ +package mage.cards.t; + +import mage.abilities.Ability; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.dynamicvalue.IntPlusDynamicValue; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.DamageTargetEffect; +import mage.abilities.hint.ValueHint; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.game.Game; +import mage.game.stack.Spell; +import mage.target.common.TargetCreaturePermanent; +import mage.watchers.common.SpellsCastWatcher; + +import java.util.UUID; + +/** + * @author Susucr + */ +public final class ThunderSalvo extends CardImpl { + + public ThunderSalvo(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{R}"); + + // Thunder Salvo deals X damage to target creature, where X is 2 plus the number of other spells you've cast this turn. + this.getSpellAbility().addEffect(new DamageTargetEffect(new IntPlusDynamicValue(2, ThunderSalvoValue.instance)) + .setText("{this} deals X damage to target creature, where X is 2 plus the number of other spells you've cast this turn.")); + this.getSpellAbility().addTarget(new TargetCreaturePermanent()); + this.getSpellAbility().addHint(new ValueHint("Number of other spells you've cast this turn", ThunderSalvoValue.instance)); + } + + private ThunderSalvo(final ThunderSalvo card) { + super(card); + } + + @Override + public ThunderSalvo copy() { + return new ThunderSalvo(this); + } +} + +enum ThunderSalvoValue implements DynamicValue { + instance; + + @Override + public int calculate(Game game, Ability sourceAbility, Effect effect) { + SpellsCastWatcher watcher = game.getState().getWatcher(SpellsCastWatcher.class); + if (watcher == null) { + return 0; + } + Spell spell = game.getSpell(sourceAbility.getSourceId()); + return watcher.getSpellsCastThisTurn(sourceAbility.getControllerId()) + .stream() + .filter(s -> spell == null || !spell.getId().equals(s.getId())) + .mapToInt(k -> 1) + .sum(); + } + + @Override + public ThunderSalvoValue copy() { + return instance; + } + + @Override + public String getMessage() { + return "Number of other spells you've cast this turn"; + } + + @Override + public String toString() { + return "1"; + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/OutlawsOfThunderJunction.java b/Mage.Sets/src/mage/sets/OutlawsOfThunderJunction.java index cfe722445aa..5b2b750cb64 100644 --- a/Mage.Sets/src/mage/sets/OutlawsOfThunderJunction.java +++ b/Mage.Sets/src/mage/sets/OutlawsOfThunderJunction.java @@ -268,6 +268,7 @@ public final class OutlawsOfThunderJunction extends ExpansionSet { cards.add(new SetCardInfo("Three Steps Ahead", 75, Rarity.RARE, mage.cards.t.ThreeStepsAhead.class)); cards.add(new SetCardInfo("Throw from the Saddle", 185, Rarity.COMMON, mage.cards.t.ThrowFromTheSaddle.class)); cards.add(new SetCardInfo("Thunder Lasso", 35, Rarity.UNCOMMON, mage.cards.t.ThunderLasso.class)); + cards.add(new SetCardInfo("Thunder Salvo", 150, Rarity.COMMON, mage.cards.t.ThunderSalvo.class)); cards.add(new SetCardInfo("Tinybones Joins Up", 108, Rarity.RARE, mage.cards.t.TinybonesJoinsUp.class)); cards.add(new SetCardInfo("Tomb Trawler", 250, Rarity.UNCOMMON, mage.cards.t.TombTrawler.class)); cards.add(new SetCardInfo("Trained Arynx", 36, Rarity.COMMON, mage.cards.t.TrainedArynx.class));