From 4586527fb274fad3e38080c5f458c52f67df176c Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sun, 6 Nov 2022 09:06:02 -0500 Subject: [PATCH] [BRO] Implement Visions of Phyrexia --- .../src/mage/cards/v/VisionsOfPhyrexia.java | 106 ++++++++++++++++++ Mage.Sets/src/mage/sets/TheBrothersWar.java | 1 + 2 files changed, 107 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/v/VisionsOfPhyrexia.java diff --git a/Mage.Sets/src/mage/cards/v/VisionsOfPhyrexia.java b/Mage.Sets/src/mage/cards/v/VisionsOfPhyrexia.java new file mode 100644 index 0000000000..8600e10557 --- /dev/null +++ b/Mage.Sets/src/mage/cards/v/VisionsOfPhyrexia.java @@ -0,0 +1,106 @@ +package mage.cards.v; + +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfEndStepTriggeredAbility; +import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; +import mage.abilities.condition.Condition; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.abilities.effects.common.ExileTopXMayPlayUntilEndOfTurnEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.TargetController; +import mage.constants.WatcherScope; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.token.PowerstoneToken; +import mage.game.stack.Spell; +import mage.watchers.Watcher; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class VisionsOfPhyrexia extends CardImpl { + + public VisionsOfPhyrexia(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{R}{R}"); + + // At the beginning of your upkeep, exile the top card of your library. You may play that card this turn. + this.addAbility(new BeginningOfUpkeepTriggeredAbility( + new ExileTopXMayPlayUntilEndOfTurnEffect(1), TargetController.YOU, false + )); + + // At the beginning of your end step, if you didn't play a card from exile this turn, create a tapped Powerstone token. + this.addAbility(new BeginningOfEndStepTriggeredAbility( + new CreateTokenEffect(new PowerstoneToken(), 1, true), + TargetController.YOU, VisionsOfPhyrexiaCondition.instance, false + ), new VisionsOfPhyrexiaConditionWatcher()); + } + + private VisionsOfPhyrexia(final VisionsOfPhyrexia card) { + super(card); + } + + @Override + public VisionsOfPhyrexia copy() { + return new VisionsOfPhyrexia(this); + } +} + +enum VisionsOfPhyrexiaCondition implements Condition { + instance; + + @Override + public boolean apply(Game game, Ability source) { + return !VisionsOfPhyrexiaConditionWatcher.checkPlayer(game, source); + } + + @Override + public String toString() { + return "you didn't play a card from exile this turn"; + } +} + +class VisionsOfPhyrexiaConditionWatcher extends Watcher { + + private final Set playerSet = new HashSet<>(); + + VisionsOfPhyrexiaConditionWatcher() { + super(WatcherScope.GAME); + } + + @Override + public void watch(GameEvent event, Game game) { + switch (event.getType()) { + case LAND_PLAYED: + if (Zone.EXILED.match(event.getZone())) { + playerSet.add(event.getPlayerId()); + } + return; + case SPELL_CAST: + Spell spell = game.getSpell(event.getTargetId()); + if (spell != null && Zone.EXILED.match(spell.getFromZone())) { + playerSet.add(spell.getControllerId()); + } + } + } + + @Override + public void reset() { + super.reset(); + playerSet.clear(); + } + + static boolean checkPlayer(Game game, Ability source) { + return game + .getState() + .getWatcher(VisionsOfPhyrexiaConditionWatcher.class) + .playerSet + .add(source.getControllerId()); + } +} diff --git a/Mage.Sets/src/mage/sets/TheBrothersWar.java b/Mage.Sets/src/mage/sets/TheBrothersWar.java index 5fde1b714d..49a993b393 100644 --- a/Mage.Sets/src/mage/sets/TheBrothersWar.java +++ b/Mage.Sets/src/mage/sets/TheBrothersWar.java @@ -262,6 +262,7 @@ public final class TheBrothersWar extends ExpansionSet { cards.add(new SetCardInfo("Urza, Powerstone Prodigy", 69, Rarity.UNCOMMON, mage.cards.u.UrzaPowerstoneProdigy.class)); cards.add(new SetCardInfo("Urza, Prince of Kroog", 226, Rarity.RARE, mage.cards.u.UrzaPrinceOfKroog.class)); cards.add(new SetCardInfo("Veteran's Powerblade", 41, Rarity.COMMON, mage.cards.v.VeteransPowerblade.class)); + cards.add(new SetCardInfo("Visions of Phyrexia", 156, Rarity.RARE, mage.cards.v.VisionsOfPhyrexia.class)); cards.add(new SetCardInfo("Warlord's Elite", 32, Rarity.COMMON, mage.cards.w.WarlordsElite.class)); cards.add(new SetCardInfo("Wasteful Harvest", 196, Rarity.COMMON, mage.cards.w.WastefulHarvest.class)); cards.add(new SetCardInfo("Weakstone's Subjugation", 72, Rarity.COMMON, mage.cards.w.WeakstonesSubjugation.class));