fixed a null pointer exception when multiple players discard

This commit is contained in:
Evan Kranzler 2020-05-15 20:51:42 -04:00
parent 42fd5a6410
commit 713a7ab35d
2 changed files with 5 additions and 3 deletions

View file

@ -103,8 +103,7 @@ public class DiscardEachPlayerEffect extends OneShotEffect {
if (player == null) {
continue;
}
Cards cardsPlayer = cardsToDiscard.get(playerId);
player.discard(cardsPlayer, source, game);
player.discard(cardsToDiscard.get(playerId), source, game);
}
return true;
}

View file

@ -721,6 +721,9 @@ public abstract class PlayerImpl implements Player, Serializable {
@Override
public Cards discard(Cards cards, Ability source, Game game) {
Cards discardedCards = new CardsImpl();
if (cards == null) {
return discardedCards;
}
for (Card card : cards.getCards(game)) {
if (doDiscard(card, source, game, false)) {
discardedCards.add(card);
@ -4005,7 +4008,7 @@ public abstract class PlayerImpl implements Player, Serializable {
for (Card card : cards) {
if (card instanceof Permanent) {
game.getBattlefield().removePermanent(card.getId());
ZoneChangeEvent event = new ZoneChangeEvent((Permanent)card,
ZoneChangeEvent event = new ZoneChangeEvent((Permanent) card,
(source == null ? null : source.getSourceId()),
byOwner ? card.getOwnerId() : getId(), Zone.BATTLEFIELD, Zone.OUTSIDE, appliedEffects);
game.fireEvent(event);