if (revealAllCards) {
this.numberCardsToReveal = new StaticValue(player.getHand().size());
}
int numberToReveal = this.numberCardsToReveal.calculate(game, source, this);
if (numberToReveal > 0) {
Cards revealedCards = new CardsImpl(Zone.HAND);
numberToReveal = Math.min(player.getHand().size(), numberToReveal);
if (player.getHand().size() > numberToReveal) {
TargetCardInHand chosenCards = new TargetCardInHand(numberToReveal, numberToReveal, new FilterCard("card in target player's hand"));
chosenCards.setNotTarget(true);
if (chosenCards.canChoose(player.getId(), game) && player.choose(Outcome.Discard, player.getHand(), chosenCards, game)) {
if (!chosenCards.getTargets().isEmpty()) {
List<UUID> targets = chosenCards.getTargets();
for (UUID targetid : targets) {
Card card = game.getCard(targetid);
if (card != null) {
revealedCards.add(card);
}
}
}
}
} else {
revealedCards.addAll(player.getHand());
}
player.revealCards(sourceCard != null ? sourceCard.getName() :"Discard", revealedCards, game);
boolean result = true;
int filteredCardsCount = revealedCards.count(filter, source.getSourceId(), source.getControllerId(), game);
int numberToDiscard = Math.min(this.numberCardsToDiscard.calculate(game, source, this), filteredCardsCount);
if (numberToDiscard > 0) {
TargetCard target = new TargetCard(numberToDiscard, Zone.HAND, filter);
if (controller.choose(Outcome.Benefit, revealedCards, target, game)) {
for (Object targetId : target.getTargets()) {
Card card = revealedCards.get((UUID) targetId, game);
if (card != null) {
if (!player.discard(card, source, game)) {
result = false;
}
}