Repository navigation
Notify players when they break a top score - #52
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e2f8195199
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const topScore = previousTop && score > previousTop.score | ||
| ? { game, previousScore: previousTop.score, newScore: score, previousHolder: previousTop.gamertag } | ||
| : null; |
There was a problem hiding this comment.
Treat leaderboard tie-breakers as record changes
When a result matches the current high score but has a faster time, Accounts.leaderboard() ranks it first using seconds as a tie-breaker, yet this strict score comparison returns null. This is especially common in Pong, where scores are highly repetitive, and means the leaderboard can acquire a new leader without showing the notification this change is intended to provide. Compare the complete leaderboard ordering rather than only score.
Useful? React with 👍 / 👎.
| user: () => currentUser, | ||
| signIn: () => dialog.showModal(), | ||
| record: async result => { if (!currentUser) return null; const recorded = await api('/api/results', { method: 'POST', body: JSON.stringify(result) }); showUnlocks(recorded.unlocked || []); return recorded; }, | ||
| record: async result => { if (!currentUser) return null; const recorded = await api('/api/results', { method: 'POST', body: JSON.stringify(result) }); showTopScore(recorded.topScore); showUnlocks(recorded.unlocked || []); return recorded; }, |
There was a problem hiding this comment.
Queue top-score and achievement notifications together
When a record-breaking result also unlocks an achievement, this line immediately displays both notifications. Both toasts are fixed at the same bottom-right coordinates in arcade.css, and the new top-score toast has the higher z-index, so it covers the achievement toast until that toast expires after 5.2 seconds. Route the top-score notification through the existing queue or otherwise offset/sequence the two notifications.
Useful? React with 👍 / 👎.
Motivation
Description
record()inserver/accounts.jsnow queries the current top entry for the game before inserting the new result and returns atopScoreobject when the new score beats the previous top (includesgame,previousScore,newScore, andpreviousHolder).arcade.jsaddsshowTopScore()with rotating congratulations messages and an accessible toast UI, andwindow.Arcade.recordnow invokesshowTopScore(recorded.topScore)when a record-breaking result is returned..top-score-toaststyles and reduced-motion support toarcade.cssfor responsive, animated presentation and a dismissal control.profile.jswill pre-select the leaderboard tab when?game=is present in the URL so leaderboard links open the correct game tab.tests/accounts.test.jsverifying initial, lower, and record-breaking scores and that a record-breaking response contains the correct previous/new score and prior holder.Testing
npm test(node --test) and all tests passed: 93 passed, 0 failed.npm run checkand static checks passed without errors.git diff --checkand no check issues were reported.Codex Task