diff --git a/Client/origin-client/autoloads/CustomLobby.gd b/Client/origin-client/autoloads/CustomLobby.gd index 1b93ddf..a5f9a23 100644 --- a/Client/origin-client/autoloads/CustomLobby.gd +++ b/Client/origin-client/autoloads/CustomLobby.gd @@ -51,6 +51,9 @@ signal rule_suggestion_received(rules: Dictionary) ## Pushed to the guest when the host rejects their rule suggestion. signal rule_suggestion_rejected +## Emitted when a lobby action is rejected gracefully (non-fatal), for lightweight UX toasts. +signal lobby_notice(message: String) + # ── State ───────────────────────────────────────────────────────────────────── var lobby_id : String = "" @@ -174,8 +177,12 @@ func set_ready(deck_id: String, pref: String) -> void: first_turn_pref = pref Network.request("game.custom.lobby.ready", { "lobbyId": lobby_id, "deckId": deck_id, "firstTurnPref": pref }, - func(_t: String, _p: Variant) -> void: - i_am_ready = true, + func(_t: String, p: Variant) -> void: + var d := p as Dictionary + var accepted := bool(d.get("isReady", true)) + i_am_ready = accepted + if not accepted: + lobby_notice.emit("Lobby is waiting for more players before ready-up.") func(code: String, msg: String) -> void: print("[CustomLobby] ERR set_ready ", code, " ", msg)) diff --git a/Client/origin-client/scenes/free_play/lobby_room_screen.gd b/Client/origin-client/scenes/free_play/lobby_room_screen.gd index 8ca1968..de9451c 100644 --- a/Client/origin-client/scenes/free_play/lobby_room_screen.gd +++ b/Client/origin-client/scenes/free_play/lobby_room_screen.gd @@ -71,6 +71,7 @@ func _exit_tree() -> void: CustomLobby.partner_left.disconnect(_on_partner_left) CustomLobby.rule_suggestion_received.disconnect(_on_rule_suggestion_received) CustomLobby.rule_suggestion_rejected.disconnect(_on_rule_suggestion_rejected) + CustomLobby.lobby_notice.disconnect(_on_lobby_notice) # ── Setup ───────────────────────────────────────────────────────────────────── @@ -135,6 +136,7 @@ func _connect_signals() -> void: CustomLobby.partner_left.connect(_on_partner_left) CustomLobby.rule_suggestion_received.connect(_on_rule_suggestion_received) CustomLobby.rule_suggestion_rejected.connect(_on_rule_suggestion_rejected) + CustomLobby.lobby_notice.connect(_on_lobby_notice) # ── Refresh ─────────────────────────────────────────────────────────────────── @@ -352,6 +354,10 @@ func _on_rule_suggestion_rejected() -> void: _show_toast("Host rejected your rule suggestion.") +func _on_lobby_notice(message: String) -> void: + _show_toast(message) + + func _on_suggestion_accept_pressed() -> void: suggestion_banner.visible = false CustomLobby.accept_rule_suggestion() diff --git a/Server/src/SOR.Game/Handlers/GameLobbyReadyHandler.cs b/Server/src/SOR.Game/Handlers/GameLobbyReadyHandler.cs index b782046..92f6f10 100644 --- a/Server/src/SOR.Game/Handlers/GameLobbyReadyHandler.cs +++ b/Server/src/SOR.Game/Handlers/GameLobbyReadyHandler.cs @@ -60,7 +60,11 @@ internal sealed class GameLobbyReadyHandler : GameHandlerBase, IMessageHandler ?? throw new GameException("LOBBY_NOT_FOUND"); if (lobby.Status != CustomLobbyStatus.Full) - throw new GameException("LOBBY_NOT_FULL"); + { + // Not an error for clients that click ready before final seat is filled. + return ServerMessage.Reply("game.custom.lobby.ready.ack", message.Seq, + new LobbyReadyResponse(LobbyId: lobby.Id, IsReady: false)); + } var isHost = lobby.HostAccountId == accountId; var isGuest = lobby.GuestAccountId == accountId; diff --git a/Server/src/SOR.Game/Handlers/GameReadyHandler.cs b/Server/src/SOR.Game/Handlers/GameReadyHandler.cs index 6cf9d9b..2a58d1d 100644 --- a/Server/src/SOR.Game/Handlers/GameReadyHandler.cs +++ b/Server/src/SOR.Game/Handlers/GameReadyHandler.cs @@ -96,7 +96,13 @@ internal sealed class GameReadyHandler : GameHandlerBase, IMessageHandler } if (session.Status != GameSessionStatus.Initializing) - throw new GameException("SESSION_NOT_INITIALIZING"); + { + // Session may already be transitioning/started on another client. + // Reply gracefully so clients can recover instead of surfacing hard errors. + await _gameDb.Database.CommitTransactionAsync(ct); + return ServerMessage.Reply("game.ready.ack", message.Seq, + new GameReadyResponse(session.Id, "AlreadyStarted")); + } // Mark this player ready. if (session.PlayerOneAccountId == accountId) diff --git a/Server/src/SOR.Game/Handlers/GameUnreadyHandler.cs b/Server/src/SOR.Game/Handlers/GameUnreadyHandler.cs index 33ad133..2ce2d53 100644 --- a/Server/src/SOR.Game/Handlers/GameUnreadyHandler.cs +++ b/Server/src/SOR.Game/Handlers/GameUnreadyHandler.cs @@ -44,7 +44,11 @@ internal sealed class GameUnreadyHandler : GameHandlerBase, IMessageHandler ?? throw new GameException("LOBBY_NOT_FOUND"); if (lobby.Status != CustomLobbyStatus.Full) - throw new GameException("LOBBY_NOT_FULL"); + { + // No-op if lobby is not in ready-up state anymore (prevents noisy client errors). + return ServerMessage.Reply("game.custom.lobby.unready.ack", message.Seq, + new UnreadyInLobbyResponse(LobbyId: lobby.Id)); + } if (lobby.HostAccountId == accountId) {