How samcorcos/legatum works
Legatum is a browser-based simultaneous-turn historical 4X strategy game. A player starts or joins a lobby, gives orders on a fogged hex map, and submits a turn; the game engine resolves orders and returns views and reports for the next turn. The graph preserves the documented AI, diplomacy, research, victory-race, and multiplayer capabilities. Source excerpts establish the app/store/engine boundary and selected UI calls; several subsystem links are documented in the README rather than verified in unsampled implementation files.
Main entry points: store.ts Game session store · game.rs Game rules engine · App.tsx App routing · screens Setup and game screens
Components 17
Game experience
- App routing
app/src/App.tsx - Game session store
app/src/store.ts - Setup and game screens
app/src/screens - Player commands
app/src/commands.ts - Hex map renderer
app/src/map/render.ts - 3D map view
app/src/map3d/Map3DView.tsx - Sound and feedback
app/src/feel/sound.ts
Game rules
- WASM client
app/src/wasmClient.ts - Game rules engine
crates/core/src/game.rs - Research and unlocks
crates/core/src/research.rs - Diplomacy
app/src/diplomacy.ts - Victory race
app/src/vp.ts
AI opponents
- AI planning
crates/ai/src/lib.rs
Online and persistence
- Online relay
infra/relay/src/index.ts - Online game hosting
app/src/net/hosting.ts - Game archive
app/src/platform/archive.ts
Other components
- Player
Connections 24
- Player → App routing: plays through
README.md - App routing → Game session store: boots and reads
app/src/App.tsx - App routing → Setup and game screens: routes views
app/src/App.tsx - Player → Setup and game screens: sets up or joins
README.md - Setup and game screens → Game session store: submits actions
app/src/screens/gameKeyHandler.ts - Game session store → Player commands: uses game actions
app/src/store.ts - Player commands → Game session store: updates session
app/src/commands.ts - Game session store → WASM client: creates engine client
app/src/store.ts - WASM client → Game rules engine: calls engine
- Game rules engine → Game session store: returns game views
- Game session store → Hex map renderer: supplies game view
- Hex map renderer → Player: renders map
README.md - Player → Hex map renderer: explores and orders
README.md - Player → 3D map view: views alternate map
- Game rules engine → Research and unlocks: computes unlocks
- Player → Research and unlocks: chooses technology
README.md - Game rules engine → AI planning: provides game rules
- AI planning → Game rules engine: plans by same rules
README.md - Player → Diplomacy: proposes treaties
README.md - Player → Victory race: tracks public score
README.md - Game session store → Sound and feedback: selects game music
app/src/main.tsx - Player → Online relay: plays online
README.md - Online relay → Online game hosting: relays multiplayer
- Game session store → Game archive: uploads finished games
app/src/main.tsx