mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
Merge branch 'target' into 'master'
Fix hasAllTargets See merge request core-developers/forge!5117
This commit is contained in:
@@ -136,17 +136,14 @@ public final class InputSelectTargets extends InputSyncronizedBase {
|
||||
if (mandatory && tgt.hasCandidates(sa, true)) {
|
||||
// Player has to click on a target
|
||||
getController().getGui().updateButtons(getOwner(), false, false, false);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
getController().getGui().updateButtons(getOwner(), false, true, false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (mandatory && tgt.hasCandidates(sa, true)) {
|
||||
// Player has to click on a target or ok
|
||||
getController().getGui().updateButtons(getOwner(), true, false, true);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
getController().getGui().updateButtons(getOwner(), true, true, true);
|
||||
}
|
||||
}
|
||||
@@ -387,7 +384,7 @@ public final class InputSelectTargets extends InputSyncronizedBase {
|
||||
|
||||
private boolean hasAllTargets() {
|
||||
return sa.isMaxTargetChosen() || (divisionValues != null && sa.getStillToDivide() == 0)
|
||||
|| (sa.isDividedAsYouChoose() && sa.getTargets().size() == sa.getStillToDivide());
|
||||
|| (divisionValues == null && sa.isDividedAsYouChoose() && sa.getTargets().size() == sa.getStillToDivide());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1167,31 +1167,6 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
||||
return toExile;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* forge.game.player.PlayerController#chooseTargets(forge.gui.card.spellability.
|
||||
* SpellAbility, forge.gui.card.spellability.SpellAbilityStackInstance)
|
||||
*/
|
||||
@Override
|
||||
public TargetChoices chooseNewTargetsFor(final SpellAbility ability, Predicate<GameObject> filter, boolean optional) {
|
||||
final SpellAbility sa = ability.isWrapper() ? ((WrappedAbility) ability).getWrappedAbility() : ability;
|
||||
if (!sa.usesTargeting()) {
|
||||
return null;
|
||||
}
|
||||
final TargetChoices oldTarget = sa.getTargets();
|
||||
final TargetSelection select = new TargetSelection(this, sa);
|
||||
sa.clearTargets();
|
||||
if (select.chooseTargets(oldTarget.size(), Lists.newArrayList(oldTarget.getDividedValues()), filter, optional, false)) {
|
||||
return sa.getTargets();
|
||||
} else {
|
||||
sa.setTargets(oldTarget);
|
||||
// Return old target, since we had to reset them above
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
@@ -2018,6 +1993,31 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* forge.game.player.PlayerController#chooseTargets(forge.gui.card.spellability.
|
||||
* SpellAbility, forge.gui.card.spellability.SpellAbilityStackInstance)
|
||||
*/
|
||||
@Override
|
||||
public TargetChoices chooseNewTargetsFor(final SpellAbility ability, Predicate<GameObject> filter, boolean optional) {
|
||||
final SpellAbility sa = ability.isWrapper() ? ((WrappedAbility) ability).getWrappedAbility() : ability;
|
||||
if (!sa.usesTargeting()) {
|
||||
return null;
|
||||
}
|
||||
final TargetChoices oldTarget = sa.getTargets();
|
||||
final TargetSelection select = new TargetSelection(this, sa);
|
||||
sa.clearTargets();
|
||||
if (select.chooseTargets(oldTarget.size(), sa.isDividedAsYouChoose() ? Lists.newArrayList(oldTarget.getDividedValues()) : null, filter, optional, false)) {
|
||||
return sa.getTargets();
|
||||
} else {
|
||||
sa.setTargets(oldTarget);
|
||||
// Return old target, since we had to reset them above
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chooseCardsPile(final SpellAbility sa, final CardCollectionView pile1,
|
||||
final CardCollectionView pile2, final String faceUp) {
|
||||
|
||||
@@ -184,8 +184,7 @@ public class TargetSelection {
|
||||
choiceResult = !inp.hasCancelled();
|
||||
bTargetingDone = inp.hasPressedOk();
|
||||
controller.getGui().restoreOldZones(playerView, playerZoneUpdates);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// for every other case an all-purpose GuiChoose
|
||||
choiceResult = this.chooseCardFromList(validTargets, true, mandatory);
|
||||
}
|
||||
@@ -257,8 +256,7 @@ public class TargetSelection {
|
||||
Object chosen = null;
|
||||
if (!choices.isEmpty() && mandatory) {
|
||||
chosen = controller.getGui().one(getTgt().getVTSelection(), choicesFiltered);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
chosen = controller.getGui().oneOrNone(getTgt().getVTSelection(), choicesFiltered);
|
||||
}
|
||||
if (chosen == null) {
|
||||
@@ -285,8 +283,7 @@ public class TargetSelection {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ability.getTargets().add(gameCacheChooseCard.get((CardView) chosen));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user