docs: fix tavern lobby spec after review

This commit is contained in:
2026-04-14 01:04:09 +02:00
parent 0455cf3180
commit d86d7cbf22

View File

@@ -47,16 +47,38 @@ SceneManager.transition_to("refectory")
# etc.
```
**Startup:** `SceneManager._ready()` loads `tavern.tscn` into `CurrentScene`.
**On `game_started`:** Logs placeholder message. Role-based routing (player → chamber, dm → dm variant) is stubbed but not active.
**Startup:** `SceneManager._ready()` loads `tavern.tscn` into `CurrentScene` — but only on client instances. The dedicated server must not load any 3D scene:
```gdscript
func _ready() -> void:
var is_server := OS.has_feature("dedicated_server") \
or "--server" in OS.get_cmdline_user_args()
if not is_server:
transition_to("tavern")
```
**`game_started` ownership:** `SceneManager` is the sole listener for `NetworkManager.game_started`. `tavern.gd` does NOT connect to this signal — that connection is removed compared to `lobby.gd`. On `game_started`, `SceneManager` logs a placeholder; the actual scene swap to `chamber` comes in the next feature.
**Role-based routing (stub, not active):**
```gdscript
func _load_for_role(scene_name: String) -> void:
# my_id is only valid after NetworkManager._on_connected_to_server fires.
# Never call this before game_started, as my_id will be 0.
var role = NetworkManager.players.get(NetworkManager.my_id, {}).get("role", "player")
# "dm" → dm variant — activated in next feature
```
**`transition_to` null guard:** The scene registry includes future entries whose `.tscn` files do not yet exist. `transition_to` must guard against missing files:
```gdscript
func transition_to(scene_name: String) -> void:
var path = SCENES.get(scene_name, "")
var packed = load(path) if path else null
if packed == null:
push_error("[SceneManager] Scene not found: %s" % scene_name)
return
# swap CurrentScene child
```
**Scene registry** (internal Dictionary):
```gdscript
const SCENES := {
@@ -103,7 +125,7 @@ After joining (`_on_connected`): JoinPanel hides, WaitPanel shows — 3D scene v
| Create | `ruf-der-pilze/scenes/tavern.tscn` |
| Create | `ruf-der-pilze/scripts/tavern.gd` |
| Create | `ruf-der-pilze/scripts/scene_manager.gd` |
| Modify | `ruf-der-pilze/scenes/main.tscn` — add `CurrentScene` node, remove lobby reference |
| Modify | `ruf-der-pilze/scenes/main.tscn` — add `CurrentScene` node; delete `[node name="Lobby"]` entry and the `ext_resource` referencing `lobby.tscn` |
| Modify | `ruf-der-pilze/project.godot` — add SceneManager autoload, change main scene |
| Delete | `ruf-der-pilze/scenes/lobby.tscn` |
| Delete | `ruf-der-pilze/scripts/lobby.gd` |