| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
import { expect, test } from "bun:test"; |
| 9 |
import { valGame } from "./arena.ts"; |
| 10 |
import { snapshotProblems } from "./engine/body.ts"; |
| 11 |
import { newMatch } from "./match.ts"; |
| 12 |
|
| 13 |
test("every body and `me` in a real snapshot of a running match fits the contract", () => { |
| 14 |
const state = newMatch(7); |
| 15 |
const game = valGame(state, () => {}); |
| 16 |
for (let i = 0; i < 90; i++) game.step(state, 1 / 30); |
| 17 |
let bodies = 0; |
| 18 |
for (const viewer of state.players) { |
| 19 |
const seen = state.players.filter((p) => p.id === viewer.id || game.visible(state, viewer, p)); |
| 20 |
const snap = game.snapshot(state, viewer, seen) as { me: unknown; players: unknown[] }; |
| 21 |
expect(snapshotProblems(snap)).toEqual([]); |
| 22 |
bodies += snap.players.length; |
| 23 |
} |
| 24 |
expect(bodies).toBeGreaterThan(state.players.length); |
| 25 |
}); |