From 35652be1520c345f13571cb449b9c4646be7ca38 Mon Sep 17 00:00:00 2001 From: Alex Vasile <48962821+Alex-Vasile@users.noreply.github.com> Date: Sun, 3 Jul 2022 17:57:48 -0400 Subject: [PATCH] Refactor: Flattened Elkin Lair --- Mage.Sets/src/mage/cards/e/ElkinLair.java | 67 +++++++++++++---------- 1 file changed, 38 insertions(+), 29 deletions(-) diff --git a/Mage.Sets/src/mage/cards/e/ElkinLair.java b/Mage.Sets/src/mage/cards/e/ElkinLair.java index fc3e806532b..e57b06a63ed 100644 --- a/Mage.Sets/src/mage/cards/e/ElkinLair.java +++ b/Mage.Sets/src/mage/cards/e/ElkinLair.java @@ -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() + " 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 cardsInExile = game.getExile().getExileZone(source.getSourceId()).getCards(game); + if (cardsInExile == null) { + return false; + } + + player.moveCardsToGraveyardWithInfo(cardsInExile, source, game, Zone.EXILED); + return true; } @Override