Implemented Teferi, Timeless Voyager

This commit is contained in:
Evan Kranzler 2020-06-29 20:53:05 -04:00
parent e9672dce5e
commit d70db82dd9
2 changed files with 141 additions and 0 deletions

View file

@ -0,0 +1,140 @@
package mage.cards.t;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.LoyaltyAbility;
import mage.abilities.common.PlaneswalkerEntersWithLoyaltyCountersAbility;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.PutOnLibraryTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
import mage.target.common.TargetOpponent;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class TeferiTimelessVoyager extends CardImpl {
public TeferiTimelessVoyager(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.PLANESWALKER}, "{4}{U}{U}");
this.addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.TEFERI);
this.addAbility(new PlaneswalkerEntersWithLoyaltyCountersAbility(4));
// +1: Draw a card.
this.addAbility(new LoyaltyAbility(new DrawCardSourceControllerEffect(1), 1));
// 3: Put target creature on top of its owner's library.
Ability ability = new LoyaltyAbility(new PutOnLibraryTargetEffect(true), -3);
ability.addTarget(new TargetCreaturePermanent());
this.addAbility(ability);
// 8: Each creature target opponent controls phases out. Until the end of your next turn, they can't phase in.
ability = new LoyaltyAbility(new TeferiTimelessVoyagerEffect(), -8);
ability.addTarget(new TargetOpponent());
this.addAbility(ability);
}
private TeferiTimelessVoyager(final TeferiTimelessVoyager card) {
super(card);
}
@Override
public TeferiTimelessVoyager copy() {
return new TeferiTimelessVoyager(this);
}
}
class TeferiTimelessVoyagerEffect extends OneShotEffect {
TeferiTimelessVoyagerEffect() {
super(Outcome.Benefit);
staticText = "each creature target opponent controls phases out. " +
"Until the end of your next turn, they can't phase in";
}
private TeferiTimelessVoyagerEffect(final TeferiTimelessVoyagerEffect effect) {
super(effect);
}
@Override
public TeferiTimelessVoyagerEffect copy() {
return new TeferiTimelessVoyagerEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
for (Permanent permanent : game
.getBattlefield()
.getAllActivePermanents(
StaticFilters.FILTER_PERMANENT_CREATURE, source.getFirstTarget(), game
)) {
MageObjectReference mor = new MageObjectReference(permanent, game);
permanent.phaseOut(game);
game.addEffect(new TeferiTimelessVoyagerPhaseEffect(mor), source);
}
return true;
}
}
class TeferiTimelessVoyagerPhaseEffect extends ContinuousRuleModifyingEffectImpl {
private int castOnTurn = 0;
private final MageObjectReference mor;
TeferiTimelessVoyagerPhaseEffect(MageObjectReference mor) {
super(Duration.Custom, Outcome.Neutral);
this.mor = mor;
}
private TeferiTimelessVoyagerPhaseEffect(final TeferiTimelessVoyagerPhaseEffect effect) {
super(effect);
this.castOnTurn = effect.castOnTurn;
this.mor = effect.mor;
}
@Override
public TeferiTimelessVoyagerPhaseEffect copy() {
return new TeferiTimelessVoyagerPhaseEffect(this);
}
@Override
public void init(Ability source, Game game) {
super.init(source, game);
castOnTurn = game.getTurnNum();
}
@Override
public boolean isInactive(Ability source, Game game) {
if (castOnTurn != game.getTurnNum() && game.getPhase().getStep().getType() == PhaseStep.END_TURN) {
return game.isActivePlayer(source.getControllerId());
}
return false;
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.PHASE_IN;
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
return this.mor.refersTo(event.getTargetId(), game);
}
}

View file

@ -272,6 +272,7 @@ public final class CoreSet2021 extends ExpansionSet {
cards.add(new SetCardInfo("Teferi's Tutelage", 78, Rarity.UNCOMMON, mage.cards.t.TeferisTutelage.class)); cards.add(new SetCardInfo("Teferi's Tutelage", 78, Rarity.UNCOMMON, mage.cards.t.TeferisTutelage.class));
cards.add(new SetCardInfo("Teferi's Wavecaster", 327, Rarity.RARE, mage.cards.t.TeferisWavecaster.class)); cards.add(new SetCardInfo("Teferi's Wavecaster", 327, Rarity.RARE, mage.cards.t.TeferisWavecaster.class));
cards.add(new SetCardInfo("Teferi, Master of Time", 75, Rarity.MYTHIC, mage.cards.t.TeferiMasterOfTime.class)); cards.add(new SetCardInfo("Teferi, Master of Time", 75, Rarity.MYTHIC, mage.cards.t.TeferiMasterOfTime.class));
cards.add(new SetCardInfo("Teferi, Timeless Voyager", 324, Rarity.MYTHIC, mage.cards.t.TeferiTimelessVoyager.class));
cards.add(new SetCardInfo("Tempered Veteran", 41, Rarity.UNCOMMON, mage.cards.t.TemperedVeteran.class)); cards.add(new SetCardInfo("Tempered Veteran", 41, Rarity.UNCOMMON, mage.cards.t.TemperedVeteran.class));
cards.add(new SetCardInfo("Temple of Epiphany", 252, Rarity.RARE, mage.cards.t.TempleOfEpiphany.class)); cards.add(new SetCardInfo("Temple of Epiphany", 252, Rarity.RARE, mage.cards.t.TempleOfEpiphany.class));
cards.add(new SetCardInfo("Temple of Malady", 253, Rarity.RARE, mage.cards.t.TempleOfMalady.class)); cards.add(new SetCardInfo("Temple of Malady", 253, Rarity.RARE, mage.cards.t.TempleOfMalady.class));