๐Ÿ—๏ธ Cozy Parrot Architecture

See also: index ยท runbook ยท opcodes ยท Nakama Multiplayer ยท Plugin Architecture

Components

flowchart LR
  Browser["Browser<br/>CozyParrotGame / Threlte"]
  MM["CozyParrotMatchManager"]
  Sock["Nakama socket"]
  Handler["cozy_parrot match handler<br/>(10 Hz)"]
  Shared["shared types<br/>CozyParrot/*"]

  Browser <--> MM
  MM <--> Sock
  Sock <--> Handler
  Handler --- Shared
  MM --- Shared

Authority

ConcernAuthorityNotes
Move {x,z}Client trustedServer clamps to arena; applied outside result
GrabServer-validatedphase===play, not holding, nearest token โ‰ค INTERACT_RADIUS
ThrowServer-validatedphase===play, holding, โ‰ค INTERACT_RADIUS of hopper; blank / IDEA / โˆ’1 score
Score / prompt / tokens / winnerIdServer-onlySpawned, filled, scored, and broadcast via GameUpdate

Snapshot โ€” CozyParrotMatchSnapshot

FieldTypeRole
playersRecord<id, CozyParrotPlayerState>Positions, score, held token/word
tokensRecord<id, CozyParrotToken>World word tokens
targetPromptCozyParrotPrompttext / blanks / filled
phase'lobby'|'countdown'|'play'|'result'Match lifecycle
timernumberTicks remaining in phase
winnerIdstring | nullSet in result

Lifecycle ticks (10 Hz)

ConstantValueMeaning
COUNTDOWN_TICKS303s pre-play
PLAY_TICKS60060s play
RESULT_TICKS505s results
TOKEN_SPAWN_INTERVAL20Spawn every 2s
MAX_TOKENS10Cap on world tokens
MIN_PLAYERS2Lobby โ†’ countdown

Directory map

games/cozy-parrot/
โ”œโ”€โ”€ frontend/src/lib/
โ”‚   โ”œโ”€โ”€ CozyParrotGame.svelte          # Threlte scene host
โ”‚   โ”œโ”€โ”€ components/                   # Player, RemotePlayer, Token, HUD, Scene
โ”‚   โ””โ”€โ”€ nakama/CozyParrot/
โ”‚       โ””โ”€โ”€ CozyParrotMatchManager.ts # reactive GameUpdate consumer
โ”œโ”€โ”€ shared/src/CozyParrot/index.ts    # snapshot, opcodes, arena consts
โ””โ”€โ”€ nakama/runtime/src/matchHandlers/cozyParrot/
    โ”œโ”€โ”€ index.ts                      # authoritative matchLoop
    โ””โ”€โ”€ createCozyParrotMessageUtils.ts

Ask Docs

AI assistant to help answer questions about the documentation. Answers are read-only and cite docs/source.

Hi! How can I help you with the documentation today? Answers are read-only and cite docs/source.

Ctrl+Enter to send