@energy8platform/platform-core 0.16.1 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -140,27 +140,25 @@ export class SimulationRunner {
140
140
  };
141
141
  }
142
142
 
143
- /** Calculate the real cost of one spin (accounting for buy bonus / ante bet) */
143
+ /**
144
+ * Calculate the real cost of one spin — mirrors v5
145
+ * ActionDefinition.DebitAmount: bet × (cost_multiplier || 1) when
146
+ * debit==='bet', otherwise 0. Returns `bet` as a fallback for unknown
147
+ * actions so RTP math still progresses (we count those as wagered).
148
+ */
144
149
  private calculateSpinCost(
145
150
  action: string,
146
151
  bet: number,
147
152
  gameDefinition: GameDefinition,
148
- params?: Record<string, unknown>,
153
+ _params?: Record<string, unknown>,
149
154
  ): number {
150
- // Check if this is a buy bonus action
151
155
  const actionDef = gameDefinition.actions[action];
152
- if (actionDef?.buy_bonus_mode && gameDefinition.buy_bonus) {
153
- const mode = gameDefinition.buy_bonus.modes[actionDef.buy_bonus_mode];
154
- if (mode) {
155
- return bet * mode.cost_multiplier;
156
- }
157
- }
158
-
159
- // Check ante bet
160
- if (params?.ante_bet && gameDefinition.ante_bet) {
161
- return bet * gameDefinition.ante_bet.cost_multiplier;
156
+ if (!actionDef) return bet;
157
+ if (actionDef.debit !== 'bet') return 0;
158
+ const mult = actionDef.cost_multiplier;
159
+ if (typeof mult === 'number' && mult > 0 && mult !== 1) {
160
+ return bet * mult;
162
161
  }
163
-
164
162
  return bet;
165
163
  }
166
164
  }
package/src/lua/index.ts CHANGED
@@ -17,9 +17,6 @@ export type {
17
17
  LuaEngineConfig,
18
18
  LuaPlayResult,
19
19
  MaxWinConfig,
20
- BuyBonusConfig,
21
- BuyBonusMode,
22
- AnteBetConfig,
23
20
  PersistentStateConfig,
24
21
  BetLevelsConfig,
25
22
  SimulationConfig,
package/src/lua/types.ts CHANGED
@@ -8,9 +8,13 @@ export interface GameDefinition {
8
8
  actions: Record<string, ActionDefinition>;
9
9
  bet_levels?: number[] | BetLevelsConfig;
10
10
  max_win?: MaxWinConfig;
11
- buy_bonus?: BuyBonusConfig;
12
- ante_bet?: AnteBetConfig;
13
11
  persistent_state?: PersistentStateConfig;
12
+ /**
13
+ * Session expiry duration as a Go-style duration string ("24h", "2h", "5ms").
14
+ * Mirrors the platform's GameDefinition.SessionTTL — defaults to 24h on
15
+ * the server when absent. Used by DevBridge to surface SESSION_EXPIRED.
16
+ */
17
+ session_ttl?: string;
14
18
  }
15
19
 
16
20
  export interface BetLevelsConfig {
@@ -24,22 +28,6 @@ export interface MaxWinConfig {
24
28
  fixed?: number;
25
29
  }
26
30
 
27
- export interface BuyBonusConfig {
28
- modes: Record<string, BuyBonusMode>;
29
- }
30
-
31
- export interface BuyBonusMode {
32
- cost_multiplier: number;
33
- /** Distribution of forced scatter counts. Optional — if omitted, Lua script handles bonus setup itself. */
34
- scatter_distribution?: Record<string, number>;
35
- /** Optional description */
36
- description?: string;
37
- }
38
-
39
- export interface AnteBetConfig {
40
- cost_multiplier: number;
41
- }
42
-
43
31
  export interface PersistentStateConfig {
44
32
  vars: string[];
45
33
  exposed_vars: string[];
@@ -47,12 +35,27 @@ export interface PersistentStateConfig {
47
35
 
48
36
  // ─── Actions & Transitions ──────────────────────────────
49
37
 
38
+ /**
39
+ * v5 action contract — cost_multiplier and feature_data live on the action
40
+ * itself. Removed in v5: top-level `buy_bonus`/`ante_bet` blocks, debit modes
41
+ * `'buy_bonus_cost'`/`'ante_bet_cost'`, action.buy_bonus_mode, params.ante_bet/
42
+ * params.buy_bonus flags. Lua reads action context via `state.action` and
43
+ * `state.action_config = { cost_multiplier, feature_data }`.
44
+ */
50
45
  export interface ActionDefinition {
51
46
  stage: string;
52
- debit: 'bet' | 'buy_bonus_cost' | 'ante_bet_cost' | 'none';
47
+ /** Either 'bet' (debit = bet × cost_multiplier) or 'none'/empty (no debit). */
48
+ debit: 'bet' | 'none';
49
+ /** Multiplier on `bet` when debit==='bet'. Defaults to 1.0. */
50
+ cost_multiplier?: number;
51
+ /**
52
+ * Opaque action-specific configuration exposed to Lua as
53
+ * `state.action_config.feature_data`. Common keys: `scatter_distribution`
54
+ * for buy-bonus actions, forced symbol counts, etc.
55
+ */
56
+ feature_data?: Record<string, unknown>;
53
57
  credit?: 'win' | 'none' | 'defer';
54
58
  requires_session?: boolean;
55
- buy_bonus_mode?: string;
56
59
  transitions: TransitionRule[];
57
60
  input_schema?: Record<string, unknown>;
58
61
  }
package/src/types.ts CHANGED
@@ -74,9 +74,6 @@ export type {
74
74
  LuaEngineConfig,
75
75
  LuaPlayResult,
76
76
  MaxWinConfig,
77
- BuyBonusConfig,
78
- BuyBonusMode,
79
- AnteBetConfig,
80
77
  PersistentStateConfig,
81
78
  BetLevelsConfig,
82
79
  SimulationConfig,