Fixed NPE errors on missing card (game.getCard can't find card);

This commit is contained in:
Oleg Agafonov 2020-01-15 07:08:56 +04:00
parent c30316512b
commit 745bfa2836
9 changed files with 25 additions and 13 deletions

View file

@ -129,7 +129,7 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
@Override
public Set<Card> getCards(FilterCard filter, Game game) {
return stream().map(game::getCard).filter(card -> filter.match(card, game)).collect(Collectors.toSet());
return stream().map(game::getCard).filter(Objects::nonNull).filter(card -> filter.match(card, game)).collect(Collectors.toSet());
}
@Override

View file

@ -164,7 +164,7 @@ public class Library implements Serializable {
* @return
*/
public List<Card> getCards(Game game) {
return library.stream().map(game::getCard).collect(Collectors.toList());
return library.stream().map(game::getCard).filter(Objects::nonNull).collect(Collectors.toList());
}
public Set<Card> getTopCards(Game game, int amount) {