From a01891f11e3578ba05c273f88e5e40a03d3c9866 Mon Sep 17 00:00:00 2001 From: jeffwadsworth Date: Sun, 25 Nov 2018 19:11:12 -0600 Subject: [PATCH] - added some null checks. --- Mage.Sets/src/mage/cards/h/HiddenPredators.java | 5 ++++- Mage.Sets/src/mage/cards/l/LurkingJackals.java | 13 ++++++++++--- Mage.Sets/src/mage/cards/o/OpalAvenger.java | 10 ++++++++-- Mage.Sets/src/mage/cards/v/VeiledCrocodile.java | 5 ++++- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/Mage.Sets/src/mage/cards/h/HiddenPredators.java b/Mage.Sets/src/mage/cards/h/HiddenPredators.java index f5ff50d09b..88f532926e 100644 --- a/Mage.Sets/src/mage/cards/h/HiddenPredators.java +++ b/Mage.Sets/src/mage/cards/h/HiddenPredators.java @@ -71,7 +71,10 @@ class HiddenPredatorsStateTriggeredAbility extends StateTriggeredAbility { @Override public boolean checkInterveningIfClause(Game game) { - return this.getSourcePermanentIfItStillExists(game).getCardType().contains(CardType.ENCHANTMENT); + if (getSourcePermanentIfItStillExists(game) != null) { + return getSourcePermanentIfItStillExists(game).isEnchantment(); + } + return false; } @Override diff --git a/Mage.Sets/src/mage/cards/l/LurkingJackals.java b/Mage.Sets/src/mage/cards/l/LurkingJackals.java index 2ff584e5a7..4822bb2c2d 100644 --- a/Mage.Sets/src/mage/cards/l/LurkingJackals.java +++ b/Mage.Sets/src/mage/cards/l/LurkingJackals.java @@ -54,15 +54,22 @@ class LurkingJackalsStateTriggeredAbility extends StateTriggeredAbility { @Override public boolean checkTrigger(GameEvent event, Game game) { - if (game.getOpponents(getControllerId()).stream().anyMatch((playerId) -> (game.getPlayer(playerId).getLife() <= 10))) { - return true; + if (game.getOpponents(getControllerId()) != null) { + for (UUID opponentId : game.getOpponents(getControllerId())) { + if (game.getPlayer(opponentId).getLife() <= 10) { + return true; + } + } } return false; } @Override public boolean checkInterveningIfClause(Game game) { - return this.getSourcePermanentIfItStillExists(game).getCardType().contains(CardType.ENCHANTMENT); + if (getSourcePermanentIfItStillExists(game) != null) { + return getSourcePermanentIfItStillExists(game).isEnchantment(); + } + return false; } @Override diff --git a/Mage.Sets/src/mage/cards/o/OpalAvenger.java b/Mage.Sets/src/mage/cards/o/OpalAvenger.java index 5586cbedf6..cc28e07424 100644 --- a/Mage.Sets/src/mage/cards/o/OpalAvenger.java +++ b/Mage.Sets/src/mage/cards/o/OpalAvenger.java @@ -54,12 +54,18 @@ class OpalAvengerStateTriggeredAbility extends StateTriggeredAbility { @Override public boolean checkTrigger(GameEvent event, Game game) { - return game.getState().getPlayer(getControllerId()).getLife() <= 10; + if (game.getState().getPlayer(getControllerId()) != null) { + return game.getState().getPlayer(getControllerId()).getLife() <= 10; + } + return false; } @Override public boolean checkInterveningIfClause(Game game) { - return this.getSourcePermanentIfItStillExists(game).getCardType().contains(CardType.ENCHANTMENT); + if (getSourcePermanentIfItStillExists(game) != null) { + return getSourcePermanentIfItStillExists(game).isEnchantment(); + } + return false; } @Override diff --git a/Mage.Sets/src/mage/cards/v/VeiledCrocodile.java b/Mage.Sets/src/mage/cards/v/VeiledCrocodile.java index c3790e5c73..860795598a 100644 --- a/Mage.Sets/src/mage/cards/v/VeiledCrocodile.java +++ b/Mage.Sets/src/mage/cards/v/VeiledCrocodile.java @@ -67,7 +67,10 @@ class VeiledCrocodileStateTriggeredAbility extends StateTriggeredAbility { @Override public boolean checkInterveningIfClause(Game game) { - return this.getSourcePermanentIfItStillExists(game).getCardType().contains(CardType.ENCHANTMENT); + if (getSourcePermanentIfItStillExists(game) != null) { + return getSourcePermanentIfItStillExists(game).isEnchantment(); + } + return false; } @Override