Phase 8: Free Play ready-up system + client scenes

Server (Phase A):
- CustomLobby: +HostReady/GuestReady/HostFirstTurnPref/GuestFirstTurnPref/MaxPlayers
- Migration: AddReadyUpSystem — applied to prod DB
- GameJoinCustomLobbyHandler: no longer auto-creates session; sets Full status,
  resets readiness, pushes CustomLobbyGuestJoinedPush to host
- GameLobbyReadyHandler (NEW): game.custom.lobby.ready — marks caller ready,
  resolves first-turn, creates session + pushes game.custom.started when all ready
- GameUnreadyHandler (NEW): game.custom.lobby.unready
- GameChangeLobbyDeckHandler (NEW): game.custom.lobby.change_deck
- GameUpdateLobbyRulesHandler (NEW): game.custom.update_rules (host only)
- GameListActiveLobbiesHandler (NEW): game.custom.list_active (Status==Started)
- GameListCustomLobbiesHandler: now batch-loads host/guest display names
- GameMessages: +LobbyReadyRequest/Response, UnreadyInLobbyRequest/Response,
  ChangeLobbyDeckRequest/Response, UpdateLobbyRulesRequest/Response,
  ListActiveLobbiesRequest/Response, LobbyReadyStatusPush, LobbyDeckChangedPush,
  ActiveLobbyDto; CustomLobbyDto +HostDisplayName/GuestDisplayName
- ServiceRegistration: register 5 new handlers

Client (Phase B):
- CustomLobby.gd: new autoload for Free Play lobby state + all server calls
- project.godot: register CustomLobby autoload
- MainScreen: +Free Play button → FreePlayScreen.tscn
- FreePlayScreen (NEW): Open Lobbies tab + Active Games tab + Create dialog
- LobbyRoomScreen (NEW): ready-up UI, first-turn selector, preset voting
- Game.gd: +is_spectating, +start_spectating(), +stop_spectating()
- game_screen.gd: spectator mode — SPECTATING label, hidden action buttons,
  neutral HUD labels, stop_spectating() on exit

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-19 09:10:55 -04:00
co-authored by Claude Happy
parent cf05bacf0c
commit d61ebe66b8
23 changed files with 2685 additions and 99 deletions
@@ -67,6 +67,7 @@ var count : int = 0
var _cam_tween : Tween = null
var _last_click_frame : int = -1
var _last_click_iid : String = ""
var _is_spectating : bool = false
# ── Affinity colors ───────────────────────────────────────────────────────────
const AFFINITY_COLORS : Dictionary = {
@@ -225,6 +226,14 @@ func _ready() -> void:
Game.opponent_inactive.connect(_on_opponent_inactive)
Game.inactive_warning.connect(_on_inactive_warning)
if Game.is_spectating:
_is_spectating = true
_setup_spectator_ui()
# State was already applied via game.spectate ack — re-emit if present.
if not Game.state.is_empty():
_on_state_updated(Game.state)
return
if not Game.state.is_empty():
_on_state_updated(Game.state)
else:
@@ -232,6 +241,8 @@ func _ready() -> void:
func _exit_tree() -> void:
if _is_spectating:
Game.stop_spectating()
if Game.state_updated.is_connected(_on_state_updated):
Game.state_updated.disconnect(_on_state_updated)
if Game.game_over.is_connected(_on_game_over):
@@ -248,6 +259,22 @@ func _exit_tree() -> void:
if child.name == "ChatOverlay":
child.queue_free()
func _setup_spectator_ui() -> void:
# "SPECTATING" overlay label.
var lbl := Label.new()
lbl.text = "SPECTATING"
lbl.modulate = Color(1.0, 0.76, 0.2)
lbl.theme_override_font_sizes = { &"font_size": 18 }
lbl.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
lbl.set_anchors_preset(Control.PRESET_TOP_WIDE)
lbl.position = Vector2(0, 8)
_hud.add_child(lbl)
# Hide action buttons — spectators can only watch.
_draw_btn.visible = false
_end_turn_btn.visible = false
# ── Environment ───────────────────────────────────────────────────────────────
func _setup_environment() -> void:
@@ -2600,13 +2627,18 @@ func _find_hand_card(iid: String) -> Dictionary:
func _update_hud(state: Dictionary) -> void:
var phase : String = state.get("phase", "")
var turn : int = state.get("turnNumber", 1)
var is_mine : bool = Game.is_my_turn()
var is_mine : bool = (not _is_spectating) and Game.is_my_turn()
var my : Dictionary = Game.get_my_player()
var opp : Dictionary = Game.get_opponent()
_phase_lbl.text = "Phase: %s" % phase
_turn_lbl.text = "Turn %d — %s" % [turn, "Your turn" if is_mine else "Opponent's turn"]
_turn_lbl.modulate = Color(0.4, 1.0, 0.5) if is_mine else Color(1.0, 0.6, 0.6)
if _is_spectating:
var active_id : String = str(state.get("activePlayerAccountId", ""))
_turn_lbl.text = "Turn %d — Spectating" % turn
_turn_lbl.modulate = Color(1.0, 0.76, 0.2)
else:
_turn_lbl.text = "Turn %d — %s" % [turn, "Your turn" if is_mine else "Opponent's turn"]
_turn_lbl.modulate = Color(0.4, 1.0, 0.5) if is_mine else Color(1.0, 0.6, 0.6)
_sp_lbl.text = "SP: %d" % int(my.get("currentSp", 0))
_st_lbl.text = "ST: %d" % int(my.get("currentSt", 0))
@@ -2617,9 +2649,13 @@ func _update_hud(state: Dictionary) -> void:
_opp_hand_lbl.text = "Hand: %d" % int(opp.get("handCount", 0))
_opp_deck_lbl.text = "Deck: %d" % int(opp.get("deckCount", 0))
_draw_btn.visible = (phase == "Draw" and is_mine)
_end_turn_btn.visible = (phase == "Main" and is_mine)
_end_turn_btn.disabled = not is_mine
if _is_spectating:
_draw_btn.visible = false
_end_turn_btn.visible = false
else:
_draw_btn.visible = (phase == "Draw" and is_mine)
_end_turn_btn.visible = (phase == "Main" and is_mine)
_end_turn_btn.disabled = not is_mine
if phase == "Placement":
var my_arch : Dictionary = my.get("archSpirit", {})