diff --git a/Mage/src/main/java/mage/abilities/costs/common/SacrificeAllCost.java b/Mage/src/main/java/mage/abilities/costs/common/SacrificeAllCost.java index 3c87feba89a0..4a4836b44e04 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/SacrificeAllCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/SacrificeAllCost.java @@ -7,6 +7,7 @@ import mage.filter.FilterPermanent; import mage.game.Game; import mage.game.permanent.Permanent; +import mage.players.Player; import java.util.ArrayList; import java.util.List; @@ -44,8 +45,12 @@ public boolean pay(Ability ability, Game game, Ability source, UUID controllerId @Override public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { + Player controller = game.getPlayer(controllerId); + if (controller == null){ + return false; + } for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, controllerId, game)) { - if (!game.getPlayer(controllerId).canPaySacrificeCost(permanent, source, controllerId, game)) { + if (!controller.canPaySacrificeCost(permanent, source, controllerId, game)) { return false; } } diff --git a/Mage/src/main/java/mage/abilities/costs/common/SacrificeTargetCost.java b/Mage/src/main/java/mage/abilities/costs/common/SacrificeTargetCost.java index e3cf1241b641..4fa11cbffc43 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/SacrificeTargetCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/SacrificeTargetCost.java @@ -8,6 +8,7 @@ import mage.filter.FilterPermanent; import mage.game.Game; import mage.game.permanent.Permanent; +import mage.players.Player; import mage.target.TargetPermanent; import mage.target.common.TargetSacrifice; import mage.util.CardUtil; @@ -82,10 +83,14 @@ protected void addSacrificeTarget(Game game, Permanent permanent) { @Override public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { + Player controller = game.getPlayer(controllerId); + if (controller == null){ + return false; + } int validTargets = 0; int neededTargets = this.getTargets().get(0).getNumberOfTargets(); for (Permanent permanent : game.getBattlefield().getActivePermanents(((TargetPermanent) this.getTargets().get(0)).getFilter(), controllerId, source, game)) { - if (game.getPlayer(controllerId).canPaySacrificeCost(permanent, source, controllerId, game)) { + if (controller.canPaySacrificeCost(permanent, source, controllerId, game)) { validTargets++; if (validTargets >= neededTargets) { return true;