fix(ability-prompts): fix 3 client wiring gaps
1. JSON case normalization
Parse CostGroupJson, ActionGroupJson, BranchesJson, RevealedCardsJson
through _normalize_keys in game_screen.gd — server serialises these
inner payloads with _jsonOpts (no naming policy = PascalCase), but the
client was reading lowercase keys, producing empty option lists.
2. Cost pick candidate list
- Add CandidatesJson to PendingCostPick; populated in AbilitySystem.PayCosts
with the actor's eligible cards (hand for DiscardFromHand, field spirits
for SendSpiritFromBattlefieldToDiscard / DealDamageToOwnSpirit).
- Thread CandidatesJson through CostPickRequestPush → GameHandlerBase push.
- Client _on_cost_pick_request now uses candidatesJson from the push instead
of Game.get_my_player().hand, fixing opponent-pick and battlefield-cost UIs.
3. Reconnect recovery via game.get_state
- Extract all pending-prompt pushes into static PushPendingPromptsAsync in
GameHandlerBase (called from PushStateToPlayersAsync as before).
- Inject IClientPush into GameGetStateHandler; call PushPendingPromptsAsync
after building the reply so any active pause prompt is re-sent to the
chooser on manual state sync / reconnect.
Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -4431,16 +4431,16 @@ func _on_cost_pick_request(req: Dictionary) -> void:
|
||||
vbox.add_child(title)
|
||||
vbox.add_child(HSeparator.new())
|
||||
|
||||
# List hand cards (most interactive costs are hand discards).
|
||||
var my_player := Game.get_my_player()
|
||||
var hand : Array = my_player.get("hand", []) as Array if my_player is Dictionary else []
|
||||
if hand.is_empty():
|
||||
var lbl := Label.new(); lbl.text = "(hand empty)"
|
||||
# Use server-supplied candidate list (covers hand, field, and opponent-pick cases).
|
||||
var candidates_raw = JSON.parse_string(str(req.get("candidatesJson", "[]")))
|
||||
var candidates : Array = candidates_raw as Array if candidates_raw is Array else []
|
||||
if candidates.is_empty():
|
||||
var lbl := Label.new(); lbl.text = "(no candidates)"
|
||||
lbl.add_theme_font_size_override("font_size", 11)
|
||||
vbox.add_child(lbl)
|
||||
else:
|
||||
for card in hand:
|
||||
var card_d : Dictionary = card as Dictionary
|
||||
for cand in candidates:
|
||||
var card_d : Dictionary = cand as Dictionary
|
||||
var iid : String = str(card_d.get("instanceId", ""))
|
||||
var name_ : String = str(card_d.get("name", iid))
|
||||
var btn := Button.new()
|
||||
@@ -4484,10 +4484,10 @@ func _on_cost_group_pick_request(req: Dictionary) -> void:
|
||||
_pending_source_id = str(req.get("sourceInstanceId", ""))
|
||||
|
||||
var group_raw = JSON.parse_string(str(req.get("costGroupJson", "{}")))
|
||||
var group : Dictionary = group_raw as Dictionary if group_raw is Dictionary else {}
|
||||
var group : Dictionary = _normalize_keys(group_raw) as Dictionary if group_raw is Dictionary else {}
|
||||
var entries : Array = group.get("entries", []) as Array
|
||||
var groups : Array = group.get("groups", []) as Array
|
||||
var logic : String = str(group.get("logicOp", "OR"))
|
||||
var logic : String = str(group.get("logicop", group.get("logicOp", "OR")))
|
||||
|
||||
_hide_pending_prompt_panel()
|
||||
var panel := PanelContainer.new()
|
||||
@@ -4506,7 +4506,7 @@ func _on_cost_group_pick_request(req: Dictionary) -> void:
|
||||
var option_idx := 0
|
||||
for entry in entries:
|
||||
var entry_d : Dictionary = entry as Dictionary
|
||||
var label : String = str(entry_d.get("typeStr", "Option %d" % (option_idx + 1)))
|
||||
var label : String = str(entry_d.get("typestr", entry_d.get("typeStr", "Option %d" % (option_idx + 1))))
|
||||
var btn := Button.new(); btn.text = label
|
||||
btn.add_theme_font_size_override("font_size", 12)
|
||||
var cap_idx : int = option_idx
|
||||
@@ -4518,7 +4518,7 @@ func _on_cost_group_pick_request(req: Dictionary) -> void:
|
||||
option_idx += 1
|
||||
for grp in groups:
|
||||
var grp_d : Dictionary = grp as Dictionary
|
||||
var lop : String = str(grp_d.get("logicOp", "OR"))
|
||||
var lop : String = str(grp_d.get("logicop", grp_d.get("logicOp", "OR")))
|
||||
var btn := Button.new(); btn.text = "Group (%s)" % lop
|
||||
btn.add_theme_font_size_override("font_size", 12)
|
||||
var cap_idx : int = option_idx
|
||||
@@ -4542,10 +4542,10 @@ func _on_action_group_pick_request(req: Dictionary) -> void:
|
||||
_pending_source_id = str(req.get("sourceInstanceId", ""))
|
||||
|
||||
var group_raw = JSON.parse_string(str(req.get("actionGroupJson", "{}")))
|
||||
var group : Dictionary = group_raw as Dictionary if group_raw is Dictionary else {}
|
||||
var group : Dictionary = _normalize_keys(group_raw) as Dictionary if group_raw is Dictionary else {}
|
||||
var actions : Array = group.get("actions", []) as Array
|
||||
var subgrps : Array = group.get("groups", []) as Array
|
||||
var logic : String = str(group.get("logicOp", "OR"))
|
||||
var logic : String = str(group.get("logicop", group.get("logicOp", "OR")))
|
||||
|
||||
_hide_pending_prompt_panel()
|
||||
var panel := PanelContainer.new()
|
||||
@@ -4581,7 +4581,7 @@ func _on_action_group_pick_request(req: Dictionary) -> void:
|
||||
option_idx += 1
|
||||
for grp in subgrps:
|
||||
var grp_d : Dictionary = grp as Dictionary
|
||||
var lop : String = str(grp_d.get("logicOp", "OR"))
|
||||
var lop : String = str(grp_d.get("logicop", grp_d.get("logicOp", "OR")))
|
||||
var btn := Button.new(); btn.text = "Group (%s)" % lop
|
||||
btn.add_theme_font_size_override("font_size", 12)
|
||||
var cap_idx : int = option_idx
|
||||
@@ -4605,7 +4605,7 @@ func _on_branch_pick_request(req: Dictionary) -> void:
|
||||
_pending_source_id = str(req.get("sourceInstanceId", ""))
|
||||
|
||||
var branches_raw = JSON.parse_string(str(req.get("branchesJson", "[]")))
|
||||
var branches : Array = branches_raw as Array if branches_raw is Array else []
|
||||
var branches : Array = _normalize_keys(branches_raw) as Array if branches_raw is Array else []
|
||||
|
||||
_hide_pending_prompt_panel()
|
||||
var panel := PanelContainer.new()
|
||||
@@ -4766,7 +4766,7 @@ func _on_reveal_choice_pick_request(req: Dictionary) -> void:
|
||||
_reveal_ordered_indices.clear()
|
||||
|
||||
var cards_raw = JSON.parse_string(str(req.get("revealedCardsJson", "[]")))
|
||||
var cards : Array = cards_raw as Array if cards_raw is Array else []
|
||||
var cards : Array = _normalize_keys(cards_raw) as Array if cards_raw is Array else []
|
||||
_reveal_total_cards = cards.size()
|
||||
|
||||
_hide_pending_prompt_panel()
|
||||
|
||||
Reference in New Issue
Block a user