[High] [Bug] Pact System: Raw mana cost never deducted when starting pact ritual #306
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Spec: docs/specs/attunements/invoker/systems/pact-system-spec.md §2.2 step 7
Severity: High
Problem:
src/lib/game/stores/prestigeStore.ts:97-108—startPactRitual()validatesrawMana < guardian.pactCostbut never deducts the cost. The spec explicitly says "Deduct guardian.pactCost raw mana" and the cancellation rule says "not refunded on cancellation," implying it should have been deducted upfront.File:
src/lib/game/stores/prestigeStore.ts:97-108Starting investigation of Issue #306: Pact System raw mana cost never deducted when starting pact ritual.
Bug confirmed. In
startPactRitual()(prestigeStore.ts:97-108), the function validatesrawMana < guardian.pactCostbut never deducts the cost. Per spec §2.2 step 7: "Deduct guardian.pactCost raw mana". The spec §2.5 also confirms the cost should NOT be refunded on cancellation, implying it must be deducted upfront at start.Root cause: The
startPactRitualfunction only setspactRitualFloorandpactRitualProgress, but never calls any mana deduction method.Fix plan: After all validations pass and before
set(), deductguardian.pactCostfrom raw mana usinguseManaStore.getState().spendMana()or equivalent. Need to check the mana store API first.Fix complete. Added
useManaStore.getState().spendRawMana(guardian.pactCost)call instartPactRitual()after all validations pass, before setting ritual state. This implements spec §2.2 step 7: "Deduct guardian.pactCost raw mana".Changes:
src/lib/game/stores/prestigeStore.ts— Added mana deduction after validation guards instartPactRitual()src/lib/game/__tests__/store-actions-combat-prestige.test.ts— Added 2 regression tests:Verification: All 54 test files (1043 tests) pass.