@hizi.io/engine-sdk 0.1.9

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.
Files changed (64) hide show
  1. package/README.md +212 -0
  2. package/lib/api.d.ts +198 -0
  3. package/lib/api.js +352 -0
  4. package/lib/constants.d.ts +44 -0
  5. package/lib/constants.js +56 -0
  6. package/lib/index.d.ts +7 -0
  7. package/lib/index.js +37 -0
  8. package/lib/network.d.ts +9 -0
  9. package/lib/network.js +63 -0
  10. package/lib/types/balance.d.ts +20 -0
  11. package/lib/types/balance.js +2 -0
  12. package/lib/types/blackjack.d.ts +163 -0
  13. package/lib/types/blackjack.js +22 -0
  14. package/lib/types/buyFeatureOption.d.ts +11 -0
  15. package/lib/types/buyFeatureOption.js +2 -0
  16. package/lib/types/collectOptions.d.ts +8 -0
  17. package/lib/types/collectOptions.js +2 -0
  18. package/lib/types/crash.d.ts +223 -0
  19. package/lib/types/crash.js +80 -0
  20. package/lib/types/freePlayInfo.d.ts +11 -0
  21. package/lib/types/freePlayInfo.js +2 -0
  22. package/lib/types/gameResult.d.ts +48 -0
  23. package/lib/types/gameResult.js +2 -0
  24. package/lib/types/gameRoundInfo.d.ts +19 -0
  25. package/lib/types/gameRoundInfo.js +2 -0
  26. package/lib/types/gameSettings.d.ts +133 -0
  27. package/lib/types/gameSettings.js +16 -0
  28. package/lib/types/gameState.d.ts +20 -0
  29. package/lib/types/gameState.js +2 -0
  30. package/lib/types/index.d.ts +32 -0
  31. package/lib/types/index.js +22 -0
  32. package/lib/types/keno.d.ts +34 -0
  33. package/lib/types/keno.js +18 -0
  34. package/lib/types/loadConfigConfig.d.ts +42 -0
  35. package/lib/types/loadConfigConfig.js +2 -0
  36. package/lib/types/loginOptions.d.ts +7 -0
  37. package/lib/types/loginOptions.js +2 -0
  38. package/lib/types/mines.d.ts +26 -0
  39. package/lib/types/mines.js +19 -0
  40. package/lib/types/network.d.ts +24 -0
  41. package/lib/types/network.js +2 -0
  42. package/lib/types/pfVerifyOptions.d.ts +48 -0
  43. package/lib/types/pfVerifyOptions.js +2 -0
  44. package/lib/types/placeBetOptions.d.ts +16 -0
  45. package/lib/types/placeBetOptions.js +2 -0
  46. package/lib/types/progressionCounter.d.ts +65 -0
  47. package/lib/types/progressionCounter.js +2 -0
  48. package/lib/types/replies.d.ts +107 -0
  49. package/lib/types/replies.js +2 -0
  50. package/lib/types/roulette.d.ts +53 -0
  51. package/lib/types/roulette.js +11 -0
  52. package/lib/types/scenarioInfo.d.ts +12 -0
  53. package/lib/types/scenarioInfo.js +2 -0
  54. package/lib/types/sessionOptions.d.ts +7 -0
  55. package/lib/types/sessionOptions.js +2 -0
  56. package/lib/types/spinAward.d.ts +31 -0
  57. package/lib/types/spinAward.js +12 -0
  58. package/lib/types/spinInfo.d.ts +9 -0
  59. package/lib/types/spinInfo.js +2 -0
  60. package/lib/types/tokenData.d.ts +7 -0
  61. package/lib/types/tokenData.js +2 -0
  62. package/lib/websocket.d.ts +27 -0
  63. package/lib/websocket.js +186 -0
  64. package/package.json +19 -0
@@ -0,0 +1,163 @@
1
+ /**
2
+ * Blackjack-specific payloads carried through `IPlaceBetOptions.additionalData`
3
+ * and returned in `IGameResult.scenario`.
4
+ *
5
+ * The full round — engine state, current hands, dealer view, available
6
+ * actions, side bets, totals — lives flat on `result.scenario`. Whether the
7
+ * round is still active is signalled by `engineData.inProgress` on the
8
+ * parent `IGameResult`. Rules switches are shipped once via `loadConfig` and
9
+ * are not echoed on every placeBet.
10
+ */
11
+ export type TBlackjackRank = 'A' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '10' | 'J' | 'Q' | 'K';
12
+ export type TBlackjackSuit = 'S' | 'H' | 'D' | 'C';
13
+ export interface IBlackjackCard {
14
+ rank: TBlackjackRank;
15
+ suit: TBlackjackSuit;
16
+ }
17
+ export type TBlackjackAction = {
18
+ kind: 'hit';
19
+ } | {
20
+ kind: 'stand';
21
+ } | {
22
+ kind: 'double';
23
+ } | {
24
+ kind: 'split';
25
+ } | {
26
+ kind: 'insurance';
27
+ amount: number;
28
+ } | {
29
+ kind: 'evenMoney';
30
+ };
31
+ export type TBlackjackActionKind = TBlackjackAction['kind'];
32
+ export interface IBlackjackSideBets {
33
+ perfectPairs?: {
34
+ stake: number;
35
+ };
36
+ twentyOnePlusThree?: {
37
+ stake: number;
38
+ };
39
+ }
40
+ export interface IBlackjackInitialBet {
41
+ /** Base stake for the main hand. */
42
+ stake: number;
43
+ /** Optional side bets placed with the initial deal. */
44
+ sideBets?: IBlackjackSideBets;
45
+ }
46
+ /**
47
+ * One legal action presented to the player while the round is in progress.
48
+ * Surfaced in `IBlackjackScenario.availableActions`. Empty once settled.
49
+ */
50
+ export interface IBlackjackChoice {
51
+ action: TBlackjackActionKind;
52
+ /** Extra stake the player must post to take this action (double, split, insurance). */
53
+ supplementalStakeCost?: number;
54
+ data?: Record<string, unknown>;
55
+ }
56
+ /**
57
+ * One player hand. `total`/`soft` are kept in sync with `cards` so the client
58
+ * never has to recompute them. All boolean flags are optional — missing
59
+ * means false. `outcome`/`payout` populate at settlement.
60
+ */
61
+ export interface IBlackjackHand {
62
+ cards: IBlackjackCard[];
63
+ total: number;
64
+ /** True when an ace is currently counted as 11 in `total`. Omitted when false. */
65
+ soft?: boolean;
66
+ stake: number;
67
+ isFromSplit?: boolean;
68
+ isFromSplitAces?: boolean;
69
+ busted?: boolean;
70
+ stood?: boolean;
71
+ doubled?: boolean;
72
+ surrendered?: boolean;
73
+ outcome?: 'win' | 'loss' | 'push' | 'blackjack' | 'bust' | 'surrender';
74
+ payout?: number;
75
+ }
76
+ export interface IBlackjackDealer {
77
+ upcard: IBlackjackCard;
78
+ /**
79
+ * Records the dealer-peek result without revealing the hole rank.
80
+ * Omitted when no peek was performed.
81
+ * - 'noBJ' : peeked, no blackjack — round continues.
82
+ * - 'bj' : peeked, dealer has blackjack — round terminates immediately.
83
+ */
84
+ peekState?: 'noBJ' | 'bj';
85
+ /** Full revealed dealer hand, present only at settlement. */
86
+ cards?: IBlackjackCard[];
87
+ /** Final dealer total, present only at settlement. */
88
+ total?: number;
89
+ }
90
+ export interface IBlackjackPerfectPairsBet {
91
+ stake: number;
92
+ /** Present only at settlement. */
93
+ result?: 'mixed' | 'colored' | 'perfect' | 'loss';
94
+ /** Present only at settlement. */
95
+ payout?: number;
96
+ }
97
+ export interface IBlackjackTwentyOnePlusThreeBet {
98
+ stake: number;
99
+ result?: 'flush' | 'straight' | 'threeOfAKind' | 'straightFlush' | 'suitedTrips' | 'loss';
100
+ payout?: number;
101
+ }
102
+ export interface IBlackjackInsuranceBet {
103
+ stake: number;
104
+ won?: boolean;
105
+ payout?: number;
106
+ }
107
+ /**
108
+ * The round shape returned in `result.scenario`.
109
+ *
110
+ * Settlement-only fields (`dealer.cards`, `dealer.total`, each hand's
111
+ * `outcome`/`payout`, side-bet `result`/`payout`, `insurance.won`/`payout`,
112
+ * `capped`/`uncappedTotalWin`) are absent mid-round and populated once the
113
+ * round terminates. Mid-round-only fields (`activeHand`, `phase`,
114
+ * `availableActions`) are dropped at settlement.
115
+ *
116
+ * Use `engineData.inProgress` to gate continuation calls; `phase` carries
117
+ * the finer-grained sub-state (`insurance_offered` vs `player_turn`) while
118
+ * the round is active.
119
+ */
120
+ export interface IBlackjackScenario {
121
+ dealer: IBlackjackDealer;
122
+ hands: IBlackjackHand[];
123
+ /** Index into `hands` of the hand the player is currently acting on. Omitted once the round is settled. */
124
+ activeHand?: number;
125
+ /**
126
+ * Sub-state of the player's decision while the round is in progress.
127
+ * Omitted once settled — use `engineData.inProgress` for round liveness.
128
+ */
129
+ phase?: 'insurance_offered' | 'player_turn';
130
+ /** Legal next-action list — present only when there is a decision to make. */
131
+ availableActions?: IBlackjackChoice[];
132
+ /** Each entry present only when that bet was placed. Whole field omitted when no side bets. */
133
+ sideBets?: {
134
+ perfectPairs?: IBlackjackPerfectPairsBet;
135
+ twentyOnePlusThree?: IBlackjackTwentyOnePlusThreeBet;
136
+ };
137
+ insurance?: IBlackjackInsuranceBet;
138
+ /** True only when the player took even money. Omitted otherwise. */
139
+ evenMoneyTaken?: boolean;
140
+ baseStake: number;
141
+ /**
142
+ * Base stake + every supplemental posted so far. Individual stake amounts
143
+ * are recoverable from `insurance.stake`, `sideBets.*.stake`, and each
144
+ * hand's `stake`. The running supplemental total is `totalStake - baseStake`.
145
+ */
146
+ totalStake: number;
147
+ /** 0 mid-round; gross payout once settled. */
148
+ totalWin: number;
149
+ /** Set when the configured `maxRoundWin` clipped the gross payout. */
150
+ capped?: boolean;
151
+ /** Pre-cap gross payout, present only when `capped` is true. */
152
+ uncappedTotalWin?: number;
153
+ }
154
+ /** Build a `placeBet` additionalData payload for the initial bet of a blackjack round. */
155
+ export declare function blackjackInitialData(sideBets?: IBlackjackSideBets): {
156
+ initialData: {
157
+ sideBets?: IBlackjackSideBets;
158
+ };
159
+ };
160
+ /** Build a `placeBet` additionalData payload for a blackjack continuation (action). */
161
+ export declare function blackjackActionData(action: TBlackjackAction): {
162
+ action: TBlackjackAction;
163
+ };
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ /**
3
+ * Blackjack-specific payloads carried through `IPlaceBetOptions.additionalData`
4
+ * and returned in `IGameResult.scenario`.
5
+ *
6
+ * The full round — engine state, current hands, dealer view, available
7
+ * actions, side bets, totals — lives flat on `result.scenario`. Whether the
8
+ * round is still active is signalled by `engineData.inProgress` on the
9
+ * parent `IGameResult`. Rules switches are shipped once via `loadConfig` and
10
+ * are not echoed on every placeBet.
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.blackjackInitialData = blackjackInitialData;
14
+ exports.blackjackActionData = blackjackActionData;
15
+ /** Build a `placeBet` additionalData payload for the initial bet of a blackjack round. */
16
+ function blackjackInitialData(sideBets) {
17
+ return { initialData: sideBets ? { sideBets } : {} };
18
+ }
19
+ /** Build a `placeBet` additionalData payload for a blackjack continuation (action). */
20
+ function blackjackActionData(action) {
21
+ return { action };
22
+ }
@@ -0,0 +1,11 @@
1
+ /** Describes an available buy-feature (direct purchase of a bonus feature). */
2
+ export interface IBuyFeatureOption {
3
+ /** Feature name referencing the feature's DB (e.g. "freespin"). */
4
+ feature: string;
5
+ /** Buy price as a multiplier of stake (e.g. 100 means cost = 100 x stake). */
6
+ price: number;
7
+ /** Expected return percentage when buying this feature. */
8
+ featureRTP: number;
9
+ /** Spins awarded on initial trigger. */
10
+ initialSpins: number;
11
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ import type { ISessionOptions } from './sessionOptions.js';
2
+ /** Options for the {@link collect} call. */
3
+ export interface ICollectOptions extends ISessionOptions {
4
+ /** Amount to collect. Omit to collect the full available amount. */
5
+ amount?: number;
6
+ /** Additional game-specific parameters (e.g. crash `betHash`). */
7
+ additionalData?: Record<string, unknown>;
8
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,223 @@
1
+ /**
2
+ * Crash payloads exchanged with foe-engine.
3
+ *
4
+ * Crash is a real-time game driven by websocket events:
5
+ *
6
+ * 1. Client calls `placeBet` with one or more bets (each may carry an
7
+ * `autoCashOutMultiplier`). The engine opens the round, debits the
8
+ * total stake, and returns immediately.
9
+ * 2. The engine ticks the curve (`timerIntervalMs`, default 90 ms) and
10
+ * broadcasts `roundTick` events with the live multiplier. Bets with
11
+ * an `autoCashOutMultiplier` settle automatically when the curve
12
+ * crosses their target.
13
+ * 3. The client calls `collect` with a `betHash` (or array of hashes)
14
+ * to cash a manual bet at the current live multiplier.
15
+ * 4. When the curve reaches the committed bust point or every bet has
16
+ * cashed out and the post-cashout flight window expires, the engine
17
+ * broadcasts `roundEnded` followed by `balanceUpdated` and ends the
18
+ * round.
19
+ *
20
+ * If the client reconnects mid-round and calls `placeBet` again with the
21
+ * same token, the engine emits `roundResumed` instead of opening a new
22
+ * round — the existing round, bets and curve are preserved.
23
+ *
24
+ * Each event arrives over the websocket as `{ event, payload }`. The
25
+ * committed crash multiplier is never returned to the client.
26
+ */
27
+ /** A single bet posted to `placeBet`. */
28
+ export interface ICrashBetRequest {
29
+ /** Stake in minor currency units. */
30
+ stake: number;
31
+ /** Decimal target multiplier (e.g. 2.5 = 2.5x). Must be > 1. Omit for manual cashout. */
32
+ autoCashOutMultiplier?: number;
33
+ }
34
+ /** Bet record persisted in `IGameResult.scenario.betsSubmitted`. */
35
+ export interface ICrashBet {
36
+ /** Engine-assigned hash. Use this to cash out via {@link crashCollectData}. */
37
+ hash: string;
38
+ stake: number;
39
+ /** Decimal target if the bet was placed with an auto-cashout. */
40
+ autoCashOutMultiplier?: number;
41
+ /** Multiplier the bet ultimately cashed out at, once settled. */
42
+ multiplierCollected?: number;
43
+ /** Win amount in minor currency units, once settled. */
44
+ amountCollected?: number;
45
+ collected?: boolean;
46
+ /** Set briefly while a cashout is in flight. */
47
+ inProgress?: boolean;
48
+ /** Milliseconds since round `startTime` when the cashout landed. */
49
+ collectedAtinMS?: number;
50
+ }
51
+ /** The scenario returned in `IGameResult.scenario` on the round-opening entry. */
52
+ export interface ICrashScenario {
53
+ /** ISO-8601 timestamp marking when the curve started ticking. */
54
+ startTime: string;
55
+ /** Bets posted on `placeBet`, in submission order. */
56
+ betsSubmitted: ICrashBet[];
57
+ /** Cashouts keyed by bet hash, populated as bets settle. */
58
+ betsCollected?: Record<string, {
59
+ multiplier: number;
60
+ amount: number;
61
+ }>;
62
+ }
63
+ /**
64
+ * Engine `loadConfig` block surfaced through `ILoadConfigReply.config.loadConfig`.
65
+ * Mirrors the creator-side `CrashConfig` (less the human-friendly `name`).
66
+ */
67
+ export interface ICrashLoadConfig {
68
+ /** Multiplier emitted at t=0 of the curve (1 = 1.00x). */
69
+ startMultiplier: number;
70
+ /** Curve resolution / broadcast tick rate in ms. */
71
+ timerIntervalMs: number;
72
+ /** Idle delay after `placeBet` before the curve starts climbing (ms). */
73
+ startGameDelayMs: number;
74
+ /** Target RTP as a fraction (0.95 = 95%). */
75
+ gameRtp: number;
76
+ /** Floor for the drawn crash multiplier (decimal, e.g. 1 = insta-bust). */
77
+ minMultiplier: number;
78
+ /** Hard payout cap. The drawn multiplier is clamped to this value. */
79
+ maxMultiplier: number;
80
+ /** Per-second exponential growth of the curve. */
81
+ growth: number;
82
+ /** Time-scale factor applied to the curve once every bet is collected (e.g. 5 = 5× normal speed). */
83
+ postCashoutSpeedMultiplier: number;
84
+ }
85
+ /** Names of the events emitted over the websocket during a crash round. */
86
+ export type TCrashEventName = 'roundStarted' | 'roundResumed' | 'roundTick' | 'betCashedOut' | 'roundEnded' | 'balanceUpdated';
87
+ /** Sent once per round when the engine has opened the round and the curve is about to tick. */
88
+ export interface ICrashRoundStartedPayload {
89
+ /** Always 0 — emitted before the first tick. */
90
+ currentMultiplier: 0;
91
+ balance?: number;
92
+ /** Hashes for every bet posted, in the same order as `bets`. */
93
+ betHashes: string[];
94
+ /** Engine round id (also returned as `gameRound` on the placeBet reply). */
95
+ roundHash: string;
96
+ }
97
+ /**
98
+ * Sent in response to a `placeBet` made against an already-open round (the
99
+ * client reconnected mid-flight). Carries enough state for the client to
100
+ * rebuild the round view without waiting for the next `roundTick`.
101
+ *
102
+ * The committed bust multiplier is intentionally absent — it is never
103
+ * revealed before the round ends.
104
+ */
105
+ export interface ICrashRoundResumedPayload {
106
+ /** Decimal live multiplier at the moment of resume. */
107
+ currentMultiplier: number;
108
+ /** ISO-8601 timestamp of when the curve started ticking. */
109
+ startTime: string;
110
+ /** Engine round id. */
111
+ roundHash: string;
112
+ /**
113
+ * Bets opened on the original `placeBet`, with `collected` / `multiplierCollected` /
114
+ * `amountCollected` populated for any that have already settled.
115
+ */
116
+ betsSubmitted: ICrashBet[];
117
+ /** Current total winnings on this round (minor units). */
118
+ totalWinValue: number;
119
+ }
120
+ /** Sent every `timerIntervalMs` while the curve is climbing. */
121
+ export interface ICrashRoundTickPayload {
122
+ /** Decimal live multiplier. */
123
+ currentMultiplier: number;
124
+ }
125
+ /** Sent after one or more bets settle (auto or manual). */
126
+ export interface ICrashBetCashedOutPayload {
127
+ /** Highest cashout multiplier in this batch. */
128
+ multiplier: number;
129
+ /** Hashes for the bets that just settled. */
130
+ betHashes: string[];
131
+ /** Cumulative round winnings after this batch (minor units). */
132
+ totalWinValue: number;
133
+ /** Per-bet win amounts in `betHashes` order (minor units). */
134
+ winValues: number[];
135
+ /** Sum of `winValues` (minor units). */
136
+ winValue: number;
137
+ /** `true` when triggered by an auto-cashout, `false` for a manual `collect`. */
138
+ isAuto: boolean;
139
+ }
140
+ /** Sent when the curve reaches the committed bust point. */
141
+ export interface ICrashRoundEndedPayload {
142
+ /** Decimal multiplier the round ended at (== committed bust multiplier). */
143
+ currentMultiplier: number;
144
+ }
145
+ /** Sent immediately after `roundEnded`. */
146
+ export interface ICrashBalanceUpdatedPayload {
147
+ /** Cumulative round winnings (minor units). */
148
+ totalWinValue: number;
149
+ /** Per-bet credits in arbitrary order. */
150
+ winValues: Array<{
151
+ hash: string;
152
+ value: number;
153
+ }>;
154
+ }
155
+ /** Discriminated union of crash websocket events. */
156
+ export type TCrashEvent = {
157
+ event: 'roundStarted';
158
+ payload: ICrashRoundStartedPayload;
159
+ } | {
160
+ event: 'roundResumed';
161
+ payload: ICrashRoundResumedPayload;
162
+ } | {
163
+ event: 'roundTick';
164
+ payload: ICrashRoundTickPayload;
165
+ } | {
166
+ event: 'betCashedOut';
167
+ payload: ICrashBetCashedOutPayload;
168
+ } | {
169
+ event: 'roundEnded';
170
+ payload: ICrashRoundEndedPayload;
171
+ } | {
172
+ event: 'balanceUpdated';
173
+ payload: ICrashBalanceUpdatedPayload;
174
+ };
175
+ /**
176
+ * Named constants for the crash event names. Prefer these over inline
177
+ * string literals so a rename surfaces as a compile error at every consumer.
178
+ */
179
+ export declare const CRASH_EVENTS: {
180
+ readonly ROUND_STARTED: "roundStarted";
181
+ readonly ROUND_RESUMED: "roundResumed";
182
+ readonly ROUND_TICK: "roundTick";
183
+ readonly BET_CASHED_OUT: "betCashedOut";
184
+ readonly ROUND_ENDED: "roundEnded";
185
+ readonly BALANCE_UPDATED: "balanceUpdated";
186
+ };
187
+ /**
188
+ * Build a `placeBet` additionalData payload for a crash round.
189
+ *
190
+ * Pass one bet per simultaneous wager. Bets with an `autoCashOutMultiplier`
191
+ * settle automatically when the curve crosses their target; bets without one
192
+ * must be cashed out manually via {@link crashCollectData}.
193
+ *
194
+ * @example
195
+ * ```ts
196
+ * await placeBet({
197
+ * backendURL,
198
+ * token,
199
+ * additionalData: crashPlaceBetData([
200
+ * { stake: 100, autoCashOutMultiplier: 2.5 },
201
+ * { stake: 100 },
202
+ * ]),
203
+ * });
204
+ * ```
205
+ */
206
+ export declare function crashPlaceBetData(bets: ICrashBetRequest[]): {
207
+ bets: ICrashBetRequest[];
208
+ };
209
+ /**
210
+ * Build a `collect` additionalData payload to manually cash out one or more bets
211
+ * at the live curve multiplier.
212
+ *
213
+ * @param betHash A single bet hash or an array of hashes (from `roundStarted`
214
+ * or `scenario.betsSubmitted`).
215
+ *
216
+ * @example
217
+ * ```ts
218
+ * await collect({ backendURL, token, additionalData: crashCollectData(betHash) });
219
+ * ```
220
+ */
221
+ export declare function crashCollectData(betHash: string | string[]): {
222
+ betHash: string | string[];
223
+ };
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ /**
3
+ * Crash payloads exchanged with foe-engine.
4
+ *
5
+ * Crash is a real-time game driven by websocket events:
6
+ *
7
+ * 1. Client calls `placeBet` with one or more bets (each may carry an
8
+ * `autoCashOutMultiplier`). The engine opens the round, debits the
9
+ * total stake, and returns immediately.
10
+ * 2. The engine ticks the curve (`timerIntervalMs`, default 90 ms) and
11
+ * broadcasts `roundTick` events with the live multiplier. Bets with
12
+ * an `autoCashOutMultiplier` settle automatically when the curve
13
+ * crosses their target.
14
+ * 3. The client calls `collect` with a `betHash` (or array of hashes)
15
+ * to cash a manual bet at the current live multiplier.
16
+ * 4. When the curve reaches the committed bust point or every bet has
17
+ * cashed out and the post-cashout flight window expires, the engine
18
+ * broadcasts `roundEnded` followed by `balanceUpdated` and ends the
19
+ * round.
20
+ *
21
+ * If the client reconnects mid-round and calls `placeBet` again with the
22
+ * same token, the engine emits `roundResumed` instead of opening a new
23
+ * round — the existing round, bets and curve are preserved.
24
+ *
25
+ * Each event arrives over the websocket as `{ event, payload }`. The
26
+ * committed crash multiplier is never returned to the client.
27
+ */
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.CRASH_EVENTS = void 0;
30
+ exports.crashPlaceBetData = crashPlaceBetData;
31
+ exports.crashCollectData = crashCollectData;
32
+ /**
33
+ * Named constants for the crash event names. Prefer these over inline
34
+ * string literals so a rename surfaces as a compile error at every consumer.
35
+ */
36
+ exports.CRASH_EVENTS = {
37
+ ROUND_STARTED: 'roundStarted',
38
+ ROUND_RESUMED: 'roundResumed',
39
+ ROUND_TICK: 'roundTick',
40
+ BET_CASHED_OUT: 'betCashedOut',
41
+ ROUND_ENDED: 'roundEnded',
42
+ BALANCE_UPDATED: 'balanceUpdated',
43
+ };
44
+ /**
45
+ * Build a `placeBet` additionalData payload for a crash round.
46
+ *
47
+ * Pass one bet per simultaneous wager. Bets with an `autoCashOutMultiplier`
48
+ * settle automatically when the curve crosses their target; bets without one
49
+ * must be cashed out manually via {@link crashCollectData}.
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * await placeBet({
54
+ * backendURL,
55
+ * token,
56
+ * additionalData: crashPlaceBetData([
57
+ * { stake: 100, autoCashOutMultiplier: 2.5 },
58
+ * { stake: 100 },
59
+ * ]),
60
+ * });
61
+ * ```
62
+ */
63
+ function crashPlaceBetData(bets) {
64
+ return { bets };
65
+ }
66
+ /**
67
+ * Build a `collect` additionalData payload to manually cash out one or more bets
68
+ * at the live curve multiplier.
69
+ *
70
+ * @param betHash A single bet hash or an array of hashes (from `roundStarted`
71
+ * or `scenario.betsSubmitted`).
72
+ *
73
+ * @example
74
+ * ```ts
75
+ * await collect({ backendURL, token, additionalData: crashCollectData(betHash) });
76
+ * ```
77
+ */
78
+ function crashCollectData(betHash) {
79
+ return { betHash };
80
+ }
@@ -0,0 +1,11 @@
1
+ /** Describes operator-granted free plays (free spin tickets). */
2
+ export interface IFreePlayInfo {
3
+ /** ISO 4217 currency code for the free play. */
4
+ currency: string;
5
+ /** Fixed stake amount for each free play. */
6
+ stake: number;
7
+ /** Number of free plays available. */
8
+ count: number;
9
+ /** Optional feature to enter directly (e.g. "freespin"). */
10
+ feature?: string;
11
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,48 @@
1
+ import type { IScenarioInfo } from './scenarioInfo.js';
2
+ import type { ISpinInfo } from './spinInfo.js';
3
+ import type { TPlayerChoiceAward } from './spinAward.js';
4
+ import type { IProgressionEvent } from './progressionCounter.js';
5
+ /**
6
+ * Primary game result returned by `placeBet()`.
7
+ * Contains the game-specific scenario data and engine state needed
8
+ * to render the outcome and determine the next action.
9
+ *
10
+ * `entryIndex` / `scenarioInfo` / `spinInfo` etc. are produced by the
11
+ * fixed-odds (entries-DB) pipeline. Rules-engine games (blackjack, crash,
12
+ * etc.) derive their result live from RNG and player input — those fields
13
+ * are not meaningful for them and are omitted from the response.
14
+ */
15
+ export interface IGameResult {
16
+ /** Game-specific result data (cast to your game's type for type safety). */
17
+ scenario: Record<string, unknown>;
18
+ /** Engine state controlling round progression. */
19
+ engineData: {
20
+ /** Index of the selected entry in the game database. Fixed-odds only. */
21
+ entryIndex?: number;
22
+ /** Multi-result scenario progression state. Fixed-odds only. */
23
+ scenarioInfo?: IScenarioInfo;
24
+ /** Active feature spin counters. Present when feature spins are in play. */
25
+ spinInfo?: Array<ISpinInfo>;
26
+ /** Pending player choice options. Present when the engine awaits player input. Each option is either a feature-spin award or a cash award (discriminated by the presence of `winMultiplier` vs `feature`/`count`). */
27
+ playerChoice?: TPlayerChoiceAward[];
28
+ /** The feature DB that produced this result. Absent during base game spins. */
29
+ currentFeature?: string;
30
+ /** Feature DB for the next spin. Absent when the round is ending. */
31
+ nextFeature?: string;
32
+ /** Progression counter values reflecting state at the current scenario step.
33
+ * For multi-result scenarios this advances per `placeBet` continuation as the
34
+ * step's per-scenario `progressionAwards` are applied. Present when the game
35
+ * has progression counters configured. */
36
+ progressionCounters?: Record<string, number>;
37
+ /** Progression events that fired at the current scenario step (increments and
38
+ * any resolved threshold-crossing awards). Absent or empty when nothing
39
+ * happened on this step. */
40
+ progressionEvents?: IProgressionEvent[];
41
+ /** Whether the player can call `collect()` right now to cash out. */
42
+ canCollect?: boolean;
43
+ /** Whether more `placeBet` calls are needed to complete this round. */
44
+ inProgress: boolean;
45
+ };
46
+ /** Cumulative win as a multiplier of stake. */
47
+ totalWin: number;
48
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,19 @@
1
+ /** Metadata about the current game round's lifecycle. */
2
+ export interface IGameRoundInfo {
3
+ /** Unique identifier for this game round. */
4
+ hash: string;
5
+ /** Round status: "open" (can collect/wager) or "closed" (round ended). */
6
+ status: string;
7
+ /** Stake amount for this round. */
8
+ stake: number;
9
+ /** Base stake before, not including buy feature costs. */
10
+ baseStake: number;
11
+ /** Game mode identifier. */
12
+ mode: string;
13
+ /** ISO 4217 currency code. */
14
+ currency: string;
15
+ /** Game code this round belongs to. */
16
+ game: string;
17
+ /** Optional multiplier applied to stakes for this player's currency. */
18
+ currencyMultiplier?: number;
19
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });