chore: small fixes
beb41da4
2 file(s) · +7 −2
| 195 | 195 | } |
|
| 196 | 196 | } |
|
| 197 | 197 | ||
| 198 | - | // Level cap validation |
|
| 199 | - | const maxLevel = Math.floor(expectedScore / GAME_CONFIG.LEVEL_SCORE_THRESHOLD) |
|
| 198 | + | // Level cap validation (use claimedScore — it's validated within ±1 of expectedScore |
|
| 199 | + | // and avoids off-by-one at level boundaries from frame-counting timing) |
|
| 200 | + | const maxLevel = Math.floor(claimedScore / GAME_CONFIG.LEVEL_SCORE_THRESHOLD) |
|
| 200 | 201 | if (prevLevel > maxLevel) { |
|
| 201 | 202 | return { ok: false, reason: 'LEVEL_TOO_HIGH' } |
|
| 202 | 203 | } |
| 211 | 211 | ||
| 212 | 212 | try { |
|
| 213 | 213 | const res = await fetch('/api/scores') |
|
| 214 | + | if (!res.ok) { |
|
| 215 | + | leaderboardList.innerHTML = '<p class="error">FAILED TO LOAD</p>' |
|
| 216 | + | return |
|
| 217 | + | } |
|
| 214 | 218 | const data = await res.json() |
|
| 215 | 219 | ||
| 216 | 220 | leaderboardCache.data = data |