mirror of
https://github.com/Such-Software/wownerogue.git
synced 2026-12-04 12:54:08 +01:00
fix: snapshot payout terms at game start (what-you-saw-is-what-you-get)
Payouts were computed at completion from LIVE config, so an admin changing multipliers mid-game would change the payout of an already-in-progress game. - Migration 016 adds payout_escape_amount/payout_treasure_amount (BIGINT) and the corresponding multipliers to the games table. - Both game-start paths stamp the resolved payout amounts (computed from the config in effect at entry) onto the game row. - completeGame pays from the snapshot, falling back to live calculation only for legacy games that predate the snapshot columns. Adds payoutSnapshot.test.js proving a mid-game config change cannot alter an in-flight payout. Full suite: 15 suites / 131 tests.
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
-- Migration 016: Snapshot payout terms on the game at start
|
||||
--
|
||||
-- Payout amounts were computed at completion time from LIVE config, so an admin changing
|
||||
-- multipliers mid-game would change the payout of an already-in-progress game ("what you
|
||||
-- saw at entry" was not honoured). Snapshot the resolved payout amounts (and the
|
||||
-- multipliers, for audit) onto the games row at start; completion reads the snapshot.
|
||||
--
|
||||
-- Amounts are atomic units (BIGINT, exact). Multipliers are stored for the audit trail.
|
||||
ALTER TABLE games
|
||||
ADD COLUMN IF NOT EXISTS payout_escape_amount BIGINT,
|
||||
ADD COLUMN IF NOT EXISTS payout_treasure_amount BIGINT,
|
||||
ADD COLUMN IF NOT EXISTS payout_escape_mult NUMERIC(8,3),
|
||||
ADD COLUMN IF NOT EXISTS payout_treasure_mult NUMERIC(8,3);
|
||||
Reference in New Issue
Block a user