From a7c2f6d22b8f29a1f284a2ca7e00ae280a463564 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Mon, 30 Dec 2019 19:15:26 -0500 Subject: [PATCH] Implemented Underworld Breach --- .../src/mage/cards/u/UnderworldBreach.java | 82 +++++++++++++++++++ .../src/mage/sets/TherosBeyondDeath.java | 1 + 2 files changed, 83 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/u/UnderworldBreach.java diff --git a/Mage.Sets/src/mage/cards/u/UnderworldBreach.java b/Mage.Sets/src/mage/cards/u/UnderworldBreach.java new file mode 100644 index 0000000000..ac4fe71f5a --- /dev/null +++ b/Mage.Sets/src/mage/cards/u/UnderworldBreach.java @@ -0,0 +1,82 @@ +package mage.cards.u; + +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfEndStepTriggeredAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.effects.common.SacrificeSourceEffect; +import mage.abilities.keyword.EscapeAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.game.Game; +import mage.players.Player; + +import java.util.Objects; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class UnderworldBreach extends CardImpl { + + public UnderworldBreach(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{R}"); + + // Each nonland card in your graveyard has escape. The escape cost is equal to the card's mana cost plus exile three other cards from your graveyard. + this.addAbility(new SimpleStaticAbility(new UnderworldBreachEffect())); + + // At the beginning of the end step, sacrifice Underworld Breach. + this.addAbility(new BeginningOfEndStepTriggeredAbility( + new SacrificeSourceEffect(), TargetController.NEXT, false + )); + } + + private UnderworldBreach(final UnderworldBreach card) { + super(card); + } + + @Override + public UnderworldBreach copy() { + return new UnderworldBreach(this); + } +} + +class UnderworldBreachEffect extends ContinuousEffectImpl { + + UnderworldBreachEffect() { + super(Duration.WhileOnBattlefield, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility); + staticText = "Each nonland card in your graveyard has escape. " + + "The escape cost is equal to the card's mana cost plus exile three other cards from your graveyard."; + } + + private UnderworldBreachEffect(final UnderworldBreachEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null) { + return false; + } + controller + .getGraveyard() + .getCards(game) + .stream() + .filter(Objects::nonNull) + .filter(card -> !card.isLand()) + .forEach(card -> { + Ability ability = new EscapeAbility(card, card.getManaCost().getText(), 3); + ability.setSourceId(card.getId()); + ability.setControllerId(card.getOwnerId()); + game.getState().addOtherAbility(card, ability); + }); + return true; + } + + @Override + public UnderworldBreachEffect copy() { + return new UnderworldBreachEffect(this); + } +} diff --git a/Mage.Sets/src/mage/sets/TherosBeyondDeath.java b/Mage.Sets/src/mage/sets/TherosBeyondDeath.java index b4ab61f8af..b8012cc2d2 100644 --- a/Mage.Sets/src/mage/sets/TherosBeyondDeath.java +++ b/Mage.Sets/src/mage/sets/TherosBeyondDeath.java @@ -77,6 +77,7 @@ public final class TherosBeyondDeath extends ExpansionSet { cards.add(new SetCardInfo("Thirst for Meaning", 74, Rarity.COMMON, mage.cards.t.ThirstForMeaning.class)); cards.add(new SetCardInfo("Treeshaker Chimera", 297, Rarity.RARE, mage.cards.t.TreeshakerChimera.class)); cards.add(new SetCardInfo("Tymaret Calls the Dead", 118, Rarity.RARE, mage.cards.t.TymaretCallsTheDead.class)); + cards.add(new SetCardInfo("Underworld Breach", 161, Rarity.RARE, mage.cards.u.UnderworldBreach.class)); cards.add(new SetCardInfo("Underworld Rage-Hound", 163, Rarity.COMMON, mage.cards.u.UnderworldRageHound.class)); cards.add(new SetCardInfo("Underworld Sentinel", 293, Rarity.RARE, mage.cards.u.UnderworldSentinel.class)); cards.add(new SetCardInfo("Victory's Envoy", 289, Rarity.RARE, mage.cards.v.VictorysEnvoy.class));