Repository navigation
feat(game-center): centre leaderboard slice on local player rank (closes #140) - #146
Merged
Merged
Conversation
#140) When `around != nil`, `GKLeaderboardLoader` now performs a two-step `GKLeaderboard` call: first `loadEntries(for: [GKLocalPlayer.local], timeScope:)` to discover the local player's rank, then `loadEntries(for:timeScope:range:)` with a window of `limit` centred on that rank (clamped to location >= 1). Scope narrowing: the `around: String?` parameter carries a teamPlayerID, which cannot be cheaply converted to a `GKPlayer` (`GKPlayer.loadPlayers(forIdentifiers:)` accepts gamePlayerID, not teamPlayerID). The realistic production use case (CompletionView) is "centre on the local player", so `GKLocalPlayer.local` is used as the rank source whenever `around` is non-nil. A follow-up issue can be filed if any future feature needs centring on a different player. Range arithmetic is extracted to a pure static helper `GKLeaderboardLoader.makeRange(centeredOnRank:limit:)` and unit tested directly; the live `GKLeaderboard` calls remain exercised by Phase 10 manual device validation (consistent with the file's COMPILE-ONLY stance). - `around == nil` path unchanged (existing 3 wiring tests still pass) - 3 new tests cover: centring at rank 50, clamp-to-1 at low rank, nil-rank fallback to top-N
- S1: doc-comment the scope-narrowing on `LeaderboardLoader.loadSlice` protocol — `around != nil` is currently honoured only as "centre on local player", non-local teamPlayerIDs not supported in live impl. - S2: add `locksTopAnchorWhenRankIsOne` boundary test asserting rank=1 → (location: 1, length: 8) without underflow. S3 (follow-up issue for non-local player centring) — will file via gh issue create separately; if the issue is created the doc-comment above should point at its number. Co-Authored-By: Claude Opus 4.7 <[email protected]>
1 task done
wei18
added a commit
that referenced
this pull request
May 26, 2026
…tformat note (#162) * docs: add wiki-migration backlog + 2026-05-26 session log + obsolete swiftformat-option-b note - foundations.md §Backlog: docs/+meetings/ → GitHub Wiki migration (2 options) - meetings/2026-05-26_session-log.md: today's PRs (#146-#161) + module-split status + tooling SSOT recap + operational learnings (CR OR rule, NO-VERIFY, surgical per-file analysis) - swiftformat-option-b.impl-notes.md: OBSOLETED banner (full swiftformat purge same day; decision preserved as history) Co-Authored-By: Claude Opus 4.7 <[email protected]> * docs(meetings): include #144/#145 spillover rows (CR #162 nit) Co-Authored-By: Claude Opus 4.7 <[email protected]> --------- Co-authored-by: Claude Opus 4.7 <[email protected]>
wei18
added a commit
that referenced
this pull request
Jun 3, 2026
…ing (#150) (#285) PR #146's loadSlice(around: PlayerID?) silently substituted GKLocalPlayer.local for any passed id — a dishonest contract (CR S3). True non-local centring isn't reachable via public GameKit API (teamPlayerID->GKPlayer has no mapping). Make the signature honest (aroundLocalPlayer: Bool); update Live/GK/Fake impls + doc, drop the narrowing note. Real non-local centring deferred to a friends feature. Co-authored-by: Claude Opus 4.8 <[email protected]>
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.
Summary
Closes #140. `GKLeaderboardLoader` now honors `around: PlayerID?` by centring the slice on `GKLocalPlayer.local` when non-nil.
Approach (per Leader's pre-research, baked into dispatch)
Implementation
3 files, +115/-12.
CR verdict: APPROVE-WITH-NITS
0 must-fix. 3 should-considers (Leader will inline-apply S1+S2 pre-merge; S3 = follow-up issue):
CR praise
Test plan
🤖 Generated with Claude Code