diff --git a/Mage.Sets/src/mage/sets/apocalypse/GoblinRingleader.java b/Mage.Sets/src/mage/sets/apocalypse/GoblinRingleader.java index 9294c654d7..20ff8370a0 100644 --- a/Mage.Sets/src/mage/sets/apocalypse/GoblinRingleader.java +++ b/Mage.Sets/src/mage/sets/apocalypse/GoblinRingleader.java @@ -28,10 +28,8 @@ package mage.sets.apocalypse; import java.util.UUID; - -import mage.constants.CardType; -import mage.constants.Rarity; import mage.MageInt; +import mage.MageObject; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.effects.OneShotEffect; @@ -40,13 +38,14 @@ import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.Cards; import mage.cards.CardsImpl; +import mage.constants.CardType; import mage.constants.Outcome; +import mage.constants.Rarity; import mage.constants.Zone; import mage.filter.FilterCard; import mage.filter.predicate.mageobject.SubtypePredicate; import mage.game.Game; import mage.players.Player; -import mage.target.TargetCard; /** * @@ -102,38 +101,21 @@ class GoblinRingleaderEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player != null) { - Cards cards = new CardsImpl(Zone.PICK); - Cards cards2 = new CardsImpl(Zone.PICK); - int count = Math.min(player.getLibrary().size(), 4); - for (int i = 0; i < count; i++) { - Card card = player.getLibrary().removeFromTop(game); - if (card != null) { - cards.add(card); - game.setZone(card.getId(), Zone.PICK); - if (filter.match(card, game)) { - card.moveToZone(Zone.HAND, source.getSourceId(), game, true); - } else { - cards2.add(card); - } - } - } - - Card sourceCard = game.getCard(source.getSourceId()); - if (!cards.isEmpty() && sourceCard != null) { - player.revealCards(sourceCard.getName(), cards, game); - } - TargetCard target = new TargetCard(Zone.PICK, new FilterCard("card to put on the bottom of your library")); - while (player.isInGame() && cards2.size() > 0 && player.choose(Outcome.Detriment, cards2, target, game)) { - Card card = cards.get(target.getFirstTarget(), game); - if (card != null) { - cards2.remove(card); - card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false); - } - target.clearChosen(); + Player controller = game.getPlayer(source.getControllerId()); + MageObject sourceObject = game.getObject(source.getSourceId()); + if (controller == null || sourceObject == null) { + return false; + } + Cards cards = new CardsImpl(); + cards.addAll(controller.getLibrary().getTopCards(game, 4)); + controller.revealCards(sourceObject.getLogName(), cards, game); + for (Card card: cards.getCards(game)) { + if (filter.match(card, game)) { + controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); + cards.remove(card); } } + controller.putCardsOnBottomOfLibrary(cards, game, source, true); return true; } }