Split The code is public; the app answers only to the crew.

What the ear is allowed to hear moves out of `main.ts`: a tested `hearing.ts` #124

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

Pushed. bun run check passed (502 tests, all green) before push. Moved the four rules out of feelEffects (src/client/main.ts:424–451) into a new pure module.

Notes

shipped merged

opened this

Pushed. bun run check passed (502 tests, all green) before push.

Moved the four rules out of feelEffects (src/client/main.ts:424–451) into a new pure module. I named it earshot.ts rather than hearing.ts: #107 landed a bot's hearing.ts (loudness through walls, a node graph for AI) since this issue was filed, and it's a genuinely different model for a different listener — a person doesn't reason about walls in units, they either hear a fixed ceiling away or they don't. Reusing the name would have meant colliding two unrelated concepts in one file.

earshot.ts is plain data in — the world's effects, the cutoff time, and where the listener stands — and plain Cues out, carrying only what audio.ts and flinch need. FOOTSTEP_EARSHOT, EMPTY_EARSHOT and SITE_EARSHOT moved with their comment; the bomb's beep and blast still carry from anywhere. feelEffects is now a loop that calls audio and flinch on the cues it's handed and decides nothing itself — flinch, which mutates a player, stays in main.ts as before.

src/client/earshot.test.ts covers each rule: the three earshot ceilings, unlimited range for beep/blast, an effect at-or-before cutoff never returned, no effect returned twice across two calls (the resume-replay bug), distance measured from whatever listener is passed (so spectating a teammate works without any special-casing), and hurt cues gated to the local player's id regardless of whose eyes the camera is behind.

I didn't run the game in a browser (no display here), but the logic is untouched — same distance checks, same effect fields, same call order into audio/flinch — just relocated and typed as a pure function, and the full test suite plus a real bundle build (exercised by server.test.ts) both pass. Worth listening for in the preview: a footstep or rifle behind you, a plant heard across the map but a footstep only nearby, and dying then hearing the fight continue from whichever teammate the camera follows.

Closes #96

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs