* Abilities with sacrifice cost - added cancel button to sacrifice target dialog;

This commit is contained in:
Oleg Agafonov 2019-03-10 15:55:33 +04:00
parent b432b4b431
commit 9d5fade2fb

View file

@ -26,6 +26,7 @@ public class SacrificeTargetCost extends CostImpl {
public SacrificeTargetCost(TargetControlledPermanent target) { public SacrificeTargetCost(TargetControlledPermanent target) {
this.addTarget(target); this.addTarget(target);
target.setNotTarget(true); // sacrifice is never targeted target.setNotTarget(true); // sacrifice is never targeted
target.setRequired(false); // can be canceled
this.text = "sacrifice " this.text = "sacrifice "
+ ((target.getNumberOfTargets() != 1 + ((target.getNumberOfTargets() != 1
|| (target.getTargetName().startsWith("an") || (target.getTargetName().startsWith("an")
@ -55,6 +56,7 @@ public class SacrificeTargetCost extends CostImpl {
if (ability.getAbilityType() == AbilityType.ACTIVATED || ability.getAbilityType() == AbilityType.SPECIAL_ACTION) { if (ability.getAbilityType() == AbilityType.ACTIVATED || ability.getAbilityType() == AbilityType.SPECIAL_ACTION) {
activator = ((ActivatedAbilityImpl) ability).getActivatorId(); activator = ((ActivatedAbilityImpl) ability).getActivatorId();
} }
// can be cancel by user
if (targets.choose(Outcome.Sacrifice, activator, sourceId, game)) { if (targets.choose(Outcome.Sacrifice, activator, sourceId, game)) {
for (UUID targetId : targets.get(0).getTargets()) { for (UUID targetId : targets.get(0).getTargets()) {
Permanent permanent = game.getPermanent(targetId); Permanent permanent = game.getPermanent(targetId);