| 1 | --- |
| 2 | description: Enforce pure server authority — clients send intents only; server owns all gameplay state and outcomes. |
| 3 | alwaysApply: true |
| 4 | --- |
| 5 | |
| 6 | # Pure server authority |
| 7 | |
| 8 | Gameplay is **server-authoritative**. Clients send **intents** only; the server validates, mutates state, and replicates outcomes. Never violate this. |
| 9 | |
| 10 | ## Allowed on the client |
| 11 | |
| 12 | - Send commands (`moveTo`, `attack`, `pickupItem`, craft cancel, `respawn`, …) |
| 13 | - Render snapshots / replication (positions, inventory, combat FX, death UI) |
| 14 | - Local presentation only (zoom, lerp, tooltips, editor overlays) |
| 15 | - Shared pure helpers for **UI preview** (e.g. recipe fit) — never as the source of truth |
| 16 | |
| 17 | ## Forbidden on the client |
| 18 | |
| 19 | - Deciding hits, damage, XP, inventory results, craft success, spawns, death, or final positions |
| 20 | - Trusting client-supplied outcomes (damage numbers, “I hit”, stack merges applied locally as fact) |
| 21 | - Predicting authoritative world mutations without a matching server apply path |
| 22 | |
| 23 | ```text |
| 24 | # ❌ BAD — client applies combat / bag results |
| 25 | onClickAttack(target) { target.hp -= 5; inventory.push(loot); } |
| 26 | |
| 27 | # ✅ GOOD — intent in; wait for server replication |
| 28 | socket.send({ type: MessageType.attack, targetEntityId }); |
| 29 | // apply combatHit / inventory messages from the server |
| 30 | ``` |
| 31 | |
| 32 | ## Server / shared |
| 33 | |
| 34 | - Simulation, combat rolls, pathfinding, spawners, banking, death/respawn live on the server |
| 35 | - `shared/` helpers may be imported by both sides for rules/display; **only the server applies them to live state** |
| 36 | - World editor saves are admin-authored map data, not a player-authority exception for play |
| 37 | |
| 38 | When unsure: if a cheater changing the client could gain an advantage, the logic belongs on the server. |