From 7dfcb15c3c17bb4e0e81bbf1d11e9559327a1add Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Mon, 3 Oct 2016 20:19:57 +0200 Subject: [PATCH] Fixed some null pointer exceptions with Thieves Auction and Avatar of the Might. --- .../mage/sets/mercadianmasques/ThievesAuction.java | 4 ++-- Mage.Sets/src/mage/sets/prophecy/AvatarOfMight.java | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Mage.Sets/src/mage/sets/mercadianmasques/ThievesAuction.java b/Mage.Sets/src/mage/sets/mercadianmasques/ThievesAuction.java index 84ffe10daf5..a153561d28d 100644 --- a/Mage.Sets/src/mage/sets/mercadianmasques/ThievesAuction.java +++ b/Mage.Sets/src/mage/sets/mercadianmasques/ThievesAuction.java @@ -109,8 +109,8 @@ class ThievesAuctionEffect extends OneShotEffect { // Starting with you, each player PlayerList playerList = game.getState().getPlayersInRange(controller.getId(), game); Player player = playerList.getCurrent(game); - while (!exiledCards.isEmpty()) { - if (player.canRespond()) { + while (!exiledCards.isEmpty() && !game.hasEnded()) { + if (player != null && player.canRespond()) { // chooses one of the exiled cards TargetCard target = new TargetCardInExile(new FilterCard()); if (player.choose(Outcome.PutCardInPlay, exiledCards, target, game)) { diff --git a/Mage.Sets/src/mage/sets/prophecy/AvatarOfMight.java b/Mage.Sets/src/mage/sets/prophecy/AvatarOfMight.java index 2b7b581f5c0..00bdd683ce7 100644 --- a/Mage.Sets/src/mage/sets/prophecy/AvatarOfMight.java +++ b/Mage.Sets/src/mage/sets/prophecy/AvatarOfMight.java @@ -105,11 +105,13 @@ class AvatarOfMightCostReductionEffect extends CostModificationEffectImpl { @Override public boolean applies(Ability abilityToModify, Ability source, Game game) { - int creatures = game.getBattlefield().countAll(new FilterCreaturePermanent(), source.getControllerId(), game); - for (UUID playerId : game.getOpponents(source.getControllerId())) { - Player opponent = game.getPlayer(playerId); - if (opponent != null && game.getBattlefield().countAll(new FilterCreaturePermanent(), opponent.getId(), game) >= creatures + 4) { - return true; + if (abilityToModify.getSourceId().equals(source.getSourceId()) && (abilityToModify instanceof SpellAbility)) { + int creatures = game.getBattlefield().countAll(new FilterCreaturePermanent(), source.getControllerId(), game); + for (UUID playerId : game.getOpponents(source.getControllerId())) { + Player opponent = game.getPlayer(playerId); + if (opponent != null && game.getBattlefield().countAll(new FilterCreaturePermanent(), opponent.getId(), game) >= creatures + 4) { + return true; + } } } return false;