Cards allCards = new CardsImpl(Zone.PICK);
Cards cards = new CardsImpl(Zone.PICK);
allCards.addAll(player.getLibrary().getCardList());
allCards.addAll(player.getGraveyard());
int number = Math.min(5, allCards.size());
TargetCard target = new TargetCard(number, number, Zone.PICK, new FilterCard());
if (player.choose(Outcome.Benefit, allCards, target, game)){
// exile the rest
for(UUID uuid : allCards){
if(!target.getTargets().contains(uuid)){
Card card = game.getCard(uuid);
if(card != null){
card.moveToExile(null, "Doomsday", source.getSourceId(), game);
}
}
else{
cards.add(uuid);
}
}
//Put the chosen cards on top of your library in any order
target = new TargetCard(Zone.PICK, new FilterCard("Card to put on top"));
while (cards.size() > 1 && player.isInGame()) {
player.choose(Outcome.Neutral, cards, target, game);
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
}
target.clearChosen();
}
if (cards.size() == 1) {
Card card = cards.get(cards.iterator().next(), game);
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
}