[CLB] Implemented Jaheira's Respite

This commit is contained in:
Evan Kranzler 2022-05-18 20:22:12 -04:00
parent 57b29ccc19
commit 5e90612555
3 changed files with 95 additions and 1 deletions

View file

@ -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);

View file

@ -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("<br>"));
}
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;
}
}

View file

@ -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));