mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 03:22:00 -08:00
* UI: added cancel button for all target definition abilities;
This commit is contained in:
parent
904660e624
commit
dab481ee17
3 changed files with 24 additions and 8 deletions
|
|
@ -325,11 +325,16 @@ public abstract class AbilityImpl implements Ability {
|
||||||
}
|
}
|
||||||
if (!getTargets().isEmpty()) {
|
if (!getTargets().isEmpty()) {
|
||||||
Outcome outcome = getEffects().isEmpty() ? Outcome.Detriment : getEffects().get(0).getOutcome();
|
Outcome outcome = getEffects().isEmpty() ? Outcome.Detriment : getEffects().get(0).getOutcome();
|
||||||
if (getTargets().chooseTargets(outcome, this.controllerId, this, noMana, game) == false) {
|
// can be cancel by user
|
||||||
if ((variableManaCost != null || announceString != null)) {
|
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");
|
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
|
} // end modes
|
||||||
|
|
|
||||||
|
|
@ -174,7 +174,7 @@ public class StackAbility extends StackObjImpl implements Ability {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Abilities<Ability> getAbilities() {
|
public Abilities<Ability> getAbilities() {
|
||||||
return new AbilitiesImpl<>(ability);
|
return new AbilitiesImpl<>(ability);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -587,7 +587,7 @@ public class StackAbility extends StackObjImpl implements Ability {
|
||||||
Outcome outcome = newAbility.getEffects().isEmpty() ? Outcome.Detriment : newAbility.getEffects().get(0).getOutcome();
|
Outcome outcome = newAbility.getEffects().isEmpty() ? Outcome.Detriment : newAbility.getEffects().get(0).getOutcome();
|
||||||
if (controller.chooseUse(outcome, "Choose new targets?", source, game)) {
|
if (controller.chooseUse(outcome, "Choose new targets?", source, game)) {
|
||||||
newAbility.getTargets().clearChosen();
|
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));
|
game.fireEvent(new GameEvent(GameEvent.EventType.COPIED_STACKOBJECT, newStackAbility.getId(), this.getId(), newControllerId));
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ public class Targets extends ArrayList<Target> {
|
||||||
return true;
|
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 (this.size() > 0) {
|
||||||
if (!canChoose(source.getSourceId(), playerId, game)) {
|
if (!canChoose(source.getSourceId(), playerId, game)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -73,12 +73,23 @@ public class Targets extends ArrayList<Target> {
|
||||||
while (!isChosen()) {
|
while (!isChosen()) {
|
||||||
Target target = this.getUnchosen().get(0);
|
Target target = this.getUnchosen().get(0);
|
||||||
UUID targetController = playerId;
|
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();
|
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);
|
target.setRequired(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// can be cancel by user
|
||||||
|
if (canCancel) {
|
||||||
|
target.setRequired(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// make response checks
|
||||||
if (!target.chooseTarget(outcome, targetController, source, game)) {
|
if (!target.chooseTarget(outcome, targetController, source, game)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue