diff --git a/Mage/src/main/java/mage/abilities/AbilityImpl.java b/Mage/src/main/java/mage/abilities/AbilityImpl.java index b652c76fe7e..49b06d14483 100644 --- a/Mage/src/main/java/mage/abilities/AbilityImpl.java +++ b/Mage/src/main/java/mage/abilities/AbilityImpl.java @@ -325,11 +325,16 @@ public abstract class AbilityImpl implements Ability { } if (!getTargets().isEmpty()) { Outcome outcome = getEffects().isEmpty() ? Outcome.Detriment : getEffects().get(0).getOutcome(); - if (getTargets().chooseTargets(outcome, this.controllerId, this, noMana, game) == false) { - if ((variableManaCost != null || announceString != null)) { + // can be cancel by user + if (getTargets().chooseTargets(outcome, this.controllerId, this, noMana, game, true) == false) { + /* + if ((variableManaCost != null) || (announceString != null && !announceString.isEmpty())) { + // ?debug message? game.informPlayer(controller, (sourceObject != null ? sourceObject.getIdName() : "") + ": no valid targets"); } - return false; // when activation of ability is canceled during target selection + */ + // when activation of ability is canceled during target selection + return false; } } } // end modes diff --git a/Mage/src/main/java/mage/game/stack/StackAbility.java b/Mage/src/main/java/mage/game/stack/StackAbility.java index 704b8399e68..295c229e4ac 100644 --- a/Mage/src/main/java/mage/game/stack/StackAbility.java +++ b/Mage/src/main/java/mage/game/stack/StackAbility.java @@ -174,7 +174,7 @@ public class StackAbility extends StackObjImpl implements Ability { @Override public Abilities getAbilities() { - return new AbilitiesImpl<>(ability); + return new AbilitiesImpl<>(ability); } @Override @@ -587,7 +587,7 @@ public class StackAbility extends StackObjImpl implements Ability { Outcome outcome = newAbility.getEffects().isEmpty() ? Outcome.Detriment : newAbility.getEffects().get(0).getOutcome(); if (controller.chooseUse(outcome, "Choose new targets?", source, game)) { newAbility.getTargets().clearChosen(); - newAbility.getTargets().chooseTargets(outcome, newControllerId, newAbility, false, game); + newAbility.getTargets().chooseTargets(outcome, newControllerId, newAbility, false, game, false); } } game.fireEvent(new GameEvent(GameEvent.EventType.COPIED_STACKOBJECT, newStackAbility.getId(), this.getId(), newControllerId)); diff --git a/Mage/src/main/java/mage/target/Targets.java b/Mage/src/main/java/mage/target/Targets.java index 112a4093165..7ebef50259f 100644 --- a/Mage/src/main/java/mage/target/Targets.java +++ b/Mage/src/main/java/mage/target/Targets.java @@ -64,7 +64,7 @@ public class Targets extends ArrayList { return true; } - public boolean chooseTargets(Outcome outcome, UUID playerId, Ability source, boolean noMana, Game game) { + public boolean chooseTargets(Outcome outcome, UUID playerId, Ability source, boolean noMana, Game game, boolean canCancel) { if (this.size() > 0) { if (!canChoose(source.getSourceId(), playerId, game)) { return false; @@ -73,12 +73,23 @@ public class Targets extends ArrayList { while (!isChosen()) { Target target = this.getUnchosen().get(0); UUID targetController = playerId; - if (target.getTargetController() != null) { // some targets can have controller different than ability controller + + // some targets can have controller different than ability controller + if (target.getTargetController() != null) { targetController = target.getTargetController(); } - if (noMana) { // if cast without mana (e.g. by suspend you may not be able to cancel the casting if you are able to cast it + + // if cast without mana (e.g. by suspend you may not be able to cancel the casting if you are able to cast it + if (noMana) { target.setRequired(true); } + + // can be cancel by user + if (canCancel) { + target.setRequired(false); + } + + // make response checks if (!target.chooseTarget(outcome, targetController, source, game)) { return false; }