Skip to content

Add network sync for auto-yield and trigger accept/decline#10355

Merged
tool4ever merged 6 commits intoCard-Forge:masterfrom
MostCromulent:fix/auto-yield-network-sync
Apr 16, 2026
Merged

Add network sync for auto-yield and trigger accept/decline#10355
tool4ever merged 6 commits intoCard-Forge:masterfrom
MostCromulent:fix/auto-yield-network-sync

Conversation

@MostCromulent
Copy link
Copy Markdown
Contributor

Cherry-picked from #9643 with architectural changes per tool4ever's feedback.

Closes #3699

Summary

Client-side auto-yield and trigger always-yes/always-no settings had no effect for remote network clients because preferences were only stored locally. This adds notifyAutoYieldChanged and notifyTriggerChoiceChanged protocol methods to sync these settings from client to server.

Rather than adding separate notification calls at each GUI call site (VStack, VAutoYields, VGameMenu across desktop and mobile), notifications are folded into AbstractGuiGame's existing setter methods (setShouldAutoYield, setShouldAlwaysAcceptTrigger, etc.). An instanceof NetGameController check ensures notifications only fire on the client side, which also avoids re-entrancy when the server-side PlayerControllerHuman applies the received state back through the same setters.

Trigger choices are carried as a TriggerChoice enum (ASK / ALWAYS_YES / ALWAYS_NO) rather than bare ints.


🤖 Generated with Claude Code

MostCromulent and others added 2 commits April 11, 2026 07:43
Client-side auto-yield and trigger always-yes/always-no settings had no
effect for remote network clients because preferences were only stored
locally. Notifications are folded into AbstractGuiGame's setter methods
so existing GUI call sites (VStack, VAutoYields, VGameMenu) work
without modification. An instanceof NetGameController check ensures
notifications only fire on the client side, avoiding re-entrancy when
the server applies the received state.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
RafaelHGOliveira added a commit to RafaelHGOliveira/forge that referenced this pull request Apr 11, 2026
…c into AbstractGuiGame setters

Architecture change per upstream feedback: instead of GUI call-sites
(VStack, VAutoYields, VGameMenu) explicitly calling notifyAutoYieldChanged
/ notifyTriggerChoiceChanged, those calls are now triggered from the
corresponding setters in AbstractGuiGame (setShouldAutoYield,
setShouldAlwaysAcceptTrigger, setShouldAlwaysDeclineTrigger,
setShouldAlwaysAskTrigger). An instanceof NetGameController guard ensures
notifications only fire on the client side, preventing re-entrancy when
the server-side PlayerControllerHuman applies received state back through
the same setters.

Also restores symbols lost from upstream merge (-X theirs):
- IGuiGame: isRemoteGuiProxy(), isAutoPassingNoActions(), showPlayerDisconnected()
- RemoteClientGuiGame: clientIndex field + getSlotIndex()
- Missing imports: CompatibleObjectEncoder/Decoder (RemoteClient),
  ForgePreferences (InputPassPriority), FServerManager + MessageEvent
  (PlayerControllerHuman), Tracker (CompatibleObjectEncoder/Decoder)
Comment thread forge-gui/src/main/java/forge/interfaces/IGameController.java Outdated
Relocate auto-yield and trigger-accept/decline preferences from the
shared GUI layer (AbstractGuiGame/IGuiGame) into per-player controllers
(PlayerControllerHuman/IGameController).

Each human player now owns independent yield preferences. In local
multiplayer, Player A auto-yielding to an ability no longer affects
Player B.

Network sync is simplified: NetGameController mirrors state locally
for UI display and sends mutations directly via protocol methods that
map 1:1 to IGameController. The TriggerChoice enum and notify* methods
are removed in favor of direct method dispatch.

Addresses review feedback on <!-- -->Card-Forge#10355.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@tool4ever
Copy link
Copy Markdown
Contributor

yea, looks better now imo

I believe this also fixed the "disable all" not working on mobile, since that was for some reason interacting with the previously unused controller field

possibly we can still reduce the footprint a bit by refactoring Accept/Decline/Ask methods pattern to the earlier approach, but maybe it's better to wait with that until we have a better understanding on how it should integrate with the more extended yield framework in the future 🤔

tool4ever
tool4ever previously approved these changes Apr 16, 2026
@tool4ever tool4ever merged commit 2c5025c into Card-Forge:master Apr 16, 2026
2 checks passed
@MostCromulent MostCromulent deleted the fix/auto-yield-network-sync branch April 16, 2026 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto Yield does not work in multiplayer

2 participants