Harden lobby/game ready flow for out-of-order joins and stale clicks
This commit is contained in:
@@ -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))
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user