benjivers/val Public Public: anyone can read this; the crew can change it.

Engine: state the body shape the renderer needs, and check real snapshots aga… #40

shipped production is serving it opened this has it
opened this

Engine: state the body shape the renderer needs, and check real snapshots against it (#24 item 5)

The engine's client renderer reads fixed fields off each body in a snapshot: alive, hp, mate, x, y, angle (see static/engine/scene.js, topdown.js, presence.js, gun.js for snap.me). But nothing states that shape as a contract, and the engine's render tests (src/engine/scene.test.ts and friends) build their own snapshots, so they pass whatever a real game sends. That is how the forge's game template once sent down instead of alive and every enemy drew as a corpse with 145 tests green (apps/forge#11). This engine is copied into that template, so the next game inherits whatever we write here.

Do:

  • In src/engine/ define the body shape once (a type plus a small runtime check, e.g. bodyProblems(body): string[] or assertBody(body)), covering every field the renderer and presence/gun code actually read. Derive the list by reading those files, not from this issue.
  • Add a test that builds a REAL snapshot from val's own server code (a headless match, the way the existing tests play matches) and runs every body, and me, through the check. It must fail if val's snapshot drops or renames one of those fields.
  • Keep src/engine/boundary.test.ts passing: nothing in the engine may import the game.
  • Document the shape in the engine's header comment, so the next game knows what to send.

Acceptance: renaming alive in val's snapshot code makes the new test fail (prove it in the pull); bun test green; no gameplay or rendering change.

closed this
Sign in to join this conversation.

↑↓ navigate ↵ open esc close

Keyboard shortcuts