feat(registry): player profiles, results, ELO ladders and records boards #1

Merged
kblack0610 merged 1 commit from feat/leaderboards into main 2026-10-04 16:47:11 +00:00
Owner

Splits main.go by concern and adds:

  • a game field on servers, with ?game= on the list; a heartbeat can update game_rules/server_name so a host keeps its join code across game swaps; an empty address takes the caller IP
  • two token tiers: SERVER_TOKEN results are verified, HOST_TOKEN results are stored unverified and never move ratings
  • PUT/GET /api/v1/players/{id}, POST /api/v1/results, GET /api/v1/leaderboards/{ladder}, GET /api/v1/records/{game}/{metric}
  • ELO (K=32, start 1000, team average, pairwise for 3+ teams)

Also fixes timestamps that always read 0001-01-01, the rate limiter keying on ip:port, and trusting X-Forwarded-For unconditionally (now TRUST_PROXY=1).

Tested: go test -race ./... 18 tests in golang:1.22-alpine; docker build registry/ and a smoke of the image. Existing routes and fields unchanged for DodginBalls.

https://claude.ai/code/session_013RaBMfSwZjGaigg6JwHv7w

Splits main.go by concern and adds: - a `game` field on servers, with `?game=` on the list; a heartbeat can update `game_rules`/`server_name` so a host keeps its join code across game swaps; an empty `address` takes the caller IP - two token tiers: SERVER_TOKEN results are verified, HOST_TOKEN results are stored unverified and never move ratings - `PUT/GET /api/v1/players/{id}`, `POST /api/v1/results`, `GET /api/v1/leaderboards/{ladder}`, `GET /api/v1/records/{game}/{metric}` - ELO (K=32, start 1000, team average, pairwise for 3+ teams) Also fixes timestamps that always read 0001-01-01, the rate limiter keying on ip:port, and trusting X-Forwarded-For unconditionally (now TRUST_PROXY=1). Tested: `go test -race ./...` 18 tests in golang:1.22-alpine; `docker build registry/` and a smoke of the image. Existing routes and fields unchanged for DodginBalls. https://claude.ai/code/session_013RaBMfSwZjGaigg6JwHv7w
Split main.go into config, db, middleware, ratelimit, servers, players,
results/elo and boards files. Existing server routes keep their paths and
JSON field names.

- Two token tiers: SERVER_TOKEN (verified) and optional HOST_TOKEN (results
  stored unverified, never move ratings). The body's verified field is ignored.
- game column on game_servers (additive migration), ?game= filter on the list.
- Heartbeat may update server_name, game and game_rules; "" means leave it.
- Register without address uses the caller's IP (X-Forwarded-For only with
  TRUST_PROXY=1, which now also keys the rate limiter).
- PUT/GET /api/v1/players/{id}, POST /api/v1/results (match or record),
  GET /api/v1/leaderboards/{ladder}, GET /api/v1/records/{game}/{metric}.
- Fixes: created_at/last_heartbeat were always 0001-01-01 (DATETIME scanned
  into a string); rate limiter lost fractional refills; crypto/rand ids.

Claude-Session: https://claude.ai/code/session_013RaBMfSwZjGaigg6JwHv7w
kblack0610 deleted branch feat/leaderboards 2026-10-04 16:47:12 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
kblack0610/bnb-game-servers!1
No description provided.