From 6bfea7bfd99a531b4057d9e215083c87a1557404 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Mon, 4 Mar 2019 03:07:29 +0400 Subject: [PATCH] Fixed NPE error in momir emblem; --- .../mage/game/command/emblems/MomirEmblem.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Mage/src/main/java/mage/game/command/emblems/MomirEmblem.java b/Mage/src/main/java/mage/game/command/emblems/MomirEmblem.java index ae721d6d07..44cb5438c7 100644 --- a/Mage/src/main/java/mage/game/command/emblems/MomirEmblem.java +++ b/Mage/src/main/java/mage/game/command/emblems/MomirEmblem.java @@ -11,7 +11,10 @@ import mage.cards.Sets; import mage.cards.repository.CardCriteria; import mage.cards.repository.CardInfo; import mage.cards.repository.CardRepository; -import mage.constants.*; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.TimingRule; +import mage.constants.Zone; import mage.game.Game; import mage.game.command.Emblem; import mage.game.permanent.token.EmptyToken; @@ -64,7 +67,9 @@ class MomirEffect extends OneShotEffect { game.informPlayers("No random creature card with converted mana cost of " + value + " was found."); return false; } - EmptyToken token = new EmptyToken(); // search for a non custom set creature + + // search for a random non custom set creature + EmptyToken token = null; while (!options.isEmpty()) { int index = RandomUtil.nextInt(options.size()); ExpansionSet expansionSet = Sets.findSet(options.get(index).getSetCode()); @@ -73,6 +78,7 @@ class MomirEffect extends OneShotEffect { } else { Card card = options.get(index).getCard(); if (card != null) { + token = new EmptyToken(); CardUtil.copyTo(token).from(card); break; } else { @@ -80,7 +86,11 @@ class MomirEffect extends OneShotEffect { } } } - token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId(), false, false); - return true; + if (token != null) { + token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId(), false, false); + return true; + } + + return false; } }