fix CardImpl.getRandom when size == 0

This commit is contained in:
Loki 2011-11-05 13:14:38 +04:00
parent 38e5ae1f03
commit 413fee4af5

View file

@ -107,6 +107,8 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
@Override
public Card getRandom(Game game) {
if (this.size() == 0)
return null;
UUID[] cards = this.toArray(new UUID[0]);
return game.getCard(cards[rnd.nextInt(cards.length)]);
}