diff --git a/Client/origin-client/scenes/game/game_screen.gd b/Client/origin-client/scenes/game/game_screen.gd index 135e02e..ec42523 100644 --- a/Client/origin-client/scenes/game/game_screen.gd +++ b/Client/origin-client/scenes/game/game_screen.gd @@ -1163,6 +1163,22 @@ func _show_card_picker(title: String, cards: Array, on_pick: Callable) -> void: # ── Ability panel ───────────────────────────────────────────────────────────── +## Recursively normalise all Dictionary keys to lowercase so ability JSON can +## be read with consistent lowercase lookups regardless of server casing. +func _normalize_keys(value: Variant) -> Variant: + if value is Dictionary: + var result := {} + for k in (value as Dictionary): + result[str(k).to_lower()] = _normalize_keys((value as Dictionary)[k]) + return result + elif value is Array: + var result : Array = [] + for item in (value as Array): + result.append(_normalize_keys(item)) + return result + return value + + func _show_ability_panel(unit_id: String, unit: Dictionary) -> void: _hide_ability_panel() # Null trap: server sends "abilitiesJson": null for units with no abilities. @@ -1172,14 +1188,16 @@ func _show_ability_panel(unit_id: String, unit: Dictionary) -> void: if abil_json.is_empty(): return var parsed = JSON.parse_string(abil_json) if not parsed is Array: return + # Server may serialise with PascalCase keys — normalise to lowercase. + var abilities : Array = _normalize_keys(parsed) as Array # Collect Active abilities. var actives : Array = [] - for i in parsed.size(): - var ab : Dictionary = parsed[i] as Dictionary + for i in abilities.size(): + var ab : Dictionary = abilities[i] as Dictionary if ab.get("type", "") == "Active": actives.append({ "index": i, - "name": ab.get("name", "Ability %d" % i), + "name": ab.get("name", "Ability %d" % i), "desc": ab.get("description", ""), "def": ab })