mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
Refactored 4 exisiting cards to use ExileTopXMayPlayUntilEndOfTurnEffect (#7401)
This commit is contained in:
parent
8580c0a196
commit
65aa3e95ec
5 changed files with 31 additions and 254 deletions
|
@ -7,11 +7,9 @@ import mage.abilities.StaticAbility;
|
|||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.ExileTopXMayPlayUntilEndOfTurnEffect;
|
||||
import mage.abilities.effects.common.InfoEffect;
|
||||
import mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect;
|
||||
import mage.abilities.effects.common.continuous.SetPowerSourceEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
|
@ -23,9 +21,6 @@ import mage.game.Game;
|
|||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Library;
|
||||
import mage.players.Player;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
|
@ -57,7 +52,7 @@ public final class BellBorcaSpectralSergeant extends CardImpl {
|
|||
|
||||
// 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 BellBorcaSpectralSergeantEffect(), TargetController.YOU, false
|
||||
new ExileTopXMayPlayUntilEndOfTurnEffect(1), TargetController.YOU, false
|
||||
), new BellBorcaSpectralSergeantWatcher());
|
||||
}
|
||||
|
||||
|
@ -156,40 +151,3 @@ class BellBorcaSpectralSergeantWatcher extends Watcher {
|
|||
return cmcMap.getOrDefault(sourceId, 0);
|
||||
}
|
||||
}
|
||||
|
||||
class BellBorcaSpectralSergeantEffect extends OneShotEffect {
|
||||
|
||||
BellBorcaSpectralSergeantEffect() {
|
||||
super(Outcome.Benefit);
|
||||
staticText = "exile the top card of your library. You may play that card this turn";
|
||||
}
|
||||
|
||||
private BellBorcaSpectralSergeantEffect(final BellBorcaSpectralSergeantEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BellBorcaSpectralSergeantEffect copy() {
|
||||
return new BellBorcaSpectralSergeantEffect(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()) {
|
||||
return false;
|
||||
}
|
||||
Library library = controller.getLibrary();
|
||||
Card card = library.getFromTop(game);
|
||||
if (card == null) {
|
||||
return true;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,24 +6,13 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.common.SacrificeTargetCost;
|
||||
import mage.abilities.costs.mana.GenericManaCost;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.abilities.effects.common.ExileTopXMayPlayUntilEndOfTurnEffect;
|
||||
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 static mage.filter.StaticFilters.FILTER_CONTROLLED_CREATURE_SHORT_TEXT;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Library;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetControlledCreaturePermanent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -41,7 +30,7 @@ public final class DarkDwellerOracle extends CardImpl {
|
|||
|
||||
// {1}, Sacrifice a creature: Exile the top card of your library. You may play that card this turn.
|
||||
Ability ability = new SimpleActivatedAbility(
|
||||
new DarkDwellerOracleExileEffect(),
|
||||
new ExileTopXMayPlayUntilEndOfTurnEffect(1, true),
|
||||
new GenericManaCost(1)
|
||||
);
|
||||
ability.addCost(new SacrificeTargetCost(new TargetControlledCreaturePermanent(FILTER_CONTROLLED_CREATURE_SHORT_TEXT)));
|
||||
|
@ -57,43 +46,3 @@ public final class DarkDwellerOracle extends CardImpl {
|
|||
return new DarkDwellerOracle(this);
|
||||
}
|
||||
}
|
||||
|
||||
class DarkDwellerOracleExileEffect extends OneShotEffect {
|
||||
|
||||
public DarkDwellerOracleExileEffect() {
|
||||
super(Outcome.Detriment);
|
||||
this.staticText = "exile the top card of your library. "
|
||||
+ "You may play that card this turn. "
|
||||
+ "<i>(You still pay its costs. "
|
||||
+ "You can play a land this way only if "
|
||||
+ "you have an available land play remaining.)</i>";
|
||||
}
|
||||
|
||||
public DarkDwellerOracleExileEffect(final DarkDwellerOracleExileEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DarkDwellerOracleExileEffect copy() {
|
||||
return new DarkDwellerOracleExileEffect(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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,21 +1,12 @@
|
|||
package mage.cards.g;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
|
||||
import mage.abilities.effects.AsThoughEffectImpl;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.abilities.effects.common.ExileTopXMayPlayUntilEndOfTurnEffect;
|
||||
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;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -33,7 +24,7 @@ public final class GrotagNightRunner extends CardImpl {
|
|||
this.toughness = new MageInt(3);
|
||||
|
||||
// Whenever Grotag Night-Runner deals combat damage to a player, exile the top card of your library. You may play that card this turn.
|
||||
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new GrotagNightRunnerExileEffect(), false));
|
||||
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new ExileTopXMayPlayUntilEndOfTurnEffect(1), false));
|
||||
}
|
||||
|
||||
private GrotagNightRunner(final GrotagNightRunner card) {
|
||||
|
@ -45,68 +36,3 @@ public final class GrotagNightRunner extends CardImpl {
|
|||
return new GrotagNightRunner(this);
|
||||
}
|
||||
}
|
||||
|
||||
class GrotagNightRunnerExileEffect extends OneShotEffect {
|
||||
|
||||
GrotagNightRunnerExileEffect() {
|
||||
super(Outcome.Detriment);
|
||||
this.staticText = "exile the top card of your library. You may play that card this turn.";
|
||||
}
|
||||
|
||||
private GrotagNightRunnerExileEffect(final GrotagNightRunnerExileEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrotagNightRunnerExileEffect copy() {
|
||||
return new GrotagNightRunnerExileEffect(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()) {
|
||||
return false;
|
||||
}
|
||||
Library library = controller.getLibrary();
|
||||
Card card = library.getFromTop(game);
|
||||
if (card == null) {
|
||||
return true;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
class GrotagNightRunnerCastFromExileEffect extends AsThoughEffectImpl {
|
||||
|
||||
GrotagNightRunnerCastFromExileEffect() {
|
||||
super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.EndOfTurn, Outcome.Benefit);
|
||||
staticText = "You may play the card from exile";
|
||||
}
|
||||
|
||||
private GrotagNightRunnerCastFromExileEffect(final GrotagNightRunnerCastFromExileEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrotagNightRunnerCastFromExileEffect copy() {
|
||||
return new GrotagNightRunnerCastFromExileEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
||||
return source.isControlledBy(affectedControllerId)
|
||||
&& objectId.equals(getTargetPointer().getFirst(game, source));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,23 +5,18 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.effects.AsThoughEffectImpl;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.DamageTargetEffect;
|
||||
import mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.abilities.effects.common.ExileTopXMayPlayUntilEndOfTurnEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.*;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.SuperType;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.players.Library;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetAnyTarget;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -61,7 +56,7 @@ public final class SyrCarahTheBold extends CardImpl {
|
|||
class SyrCarahTheBoldTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
SyrCarahTheBoldTriggeredAbility() {
|
||||
super(Zone.BATTLEFIELD, new SyrCarahTheBoldExileEffect(), false);
|
||||
super(Zone.BATTLEFIELD, new ExileTopXMayPlayUntilEndOfTurnEffect(1), false);
|
||||
}
|
||||
|
||||
private SyrCarahTheBoldTriggeredAbility(final SyrCarahTheBoldTriggeredAbility ability) {
|
||||
|
@ -93,68 +88,4 @@ class SyrCarahTheBoldTriggeredAbility extends TriggeredAbilityImpl {
|
|||
return "Whenever {this} or an instant or sorcery spell you control deals damage to a player, " +
|
||||
"exile the top card of your library. You may play that card this turn.";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class SyrCarahTheBoldExileEffect extends OneShotEffect {
|
||||
|
||||
SyrCarahTheBoldExileEffect() {
|
||||
super(Outcome.Detriment);
|
||||
}
|
||||
|
||||
private SyrCarahTheBoldExileEffect(final SyrCarahTheBoldExileEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SyrCarahTheBoldExileEffect copy() {
|
||||
return new SyrCarahTheBoldExileEffect(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()) {
|
||||
return false;
|
||||
}
|
||||
Library library = controller.getLibrary();
|
||||
Card card = library.getFromTop(game);
|
||||
if (card == null) {
|
||||
return true;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
class SyrCarahTheBoldCastFromExileEffect extends AsThoughEffectImpl {
|
||||
|
||||
SyrCarahTheBoldCastFromExileEffect() {
|
||||
super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.EndOfTurn, Outcome.Benefit);
|
||||
}
|
||||
|
||||
private SyrCarahTheBoldCastFromExileEffect(final SyrCarahTheBoldCastFromExileEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SyrCarahTheBoldCastFromExileEffect copy() {
|
||||
return new SyrCarahTheBoldCastFromExileEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
||||
return source.isControlledBy(affectedControllerId)
|
||||
&& objectId.equals(getTargetPointer().getFirst(game, source));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,15 +20,22 @@ import java.util.Set;
|
|||
public class ExileTopXMayPlayUntilEndOfTurnEffect extends OneShotEffect {
|
||||
|
||||
private final int amount;
|
||||
private final boolean showHint;
|
||||
|
||||
public ExileTopXMayPlayUntilEndOfTurnEffect(int amount) {
|
||||
this(amount, false);
|
||||
}
|
||||
|
||||
public ExileTopXMayPlayUntilEndOfTurnEffect(int amount, boolean showHint) {
|
||||
super(Outcome.Benefit);
|
||||
this.amount = amount;
|
||||
this.showHint = showHint;
|
||||
}
|
||||
|
||||
private ExileTopXMayPlayUntilEndOfTurnEffect(final ExileTopXMayPlayUntilEndOfTurnEffect effect) {
|
||||
super(effect);
|
||||
this.amount = effect.amount;
|
||||
this.showHint = effect.showHint;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -62,11 +69,17 @@ public class ExileTopXMayPlayUntilEndOfTurnEffect extends OneShotEffect {
|
|||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (amount == 1) {
|
||||
return "exile the top card of your library. You may play that card this turn";
|
||||
sb.append("exile the top card of your library. You may play that card this turn");
|
||||
} else {
|
||||
sb.append("exile the top ");
|
||||
sb.append(CardUtil.numberToText(amount));
|
||||
sb.append(" cards of your library. Until end of turn, you may play cards exiled this way");
|
||||
}
|
||||
return "exile the top " +
|
||||
CardUtil.numberToText(amount) +
|
||||
" cards of your library. Until end of turn, you may play cards exiled this way";
|
||||
if (showHint) {
|
||||
sb.append(". <i>(You still pay its costs. You can play a land this way only if you have an available land play remaining.)</i>");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue