@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.
- package/README.md +25 -3
- package/dist/dev-bridge.cjs.js +175 -74
- package/dist/dev-bridge.cjs.js.map +1 -1
- package/dist/dev-bridge.d.ts +50 -33
- package/dist/dev-bridge.esm.js +175 -74
- package/dist/dev-bridge.esm.js.map +1 -1
- package/dist/index.cjs.js +175 -74
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +51 -34
- package/dist/index.esm.js +175 -74
- package/dist/index.esm.js.map +1 -1
- package/dist/lua.cjs.js +142 -37
- package/dist/lua.cjs.js.map +1 -1
- package/dist/lua.d.ts +40 -22
- package/dist/lua.esm.js +142 -37
- package/dist/lua.esm.js.map +1 -1
- package/dist/simulation.d.ts +23 -17
- package/package.json +1 -1
- package/scripts/install-simulate.mjs +1 -1
- package/src/dev-bridge/DevBridge.ts +187 -82
- package/src/index.ts +0 -3
- package/src/lua/LuaEngine.ts +128 -23
- package/src/lua/SessionManager.ts +23 -1
- package/src/lua/SimulationRunner.ts +12 -14
- package/src/lua/index.ts +0 -3
- package/src/lua/types.ts +23 -20
- package/src/types.ts +0 -3
|
@@ -140,27 +140,25 @@ export class SimulationRunner {
|
|
|
140
140
|
};
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
/**
|
|
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
|
-
|
|
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
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
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
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
|
-
|
|
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
|
}
|