Fix phase stop preferences for multiplayer and network games#9820
Fix phase stop preferences for multiplayer and network games#9820tool4ever merged 4 commits intoCard-Forge:masterfrom
Conversation
…ndex The old code assumed field index [0] is always the human player and index [1+] is always AI. This is incorrect in multiplayer and network games. Use isLocalPlayer() to select the correct pref set for each field. Fixes both desktop (CMatchUI) and mobile (MatchController). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
tool4ever
left a comment
There was a problem hiding this comment.
what about the additional writeMatchPreferences() call that was previously being added (see open thread in old PR):
I thought it might make sense since otherwise it can only be reached by one player via ControlWinLose.nextGameAction (though maybe not in that exact location)?
…anges Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Yep, have added back in. |
|
seems AI isn't that good at analyzing previous PR progression: |
Local games already save via ControlWinLose.saveOptions(). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Digging into it, looks like AI did consider this but came to view the double-write was harmless. Have now got it to implement the netplay check suggested on the old PR, sorry about that. |
…rge#9820) * Save phase stop prefs in finishGame so all network players persist changes Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Summary
Addresses the issue raised in #8335, which was closed as stale. Per @tool4ever's request, this is a fresh PR implementing a clean fix from first principles for both desktop and mobile.
The bug
actuateMatchPreferences()andwriteMatchPreferences()hardcode the assumption that field index[0]is the human player and index[1+]is AI. This means the wrong phase stop preferences are applied whenever the local player is not at index 0 — which can occur in:The bug is difficult to reproduce in 2-player network testing because
openView()swaps the field order to ensure the local player is at index 0 in the 2-player case. It is also invisible when the human and AI phase preferences happen to have the same values.The fix
Replace the hardcoded index assumption with
isLocalPlayer()checks. For each field, determine whether its player is controlled by this GUI instance and applyPHASE_HUMAN_*orPHASE_AI_*preferences accordingly.Added
FPref.PHASES_HUMANandFPref.PHASES_AIarrays to enable iteration over phase preferences inPhaseTypeorder, replacing the per-label boilerplate.The fix is applied separately in desktop (
CMatchUI) and mobile (MatchController) rather than consolidated intoAbstractGuiGame, because the two platforms use different phase indicator classes with different APIs (PhaseIndicator.setEnabled()vsVPhaseIndicator.setStopAtPhase()). Unifying them would require abstracting over these platform-specific UI types in the shared base class, which is not warranted for this fix.3 files changed, 54 insertions, 127 deletions.
Test plan
Coded with Claude Code