@slot-engine/core 0.0.2 → 0.0.4

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/dist/index.d.mts CHANGED
@@ -603,12 +603,6 @@ declare class GameState<TGameModes extends AnyGameModes, TSymbols extends AnySym
603
603
  */
604
604
  getCurrentGameMode(): GameMode;
605
605
  resetState(): void;
606
- /**
607
- * Checks if a max win is reached by comparing `wallet.currentWin` to `config.maxWin`.
608
- *
609
- * Should be called after `wallet.confirmSpinWin()`.
610
- */
611
- isMaxWinTriggered(): void;
612
606
  /**
613
607
  * Empties the list of pending records in the recorder.
614
608
  */
@@ -769,7 +763,7 @@ declare class Board<TGameModes extends AnyGameModes, TSymbols extends AnySymbols
769
763
  */
770
764
  getRandomReelStops(reels: Reels, reelStops: number[][], amount: number): Record<string, number>;
771
765
  /**
772
- * Selects a random reelset based on the configured weights for the current game mode.\
766
+ * Selects a random reel set based on the configured weights of the current result set.\
773
767
  * Returns the reels as arrays of GameSymbols.
774
768
  */
775
769
  getRandomReelset(): Reels;
@@ -879,7 +873,7 @@ declare class GameConfig<TGameModes extends AnyGameModes = AnyGameModes, TSymbol
879
873
  readonly id: string;
880
874
  readonly name: string;
881
875
  readonly gameModes: Record<GameModeName, GameMode>;
882
- readonly symbols: Map<TSymbols[number]["id"], TSymbols[number]>;
876
+ readonly symbols: Map<keyof TSymbols & string, TSymbols[keyof TSymbols]>;
883
877
  readonly padSymbols?: number;
884
878
  readonly scatterToFreespins: Record<string, Record<number, number>>;
885
879
  readonly anticipationTriggers: Record<SpinType, number>;
@@ -896,7 +890,7 @@ declare class GameConfig<TGameModes extends AnyGameModes = AnyGameModes, TSymbol
896
890
  /**
897
891
  * Retrieves a reel set by its ID within a specific game mode.
898
892
  */
899
- getReelsetById(gameMode: string, id: string): ReelGenerator;
893
+ getReelsetById(gameMode: string, id: string): Reels;
900
894
  /**
901
895
  * Retrieves the number of free spins awarded for a given spin type and scatter count.
902
896
  */
@@ -904,11 +898,11 @@ declare class GameConfig<TGameModes extends AnyGameModes = AnyGameModes, TSymbol
904
898
  /**
905
899
  * Retrieves a result set by its criteria within a specific game mode.
906
900
  */
907
- getGameModeCriteria(mode: string, criteria: string): ResultSet<any>;
901
+ getResultSetByCriteria(mode: string, criteria: string): ResultSet<any>;
908
902
  /**
909
903
  * Returns all configured symbols as an array.
910
904
  */
