[BRO] Implement Visions of Phyrexia

This commit is contained in:
Evan Kranzler 2022-11-06 09:06:02 -05:00
parent dc3d867584
commit 4586527fb2
2 changed files with 107 additions and 0 deletions

View file

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

View file

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