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

Death and the end of the match read right: spectate the player you are watching, and show the result #11

shipped merged opened this has it
opened this

Finish the two ends of a match — dying and winning — so the game stops leaving you looking at a HUD that belongs to someone else and a menu that never says who won.

Two concrete holes in src/client/main.ts and src/client/hud.ts:

  • spectated() moves the camera to a living teammate when you die, but drawHud is handed world and always reads world.me. So you watch a teammate's view while the HUD shows your zero health, your empty magazine and a crosshair for a corpse. It also never says who killed you.
  • When world.match.phase becomes match_over, the loop stops and calls show(menu, true). The menu still reads "Defuse or detonate": the final score, whether you won, and what you did are nowhere on the screen. postResult(true) refreshes the leaderboard section far below the fold, and that is the only trace.

Done looks like

  • [ ] drawHud takes the player it is drawing rather than reaching for world.me, and shows that player's health, armour, ammo and weapon.
  • [ ] While dead: no crosshair, a clear "watching <name>" line, and a line naming who killed you and with what, taken from the kill feed.
  • [ ] Cycling between living teammates with a click or the fire key while dead, or a stated decision not to and why.
  • [ ] When the round ends, the round result stays on screen through the freeze time — the existing messages line is enough if it survives long enough to read.
  • [ ] At match_over an overlay says who won, the final score, and your kills, deaths, headshots and damage, with a button that starts another match and a button back to the menu. It is DOM like the other overlays, keyboard-reachable, 44px controls, and it does not shift the page.
  • [ ] The overlay appears after postResult(true) has been sent, and a failed post does not stop it appearing.
  • [ ] bun test covers what is headless: the summary's numbers come from a pure function over World (who won, the score from the player's side, the player's line) and it is tested; the server already refuses impossible numbers, so nothing changes there.
  • [ ] bun run scripts/build.ts run and the rebuilt bundle committed.

Files I expect to change

src/client/hud.ts, src/client/main.ts, src/pages/game.ts (the new overlay's markup and its styles), src/client/match.ts or a small new module for the summary, its test, static/app.<hash>.js.

Risks

The HUD signature change touches every call site — there is only one, but the hit markers and the damage indicator are drawn for the player being watched, and a spectator must not see the dead player's old markers. The summary overlay must not steal pointer lock back while the match is over.

Who

The same builder as the damage-indicator issue, after it: both rewrite drawHud's reading of the player, and doing them in the other order means a conflict.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs