feat: ScoreKeeper leaderboard helper#40
Merged
Merged
Conversation
Timer-free helper standardising live (Record), disconnect (FlushLeave), and periodic (FlushAll) leaderboard posting, plus PersistBest/PersistWallet KV sugar. Pure SDK addition over Room.Post + KV — no wire/ABI change. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This was referenced Jun 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
kit.ScoreKeeper, a small timer-free helper that standardises the three ways a game posts to the leaderboard. This is the foundation for making every game record scores and survive disconnects (games + platform changes ride on top in separate PRs).API
Record(r, p, metric)— post live per aCadence(OnImproveposts only on a new high, for monotonic boards;OnChangeon any change).FlushLeave(r, p, status)— post the player's current metric on disconnect (call fromOnLeave); no-op if untracked.FlushAll(r, status)— re-post all tracked players in deterministic AccountID order; continuous games call this fromOnWakeon a throttled interval so an abandoned, still-ticking world keeps recording.PersistBest/PersistWallet— KV resume sugar (MergeMax / MergeSum), folding the duplicated per-gamepersistWallet/persistBesthelpers into one place.Notes
Room.Post+ KV surface — no wire/ABI change. Holds no goroutines/timers, so behaviour stays deterministic under hibernation/replay..changeset/entry marks this a minor bump (next release ≈ v2.11.0).FlushLeavedocs the lower-is-better caveat: the platform reader ranks DNF rows like finished ones, so callers must pass a fair full-run metric (e.g. par-extrapolated) on lower-better boards.Test
6 new tests via
kittestcovering cadence, DNF flush + no-op-after-leave, deterministicFlushAll, and KV merge rules.go test ./...,go build ./...,go vet ./...all clean.🤖 Generated with Claude Code