From 9c8bb2473a5d2f4ef44937f4af023fb1cd1b649e Mon Sep 17 00:00:00 2001 From: theelk801 Date: Wed, 9 Jul 2025 09:26:32 -0400 Subject: [PATCH] [EOE] Implement Unravel --- Mage.Sets/src/mage/cards/u/Unravel.java | 77 +++++++++++++++++++ Mage.Sets/src/mage/sets/EdgeOfEternities.java | 1 + 2 files changed, 78 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/u/Unravel.java diff --git a/Mage.Sets/src/mage/cards/u/Unravel.java b/Mage.Sets/src/mage/cards/u/Unravel.java new file mode 100644 index 00000000000..169faf1c777 --- /dev/null +++ b/Mage.Sets/src/mage/cards/u/Unravel.java @@ -0,0 +1,77 @@ +package mage.cards.u; + +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.game.Controllable; +import mage.game.Game; +import mage.game.stack.Spell; +import mage.target.TargetSpell; + +import java.util.Optional; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class Unravel extends CardImpl { + + public Unravel(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{U}{U}"); + + // Counter target spell. If the amount of mana spent to cast that spell was less than its mana value, you draw a card. + this.getSpellAbility().addEffect(new UnravelEffect()); + this.getSpellAbility().addTarget(new TargetSpell()); + } + + private Unravel(final Unravel card) { + super(card); + } + + @Override + public Unravel copy() { + return new Unravel(this); + } +} + +class UnravelEffect extends OneShotEffect { + + UnravelEffect() { + super(Outcome.Benefit); + staticText = "counter target spell. If the amount of mana spent to cast that spell was less than its mana value, you draw a card"; + } + + private UnravelEffect(final UnravelEffect effect) { + super(effect); + } + + @Override + public UnravelEffect copy() { + return new UnravelEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Spell spell = game.getSpell(getTargetPointer().getFirst(game, source)); + if (spell == null) { + return false; + } + boolean flag = spell + .getStackAbility() + .getManaCostsToPay() + .getUsedManaToPay() + .count() < spell.getManaValue(); + game.getStack().counter(spell.getId(), source, game); + if (!flag) { + return true; + } + Optional.ofNullable(source) + .map(Controllable::getControllerId) + .map(game::getPlayer) + .ifPresent(player -> player.drawCards(1, source, game)); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/EdgeOfEternities.java b/Mage.Sets/src/mage/sets/EdgeOfEternities.java index 2bcf3793d62..a49bdea1a08 100644 --- a/Mage.Sets/src/mage/sets/EdgeOfEternities.java +++ b/Mage.Sets/src/mage/sets/EdgeOfEternities.java @@ -110,6 +110,7 @@ public final class EdgeOfEternities extends ExpansionSet { cards.add(new SetCardInfo("Thrumming Hivepool", 247, Rarity.RARE, mage.cards.t.ThrummingHivepool.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Thrumming Hivepool", 356, Rarity.RARE, mage.cards.t.ThrummingHivepool.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Tragic Trajectory", 122, Rarity.UNCOMMON, mage.cards.t.TragicTrajectory.class)); + cards.add(new SetCardInfo("Unravel", 83, Rarity.UNCOMMON, mage.cards.u.Unravel.class)); cards.add(new SetCardInfo("Uthros, Titanic Godcore", 260, Rarity.MYTHIC, mage.cards.u.UthrosTitanicGodcore.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Uthros, Titanic Godcore", 285, Rarity.MYTHIC, mage.cards.u.UthrosTitanicGodcore.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Uthros, Titanic Godcore", 380, Rarity.MYTHIC, mage.cards.u.UthrosTitanicGodcore.class, NON_FULL_USE_VARIOUS));