From 7b2a5dbd08324d63a94df8f284f1eb55b07a03ae Mon Sep 17 00:00:00 2001 From: theelk801 Date: Thu, 15 May 2025 13:20:28 -0400 Subject: [PATCH] [FIC] Implement Yuna's Whistle --- Mage.Sets/src/mage/cards/y/YunasWhistle.java | 91 +++++++++++++++++++ .../src/mage/sets/FinalFantasyCommander.java | 1 + 2 files changed, 92 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/y/YunasWhistle.java diff --git a/Mage.Sets/src/mage/cards/y/YunasWhistle.java b/Mage.Sets/src/mage/cards/y/YunasWhistle.java new file mode 100644 index 00000000000..67ca2404011 --- /dev/null +++ b/Mage.Sets/src/mage/cards/y/YunasWhistle.java @@ -0,0 +1,91 @@ +package mage.cards.y; + +import mage.abilities.Ability; +import mage.abilities.common.delayed.ReflexiveTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.counter.AddCountersTargetEffect; +import mage.cards.*; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.counters.CounterType; +import mage.game.Game; +import mage.players.Player; +import mage.target.common.TargetControlledCreaturePermanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class YunasWhistle extends CardImpl { + + public YunasWhistle(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{G}{G}"); + + // Reveal cards from the top of your library until you reveal a creature card. Put that card into your hand and the rest on the bottom of your library in a random order. When you reveal a creature card this way, put X+1/+1 counters on target creature you control, where X is the mana value of that card. + this.getSpellAbility().addEffect(new YunasWhistleEffect()); + } + + private YunasWhistle(final YunasWhistle card) { + super(card); + } + + @Override + public YunasWhistle copy() { + return new YunasWhistle(this); + } +} + +class YunasWhistleEffect extends OneShotEffect { + + YunasWhistleEffect() { + super(Outcome.Benefit); + staticText = "reveal cards from the top of your library until you reveal a creature card. " + + "Put that card into your hand and the rest on the bottom of your library in a random order. " + + "When you reveal a creature card this way, put X +1/+1 counters on target creature you control, " + + "where X is the mana value of that card"; + } + + private YunasWhistleEffect(final YunasWhistleEffect effect) { + super(effect); + } + + @Override + public YunasWhistleEffect copy() { + return new YunasWhistleEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + Cards cards = new CardsImpl(); + Card card = getCard(player, cards, game, source); + player.revealCards(source, cards, game); + if (card == null) { + return player.putCardsOnBottomOfLibrary(cards, game, source, false); + } + player.moveCards(card, Zone.HAND, source, game); + ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility( + new AddCountersTargetEffect(CounterType.P1P1.createInstance(card.getManaValue())), false + ); + ability.addTarget(new TargetControlledCreaturePermanent()); + game.fireReflexiveTriggeredAbility(ability, source); + cards.retainZone(Zone.LIBRARY, game); + player.putCardsOnBottomOfLibrary(cards, game, source, false); + return true; + } + + private static Card getCard(Player player, Cards cards, Game game, Ability source) { + for (Card card : player.getLibrary().getCards(game)) { + cards.add(card); + if (card.isCreature(game)) { + return card; + } + } + return null; + } +} diff --git a/Mage.Sets/src/mage/sets/FinalFantasyCommander.java b/Mage.Sets/src/mage/sets/FinalFantasyCommander.java index 8c19aebdb85..e79613a1e0a 100644 --- a/Mage.Sets/src/mage/sets/FinalFantasyCommander.java +++ b/Mage.Sets/src/mage/sets/FinalFantasyCommander.java @@ -370,5 +370,6 @@ public final class FinalFantasyCommander extends ExpansionSet { cards.add(new SetCardInfo("Y'shtola, Night's Blessed", 7, Rarity.MYTHIC, mage.cards.y.YshtolaNightsBlessed.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Yuna's Decision", 125, Rarity.RARE, mage.cards.y.YunasDecision.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Yuna's Decision", 74, Rarity.RARE, mage.cards.y.YunasDecision.class, NON_FULL_USE_VARIOUS)); + cards.add(new SetCardInfo("Yuna's Whistle", 126, Rarity.RARE, mage.cards.y.YunasWhistle.class, NON_FULL_USE_VARIOUS)); } }