TargetChoices extend ForwardingList

This commit is contained in:
Hans Mackowiak
2020-11-08 10:48:01 +01:00
parent ed58918f12
commit 71348b7317
50 changed files with 171 additions and 242 deletions

View File

@@ -98,7 +98,7 @@ public final class InputSelectTargets extends InputSyncronizedBase {
}
final int maxTargets = tgt.getMaxTargets(sa.getHostCard(), sa);
final int targeted = sa.getTargets().getNumTargeted();
final int targeted = sa.getTargets().size();
if(maxTargets > 1) {
sb.append(TextUtil.concatNoSpace("\n(", String.valueOf(maxTargets - targeted), " more can be targeted)"));
}
@@ -108,7 +108,7 @@ public final class InputSelectTargets extends InputSyncronizedBase {
"(Targeting ERROR)", "");
showMessage(message, sa.getView());
if (tgt.isDividedAsYouChoose() && tgt.getMinTargets(sa.getHostCard(), sa) == 0 && sa.getTargets().getNumTargeted() == 0) {
if (tgt.isDividedAsYouChoose() && tgt.getMinTargets(sa.getHostCard(), sa) == 0 && sa.getTargets().size() == 0) {
// extra logic for Divided with min targets = 0, should only work if num targets are 0 too
getController().getGui().updateButtons(getOwner(), true, true, false);
} else if (!tgt.isMinTargetsChosen(sa.getHostCard(), sa) || tgt.isDividedAsYouChoose()) {
@@ -243,7 +243,7 @@ public final class InputSelectTargets extends InputSyncronizedBase {
final int stillToDivide = tgt.getStillToDivide();
int allocatedPortion = 0;
// allow allocation only if the max targets isn't reached and there are more candidates
if ((sa.getTargets().getNumTargeted() + 1 < tgt.getMaxTargets(sa.getHostCard(), sa))
if ((sa.getTargets().size() + 1 < tgt.getMaxTargets(sa.getHostCard(), sa))
&& (tgt.getNumCandidates(sa, true) - 1 > 0) && stillToDivide > 1) {
final ImmutableList.Builder<Integer> choices = ImmutableList.builder();
for (int i = 1; i <= stillToDivide; i++) {
@@ -304,7 +304,7 @@ public final class InputSelectTargets extends InputSyncronizedBase {
final int stillToDivide = tgt.getStillToDivide();
int allocatedPortion = 0;
// allow allocation only if the max targets isn't reached and there are more candidates
if ((sa.getTargets().getNumTargeted() + 1 < tgt.getMaxTargets(sa.getHostCard(), sa)) && (tgt.getNumCandidates(sa, true) - 1 > 0) && stillToDivide > 1) {
if ((sa.getTargets().size() + 1 < tgt.getMaxTargets(sa.getHostCard(), sa)) && (tgt.getNumCandidates(sa, true) - 1 > 0) && stillToDivide > 1) {
final ImmutableList.Builder<Integer> choices = ImmutableList.builder();
for (int i = 1; i <= stillToDivide; i++) {
choices.add(Integer.valueOf(i));

View File

@@ -314,7 +314,7 @@ public class HumanPlaySpellAbility {
final StringBuilder sb = new StringBuilder();
sb.append(ability.getHostCard().getName());
if (ability.getTargetRestrictions() != null) {
final Iterable<GameObject> targets = ability.getTargets().getTargets();
final Iterable<GameObject> targets = ability.getTargets();
if (!Iterables.isEmpty(targets)) {
sb.append(" - Targeting ");
for (final GameObject o : targets) {

View File

@@ -1033,7 +1033,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
final TargetChoices oldTarget = sa.getTargets();
final TargetSelection select = new TargetSelection(this, sa);
sa.resetTargets();
if (select.chooseTargets(oldTarget.getNumTargeted())) {
if (select.chooseTargets(oldTarget.size())) {
return sa.getTargets();
} else {
// Return old target, since we had to reset them above

View File

@@ -81,7 +81,7 @@ public class TargetSelection {
final int minTargets = numTargets != null ? numTargets.intValue() : tgt.getMinTargets(ability.getHostCard(), ability);
final int maxTargets = numTargets != null ? numTargets.intValue() : tgt.getMaxTargets(ability.getHostCard(), ability);
//final int maxTotalCMC = tgt.getMaxTotalCMC(ability.getHostCard(), ability);
final int numTargeted = ability.getTargets().getNumTargeted();
final int numTargeted = ability.getTargets().size();
final boolean isSingleZone = ability.getTargetRestrictions().isSingleZone();
final boolean hasEnoughTargets = minTargets == 0 || numTargeted >= minTargets;