Fixed a bug that if a human player had to discard more cards than he had on hand, the game UI was blocked.

This commit is contained in:
LevelX2 2015-06-15 17:35:48 +02:00
parent 09dd373909
commit cd0f273122
5 changed files with 33 additions and 13 deletions

View file

@ -709,7 +709,8 @@ public abstract class PlayerImpl implements Player, Serializable {
}
}
} else {
TargetDiscard target = new TargetDiscard(amount, amount, new FilterCard(CardUtil.numberToText(amount, "a") + " card" + (amount > 1 ? "s" : "")), playerId);
int possibleAmount = Math.min(getHand().size(), amount);
TargetDiscard target = new TargetDiscard(possibleAmount, possibleAmount, new FilterCard(CardUtil.numberToText(possibleAmount, "a") + " card" + (possibleAmount > 1 ? "s" : "")), playerId);
choose(Outcome.Discard, target, source == null ? null : source.getSourceId(), game);
for (UUID cardId : target.getTargets()) {
Card card = this.getHand().get(cardId, game);