From 3b7ecfca68dce0b7c4b5408817b0145f5f20dd7e Mon Sep 17 00:00:00 2001 From: xenohedron Date: Thu, 12 Oct 2023 20:56:32 -0400 Subject: [PATCH] Implement [TOR] Flaming Gambit --- Mage.Sets/src/mage/cards/f/FlamingGambit.java | 95 +++++++++++++++++++ Mage.Sets/src/mage/sets/Torment.java | 1 + 2 files changed, 96 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/f/FlamingGambit.java diff --git a/Mage.Sets/src/mage/cards/f/FlamingGambit.java b/Mage.Sets/src/mage/cards/f/FlamingGambit.java new file mode 100644 index 00000000000..48d2e0a7021 --- /dev/null +++ b/Mage.Sets/src/mage/cards/f/FlamingGambit.java @@ -0,0 +1,95 @@ +package mage.cards.f; + +import mage.abilities.Ability; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.dynamicvalue.common.ManacostVariableValue; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.keyword.FlashbackAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.Target; +import mage.target.common.TargetControlledCreaturePermanent; +import mage.target.common.TargetPlayerOrPlaneswalker; + +import java.util.UUID; + +/** + * @author xenohedron + */ +public final class FlamingGambit extends CardImpl { + + public FlamingGambit(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{X}{R}"); + + // Flaming Gambit deals X damage to target player or planeswalker. That player or that planeswalker's controller may choose a creature they control and have Flaming Gambit deal that damage to it instead. + this.getSpellAbility().addTarget(new TargetPlayerOrPlaneswalker()); + this.getSpellAbility().addEffect(new FlamingGambitEffect()); + + // Flashback {X}{R}{R} + this.addAbility(new FlashbackAbility(this, new ManaCostsImpl<>("{X}{R}{R}"))); + + } + + private FlamingGambit(final FlamingGambit card) { + super(card); + } + + @Override + public FlamingGambit copy() { + return new FlamingGambit(this); + } +} + +class FlamingGambitEffect extends OneShotEffect { + + FlamingGambitEffect() { + super(Outcome.Damage); + staticText = "{this} deals X damage to target player or planeswalker. " + + "That player or that planeswalker's controller may choose a creature they control and have {this} deal that damage to it instead"; + } + + private FlamingGambitEffect(final FlamingGambitEffect effect) { + super(effect); + } + + @Override + public FlamingGambitEffect copy() { + return new FlamingGambitEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayerOrPlaneswalkerController(getTargetPointer().getFirst(game, source)); + if (player == null) { + return false; + } + int damage = ManacostVariableValue.REGULAR.calculate(game, source, this); + if (game.getBattlefield().count(StaticFilters.FILTER_PERMANENT_CREATURE, player.getId(), source, game) > 0) { + String message = "Choose a creature you control to deal " + damage + " damage to instead?"; + if (player.chooseUse(outcome, message, source, game)) { + Target target = new TargetControlledCreaturePermanent().withNotTarget(true); + player.choose(outcome, target, source, game); + Permanent permanent = game.getPermanent(target.getFirstTarget()); + if (permanent != null) { + return permanent.damage(damage, source, game) > 0; + } + } + } + // No creature chosen; damage player or planeswalker + Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source)); + if (targetPlayer != null) { + return player.damage(damage, source, game) > 0; + } + Permanent planeswalker = game.getPermanent(getTargetPointer().getFirst(game, source)); + if (planeswalker != null) { + return planeswalker.damage(damage, source, game) > 0; + } + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/Torment.java b/Mage.Sets/src/mage/sets/Torment.java index 9c8b9fac77f..fbc8089ce63 100644 --- a/Mage.Sets/src/mage/sets/Torment.java +++ b/Mage.Sets/src/mage/sets/Torment.java @@ -76,6 +76,7 @@ public final class Torment extends ExpansionSet { cards.add(new SetCardInfo("False Memories", 37, Rarity.RARE, mage.cards.f.FalseMemories.class)); cards.add(new SetCardInfo("Far Wanderings", 125, Rarity.COMMON, mage.cards.f.FarWanderings.class)); cards.add(new SetCardInfo("Fiery Temper", 97, Rarity.COMMON, mage.cards.f.FieryTemper.class)); + cards.add(new SetCardInfo("Flaming Gambit", 98, Rarity.UNCOMMON, mage.cards.f.FlamingGambit.class)); cards.add(new SetCardInfo("Flash of Defiance", 99, Rarity.COMMON, mage.cards.f.FlashOfDefiance.class)); cards.add(new SetCardInfo("Floating Shield", 5, Rarity.COMMON, mage.cards.f.FloatingShield.class)); cards.add(new SetCardInfo("Frantic Purification", 6, Rarity.COMMON, mage.cards.f.FranticPurification.class));