Fix free game: display names in lobby/game screen + rules fallback
- CustomLobbyGuestJoinedPush: add GuestDisplayName (host now sees guest's real name) - JoinCustomLobbyResponse: add HostAccountId/Name + GuestAccountId/Name so guest lobby room shows correct state instead of "Waiting for guest…" - CustomLobbyGameStartedPush: add OpponentDisplayName so game screen shows name not GUID - GameJoinCustomLobbyHandler: use 3-tier rules fallback (lobby override → db custom-default → hard-coded default) matching StartGameAsync, fixing inconsistent rule display on join - GameLobbyReadyHandler: inject SorIdentityDbContext, fetch display names for both players before pushing game.custom.started - CustomLobby.gd: set Game.opponent_name on game.custom.started push; emit display names in guest_joined and game_starting signals; patch join response lobby dict - lobby_room_screen.gd: use display name in _on_guest_joined; update _on_game_starting signature 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:
@@ -16,7 +16,7 @@ extends Node
|
||||
# ── Signals ───────────────────────────────────────────────────────────────────
|
||||
|
||||
## Pushed when a guest joins the host's open lobby.
|
||||
signal guest_joined(guest_account_id: String)
|
||||
signal guest_joined(guest_account_id: String, guest_display_name: String)
|
||||
|
||||
## Pushed when the host updates lobby rules (or a preset vote is approved).
|
||||
signal lobby_rules_updated(new_rules: Dictionary)
|
||||
@@ -29,7 +29,7 @@ signal ready_status_changed(host_ready: bool, guest_ready: bool)
|
||||
|
||||
## Pushed when both players are ready and the game session has been created.
|
||||
## Navigate to GameScreen.tscn after receiving this.
|
||||
signal game_starting(session_id: String, opponent_account_id: String)
|
||||
signal game_starting(session_id: String, opponent_account_id: String, opponent_display_name: String)
|
||||
|
||||
## Pushed when the host proposes loading a preset; guests should show a vote banner.
|
||||
signal preset_vote_requested(payload: Dictionary)
|
||||
@@ -120,6 +120,10 @@ func join(lid: String, deck_id: String, password: String,
|
||||
lobby_id = str(d.get("lobbyId", ""))
|
||||
lobby = d
|
||||
is_host = false
|
||||
# Ensure the lobby dict has the fields _refresh_display needs.
|
||||
lobby["guestAccountId"] = str(d.get("guestAccountId", ""))
|
||||
lobby["guestDisplayName"] = str(d.get("guestDisplayName", ""))
|
||||
lobby["hasGuest"] = true
|
||||
if on_success.is_valid(): on_success.call(d),
|
||||
func(code: String, msg: String) -> void:
|
||||
print("[CustomLobby] ERR join ", code, " ", msg)
|
||||
@@ -256,9 +260,10 @@ func _on_server_push(type: String, payload: Variant) -> void:
|
||||
print("[CustomLobby] PUSH ", type, " ", JSON.stringify(payload).substr(0, 200))
|
||||
match type:
|
||||
"game.custom.lobby.guest_joined":
|
||||
var d := payload as Dictionary
|
||||
var gid : String = str(d.get("guestAccountId", ""))
|
||||
guest_joined.emit(gid)
|
||||
var d := payload as Dictionary
|
||||
var gid : String = str(d.get("guestAccountId", ""))
|
||||
var gname: String = str(d.get("guestDisplayName", gid.substr(0, 8)))
|
||||
guest_joined.emit(gid, gname)
|
||||
|
||||
"game.custom.lobby_updated":
|
||||
var d := payload as Dictionary
|
||||
@@ -284,12 +289,14 @@ func _on_server_push(type: String, payload: Variant) -> void:
|
||||
ready_status_changed.emit(hr, gr)
|
||||
|
||||
"game.custom.started":
|
||||
var d := payload as Dictionary
|
||||
var sid : String = str(d.get("sessionId", ""))
|
||||
var opp : String = str(d.get("opponentAccountId", ""))
|
||||
Game.session_id = sid
|
||||
Game.state = {}
|
||||
game_starting.emit(sid, opp)
|
||||
var d := payload as Dictionary
|
||||
var sid : String = str(d.get("sessionId", ""))
|
||||
var opp : String = str(d.get("opponentAccountId", ""))
|
||||
var oname : String = str(d.get("opponentDisplayName", opp.substr(0, 8)))
|
||||
Game.session_id = sid
|
||||
Game.opponent_name = oname
|
||||
Game.state = {}
|
||||
game_starting.emit(sid, opp, oname)
|
||||
|
||||
"game.custom.preset.vote_requested":
|
||||
preset_vote_requested.emit(payload as Dictionary)
|
||||
|
||||
Reference in New Issue
Block a user