feat(arcade): add Hangman built-in game + leaderboard

Hangman joins Snake as a built-in, leaderboard-backed TUI game (PRD §5.1).
Endless mode: each solved word banks points (longer words and unused guesses
score more) and deals a fresh word with full lives; the run ends when one word
exhausts all six wrong guesses, persisting the total for members under the
"hangman" score key. Guests play without persisting, same as Snake.

Generalize the leaderboard board to take a game name and split the single
"Leaderboard" row into per-game "Leaderboard — Snake" / "Leaderboard — Hangman"
entries.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Anthony Ettinger 2026-06-22 14:59:06 +00:00
parent a56f3afbca
commit 93eaef1184
4 changed files with 314 additions and 12 deletions

View file

@ -10,18 +10,21 @@ import (
"github.com/profullstack/agentbbs/internal/ui"
)
// board renders the global top scores (PRD §5.1 leaderboards).
// board renders the global top scores for one game (PRD §5.1 leaderboards).
type board struct {
ctx plugin.Context
game string
scores []store.Score
err error
}
func newBoard(ctx plugin.Context) *board { return &board{ctx: ctx} }
func newBoard(ctx plugin.Context, game string) *board {
return &board{ctx: ctx, game: game}
}
func (b *board) Init() tea.Cmd {
return func() tea.Msg {
scores, err := b.ctx.Store.TopScores("snake", 10)
scores, err := b.ctx.Store.TopScores(b.game, 10)
return boardMsg{scores: scores, err: err}
}
}
@ -42,7 +45,7 @@ func (b *board) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
func (b *board) View() string {
s := theme.Title("Leaderboard — snake") + "\n\n"
s := theme.Title("Leaderboard — "+b.game) + "\n\n"
switch {
case b.err != nil:
s += ui.Danger.Render("error: " + b.err.Error())