From 5bf12d227c81deff3bbc5ecf088c15a5b8ddbc5a Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Fri, 1 Sep 2017 23:50:07 +0200 Subject: [PATCH] Some minor changes. --- .../src/mage/player/human/HumanPlayer.java | 23 +++++++++++++++---- .../common/ChooseCreatureTypeEffect.java | 8 ++++--- .../main/java/mage/players/PlayerImpl.java | 5 ++-- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java b/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java index 995303191f..bff6dea4ea 100644 --- a/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java +++ b/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java @@ -834,10 +834,23 @@ public class HumanPlayer extends PlayerImpl { return !controllingPlayer.getUserData().getUserSkipPrioritySteps().getOpponentTurn().isPhaseStepSet(game.getStep().getType()); } } catch (NullPointerException ex) { - String isNull = controllingPlayer.getUserData() == null ? "null" : "not null"; - logger.error("null pointer exception UserData = " + isNull); + if (controllingPlayer.getUserData() != null) { + if (controllingPlayer.getUserData().getUserSkipPrioritySteps() != null) { + if (game.getStep() != null) { + if (game.getStep().getType() == null) { + logger.error("game.getStep().getType() == null"); + } + } else { + logger.error("game.getStep() == null"); + } + } else { + logger.error("UserData.getUserSkipPrioritySteps == null"); + } + } else { + logger.error("UserData == null"); + } } - return true; + return false; } @Override @@ -1223,7 +1236,9 @@ public class HumanPlayer extends PlayerImpl { FilterCreatureForCombatBlock filter = filterCreatureForCombatBlock.copy(); filter.add(new ControllerIdPredicate(defendingPlayerId)); if (game.getBattlefield().count(filter, null, playerId, game) == 0 - && !getControllingPlayersUserData(game).getUserSkipPrioritySteps().isStopOnDeclareBlockerIfNoneAvailable()) { + && !getControllingPlayersUserData(game) + .getUserSkipPrioritySteps() + .isStopOnDeclareBlockerIfNoneAvailable()) { return; } while (!abort) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/ChooseCreatureTypeEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ChooseCreatureTypeEffect.java index 412278414f..3a9b80b994 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ChooseCreatureTypeEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ChooseCreatureTypeEffect.java @@ -27,6 +27,8 @@ */ package mage.abilities.effects.common; +import java.util.LinkedHashSet; +import java.util.stream.Collectors; import mage.MageObject; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; @@ -39,9 +41,6 @@ import mage.game.permanent.Permanent; import mage.players.Player; import mage.util.CardUtil; -import java.util.LinkedHashSet; -import java.util.stream.Collectors; - /** * @author LevelX2 */ @@ -72,6 +71,9 @@ public class ChooseCreatureTypeEffect extends OneShotEffect { return false; } } + if (typeChoice.getChoice() == null) { + return false; + } if (!game.isSimulation()) { game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoice()); } diff --git a/Mage/src/main/java/mage/players/PlayerImpl.java b/Mage/src/main/java/mage/players/PlayerImpl.java index 9fa5e19e8a..aa9321c2f6 100644 --- a/Mage/src/main/java/mage/players/PlayerImpl.java +++ b/Mage/src/main/java/mage/players/PlayerImpl.java @@ -2959,7 +2959,7 @@ public abstract class PlayerImpl implements Player, Serializable { } public UserData getControllingPlayersUserData(Game game) { - if (isGameUnderControl()) { + if (!isGameUnderControl()) { Player player = game.getPlayer(getTurnControlledBy()); if (player.isHuman()) { return player.getUserData(); @@ -2969,8 +2969,7 @@ public abstract class PlayerImpl implements Player, Serializable { } @Override - public void setUserData(UserData userData - ) { + public void setUserData(UserData userData) { this.userData = userData; getManaPool().setAutoPayment(userData.isManaPoolAutomatic()); getManaPool().setAutoPaymentRestricted(userData.isManaPoolAutomaticRestricted());