From 11ea8e099ab6374b8d392b72b045ae2f578ee630 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Tue, 8 Jan 2019 13:25:43 -0500 Subject: [PATCH] Implemented Theater of Horrors --- .../src/mage/cards/t/TheaterOfHorrors.java | 127 ++++++++++++++++++ .../src/mage/sets/RavnicaAllegiance.java | 1 + 2 files changed, 128 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/t/TheaterOfHorrors.java diff --git a/Mage.Sets/src/mage/cards/t/TheaterOfHorrors.java b/Mage.Sets/src/mage/cards/t/TheaterOfHorrors.java new file mode 100644 index 0000000000..b046462d3f --- /dev/null +++ b/Mage.Sets/src/mage/cards/t/TheaterOfHorrors.java @@ -0,0 +1,127 @@ +package mage.cards.t; + +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.AsThoughEffectImpl; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.DamageTargetEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.game.ExileZone; +import mage.game.Game; +import mage.players.Player; +import mage.target.common.TargetOpponentOrPlaneswalker; +import mage.util.CardUtil; +import mage.watchers.common.PlayerLostLifeWatcher; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class TheaterOfHorrors extends CardImpl { + + public TheaterOfHorrors(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{B}{R}"); + + // At the beginning of your upkeep, exile the top card of your library. + this.addAbility(new BeginningOfUpkeepTriggeredAbility( + new TheaterOfHorrorsExileEffect(), + TargetController.YOU, false + )); + + // During your turn, if an opponent lost life this turn, you may play cards exiled with Theater of Horrors. + this.addAbility(new SimpleStaticAbility(new TheaterOfHorrorsCastEffect())); + + // {3}{R}: Theater of Horrors deals 1 damage to target opponent or planeswalker. + Ability ability = new SimpleActivatedAbility( + new DamageTargetEffect(1), + new ManaCostsImpl("{3}{R}") + ); + ability.addTarget(new TargetOpponentOrPlaneswalker()); + this.addAbility(ability); + } + + private TheaterOfHorrors(final TheaterOfHorrors card) { + super(card); + } + + @Override + public TheaterOfHorrors copy() { + return new TheaterOfHorrors(this); + } +} + +class TheaterOfHorrorsExileEffect extends OneShotEffect { + + TheaterOfHorrorsExileEffect() { + super(Outcome.Benefit); + staticText = "exile the top card of your library."; + } + + private TheaterOfHorrorsExileEffect(final TheaterOfHorrorsExileEffect effect) { + super(effect); + } + + @Override + public TheaterOfHorrorsExileEffect copy() { + return new TheaterOfHorrorsExileEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + Card card = player.getLibrary().getFromTop(game); + if (card == null) { + return false; + } + return player.moveCardsToExile( + card, source, game, true, CardUtil.getCardExileZoneId(game, source), + CardUtil.createObjectRealtedWindowTitle(source, game, null) + ); + } +} + +class TheaterOfHorrorsCastEffect extends AsThoughEffectImpl { + + TheaterOfHorrorsCastEffect() { + super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.EndOfGame, Outcome.Benefit); + staticText = "During your turn, if an opponent lost life this turn, " + + "you may play cards exiled with {this}"; + } + + private TheaterOfHorrorsCastEffect(final TheaterOfHorrorsCastEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public TheaterOfHorrorsCastEffect copy() { + return new TheaterOfHorrorsCastEffect(this); + } + + @Override + public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { + PlayerLostLifeWatcher watcher = game.getState().getWatcher(PlayerLostLifeWatcher.class); + if (watcher != null && game.isActivePlayer(source.getControllerId()) + && watcher.getAllOppLifeLost(source.getControllerId(), game) > 0 + && affectedControllerId.equals(source.getControllerId()) + && game.getState().getZone(objectId) == Zone.EXILED) { + ExileZone zone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source)); + return zone != null && zone.contains(objectId); + } + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/RavnicaAllegiance.java b/Mage.Sets/src/mage/sets/RavnicaAllegiance.java index cd845434ad..c27deabc83 100644 --- a/Mage.Sets/src/mage/sets/RavnicaAllegiance.java +++ b/Mage.Sets/src/mage/sets/RavnicaAllegiance.java @@ -139,6 +139,7 @@ public final class RavnicaAllegiance extends ExpansionSet { cards.add(new SetCardInfo("Syndicate Guildmage", 211, Rarity.UNCOMMON, mage.cards.s.SyndicateGuildmage.class)); cards.add(new SetCardInfo("Teysa Karlov", 212, Rarity.RARE, mage.cards.t.TeysaKarlov.class)); cards.add(new SetCardInfo("The Haunt of Hightower", 273, Rarity.MYTHIC, mage.cards.t.TheHauntOfHightower.class)); + cards.add(new SetCardInfo("Theater of Horrors", 213, Rarity.RARE, mage.cards.t.TheaterOfHorrors.class)); cards.add(new SetCardInfo("Titanic Brawl", 146, Rarity.COMMON, mage.cards.t.TitanicBrawl.class)); cards.add(new SetCardInfo("Tithe Taker", 27, Rarity.RARE, mage.cards.t.TitheTaker.class)); cards.add(new SetCardInfo("Trollbred Guardian", 148, Rarity.UNCOMMON, mage.cards.t.TrollbredGuardian.class));