@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player targetPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (controller != null && targetPlayer != null) {
CardsImpl cards = new CardsImpl(targetPlayer.getLibrary().getTopCards(game, 3));
if (!cards.isEmpty()) {
controller.lookAtCards(source, null, cards, game);
TargetCard targetExile = new TargetCard(0, Integer.MAX_VALUE, Zone.LIBRARY, new FilterCard("cards to exile"));
if (controller.choose(Outcome.Exile, cards, targetExile, game)) {
Cards toExile = new CardsImpl(targetExile.getTargets());
controller.moveCards(toExile, Zone.EXILED, source, game);
cards.removeAll(toExile);
}
controller.putCardsOnTopOfLibrary(cards, game, source, true);
}
return true;
}
return false;
}
}