1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-04-05 09:12:29 -09:00

Simplified several cards by replacing custom effects with ExileTopXMayPlayUntilEndOfTurnEffect ()

This commit is contained in:
Alex Vasile 2022-01-30 23:54:50 -05:00 committed by GitHub
parent 878dc7bd2e
commit c5baf413e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 18 additions and 399 deletions

View file

@ -2,22 +2,12 @@ package mage.cards.a;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.AsThoughEffectImpl;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect;
import mage.abilities.effects.common.ExileTopXMayPlayUntilEndOfTurnEffect;
import mage.abilities.keyword.ProwessAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Library;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
/**
*
@ -36,7 +26,7 @@ public final class AbbotOfKeralKeep extends CardImpl {
this.addAbility(new ProwessAbility());
// When Abbot of Keral Keep enters the battlefield, exile the top card of your library. Until end of turn, you may play that card.
this.addAbility(new EntersBattlefieldTriggeredAbility(new AbbotOfKeralKeepExileEffect()));
this.addAbility(new EntersBattlefieldTriggeredAbility(new ExileTopXMayPlayUntilEndOfTurnEffect(1)));
}
private AbbotOfKeralKeep(final AbbotOfKeralKeep card) {
@ -48,67 +38,3 @@ public final class AbbotOfKeralKeep extends CardImpl {
return new AbbotOfKeralKeep(this);
}
}
class AbbotOfKeralKeepExileEffect extends OneShotEffect {
public AbbotOfKeralKeepExileEffect() {
super(Outcome.Detriment);
this.staticText = "exile the top card of your library. Until end of turn, you may play that card";
}
public AbbotOfKeralKeepExileEffect(final AbbotOfKeralKeepExileEffect effect) {
super(effect);
}
@Override
public AbbotOfKeralKeepExileEffect copy() {
return new AbbotOfKeralKeepExileEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (sourcePermanent != null && controller != null && controller.getLibrary().hasCards()) {
Library library = controller.getLibrary();
Card card = library.getFromTop(game);
if (card != null) {
String exileName = sourcePermanent.getIdName() + " <this card may be played the turn it was exiled>";
controller.moveCardsToExile(card, source, game, true, source.getSourceId(), exileName);
ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect(Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(card, game));
game.addEffect(effect, source);
}
return true;
}
return false;
}
}
class AbbotOfKeralKeepCastFromExileEffect extends AsThoughEffectImpl {
public AbbotOfKeralKeepCastFromExileEffect() {
super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.EndOfTurn, Outcome.Benefit);
staticText = "You may play the card from exile";
}
public AbbotOfKeralKeepCastFromExileEffect(final AbbotOfKeralKeepCastFromExileEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public AbbotOfKeralKeepCastFromExileEffect copy() {
return new AbbotOfKeralKeepCastFromExileEffect(this);
}
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
return source.isControlledBy(affectedControllerId)
&& objectId.equals(getTargetPointer().getFirst(game, source));
}
}

View file

@ -2,26 +2,14 @@ package mage.cards.a;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect;
import mage.abilities.effects.common.ExileTopXMayPlayUntilEndOfTurnEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Library;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
/**
*
@ -41,7 +29,10 @@ public final class AerialCaravan extends CardImpl {
this.addAbility(FlyingAbility.getInstance());
// {1}{U}{U}: Exile the top card of your library. Until end of turn, you may play that card.
this.addAbility(new SimpleActivatedAbility(new AerialCaravanExileEffect(), new ManaCostsImpl("{1}{U}{U}")));
this.addAbility(new SimpleActivatedAbility(
new ExileTopXMayPlayUntilEndOfTurnEffect(1).setText("Exile the top card of your library. " +
"Until end of turn, you may play that card. <i>(Reveal the card as you exile it.)</i>"),
new ManaCostsImpl("{1}{U}{U}")));
}
private AerialCaravan(final AerialCaravan card) {
@ -53,39 +44,3 @@ public final class AerialCaravan extends CardImpl {
return new AerialCaravan(this);
}
}
class AerialCaravanExileEffect extends OneShotEffect {
public AerialCaravanExileEffect() {
super(Outcome.Detriment);
this.staticText = "Exile the top card of your library. Until end of turn, you may play that card";
}
public AerialCaravanExileEffect(final AerialCaravanExileEffect effect) {
super(effect);
}
@Override
public AerialCaravanExileEffect copy() {
return new AerialCaravanExileEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (sourcePermanent != null && controller != null && controller.getLibrary().hasCards()) {
Library library = controller.getLibrary();
Card card = library.getFromTop(game);
if (card != null) {
String exileName = sourcePermanent.getIdName() + " <this card may be played the turn it was exiled>";
controller.moveCardsToExile(card, source, game, true, source.getSourceId(), exileName);
ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(card, game));
game.addEffect(effect, source);
}
return true;
}
return false;
}
}

View file

@ -3,26 +3,15 @@ package mage.cards.i;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.TurnedFaceUpSourceTriggeredAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.AsThoughEffectImpl;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ExileTopXMayPlayUntilEndOfTurnEffect;
import mage.abilities.keyword.MenaceAbility;
import mage.abilities.keyword.MorphAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AsThoughEffectType;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
/**
*
@ -44,7 +33,7 @@ public final class IreShaman extends CardImpl {
this.addAbility(new MorphAbility(this, new ManaCostsImpl("{R}"), true));
// When Ire Shaman is turned face up, exile the top card of your library. Until end of turn, you may play that card.
this.addAbility(new TurnedFaceUpSourceTriggeredAbility(new IreShamanExileEffect(), false));
this.addAbility(new TurnedFaceUpSourceTriggeredAbility(new ExileTopXMayPlayUntilEndOfTurnEffect(1), false));
}
private IreShaman(final IreShaman card) {
@ -56,66 +45,3 @@ public final class IreShaman extends CardImpl {
return new IreShaman(this);
}
}
class IreShamanExileEffect extends OneShotEffect {
public IreShamanExileEffect() {
super(Outcome.Detriment);
this.staticText = "exile the top card of your library. Until end of turn, you may play that card";
}
public IreShamanExileEffect(final IreShamanExileEffect effect) {
super(effect);
}
@Override
public IreShamanExileEffect copy() {
return new IreShamanExileEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (sourcePermanent != null && controller != null && controller.getLibrary().hasCards()) {
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
String exileName = sourcePermanent.getIdName() + " <this card may be played the turn it was exiled>";
controller.moveCardsToExile(card, source, game, true, source.getSourceId(), exileName);
ContinuousEffect effect = new IreShamanCastFromExileEffect();
effect.setTargetPointer(new FixedTarget(card.getId()));
game.addEffect(effect, source);
}
return true;
}
return false;
}
}
class IreShamanCastFromExileEffect extends AsThoughEffectImpl {
public IreShamanCastFromExileEffect() {
super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.EndOfTurn, Outcome.Benefit);
staticText = "You may play the card from exile";
}
public IreShamanCastFromExileEffect(final IreShamanCastFromExileEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public IreShamanCastFromExileEffect copy() {
return new IreShamanCastFromExileEffect(this);
}
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
return source.isControlledBy(affectedControllerId)
&& objectId.equals(getTargetPointer().getFirst(game, source));
}
}

View file

@ -8,6 +8,7 @@ import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.decorator.ConditionalActivatedAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ExileTopXMayPlayUntilEndOfTurnEffect;
import mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.CardImpl;
@ -27,13 +28,12 @@ public final class OraclesVault extends CardImpl {
public OraclesVault(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}");
// {2}, {T}: Exile the top card of your library. Until end of turn, you may play that card. Put a brick counter on Oracle's Vault.
Effect effect = new OraclesVaultEffect();
effect.setText("Exile the top card of your library. Until end of turn, you may play that card");
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new GenericManaCost(2));
// {2}, {T}: Exile the top card of your library. Until end of turn, you may play that card.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ExileTopXMayPlayUntilEndOfTurnEffect(1), new GenericManaCost(2));
ability.addCost(new TapSourceCost());
// Put a brick counter on Oracle's Vault.
Effect effect2 = new AddCountersSourceEffect(CounterType.BRICK.createInstance());
effect2.setText("Put a brick counter on {this}");
ability.addEffect(effect2);
this.addAbility(ability);
@ -55,32 +55,6 @@ public final class OraclesVault extends CardImpl {
}
}
class OraclesVaultEffect extends OneShotEffect {
public OraclesVaultEffect() {
super(Outcome.Benefit);
}
public OraclesVaultEffect(final OraclesVaultEffect effect) {
super(effect);
}
@Override
public OraclesVaultEffect copy() {
return new OraclesVaultEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
return PlayFromNotOwnHandZoneTargetEffect.exileAndPlayFromExile(game, source, controller.getLibrary().getFromTop(game),
TargetController.YOU, Duration.EndOfTurn, false, false, false);
}
return false;
}
}
class OraclesVaultFreeEffect extends OneShotEffect {
public OraclesVaultFreeEffect() {

View file

@ -7,26 +7,16 @@ import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.common.ZoneChangeAllTriggeredAbility;
import mage.abilities.condition.common.ModeChoiceSourceCondition;
import mage.abilities.decorator.ConditionalTriggeredAbility;
import mage.abilities.effects.AsThoughEffectImpl;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ChooseModeEffect;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.cards.Card;
import mage.abilities.effects.common.ExileTopXMayPlayUntilEndOfTurnEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AsThoughEffectType;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetAnyTarget;
import mage.target.targetpointer.FixedTarget;
/**
*
@ -46,7 +36,7 @@ public final class OutpostSiege extends CardImpl {
// * Khans - At the beginning of your upkeep, exile the top card of your library. Until end of turn, you may play that card.
this.addAbility(new ConditionalTriggeredAbility(
new BeginningOfUpkeepTriggeredAbility(new OutpostSiegeExileEffect(), TargetController.YOU, false),
new BeginningOfUpkeepTriggeredAbility(new ExileTopXMayPlayUntilEndOfTurnEffect(1), TargetController.YOU, false),
new ModeChoiceSourceCondition("Khans"),
ruleTrigger1));
@ -70,79 +60,3 @@ public final class OutpostSiege extends CardImpl {
return new OutpostSiege(this);
}
}
class OutpostSiegeExileEffect extends OneShotEffect {
public OutpostSiegeExileEffect() {
super(Outcome.Benefit);
this.staticText = "exile the top card of your library. Until end of turn, you may play that card";
}
public OutpostSiegeExileEffect(final OutpostSiegeExileEffect effect) {
super(effect);
}
@Override
public OutpostSiegeExileEffect copy() {
return new OutpostSiegeExileEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (controller != null && sourcePermanent != null) {
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
String exileName = sourcePermanent.getIdName() + " <this card may be played the turn it was exiled";
controller.moveCardsToExile(card, source, game, true, source.getSourceId(), exileName);
if (game.getState().getZone(card.getId()) == Zone.EXILED) {
ContinuousEffect effect = new CastFromNonHandZoneTargetEffect(Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(card, game));
game.addEffect(effect, source);
}
}
return true;
}
return false;
}
}
class CastFromNonHandZoneTargetEffect extends AsThoughEffectImpl {
public CastFromNonHandZoneTargetEffect(Duration duration) {
super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, duration, Outcome.Benefit);
staticText = "until end of turn, you may play that card";
}
public CastFromNonHandZoneTargetEffect(final CastFromNonHandZoneTargetEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public CastFromNonHandZoneTargetEffect copy() {
return new CastFromNonHandZoneTargetEffect(this);
}
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
Card theCard = game.getCard(objectId);
if (theCard == null) {
return false;
}
objectId = theCard.getMainCard().getId(); // for split cards and mdfc
if (getTargetPointer().getTargets(game, source).contains(objectId)
&& source.isControlledBy(affectedControllerId)) {
Card card = game.getCard(objectId);
if (card != null) {
return true;
}
}
return false;
}
}

View file

@ -3,27 +3,15 @@ package mage.cards.s;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.AsThoughEffectImpl;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ExileTopXMayPlayUntilEndOfTurnEffect;
import mage.abilities.keyword.MadnessAbility;
import mage.abilities.keyword.TrampleAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AsThoughEffectType;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
/**
*
@ -42,7 +30,7 @@ public final class StromkirkOccultist extends CardImpl {
this.addAbility(TrampleAbility.getInstance());
// Whenever Stromkirk Mystic deals combat damage to a player, exile the top card of your library. Until end of turn, you may play that card.
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new StromkirkOccultistExileEffect(), false));
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new ExileTopXMayPlayUntilEndOfTurnEffect(1), false));
// Madness {1}{R}
this.addAbility(new MadnessAbility(this, new ManaCostsImpl("{1}{R}")));
@ -57,67 +45,3 @@ public final class StromkirkOccultist extends CardImpl {
return new StromkirkOccultist(this);
}
}
class StromkirkOccultistExileEffect extends OneShotEffect {
public StromkirkOccultistExileEffect() {
super(Outcome.Detriment);
this.staticText = "exile the top card of your library. Until end of turn, you may play that card";
}
public StromkirkOccultistExileEffect(final StromkirkOccultistExileEffect effect) {
super(effect);
}
@Override
public StromkirkOccultistExileEffect copy() {
return new StromkirkOccultistExileEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (sourcePermanent != null && controller != null && controller.getLibrary().hasCards()) {
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
String exileName = sourcePermanent.getIdName() + " <this card may be played the turn it was exiled>";
if (controller.moveCardToExileWithInfo(card, source.getSourceId(), exileName, source, game, Zone.LIBRARY, true)) {
ContinuousEffect effect = new StromkirkOccultistPlayFromExileEffect();
effect.setTargetPointer(new FixedTarget(card.getId()));
game.addEffect(effect, source);
}
}
return true;
}
return false;
}
}
class StromkirkOccultistPlayFromExileEffect extends AsThoughEffectImpl {
public StromkirkOccultistPlayFromExileEffect() {
super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.EndOfTurn, Outcome.Benefit);
staticText = "You may play the card from exile";
}
public StromkirkOccultistPlayFromExileEffect(final StromkirkOccultistPlayFromExileEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public StromkirkOccultistPlayFromExileEffect copy() {
return new StromkirkOccultistPlayFromExileEffect(this);
}
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
return source.isControlledBy(affectedControllerId)
&& objectId.equals(getTargetPointer().getFirst(game, source));
}
}