911
- getSymbolArray(): TSymbols[number][];
905
+ getSymbolArray(): TSymbols[keyof TSymbols][];
912
906
  static SPIN_TYPE: {
913
907
  readonly BASE_GAME: "basegame";
914
908
  readonly FREE_SPINS: "freespins";
@@ -928,7 +922,7 @@ declare class WinType {
928
922
  *
929
923
  * This gives the WinType access to the current board.
930
924
  */
931
- context(ctx: AnySimulationContext): WinType;
925
+ context(ctx: SimulationContext<any, any, any>): WinType;
932
926
  protected ensureContext(): void;
933
927
  /**
934
928
  * Implementation of win evaluation logic. Sets `this.payout` and `this.winCombinations`.
@@ -985,7 +979,7 @@ type WildSymbol = GameSymbol | Record<string, any>;
985
979
  declare class LinesWinType extends WinType {
986
980
  protected lines: Record<number, number[]>;
987
981
  protected winCombinations: LineWinCombination[];
988
- context: (ctx: AnySimulationContext) => LinesWinType;
982
+ context: (ctx: SimulationContext<any, any, any>) => LinesWinType;
989
983
  getWins: () => {
990
984
  payout: number;
991
985
  winCombinations: LineWinCombination[];
@@ -1175,64 +1169,14 @@ declare class SlotGame<TGameModes extends AnyGameModes = AnyGameModes, TSymbols
1175
1169
  * @internal
1176
1170
  */
1177
1171
  interface CommonGameOptions<TGameModes extends AnyGameModes = AnyGameModes, TSymbols extends AnySymbols = AnySymbols, TUserState extends AnyUserData = AnyUserData> {
1178
- /**
1179
- * The unique identifier of the game, used for configuration and identification.
1180
- */
1181
1172
  id: string;
1182
- /**
1183
- * The name of the game, used for display purposes.
1184
- */
1185
1173
  name: string;
1186
- /**
1187
- * A GameMode is the core structure of a slot, defining the board,\
1188
- * bet cost, win type, and other properties.
1189
- *
1190
- * One-off mechanisms can also be injected into the core game logic from here.
1191
- */
1192
1174
  gameModes: Record<GameModeName, GameMode>;
1193
- /**
1194
- * A list of all symbols that will appear on the reels.
1195
- */
1196
- symbols: GameSymbol[];
1197
- /**
1198
- * A mapping from spin type to scatter counts to the number of free spins awarded.
1199
- *
1200
- * @example
1201
- * ```ts
1202
- * scatterToFreespins: {
1203
- * [GameConfig.CONSTANTS.BASE_GAME]: {
1204
- * 3: 10,
1205
- * 4: 12,
1206
- * 5: 15,
1207
- * },
1208
- * [GameConfig.CONSTANTS.FREE_SPINS]: {
1209
- * 3: 6,
1210
- * 4: 8,
1211
- * 5: 10,
1212
- * },
1213
- * },
1214
- * ```
1215
- */
1175
+ symbols: TSymbols;
1216
1176
  scatterToFreespins: Record<string, Record<number, number>>;
1217
- /**
1218
- * If set, this will pad the board with symbols on the top and bottom of the reels.\
1219
- * Useful for teasing symbols right above or below the active board.
1220
- *
1221
- * Default: 1
1222
- */
1223
1177
  padSymbols?: number;
1224
- /**
1225
- * The maximum win multiplier of the game, e.g. 5000 for a 5000x max win.
1226
- */
1227
1178
  maxWinX: number;
1228
- /**
1229
- * Hooks are used to inject custom logic at specific points in the game flow.\
1230
- * Some required hooks must be implemented for certain features to work.
1231
- */
1232
1179
  hooks: GameHooks<TGameModes, TSymbols, TUserState>;
1233
- /**
1234
- * Custom additional state that can be used in game flow logic.
1235
- */
1236
1180
  userState?: TUserState;
1237
1181
  }
1238
1182
  /**
@@ -1246,7 +1190,7 @@ type AnyGameModes = Record<string, GameMode>;
1246
1190
  /**
1247
1191
  * @internal
1248
1192
  */
1249
- type AnySymbols = GameSymbol[];
1193
+ type AnySymbols = Record<string, GameSymbol>;
1250
1194
  /**
1251
1195
  * @internal
1252
1196
  */
@@ -1280,19 +1224,67 @@ type HookContext<T> = T extends SlotGame<infer G, infer S, infer U> ? Simulation
1280
1224
 
1281
1225
  type InferGameType<TGameModes extends AnyGameModes, TSymbols extends AnySymbols, TUserState extends AnyUserData> = SlotGame<TGameModes, TSymbols, TUserState>;
1282
1226
  interface CreateSlotGameOpts<TGameModes extends AnyGameModes = AnyGameModes, TSymbols extends AnySymbols = AnySymbols, TUserState extends AnyUserData = AnyUserData> {
1227
+ /**
1228
+ * The unique identifier of the game, used for configuration and identification.
1229
+ */
1283
1230
  id: CommonGameOptions["id"];
1231
+ /**
1232
+ * The name of the game, used for display purposes.
1233
+ */
1284
1234
  name: CommonGameOptions["name"];
1235
+ /**
1236
+ * A GameMode is the core structure of a slot, defining the board,\
1237
+ * bet cost, win type, and other properties.
1238
+ */
1285
1239
  gameModes: TGameModes;
1240
+ /**
1241
+ * A list of all symbols that will appear on the reels.
1242
+ */
1286
1243
  symbols: TSymbols;
1244
+ /**
1245
+ * A mapping from spin type to scatter counts to the number of free spins awarded.
1246
+ *
1247
+ * @example
1248
+ * ```ts
1249
+ * scatterToFreespins: {
1250
+ * [GameConfig.SPIN_TYPE.BASE_GAME]: {
1251
+ * 3: 10,
1252
+ * 4: 12,
1253
+ * 5: 15,
1254
+ * },
1255
+ * [GameConfig.SPIN_TYPE.FREE_SPINS]: {
1256
+ * 3: 6,
1257
+ * 4: 8,
1258
+ * 5: 10,
1259
+ * },
1260
+ * },
1261
+ * ```
1262
+ */
1287
1263
  scatterToFreespins: CommonGameOptions["scatterToFreespins"];
1264
+ /**
1265
+ * If set, this will pad the board with symbols on the top and bottom of the reels.\
1266
+ * Useful for teasing symbols right above or below the active board.
1267
+ *
1268
+ * Default: 1
1269
+ */
1288
1270
  padSymbols?: CommonGameOptions["padSymbols"];
1271
+ /**
1272
+ * The maximum win multiplier of the game, e.g. 5000 for a 5000x max win.
1273
+ */
1289
1274
  maxWinX: CommonGameOptions["maxWinX"];
1275
+ /**
1276
+ * Custom additional state that can be used in game flow logic.
1277
+ */
1290
1278
  userState?: TUserState;
1279
+ /**
1280
+ * Hooks are used to inject custom logic at specific points in the game flow.\
1281
+ * Some required hooks must be implemented for certain features to work.
1282
+ */
1291
1283
  hooks: CommonGameOptions<TGameModes, TSymbols, TUserState>["hooks"];
1292
1284
  }
1293
1285
  declare function createSlotGame<TGame>(opts: TGame extends InferGameType<infer G, infer S, infer U> ? CreateSlotGameOpts<G, S, U> : never): TGame;
1294
1286
  declare const defineUserState: <TUserState extends AnyUserData>(data: TUserState) => TUserState;
1295
- declare const defineSymbols: <TSymbol extends GameSymbol>(symbols: TSymbol[]) => TSymbol[];
1287
+ declare const defineSymbols: <TSymbols extends AnySymbols>(symbols: TSymbols) => TSymbols;
1296
1288
  declare const defineGameModes: <TGameModes extends AnyGameModes>(gameModes: TGameModes) => TGameModes;
1297
1289
  declare const defineReelSets: <TSymbols extends AnySymbols>(reelSets: ReelGenerator[]) => ReelGenerator[];
1298
1290
 
package/dist/index.d.ts CHANGED
@@ -603,12 +603,6 @@ declare class GameState<TGameModes extends AnyGameModes, TSymbols extends AnySym
603
603
  */
604
604
  getCurrentGameMode(): GameMode;
605
605
  resetState(): void;
606
- /**
607
- * Checks if a max win is reached by comparing `wallet.currentWin` to `config.maxWin`.
608
- *
609
- * Should be called after `wallet.confirmSpinWin()`.
610
- */
611
- isMaxWinTriggered(): void;
612
606
  /**
613
607
  * Empties the list of pending records in the recorder.
614
608
  */
@@ -769,7 +763,7 @@ declare class Board<TGameModes extends AnyGameModes, TSymbols extends AnySymbols
769
763
  */
770
764
  getRandomReelStops(reels: Reels, reelStops: number[][], amount: number): Record<string, number>;
771
765
  /**
772
- * Selects a random reelset based on the configured weights for the current game mode.\
766
+ * Selects a random reel set based on the configured weights of the current result set.\
773
767
  * Returns the reels as arrays of GameSymbols.
774
768
  */
775
769
  getRandomReelset(): Reels;
@@ -879,7 +873,7 @@ declare class GameConfig<TGameModes extends AnyGameModes = AnyGameModes, TSymbol
879
873
  readonly id: string;
880
874
  readonly name: string;
881
875
  readonly gameModes: Record<GameModeName, GameMode>;
882
- readonly symbols: Map<TSymbols[number]["id"], TSymbols[number]>;
876
+ readonly symbols: Map<keyof TSymbols & string, TSymbols[keyof TSymbols]>;
883
877
  readonly padSymbols?: number;
884
878
  readonly scatterToFreespins: Record<string, Record<number, number>>;
885
879
  readonly anticipationTriggers: Record<SpinType, number>;
@@ -896,7 +890,7 @@ declare class GameConfig<TGameModes extends AnyGameModes = AnyGameModes, TSymbol
896
890
  /**
897
891
  * Retrieves a reel set by its ID within a specific game mode.
898
892
  */
899
- getReelsetById(gameMode: string, id: string): ReelGenerator;
893
+ getReelsetById(gameMode: string, id: string): Reels;
900
894
  /**
901
895
  * Retrieves the number of free spins awarded for a given spin type and scatter count.
902
896
  */
@@ -904,11 +898,11 @@ declare class GameConfig<TGameModes extends AnyGameModes = AnyGameModes, TSymbol
904
898
  /**
905
899
  * Retrieves a result set by its criteria within a specific game mode.
906
900
  */
907
- getGameModeCriteria(mode: string, criteria: string): ResultSet<any>;
901
+ getResultSetByCriteria(mode: string, criteria: string): ResultSet<any>;
908
902
  /**
909
903
  * Returns all configured symbols as an array.
910
904
  */
911
- getSymbolArray(): TSymbols[number][];
905
+ getSymbolArray(): TSymbols[keyof TSymbols][];
912
906
  static SPIN_TYPE: {
913
907
  readonly BASE_GAME: "basegame";
914
908
  readonly FREE_SPINS: "freespins";
@@ -928,7 +922,7 @@ declare class WinType {
928
922
  *
929
923
  * This gives the WinType access to the current board.
930
924
  */
931
- context(ctx: AnySimulationContext): WinType;
925
+ context(ctx: SimulationContext<any, any, any>): WinType;
932
926
  protected ensureContext(): void;
933
927
  /**
934
928
  * Implementation of win evaluation logic. Sets `this.payout` and `this.winCombinations`.
@@ -985,7 +979,7 @@ type WildSymbol = GameSymbol | Record<string, any>;
985
979
  declare class LinesWinType extends WinType {
986
980
  protected lines: Record<number, number[]>;
987
981
  protected winCombinations: LineWinCombination[];
988
- context: (ctx: AnySimulationContext) => LinesWinType;
982
+ context: (ctx: SimulationContext<any, any, any>) => LinesWinType;
989
983
  getWins: () => {
990
984
  payout: number;
991
985
  winCombinations: LineWinCombination[];
@@ -1175,64 +1169,14 @@ declare class SlotGame<TGameModes extends AnyGameModes = AnyGameModes, TSymbols
1175
1169
  * @internal
1176
1170
  */
1177
1171
  interface CommonGameOptions<TGameModes extends AnyGameModes = AnyGameModes, TSymbols extends AnySymbols = AnySymbols, TUserState extends AnyUserData = AnyUserData> {
1178
- /**
1179
- * The unique identifier of the game, used for configuration and identification.
1180
- */
1181
1172
  id: string;
1182
- /**
1183
- * The name of the game, used for display purposes.
1184
- */
1185
1173
  name: string;
1186
- /**
1187
- * A GameMode is the core structure of a slot, defining the board,\
1188
- * bet cost, win type, and other properties.
1189
- *
1190
- * One-off mechanisms can also be injected into the core game logic from here.
1191
- */
1192
1174
  gameModes: Record<GameModeName, GameMode>;
1193
- /**
1194
- * A list of all symbols that will appear on the reels.
1195
- */
1196
- symbols: GameSymbol[];
1197
- /**
1198
- * A mapping from spin type to scatter counts to the number of free spins awarded.
1199
- *
1200
- * @example
1201
- * ```ts
1202
- * scatterToFreespins: {
1203
- * [GameConfig.CONSTANTS.BASE_GAME]: {
1204
- * 3: 10,
1205
- * 4: 12,
1206
- * 5: 15,
1207
- * },
1208
- * [GameConfig.CONSTANTS.FREE_SPINS]: {
1209
- * 3: 6,
1210
- * 4: 8,
1211
- * 5: 10,
1212
- * },
1213
- * },
1214
- * ```
1215
- */
1175
+ symbols: TSymbols;
1216
1176
  scatterToFreespins: Record<string, Record<number, number>>;
1217
- /**
1218
- * If set, this will pad the board with symbols on the top and bottom of the reels.\
1219
- * Useful for teasing symbols right above or below the active board.
1220
- *
1221
- * Default: 1
1222
- */
1223
1177
  padSymbols?: number;
1224
- /**
1225
- * The maximum win multiplier of the game, e.g. 5000 for a 5000x max win.
1226
- */
1227
1178
  maxWinX: number;
1228
- /**
1229
- * Hooks are used to inject custom logic at specific points in the game flow.\
1230
- * Some required hooks must be implemented for certain features to work.
1231
- */
1232
1179
  hooks: GameHooks<TGameModes, TSymbols, TUserState>;
1233
- /**
1234
- * Custom additional state that can be used in game flow logic.
1235
- */
1236
1180
  userState?: TUserState;
1237
1181
  }
1238
1182
  /**
@@ -1246,7 +1190,7 @@ type AnyGameModes = Record<string, GameMode>;
1246
1190
  /**
1247
1191
  * @internal
1248
1192
  */
1249
- type AnySymbols = GameSymbol[];
1193
+ type AnySymbols = Record<string, GameSymbol>;
1250
1194
  /**
1251
1195
  * @internal
1252
1196
  */
@@ -1280,19 +1224,67 @@ type HookContext<T> = T extends SlotGame<infer G, infer S, infer U> ? Simulation
1280
1224
 
1281
1225
  type InferGameType<TGameModes extends AnyGameModes, TSymbols extends AnySymbols, TUserState extends AnyUserData> = SlotGame<TGameModes, TSymbols, TUserState>;
1282
1226
  interface CreateSlotGameOpts<TGameModes extends AnyGameModes = AnyGameModes, TSymbols extends AnySymbols = AnySymbols, TUserState extends AnyUserData = AnyUserData> {
1227
+ /**
1228
+ * The unique identifier of the game, used for configuration and identification.
1229
+ */
1283
1230
  id: CommonGameOptions["id"];
1231
+ /**
1232
+ * The name of the game, used for display purposes.
1233
+ */
1284
1234
  name: CommonGameOptions["name"];
1235
+ /**
1236
+ * A GameMode is the core structure of a slot, defining the board,\
1237
+ * bet cost, win type, and other properties.
1238
+ */
1285
1239
  gameModes: TGameModes;
1240
+ /**
1241
+ * A list of all symbols that will appear on the reels.
1242
+ */
1286
1243
  symbols: TSymbols;
1244
+ /**
1245
+ * A mapping from spin type to scatter counts to the number of free spins awarded.
1246
+ *
1247
+ * @example
1248
+ * ```ts
1249
+ * scatterToFreespins: {
1250
+ * [GameConfig.SPIN_TYPE.BASE_GAME]: {
1251
+ * 3: 10,
1252
+ * 4: 12,
1253
+ * 5: 15,
1254
+ * },
1255
+ * [GameConfig.SPIN_TYPE.FREE_SPINS]: {
1256
+ * 3: 6,
1257
+ * 4: 8,
1258
+ * 5: 10,
1259
+ * },
1260
+ * },
1261
+ * ```
1262
+ */
1287
1263
  scatterToFreespins: CommonGameOptions["scatterToFreespins"];
1264
+ /**
1265
+ * If set, this will pad the board with symbols on the top and bottom of the reels.\
1266
+ * Useful for teasing symbols right above or below the active board.
1267
+ *
1268
+ * Default: 1
1269
+ */
1288
1270
  padSymbols?: CommonGameOptions["padSymbols"];
1271
+ /**
1272
+ * The maximum win multiplier of the game, e.g. 5000 for a 5000x max win.
1273
+ */
1289
1274
  maxWinX: CommonGameOptions["maxWinX"];
1275
+ /**
1276
+ * Custom additional state that can be used in game flow logic.
1277
+ */
1290
1278
  userState?: TUserState;
1279
+ /**
1280
+ * Hooks are used to inject custom logic at specific points in the game flow.\
1281
+ * Some required hooks must be implemented for certain features to work.
1282
+ */
1291
1283
  hooks: CommonGameOptions<TGameModes, TSymbols, TUserState>["hooks"];
1292
1284
  }
1293
1285
  declare function createSlotGame<TGame>(opts: TGame extends InferGameType<infer G, infer S, infer U> ? CreateSlotGameOpts<G, S, U> : never): TGame;
1294
1286
  declare const defineUserState: <TUserState extends AnyUserData>(data: TUserState) => TUserState;
1295
- declare const defineSymbols: <TSymbol extends GameSymbol>(symbols: TSymbol[]) => TSymbol[];
1287
+ declare const defineSymbols: <TSymbols extends AnySymbols>(symbols: TSymbols) => TSymbols;
1296
1288
  declare const defineGameModes: <TGameModes extends AnyGameModes>(gameModes: TGameModes) => TGameModes;
1297
1289
  declare const defineReelSets: <TSymbols extends AnySymbols>(reelSets: ReelGenerator[]) => ReelGenerator[];
1298
1290