You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -141,10 +141,12 @@ The frontend renders the pure hex-grid state into a smooth, continuous graphical
141
141
142
142
#### Key Design Patterns
143
143
144
-
-**`main.ts`**: The client-side controller. Manages WebSocket connections, local-AI execution, and phase transitions. It orchestrates the Renderer, Input, and UI through a centralized **`ClientContext`** and a single **`dispatch(GameCommand)`** entry point.
144
+
-**`main.ts`**: The client-side coordinator. Manages WebSocket connections, local-AI execution, and phase transitions. Orchestrates the Renderer, Input, and UI through a centralized **`ClientContext`**. Commands are dispatched via `dispatchGameCommand()` in `game/command-router.ts`.
145
145
-**`renderer/renderer.ts`**: A highly optimized Canvas 2D renderer. It separates logical hex coordinates from pixel coordinates. It features smooth camera interpolation, persistent trails, and movement/combat animations that occur *between* turn phases.
146
146
-**`input.ts`**: Manages user interaction (panning, zooming, clicking). It translates raw browser events into `InputEvent` objects. Pure `interpretInput()` then maps these to `GameCommand[]`, ensuring the input layer never directly mutates the application state.
147
-
-**`game/` / `renderer/` / `ui/` subfolders**: Pure client-side helpers for combat selection, input planning, minimap geometry, phase derivation, formatting, and tooltip/view-model logic.
147
+
-**`game/`**: Command routing, action handlers (astrogation/combat/ordnance), phase derivation, transport abstraction, connection management, input interpretation, view-model helpers, and presentation logic.
-**`ui/`**: Screen visibility, HUD view building, button bindings, game log, fleet building, ship list, formatters, and layout metrics.
148
150
-**`ui/ui.ts`** / **`audio.ts`**: Handles the HTML overlay (menus, HUD) and Web Audio API interactions.
149
151
-**Visual Polish**: Employs a premium design system with glassmorphism tokens (backdrop-filters), tactile micro-animations (recoil, scaling glows), and pulsing orbital effects for high-end UX.
150
152
@@ -196,12 +198,13 @@ main.ts (GameClient)
196
198
├→ renderer/renderer.ts (draw canvas, reads planningState by reference)
197
199
├→ input.ts (parse mouse/keyboard → InputEvent)
198
200
├→ ui/ui.ts (manage screens, accept UIEvent)
201
+
├→ game/command-router.ts (GameCommand → state mutation or network)
199
202
├→ game/network.ts, game/messages.ts (handle S2C)
200
203
├→ game/transport.ts (choose WebSocket or Local)
201
204
├→ game/phase.ts (derive ClientState from GameState)
├→ shared/engine/game-engine.ts (createGame, local resolution)
@@ -242,7 +245,7 @@ An analysis of what could be extracted as a reusable hex-grid multiplayer game f
242
245
243
246
| Component | LOC | Reusability | Notes |
244
247
|-----------|-----|-------------|-------|
245
-
|`shared/hex.ts`|289|**100%**| Zero game knowledge. Axial coords, line draw, pixel conversion. |
248
+
|`shared/hex.ts`|306|**100%**| Zero game knowledge. Axial coords, line draw, pixel conversion. |
246
249
|`shared/util.ts`| 170 |**100%**| Pure FP collection helpers. |
247
250
|`renderer/camera.ts`| 96 |**95%**| Pan/zoom/lerp. Only tie: `HEX_SIZE` constant. |
248
251
|`client/input.ts`| 234 |**90%**| Mouse/touch/pinch → clickHex/hoverHex. No game knowledge. |
@@ -325,4 +328,4 @@ All three engine safety items are complete:
325
328
-**Generic `RuleSet<S, C, E, P>` interface**: Designing a framework from N=1 games is premature abstraction. The current code is readable because it knows what a Ship is.
326
329
-**Full package extraction** (`hex-core`, `match-runtime`, `delta-v-rules`): Wait until game #2 exists. Build the framework from two concrete implementations, not one.
327
330
-**Serialisation codec**: `GameState` is plain JSON. A codec adds overhead with zero current benefit.
328
-
-**UI framework adoption**: The DOM UI layer is ~1900 LOC across 8 files. A framework (Preact, etc.) adds build complexity and migration risk for a layer that works and is small enough to iterate on directly.
331
+
-**UI framework adoption**: The DOM UI layer is ~2100 LOC across 13 files. A framework (Preact, etc.) adds build complexity and migration risk for a layer that works and is small enough to iterate on directly.
Copy file name to clipboardExpand all lines: docs/CODING_STANDARDS.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -241,7 +241,7 @@ Client game modules use two patterns depending on purity (see [dependency inject
241
241
242
242
-**Managers** use a factory pattern: `createXxx(deps: XxxDeps): XxxManager`. The returned object's methods close over the deps. Examples: `createConnectionManager()`, `createTurnTimerManager()`, `createLocalTransport()`.
243
243
244
-
`GameClient` in `main.ts` wires deps objects via lazy getters that bind callbacks to live context. The `dispatch()`switch routes commands to the extracted action functions.
244
+
`GameClient` in `main.ts` wires deps objects via lazy getters that bind callbacks to live context. `dispatchGameCommand()`in `game/command-router.ts` routes commands to the extracted action functions.
245
245
246
246
When adding new side-effecting logic, prefer extending an existing `*Deps` interface over adding methods to `GameClient`. Keep pure derivation functions as direct-parameter exports — they don't need deps.
0 commit comments