From 5e9061255543ba72669ffe4fb4563cb52f3dd7e3 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Wed, 18 May 2022 20:22:12 -0400 Subject: [PATCH] [CLB] Implemented Jaheira's Respite --- .../src/mage/cards/e/ErinisGloomStalker.java | 2 +- .../src/mage/cards/j/JaheirasRespite.java | 93 +++++++++++++++++++ .../CommanderLegendsBattleForBaldursGate.java | 1 + 3 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 Mage.Sets/src/mage/cards/j/JaheirasRespite.java diff --git a/Mage.Sets/src/mage/cards/e/ErinisGloomStalker.java b/Mage.Sets/src/mage/cards/e/ErinisGloomStalker.java index 5182c380a8e..4789e98dc1f 100644 --- a/Mage.Sets/src/mage/cards/e/ErinisGloomStalker.java +++ b/Mage.Sets/src/mage/cards/e/ErinisGloomStalker.java @@ -26,7 +26,7 @@ public final class ErinisGloomStalker extends CardImpl { public ErinisGloomStalker(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{G}"); - + this.addSuperType(SuperType.LEGENDARY); this.subtype.add(SubType.HALFLING); this.subtype.add(SubType.RANGER); diff --git a/Mage.Sets/src/mage/cards/j/JaheirasRespite.java b/Mage.Sets/src/mage/cards/j/JaheirasRespite.java new file mode 100644 index 00000000000..6ddf73a4fe8 --- /dev/null +++ b/Mage.Sets/src/mage/cards/j/JaheirasRespite.java @@ -0,0 +1,93 @@ +package mage.cards.j; + +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.PreventAllDamageByAllPermanentsEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.cards.Cards; +import mage.cards.CardsImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.combat.CombatGroup; +import mage.players.Player; +import mage.target.common.TargetCardInLibrary; + +import java.util.List; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class JaheirasRespite extends CardImpl { + + public JaheirasRespite(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{4}{G}"); + + // Search your library for up to X basic land cards, where X is the number of creatures attacking you, put those cards onto the battlefield tapped, then shuffle. + this.getSpellAbility().addEffect(new JaheirasRespiteEffect()); + + // Prevent all combat damage that would be dealt this turn. + this.getSpellAbility().addEffect(new PreventAllDamageByAllPermanentsEffect(Duration.EndOfTurn, true).concatBy("
")); + } + + private JaheirasRespite(final JaheirasRespite card) { + super(card); + } + + @Override + public JaheirasRespite copy() { + return new JaheirasRespite(this); + } +} + +class JaheirasRespiteEffect extends OneShotEffect { + + JaheirasRespiteEffect() { + super(Outcome.Benefit); + staticText = "search your library for up to X basic land cards, where X is the number " + + "of creatures attacking you, put those cards onto the battlefield tapped, then shuffle"; + } + + private JaheirasRespiteEffect(final JaheirasRespiteEffect effect) { + super(effect); + } + + @Override + public JaheirasRespiteEffect copy() { + return new JaheirasRespiteEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + int count = game + .getCombat() + .getGroups() + .stream() + .filter(combatGroup -> source.isControlledBy(combatGroup.getDefenderId())) + .map(CombatGroup::getAttackers) + .mapToInt(List::size) + .sum(); + TargetCardInLibrary target = new TargetCardInLibrary(0, count, StaticFilters.FILTER_CARD_BASIC_LANDS); + player.searchLibrary(target, source, game); + Cards cards = new CardsImpl(); + target.getTargets() + .stream() + .map(cardId -> player.getLibrary().getCard(cardId, game)) + .forEach(cards::add); + player.moveCards( + cards.getCards(game), Zone.BATTLEFIELD, source, game, + true, false, false, null + ); + player.shuffleLibrary(source, game); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java b/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java index 63228804215..2f783dd7688 100644 --- a/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java +++ b/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java @@ -50,6 +50,7 @@ public final class CommanderLegendsBattleForBaldursGate extends ExpansionSet { cards.add(new SetCardInfo("Gorion, Wise Mentor", 276, Rarity.RARE, mage.cards.g.GorionWiseMentor.class)); cards.add(new SetCardInfo("Imoen, Mystic Trickster", 77, Rarity.UNCOMMON, mage.cards.i.ImoenMysticTrickster.class)); cards.add(new SetCardInfo("Island", 455, Rarity.LAND, mage.cards.basiclands.Island.class, NON_FULL_USE_VARIOUS)); + cards.add(new SetCardInfo("Jaheira's Respite", 238, Rarity.RARE, mage.cards.j.JaheirasRespite.class)); cards.add(new SetCardInfo("Korlessa, Scale Singer", 280, Rarity.UNCOMMON, mage.cards.k.KorlessaScaleSinger.class)); cards.add(new SetCardInfo("Lightning Bolt", 187, Rarity.COMMON, mage.cards.l.LightningBolt.class)); cards.add(new SetCardInfo("Luxury Suite", 355, Rarity.RARE, mage.cards.l.LuxurySuite.class));