Player auto-choose respects required targets (#10557)

* Player auto-choose respects required targets
This commit is contained in:
Alexander Novotny 2023-07-03 20:02:46 -07:00 committed by GitHub
parent fae63d9d4b
commit fb8424556e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View file

@ -540,7 +540,7 @@ public class HumanPlayer extends PlayerImpl {
required = false; required = false;
} }
UUID responseId = target.tryToAutoChoose(abilityControllerId, source, game); UUID responseId = required ? target.tryToAutoChoose(abilityControllerId, source, game) : null;
// responseId is null if a choice couldn't be automatically made // responseId is null if a choice couldn't be automatically made
if (responseId == null) { if (responseId == null) {
@ -640,7 +640,7 @@ public class HumanPlayer extends PlayerImpl {
required = false; required = false;
} }
UUID responseId = target.tryToAutoChoose(abilityControllerId, source, game); UUID responseId = required ? target.tryToAutoChoose(abilityControllerId, source, game) : null;
// responseId is null if a choice couldn't be automatically made // responseId is null if a choice couldn't be automatically made
if (responseId == null) { if (responseId == null) {
@ -738,7 +738,8 @@ public class HumanPlayer extends PlayerImpl {
required = false; required = false;
} }
UUID responseId = target.tryToAutoChoose(abilityControllerId, source, game, possibleTargets); UUID responseId = required ? target.tryToAutoChoose(abilityControllerId, source, game, possibleTargets)
: null;
if (responseId == null) { if (responseId == null) {
Map<String, Serializable> options = getOptions(target, null); Map<String, Serializable> options = getOptions(target, null);
@ -819,7 +820,8 @@ public class HumanPlayer extends PlayerImpl {
required = false; required = false;
} }
UUID responseId = target.tryToAutoChoose(abilityControllerId, source, game, possibleTargets); UUID responseId = required ? target.tryToAutoChoose(abilityControllerId, source, game, possibleTargets)
: null;
if (responseId == null) { if (responseId == null) {
List<UUID> chosenTargets = target.getTargets(); List<UUID> chosenTargets = target.getTargets();
@ -894,7 +896,7 @@ public class HumanPlayer extends PlayerImpl {
required = false; required = false;
} }
UUID responseId = target.tryToAutoChoose(abilityControllerId, source, game); UUID responseId = required ? target.tryToAutoChoose(abilityControllerId, source, game) : null;
// responseId is null if a choice couldn't be automatically made // responseId is null if a choice couldn't be automatically made
if (responseId == null) { if (responseId == null) {

View file

@ -350,7 +350,7 @@ public abstract class TargetImpl implements Target {
} }
} else { } else {
// Try to autochoosen // Try to autochoosen
UUID autoChosenId = tryToAutoChoose(playerId, source, game); UUID autoChosenId = required ? tryToAutoChoose(playerId, source, game) : null;
if (autoChosenId != null) { if (autoChosenId != null) {
addTarget(autoChosenId, source, game); addTarget(autoChosenId, source, game);
} else if (!targetController.chooseTarget(outcome, this, source, game)) { // If couldn't autochoose ask player } else if (!targetController.chooseTarget(outcome, this, source, game)) { // If couldn't autochoose ask player