* Implemented handling of up to for TargetAmount.

This commit is contained in:
LevelX2 2020-01-10 15:49:10 +01:00
parent ac2a59fdc2
commit e91639a478
2 changed files with 16 additions and 25 deletions

View file

@ -52,7 +52,10 @@ public abstract class TargetAmount extends TargetImpl {
@Override
public boolean doneChosing() {
return amountWasSet && remainingAmount == 0;
return amountWasSet
&& (remainingAmount == 0
|| (getMinNumberOfTargets() < getMaxNumberOfTargets()
&& getTargets().size() >= getMinNumberOfTargets()));
}
@Override
@ -85,9 +88,9 @@ public abstract class TargetAmount extends TargetImpl {
@Override
public void remove(UUID id) {
int amount = getTargetAmount(id);
int usedAmount = getTargetAmount(id);
super.remove(id);
this.remainingAmount += amount;
this.remainingAmount += usedAmount;
}
@Override
@ -95,16 +98,16 @@ public abstract class TargetAmount extends TargetImpl {
if (!amountWasSet) {
setAmount(source, game);
}
chosen = remainingAmount == 0;
chosen = isChosen();
while (remainingAmount > 0) {
if (!getTargetController(game, playerId).chooseTargetAmount(outcome, this, source, game)) {
if (!getTargetController(game, playerId).chooseTargetAmount(outcome, this, source, game)) {
return chosen;
}
chosen = remainingAmount == 0;
chosen = isChosen();
}
return chosen = true;
}
@Override
public List<? extends TargetAmount> getTargetOptions(Ability source, Game game) {
List<TargetAmount> options = new ArrayList<>();