- added some null checks.

This commit is contained in:
jeffwadsworth 2018-11-25 19:11:12 -06:00
parent 4f0725586b
commit a01891f11e
4 changed files with 26 additions and 7 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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