Skip to content

Commit af10f53

Browse files
B2JK-Industryclaude
andcommitted
fix(score): post-game modal — return credited delta, not state total
ScoreSuccess.resources je type-doc-ovaný ako "credited resource delta", ale BE vracal credit.resources (= total state.resources po pripočítaní). PostGameBreakdown chip-y to renderovali ako "+98691 watts" namiesto skutočnej +12 watts delty z hry. - app/api/score/route.ts:172 — resources = trimmed (delta), nie credit.resources (total) - app/api/score/route.ts:107 — narrow type na Partial<Record<ResourceKey, number>> User-trust kritické: bez fix-u modal sľuboval desaťtisíce zdrojov ktoré sa nezhmotnili v reálnom stave. Tests: typecheck clean, lint 0 errors, vitest 719/719 pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 91bf026 commit af10f53

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

app/api/score/route.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export async function POST(request: NextRequest) {
104104
// the anti-grind rule: replays that don't beat the prior best yield 0.
105105
// Ledger dedupe key: `score:${gameId}:${previousBest}->${newBest}` — that
106106
// exact transition can happen at most once per player.
107-
let resources = null as Awaited<ReturnType<typeof getPlayerState>>["resources"] | null;
107+
let resources: Partial<Record<ResourceKey, number>> | null = null;
108108
let capped = false;
109109
// HIGH-4: expose the breakdown so the post-game modal can render the
110110
// ladder; the final number the modal shows is guaranteed to match the
@@ -169,7 +169,11 @@ export async function POST(request: NextRequest) {
169169
),
170170
);
171171
}
172-
resources = credit.resources;
172+
// Return the credited delta (what this score added), not the
173+
// post-credit total state — the post-game modal reads this field
174+
// as a delta and would otherwise render the player's full balance
175+
// as the per-game gain.
176+
resources = trimmed;
173177
}
174178
}
175179

0 commit comments

Comments
 (0)