Add Game.gd debug logging for all packets sent and received

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:
dingo
2026-03-07 10:50:44 -05:00
co-authored by Claude Happy
parent c58f03757d
commit 926c9d53a6
+21 -3
View File
@@ -123,15 +123,18 @@ func board_height() -> int:
# ── Server actions ────────────────────────────────────────────────────────────
func send_ready() -> void:
print("[Game] >>> game.ready sessionId=", session_id)
Network.request("game.ready",
{ "sessionId": session_id },
func(_t: String, p: Variant) -> void:
print("[Game] <<< game.ready.ack ", JSON.stringify(p))
var d := p as Dictionary
if d.get("status", "") == "AlreadyStarted":
_fetch_state()
else:
_apply_state_from_payload(p),
func(_c: String, _m: String) -> void: pass)
func(code: String, msg: String) -> void:
print("[Game] ERR game.ready code=", code, " msg=", msg))
func _fetch_state() -> void:
@@ -211,16 +214,24 @@ func send_activate_ability(source_id: String, ability_index: int) -> void:
func _game_request(msg_type: String, extra: Dictionary) -> void:
var payload := { "sessionId": session_id }
payload.merge(extra)
print("[Game] >>> ", msg_type, " ", JSON.stringify(extra))
Network.request(msg_type, payload,
func(_t: String, p: Variant) -> void: _apply_state_from_payload(p),
func(_c: String, _m: String) -> void: pass)
func(_t: String, p: Variant) -> void:
print("[Game] <<< ", msg_type, ".ack payload=", JSON.stringify(p))
_apply_state_from_payload(p),
func(code: String, msg: String) -> void:
print("[Game] ERR ", msg_type, " code=", code, " msg=", msg))
func _apply_state_from_payload(p: Variant) -> void:
var d := p as Dictionary
var s := d.get("state", {}) as Dictionary
if s.is_empty():
print("[Game] _apply_state_from_payload: no 'state' key in payload ", JSON.stringify(p))
return
print("[Game] state applied phase=", s.get("phase","?"),
" turn=", s.get("turnNumber","?"),
" activePlayer=", str(s.get("activePlayerAccountId","?")).substr(0,8))
state = s
state_updated.emit(state)
@@ -233,6 +244,8 @@ func _player_by_id(account_id: String) -> Dictionary:
func _on_server_push(type: String, payload: Variant) -> void:
if type.begins_with("game.") or type.begins_with("matchmaking."):
print("[Game] PUSH ", type, " ", JSON.stringify(payload).substr(0, 200))
match type:
"matchmaking.match_found":
var d := payload as Dictionary
@@ -247,8 +260,13 @@ func _on_server_push(type: String, payload: Variant) -> void:
var d := payload as Dictionary
var s := d.get("state", {}) as Dictionary
if not s.is_empty():
print("[Game] PUSH state_update phase=", s.get("phase","?"),
" turn=", s.get("turnNumber","?"),
" activePlayer=", str(s.get("activePlayerAccountId","?")).substr(0,8))
state = s
state_updated.emit(state)
else:
print("[Game] PUSH state_update: no 'state' key")
"game.over":
var d := payload as Dictionary