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)) {
|
if (mandatory && tgt.hasCandidates(sa, true)) {
|
||||||
// Player has to click on a target
|
// Player has to click on a target
|
||||||
getController().getGui().updateButtons(getOwner(), false, false, false);
|
getController().getGui().updateButtons(getOwner(), false, false, false);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
getController().getGui().updateButtons(getOwner(), false, true, false);
|
getController().getGui().updateButtons(getOwner(), false, true, false);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (mandatory && tgt.hasCandidates(sa, true)) {
|
if (mandatory && tgt.hasCandidates(sa, true)) {
|
||||||
// Player has to click on a target or ok
|
// Player has to click on a target or ok
|
||||||
getController().getGui().updateButtons(getOwner(), true, false, true);
|
getController().getGui().updateButtons(getOwner(), true, false, true);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
getController().getGui().updateButtons(getOwner(), true, true, true);
|
getController().getGui().updateButtons(getOwner(), true, true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -387,7 +384,7 @@ public final class InputSelectTargets extends InputSyncronizedBase {
|
|||||||
|
|
||||||
private boolean hasAllTargets() {
|
private boolean hasAllTargets() {
|
||||||
return sa.isMaxTargetChosen() || (divisionValues != null && sa.getStillToDivide() == 0)
|
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
|
@Override
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public abstract class InputSyncronizedBase extends InputBase implements InputSyn
|
|||||||
@Override
|
@Override
|
||||||
public void awaitLatchRelease() {
|
public void awaitLatchRelease() {
|
||||||
FThreads.assertExecutedByEdt(false);
|
FThreads.assertExecutedByEdt(false);
|
||||||
try{
|
try {
|
||||||
cdlDone.await();
|
cdlDone.await();
|
||||||
} catch (final InterruptedException e) {
|
} catch (final InterruptedException e) {
|
||||||
BugReporter.reportException(e);
|
BugReporter.reportException(e);
|
||||||
|
|||||||
@@ -1167,31 +1167,6 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
|||||||
return toExile;
|
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)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
@@ -2018,6 +1993,31 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
|||||||
return result;
|
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
|
@Override
|
||||||
public boolean chooseCardsPile(final SpellAbility sa, final CardCollectionView pile1,
|
public boolean chooseCardsPile(final SpellAbility sa, final CardCollectionView pile1,
|
||||||
final CardCollectionView pile2, final String faceUp) {
|
final CardCollectionView pile2, final String faceUp) {
|
||||||
|
|||||||
@@ -184,8 +184,7 @@ public class TargetSelection {
|
|||||||
choiceResult = !inp.hasCancelled();
|
choiceResult = !inp.hasCancelled();
|
||||||
bTargetingDone = inp.hasPressedOk();
|
bTargetingDone = inp.hasPressedOk();
|
||||||
controller.getGui().restoreOldZones(playerView, playerZoneUpdates);
|
controller.getGui().restoreOldZones(playerView, playerZoneUpdates);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// for every other case an all-purpose GuiChoose
|
// for every other case an all-purpose GuiChoose
|
||||||
choiceResult = this.chooseCardFromList(validTargets, true, mandatory);
|
choiceResult = this.chooseCardFromList(validTargets, true, mandatory);
|
||||||
}
|
}
|
||||||
@@ -257,8 +256,7 @@ public class TargetSelection {
|
|||||||
Object chosen = null;
|
Object chosen = null;
|
||||||
if (!choices.isEmpty() && mandatory) {
|
if (!choices.isEmpty() && mandatory) {
|
||||||
chosen = controller.getGui().one(getTgt().getVTSelection(), choicesFiltered);
|
chosen = controller.getGui().one(getTgt().getVTSelection(), choicesFiltered);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
chosen = controller.getGui().oneOrNone(getTgt().getVTSelection(), choicesFiltered);
|
chosen = controller.getGui().oneOrNone(getTgt().getVTSelection(), choicesFiltered);
|
||||||
}
|
}
|
||||||
if (chosen == null) {
|
if (chosen == null) {
|
||||||
@@ -285,8 +283,7 @@ public class TargetSelection {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ability.getTargets().add(gameCacheChooseCard.get((CardView) chosen));
|
ability.getTargets().add(gameCacheChooseCard.get((CardView) chosen));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -313,7 +310,7 @@ public class TargetSelection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while(!bTargetingDone) {
|
while (!bTargetingDone) {
|
||||||
if (ability.isMaxTargetChosen()) {
|
if (ability.isMaxTargetChosen()) {
|
||||||
bTargetingDone = true;
|
bTargetingDone = true;
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user