[Medium] [Bug] Spire Climbing: Treasure loot uses non-seeded random, breaking determinism #298

Closed
opened 2026-06-07 17:41:01 +02:00 by Anexim · 1 comment
Owner

Spec: docs/specs/spire-climbing-spec.md §4.9
Severity: Medium

Problem: src/lib/game/utils/spire-utils.ts:273-278 uses Math.random() for treasure item count instead of the seeded random used everywhere else. This means treasure loot varies between page reloads and between ascent/descent.

File: src/lib/game/utils/spire-utils.ts:273-278

**Spec:** docs/specs/spire-climbing-spec.md §4.9 **Severity:** Medium **Problem:** `src/lib/game/utils/spire-utils.ts:273-278` uses `Math.random()` for treasure item count instead of the seeded random used everywhere else. This means treasure loot varies between page reloads and between ascent/descent. **File:** `src/lib/game/utils/spire-utils.ts:273-278`
Anexim added the ai:todo label 2026-06-07 17:41:01 +02:00
n8n-gitea was assigned by Anexim 2026-06-07 17:41:01 +02:00
Anexim added ai:done and removed ai:todo labels 2026-06-08 14:55:33 +02:00
Author
Owner

Fix applied and pushed. Treasure loot now uses seeded random instead of Math.random().

Root cause: generateTreasureLoot() used Math.random() for item count determination, breaking determinism between page reloads and between ascent/descent.

Changes:

  • Added runId parameter to generateTreasureLoot()
  • Created seeded RNG (makeSeededRandom(floor * 12345 + runId + 31337)) for item count determination
  • All item counts now use rng() instead of Math.random()

Tests: 1069 passed (58 files), all pre-commit checks pass.

**Fix applied and pushed.** Treasure loot now uses seeded random instead of `Math.random()`. **Root cause:** `generateTreasureLoot()` used `Math.random()` for item count determination, breaking determinism between page reloads and between ascent/descent. **Changes:** - Added `runId` parameter to `generateTreasureLoot()` - Created seeded RNG (`makeSeededRandom(floor * 12345 + runId + 31337)`) for item count determination - All item counts now use `rng()` instead of `Math.random()` **Tests:** 1069 passed (58 files), all pre-commit checks pass.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#298