mirror of
https://github.com/correl/mage.git
synced 2024-11-14 19:19:32 +00:00
* UI: improved choose target amount dialog (selected targets can be removed/de-selected);
This commit is contained in:
parent
eafb4eb653
commit
6cc2472ed6
2 changed files with 29 additions and 11 deletions
|
@ -721,8 +721,19 @@ public class HumanPlayer extends PlayerImpl {
|
|||
if (response.getUUID() != null) {
|
||||
if (target.canTarget(response.getUUID(), source, game)) {
|
||||
UUID targetId = response.getUUID();
|
||||
int amountSelected = getAmount(1, target.getAmountRemaining(), "Select amount", game);
|
||||
target.addTarget(targetId, amountSelected, source, game);
|
||||
MageObject targetObject = game.getObject(targetId);
|
||||
|
||||
boolean removeMode = target.getTargets().contains(targetId)
|
||||
&& chooseUse(outcome, "What do you want to do with " + (targetObject != null ? targetObject.getLogName() : "target") + "?", "",
|
||||
"Remove from selected", "Add extra amount", source, game);
|
||||
|
||||
if (removeMode) {
|
||||
target.remove(targetId);
|
||||
} else {
|
||||
int amountSelected = getAmount(1, target.getAmountRemaining(), "Select amount", game);
|
||||
target.addTarget(targetId, amountSelected, source, game);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} else if (!target.isRequired(source)) {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
package mage.target;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
@ -7,11 +5,14 @@ import mage.abilities.dynamicvalue.DynamicValue;
|
|||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import java.util.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public abstract class TargetAmount extends TargetImpl {
|
||||
|
@ -63,8 +64,8 @@ public abstract class TargetAmount extends TargetImpl {
|
|||
|
||||
public void setAmountDefinition(DynamicValue amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setAmount(Ability source, Game game) {
|
||||
remainingAmount = amount.calculate(game, source, null);
|
||||
amountWasSet = true;
|
||||
|
@ -82,6 +83,13 @@ public abstract class TargetAmount extends TargetImpl {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(UUID id) {
|
||||
int amount = getTargetAmount(id);
|
||||
super.remove(id);
|
||||
this.remainingAmount += amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chooseTarget(Outcome outcome, UUID playerId, Ability source, Game game) {
|
||||
if (!amountWasSet) {
|
||||
|
@ -111,7 +119,7 @@ public abstract class TargetAmount extends TargetImpl {
|
|||
if (!amountWasSet) {
|
||||
setAmount(source, game);
|
||||
}
|
||||
for (UUID targetId: targets) {
|
||||
for (UUID targetId : targets) {
|
||||
for (int n = 1; n <= target.remainingAmount; n++) {
|
||||
TargetAmount t = target.copy();
|
||||
t.addTarget(targetId, n, source, game, true);
|
||||
|
@ -120,8 +128,7 @@ public abstract class TargetAmount extends TargetImpl {
|
|||
Set<UUID> newTargets = targets.stream().filter(newTarget -> !newTarget.equals(targetId)).collect(Collectors.toSet());
|
||||
addTargets(t, newTargets, options, source, game);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
options.add(t);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue