// cards in Graveyard
int cardsCount = (cardName.isEmpty() ? 0 :targetPlayer.getGraveyard().count(filter, game));
if (cardsCount > 0) {
filter.setMessage("card named " + cardName + " in the graveyard of " + targetPlayer.getName());
TargetCard target = new TargetCard((graveyardExileOptional ? 0 :cardsCount), cardsCount,Zone.GRAVEYARD, filter);
if (controller.choose(Outcome.Exile, targetPlayer.getGraveyard(), target, game)) {
List<UUID> targets = target.getTargets();
for (UUID targetId : targets) {
Card targetCard = targetPlayer.getGraveyard().get(targetId, game);
if (targetCard != null) {
targetPlayer.getGraveyard().remove(targetCard);
controller.moveCardToExileWithInfo(targetCard, null, null, source.getSourceId(), game, Zone.GRAVEYARD);
}
}
}
}
// cards in Hand
cardsCount = (cardName.isEmpty() ? 0 :targetPlayer.getHand().count(filter, game));
if (cardsCount > 0) {
filter.setMessage("card named " + cardName + " in the hand of " + targetPlayer.getName());
TargetCard target = new TargetCard(0, cardsCount, Zone.HAND, filter);
if (controller.choose(Outcome.Exile, targetPlayer.getHand(), target, game)) {
List<UUID> targets = target.getTargets();
for (UUID targetId : targets) {
Card targetCard = targetPlayer.getHand().get(targetId, game);
if (targetCard != null) {
targetPlayer.getHand().remove(targetCard);
controller.moveCardToExileWithInfo(targetCard, null, null, source.getSourceId(), game, Zone.HAND);
}
}
}
} else {
if (targetPlayer.getHand().size() > 0) {
controller.lookAtCards(targetPlayer.getName() + " hand", targetPlayer.getHand(), game);
}
}
// cards in Library
Cards cardsInLibrary = new CardsImpl(Zone.LIBRARY);
cardsInLibrary.addAll(targetPlayer.getLibrary().getCards(game));
cardsCount = (cardName.isEmpty() ? 0 : cardsInLibrary.count(filter, game));
if (cardsCount > 0) {
filter.setMessage("card named " + cardName + " in the library of " + targetPlayer.getName());
TargetCardInLibrary target = new TargetCardInLibrary(0, cardsCount, filter);
if (controller.choose(Outcome.Exile, cardsInLibrary, target, game)) {
List<UUID> targets = target.getTargets();
for (UUID targetId : targets) {
Card targetCard = targetPlayer.getLibrary().remove(targetId, game);
if (targetCard != null) {
controller.moveCardToExileWithInfo(targetCard, null, null, source.getSourceId(), game, Zone.LIBRARY);
}