mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
fix CardImpl.getRandom when size == 0
This commit is contained in:
parent
38e5ae1f03
commit
413fee4af5
1 changed files with 2 additions and 0 deletions
|
@ -107,6 +107,8 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Card getRandom(Game game) {
|
public Card getRandom(Game game) {
|
||||||
|
if (this.size() == 0)
|
||||||
|
return null;
|
||||||
UUID[] cards = this.toArray(new UUID[0]);
|
UUID[] cards = this.toArray(new UUID[0]);
|
||||||
return game.getCard(cards[rnd.nextInt(cards.length)]);
|
return game.getCard(cards[rnd.nextInt(cards.length)]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue