From 0fc3afb235bf9bde31e5aeacd0e6aad9ca43c8fc Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Thu, 12 Oct 2017 07:56:45 -0400 Subject: [PATCH] fixed Evangelize not being castable when caster controls no creatures. (fixes #4094) --- .../TargetOpponentsChoicePermanent.java | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/Mage/src/main/java/mage/target/common/TargetOpponentsChoicePermanent.java b/Mage/src/main/java/mage/target/common/TargetOpponentsChoicePermanent.java index 813ae0951d..5dce07ed4c 100644 --- a/Mage/src/main/java/mage/target/common/TargetOpponentsChoicePermanent.java +++ b/Mage/src/main/java/mage/target/common/TargetOpponentsChoicePermanent.java @@ -6,6 +6,7 @@ package mage.target.common; import java.util.UUID; +import mage.MageObject; import mage.abilities.Ability; import mage.constants.Outcome; import mage.filter.FilterPermanent; @@ -49,7 +50,7 @@ public class TargetOpponentsChoicePermanent extends TargetPermanent { if (opponentId != null) { if (permanent != null) { if (source != null) { - boolean canSourceControllerTarget = true; + boolean canSourceControllerTarget = true; if (!isNotTarget()) { if (!permanent.canBeTargetedBy(game.getObject(source.getId()), controllerId, game) || !permanent.canBeTargetedBy(game.getObject(source.getSourceId()), controllerId, game)) { @@ -70,6 +71,33 @@ public class TargetOpponentsChoicePermanent extends TargetPermanent { return super.chooseTarget(outcome, getOpponentId(playerId, source, game), source, game); } + @Override + public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { + MageObject sourceObject = game.getObject(sourceId); + Player player = game.getPlayer(sourceControllerId); + if (sourceObject == null || player == null) { + return false; + } + int counter; + for (UUID oppId : game.getState().getPlayersInRange(player.getId(), game)) { + counter = 0; + Player opp = game.getPlayer(oppId); + if (opp != null && player.hasOpponent(opp.getId(), game)) { + for (Permanent perm : game.getBattlefield().getActivePermanents(opp.getId(), game)) { + if (!targets.containsKey(perm.getId()) + && filter.match(perm, sourceId, opp.getId(), game) + && perm.canBeTargetedBy(sourceObject, sourceControllerId, game)) { + counter++; + if (counter >= minNumberOfTargets) { + return true; + } + } + } + } + } + return false; + } + @Override public TargetOpponentsChoicePermanent copy() { return new TargetOpponentsChoicePermanent(this);