World / Game Flow
How a shard campaign run moves from tavern entry to exploration, chat, combat, and back again.
This page documents the live runtime loop: a shard campaign launches through the tavern, the hexmap enters exploration, room chat stays active inside that loop, combat interrupts through a phase transition, and resolved encounters return the run to exploration with continuity state still intact.
Player-facing loop
Think of the run as one persistent shard cycle. Tavern entry sets the stage, exploration handles movement and discovery, chat covers in-room conversation, encounter mode takes over when danger commits, and the run returns to exploration when the fight resolves.
- A shard campaign and selected character define the launch context.
- Startup narration and room state are delivered before free exploration begins.
- Chat is part of exploration, not a separate world map or menu mode.
- Combat is a temporary phase shift, not a separate campaign instance.
System-facing loop
The runtime stays server-authoritative. Hexmap bootstraps the launch payload, GameCoordinator loads the current state and unseen events, phase handlers route intents, and the server returns canonical game state, available actions, events, and narration after each meaningful step.
- HexMapController hydrates launch context and dungeon payload.
- GameCoordinatorService ensures game_state, campaign_clock, and initial startup events exist.
- PhaseManager merges server state so exploration and encounter data stay in sync.
- Narration, chat, world mutations, and combat state all flow back through the same runtime shell.
Primary campaign loop
End-to-end run lifecycle
This is the top-level player journey for an active campaign run.
Key points
- The tavern is the first in-world location for a campaign run.
- Exploration is the default phase after startup state has been applied.
- Combat returns to the same persistent campaign state instead of forking a new run.
Launch and tavern startup
How the run boots into the first room
The launch path starts before the player can move: route selection, state hydration, startup narration, and the first encounter-ready room view.
Key points
- Startup narration is delivered as a real room_entered event.
- Campaign clock and current phase are part of the canonical state payload.
- The client processes initial events before normal polling continues.
Encounter room loop
Movement, investigation, turn order, and room-state updates
Encounter is the default runtime loop on the hexmap. Room actions, movement, and conversation stay in this one framework.
Key points
- Movement, search, talk, and explicit end-turn/no-action choices stay in encounter.
- Room narration is first-visit gated and emitted through the event pipeline.
- Chat can update world context without forcing a phase change.
Chat loop
Conversation inside the current room
Room chat runs inside the live hexmap shell so players can converse without leaving the run. The GM path can be deterministic, cached, or algorithm-backed; NPC room reactions and private channels each have their own generation operations.
Key points
- Room channel GM narration uses operation `room_chat_gm_reply`, with optional `room_chat_gm_retry` if authoritative action validation fails.
- Private channels bypass the GM layer and go straight to `channel_npc_reply` for in-character NPC speech.
- Room interjections are two-stage: `npc_interjection_eval_single` decides whether an NPC speaks, then `npc_room_dialogue` generates the actual line for NPCs that passed.
- Deterministic shortcuts and GM response cache hits can skip some or all generation calls for low-variance turns.
Chat workflow detail
Every generation call in the chat pipeline
These are the concrete generation operations used by RoomChatService. They do not all fire on every turn; the pipeline branches based on channel type, deterministic shortcuts, response cache hits, and whether NPC interjections are even eligible.
| Order | Operation | When it runs | Purpose |
|---|---|---|---|
| 1 | room_chat_gm_reply | Room channel only, after deterministic handling and cache lookup both miss. | Primary GM narration/action generation for the current player turn. |
| 2 | room_chat_gm_retry | Only after the primary GM reply proposed mechanical actions that failed authoritative validation. | Regenerates the GM reply using a reality snapshot and validation errors. |
| 3 | npc_interjection_eval_single | Room channel only, once per candidate NPC after the GM reply, excluding directly addressed NPCs that are already forced into consideration. | Binary SPEAK/PASS gate to decide whether a specific NPC should take a turn this round. |
| 4 | npc_room_dialogue | Only for NPCs that passed the interjection gate, unless a deterministic NPC response already handled them. | Produces the actual in-room spoken line for that NPC. |
| A | channel_npc_reply | Private whisper/ability channels instead of the room GM path. | Generates the direct in-character NPC reply for that private channel conversation. |
Branching rules
- If the turn is handled by deterministic room logic, the chat response can complete with zero generation calls.
- If a low-variance GM narration turn hits the response cache, the GM reply also completes with zero GM generation calls.
- Private channels use channel_npc_reply instead of room_chat_gm_reply.
- Each candidate interjecting NPC is evaluated separately, so crowded rooms can trigger multiple npc_interjection_eval_single calls and multiple npc_room_dialogue calls in one player turn.
Combat loop
Encounter phase from initiation through resolution
Combat takes over when the run commits to a hostile encounter, then hands control back after the encounter ends.
Key points
- Encounter state stays server-authoritative through combat APIs and services.
- NPC turns can auto-play through algorithmic or fallback logic.
- Resolved encounters transition back to exploration instead of trapping the run in combat mode.
Authority and transition flow
How client actions become canonical state
The client proposes intent; the server returns the state that actually counts.
Key points
- Phase handlers own the rules for exploration, encounter, and downtime transitions.
- The action rail, narration overlay, and current phase all refresh from returned state.
- This is why campaign time, room narration, and combat phase changes must stay aligned with server responses.