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

Your own row on the board, wherever you rank #95

shipped merged opened this
opened this

statsHtml renders standings(db, 10) and db.ts:136 ends in LIMIT ?1: the board is the top ten and nothing else. A player who has finished four matches and sits eleventh sees a table they are not in, under a line that only says what they are called. They have no rank, no record and no reason to play a fifth.

Done looks like

  • [ ] The leaderboard block shows the visitor's own row wherever they rank: highlighted in place when they are inside the top ten, pinned underneath the table with its true rank when they are not.
  • [ ] A visitor who has played nothing keeps today's "You are playing as …" line and gets no invented row.
  • [ ] src/db.ts grows one query that answers rank and totals for a single identity without reading the whole table — the rank is a count of the identities that outrank them under the order the table already uses (kills DESC, damage DESC), and ties resolve the same way there as in the table.
  • [ ] GET /api/leaderboard answers with the same thing the page shows: a you field, null when there is nothing to say. The identity string still never travels — only the guest flag, exactly as leaderboardJson does today.
  • [ ] The HTML that POST /api/match answers with shows the row already updated: finish a round, and your own line moves.
  • [ ] src/db.test.ts, src/pages/game.test.ts and src/server.test.ts gain tests that fail without it — twelve identities, and the eleventh is shown as rank 11 with their own numbers.

Files I expect to change: src/db.ts, src/pages/game.ts, src/server.ts (the two places statsHtml/leaderboardJson are called already know the player), and their tests.

Risks: a guest's identity is guest:<session> — it is a credential-shaped string and must not reach the page or the JSON, only the guest tag; the name shown for an identity is the one from its most recent match (the comment above standings explains why), so the pinned row must use the same rule or a rename will look like two people; the terminal has no "you" — src/tty.ts is the operator's view and this issue does not touch it, which is worth a sentence in the pull so the parity rule in AGENTS.md is not read as broken.

Waits for #50, which is in pull #76 and rewrites the same rows and the same statsHtml.

Brief that fits: scout.

commented

Ordering note, not a change to this issue: #141 (the leaderboard at 360px) rewrites the same seven-column table this issue adds a row to — it decides which columns survive on a phone and how. The two should not run concurrently, and #141 is the one to do first: this issue then puts a row into a layout that exists instead of one that is about to change under it.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs