From f3fafbdb147a1261f7858d75036b3f994cc3b22f Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Mon, 13 Jul 2020 17:13:30 +0200 Subject: [PATCH] * Fixed that choose opponent was handled targeted but shouldn't (e.g.used for Stalking Leonin) fixed #6836. --- .../common/ChooseSecretOpponentEffect.java | 76 +++++++++---------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/Mage/src/main/java/mage/abilities/effects/common/ChooseSecretOpponentEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ChooseSecretOpponentEffect.java index 6c1a8ba5c61..e8b893706cb 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ChooseSecretOpponentEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ChooseSecretOpponentEffect.java @@ -9,6 +9,7 @@ import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.common.TargetOpponent; import mage.util.CardUtil; + /** * * @author LevelX2 @@ -19,50 +20,49 @@ public class ChooseSecretOpponentEffect extends OneShotEffect { public static final String SECRET_OPPONENT = "_secOpp"; public static final String SECRET_OWNER = "_secOwn"; - public ChooseSecretOpponentEffect() { - super(Outcome.Neutral); - staticText = "secretly choose an opponent"; - } + public ChooseSecretOpponentEffect() { + super(Outcome.Neutral); + staticText = "secretly choose an opponent"; + } - public ChooseSecretOpponentEffect(final ChooseSecretOpponentEffect effect) { - super(effect); - } + public ChooseSecretOpponentEffect(final ChooseSecretOpponentEffect effect) { + super(effect); + } - @Override - public boolean apply(Game game, Ability source) { - Player controller = game.getPlayer(source.getControllerId()); - MageObject mageObject = game.getPermanentEntering(source.getSourceId()); - if (mageObject == null) { - mageObject = game.getObject(source.getSourceId()); - } - if (controller != null && mageObject != null) { - TargetOpponent targetOpponent = new TargetOpponent(); - targetOpponent.setTargetName("opponent (secretly)"); - while (!controller.choose(outcome, targetOpponent, source.getSourceId(), game)) { - if (!controller.canRespond()) { - return false; - } - } - if (targetOpponent.getTargets().isEmpty()) { + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + MageObject mageObject = game.getPermanentEntering(source.getSourceId()); + if (mageObject == null) { + mageObject = game.getObject(source.getSourceId()); + } + if (controller != null && mageObject != null) { + TargetOpponent targetOpponent = new TargetOpponent(true); + targetOpponent.setTargetName("opponent (secretly)"); + while (!controller.choose(outcome, targetOpponent, source.getSourceId(), game)) { + if (!controller.canRespond()) { return false; } - if (!game.isSimulation()) { - game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has secretly chosen an opponent."); - } - game.getState().setValue(mageObject.getId() + SECRET_OPPONENT, targetOpponent.getTargets().get(0)); - game.getState().setValue(mageObject.getId() + SECRET_OWNER, controller.getId()); - if (mageObject instanceof Permanent) { - ((Permanent) mageObject).addInfo(SECRET_OPPONENT, - CardUtil.addToolTipMarkTags(controller.getLogName() + " has secretly chosen an opponent."), game); - } } - return false; - } - - @Override - public ChooseSecretOpponentEffect copy() { - return new ChooseSecretOpponentEffect(this); + if (targetOpponent.getTargets().isEmpty()) { + return false; + } + if (!game.isSimulation()) { + game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has secretly chosen an opponent."); + } + game.getState().setValue(mageObject.getId() + SECRET_OPPONENT, targetOpponent.getTargets().get(0)); + game.getState().setValue(mageObject.getId() + SECRET_OWNER, controller.getId()); + if (mageObject instanceof Permanent) { + ((Permanent) mageObject).addInfo(SECRET_OPPONENT, + CardUtil.addToolTipMarkTags(controller.getLogName() + " has secretly chosen an opponent."), game); + } } + return false; + } + @Override + public ChooseSecretOpponentEffect copy() { + return new ChooseSecretOpponentEffect(this); + } }