mirror of
https://github.com/correl/mage.git
synced 2024-11-14 19:19:32 +00:00
Refactor: Flattened Elkin Lair
This commit is contained in:
parent
21e5d36962
commit
35652be152
1 changed files with 38 additions and 29 deletions
|
@ -35,7 +35,9 @@ public final class ElkinLair extends CardImpl {
|
|||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{R}");
|
||||
addSuperType(SuperType.WORLD);
|
||||
|
||||
// At the beginning of each player's upkeep, that player exiles a card at random from their hand. The player may play that card this turn. At the beginning of the next end step, if the player hasn't played the card, they put it into their graveyard.
|
||||
// At the beginning of each player's upkeep, that player exiles a card at random from their hand.
|
||||
// The player may play that card this turn.
|
||||
// At the beginning of the next end step, if the player hasn't played the card, they put it into their graveyard.
|
||||
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new ElkinLairUpkeepEffect(), TargetController.ANY, false));
|
||||
|
||||
}
|
||||
|
@ -74,28 +76,32 @@ class ElkinLairUpkeepEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(game.getActivePlayerId());
|
||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||
if (player != null
|
||||
&& sourcePermanent != null) {
|
||||
Card[] cards = player.getHand().getCards(new FilterCard(), game).toArray(new Card[0]);
|
||||
if (cards.length > 0) {
|
||||
Card card = cards[RandomUtil.nextInt(cards.length)];
|
||||
if (card != null) {
|
||||
String exileName = sourcePermanent.getIdName() + " <this card may be played the turn it was exiled";
|
||||
player.moveCardsToExile(card, source, game, true, source.getSourceId(), exileName);
|
||||
if (game.getState().getZone(card.getId()) == Zone.EXILED) {
|
||||
ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, TargetController.OWNER, Duration.EndOfTurn);
|
||||
effect.setTargetPointer(new FixedTarget(card, game));
|
||||
game.addEffect(effect, source);
|
||||
DelayedTriggeredAbility delayed
|
||||
= new AtTheBeginOfNextEndStepDelayedTriggeredAbility(
|
||||
new ElkinLairPutIntoGraveyardEffect());
|
||||
game.addDelayedTriggeredAbility(delayed, source);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (player == null || sourcePermanent == null) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
Card[] cards = player.getHand().getCards(new FilterCard(), game).toArray(new Card[0]);
|
||||
if (cards.length == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Card card = cards[RandomUtil.nextInt(cards.length)];
|
||||
if (card == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String exileName = sourcePermanent.getIdName() + " <this card may be played the turn it was exiled";
|
||||
player.moveCardsToExile(card, source, game, true, source.getSourceId(), exileName);
|
||||
if (game.getState().getZone(card.getId()) != Zone.EXILED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, TargetController.OWNER, Duration.EndOfTurn);
|
||||
effect.setTargetPointer(new FixedTarget(card, game));
|
||||
game.addEffect(effect, source);
|
||||
DelayedTriggeredAbility delayed = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ElkinLairPutIntoGraveyardEffect());
|
||||
game.addDelayedTriggeredAbility(delayed, source);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,14 +119,17 @@ class ElkinLairPutIntoGraveyardEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(game.getActivePlayerId());
|
||||
if (player != null) {
|
||||
Set<Card> cardsInExile = game.getExile().getExileZone(source.getSourceId()).getCards(game);
|
||||
if (cardsInExile != null) {
|
||||
player.moveCardsToGraveyardWithInfo(cardsInExile, source, game, Zone.EXILED);
|
||||
return true;
|
||||
}
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
Set<Card> cardsInExile = game.getExile().getExileZone(source.getSourceId()).getCards(game);
|
||||
if (cardsInExile == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
player.moveCardsToGraveyardWithInfo(cardsInExile, source, game, Zone.EXILED);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue