Forward setUsedToPay highlights to network clients#10272
Merged
tool4ever merged 3 commits intoCard-Forge:masterfrom Apr 4, 2026
Merged
Forward setUsedToPay highlights to network clients#10272tool4ever merged 3 commits intoCard-Forge:masterfrom
tool4ever merged 3 commits intoCard-Forge:masterfrom
Conversation
Network clients never received setUsedToPay highlights because the method was missing from the protocol. This meant blocker assignment, attacker selection, target highlighting, and London mulligan selection were all invisible to remote players. Add setUsedToPay to ProtocolMethod and override in NetGuiGame to forward to clients. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
good idea: I have taken this one step further and also included player highlighting by merging both - this allowed cleaner code too :) |
tool4ever
approved these changes
Apr 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Remote network clients currently don't get the blocker assignment highlight during declare blockers phase.
InputBlock.setCurrentAttacker()callssetUsedToPay()to highlight the selected attacker, but this only reaches the host's local GUI.InputBlockruns on the host as part of the game engine, so the host'sPlayerControllerHuman.getGui()returns its localCMatchUI. For the remote client player,getGui()returnsNetGuiGame— butsetUsedToPaywas missing from the network protocol, so the call was silently absorbed without forwarding to the client.Solution
Add
setUsedToPaytoProtocolMethodand override inNetGuiGameto forward to clients.Simplify
InputBlock.setCurrentAttackerto track previous/new selection instead of looping all attackers — The old setCurrentAttacker looped over all attackers, calling setUsedToPay once per attacker to clear all highlights then set the new one. Since setUsedToPay is now a protocol message, that loop would send N messages when only 2 matter (unhighlight old, highlight new). Replaced the loop with explicit previous/new tracking to avoid the redundant sends. This is safe because InputBlock only ever has one selected attacker at a time, stored in the currentAttacker field.Side benefit: also enables other highlights in network play that were previously host-only (attacker/defender selection, target highlighting, London mulligan selection)
Alternatives considered
The core challenge is that
setUsedToPayis driven byInputBlockon the host, which has access to the game engine - it knows which attackers exist, which can be legally blocked, and which is currently selected. The remote client has none of this context.So there are fundamentally two approaches: transmit across the network boundary, or attempt to recreate it client-side with a heuristic that can't access engine state. The latter approach requires significantly more code and can never be fully accurate (e.g. it can't check blocking legality). Transmitting is simpler and correct by construction.
The following alternative options were considered:
selectCardto sync with host. No protocol change needed, but the heuristic can't check blocking legality (e.g. flying) and may highlight an unblockable attacker.highlightAttackerprotocol method (~15 lines, 7 files) — Purpose-built method acrossIGuiGame,ProtocolMethod,NetGuiGame, and implementations. Adds a new interface method for a narrow use case.showCombatparameter (~20 lines, 7 files) — Pass the selected attacker as a parameter toshowCombat(). Changes an existing interface signature across all implementations and callers.setUsedToPayvia protocol (chosen, 10 lines, 3 files) — Reuses existingIGuiGamemethod. Host remains authoritative with no engine changes. Smallest diff by far.Network cost
Network cost is trivial — each message is a CardView reference + boolean.
setCurrentAttackersends at most 2 messages (unhighlight previous, highlight new) rather than iterating all attackers. On the receiving end,AbstractGuiGame.setUsedToPayshort-circuits redundant calls.setUsedToPayis transient UI state, not persistent game model state. The protocol message is fire-and-forget, same assetPanelSelectionorsetSelectables.🤖 Generated with Claude Code