Player targetPlayer = game.getPlayer(card.getOwnerId());
if (targetPlayer != null) {
FilterCard filter = new FilterCard("card named " + card.getName());
filter.add(new NamePredicate(card.getName()));
Cards cardsInLibrary = new CardsImpl(Zone.LIBRARY);
cardsInLibrary.addAll(targetPlayer.getLibrary().getCards(game));
// cards in Graveyard
int cardsCount = targetPlayer.getGraveyard().count(filter, game);
if (cardsCount > 0) {
filter.setMessage("card named " + card.getName() + " in the graveyard of " + targetPlayer.getName());
TargetCardInGraveyard target = new TargetCardInGraveyard(0, cardsCount, filter);
if (player.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) {
player.moveCardToExileWithInfo(targetCard, null, "", source.getSourceId(), game, Zone.GRAVEYARD);
}
}
}
}
// cards in Hand
cardsCount = targetPlayer.getHand().count(filter, game);
if (cardsCount > 0) {
filter.setMessage("card named " + card.getName() + " in the hand of " + targetPlayer.getName());
TargetCardInHand target = new TargetCardInHand(0, cardsCount, filter);
if (player.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) {
player.moveCardToExileWithInfo(targetCard, null, "", source.getSourceId(), game, Zone.HAND);
}
}
}
} else {
player.lookAtCards(targetPlayer.getName() + " hand", targetPlayer.getHand(), game);
}
// cards in Library
cardsCount = cardsInLibrary.count(filter, game);
if (cardsCount > 0) {
filter.setMessage("card named " + card.getName() + " in the library of " + targetPlayer.getName());
TargetCardInLibrary target = new TargetCardInLibrary(0, cardsCount, filter);
if (player.searchLibrary(target, game, targetPlayer.getId())) {
List<UUID> targets = target.getTargets();