@slot-engine/core 0.0.10 → 0.0.11
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 +18 -5
- package/dist/index.d.ts +18 -5
- package/dist/index.js +43 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +43 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -428,7 +428,11 @@ declare class BoardService<TGameModes extends AnyGameModes = AnyGameModes, TSymb
|
|
|
428
428
|
/**
|
|
429
429
|
* Draws a board using specified reel stops.
|
|
430
430
|
*/
|
|
431
|
-
drawBoardWithForcedStops(
|
|
431
|
+
drawBoardWithForcedStops(opts: {
|
|
432
|
+
reels: Reels;
|
|
433
|
+
forcedStops: Record<string, number>;
|
|
434
|
+
randomOffset?: boolean;
|
|
435
|
+
}): void;
|
|
432
436
|
/**
|
|
433
437
|
* Draws a board using random reel stops.
|
|
434
438
|
*/
|
|
@@ -609,7 +613,7 @@ declare class ReelSet {
|
|
|
609
613
|
reels: Reels;
|
|
610
614
|
protected rng: RandomNumberGenerator;
|
|
611
615
|
constructor(opts: ReelSetOptions);
|
|
612
|
-
generateReels(
|
|
616
|
+
generateReels(config: GameConfig): ReelSet;
|
|
613
617
|
/**
|
|
614
618
|
* Reads a reelset CSV file and returns the reels as arrays of GameSymbols.
|
|
615
619
|
*/
|
|
@@ -687,6 +691,11 @@ interface GameModeOpts {
|
|
|
687
691
|
|
|
688
692
|
declare class GameService<TGameModes extends AnyGameModes = AnyGameModes, TSymbols extends AnySymbols = AnySymbols, TUserState extends AnyUserData = AnyUserData> extends AbstractService {
|
|
689
693
|
constructor(ctx: () => GameContext<TGameModes, TSymbols, TUserState>);
|
|
694
|
+
/**
|
|
695
|
+
* Intended for internal use only.\
|
|
696
|
+
* Generates reels for all reel sets in the game configuration.
|
|
697
|
+
*/
|
|
698
|
+
_generateReels(): void;
|
|
690
699
|
/**
|
|
691
700
|
* Retrieves a reel set by its ID within a specific game mode.
|
|
692
701
|
*/
|
|
@@ -1344,7 +1353,7 @@ declare class GeneratedReelSet extends ReelSet {
|
|
|
1344
1353
|
* Checks if a symbol can be placed at the target index without violating spacing rules.
|
|
1345
1354
|
*/
|
|
1346
1355
|
private violatesSpacing;
|
|
1347
|
-
generateReels(
|
|
1356
|
+
generateReels(config: GameConfig): this;
|
|
1348
1357
|
}
|
|
1349
1358
|
interface GeneratedReelSetOptions extends ReelSetOptions {
|
|
1350
1359
|
/**
|
|
@@ -1458,7 +1467,7 @@ declare class StaticReelSet extends ReelSet {
|
|
|
1458
1467
|
private _strReels;
|
|
1459
1468
|
constructor(opts: StaticReelSetOptions);
|
|
1460
1469
|
private validateConfig;
|
|
1461
|
-
generateReels(
|
|
1470
|
+
generateReels(config: GameConfig): this;
|
|
1462
1471
|
}
|
|
1463
1472
|
interface StaticReelSetOptions extends ReelSetOptions {
|
|
1464
1473
|
reels?: string[][];
|
|
@@ -1537,7 +1546,11 @@ declare class StandaloneBoard {
|
|
|
1537
1546
|
/**
|
|
1538
1547
|
* Draws a board using specified reel stops.
|
|
1539
1548
|
*/
|
|
1540
|
-
drawBoardWithForcedStops(
|
|
1549
|
+
drawBoardWithForcedStops(opts: {
|
|
1550
|
+
reels: Reels;
|
|
1551
|
+
forcedStops: Record<string, number>;
|
|
1552
|
+
randomOffset?: boolean;
|
|
1553
|
+
}): void;
|
|
1541
1554
|
/**
|
|
1542
1555
|
* Draws a board using random reel stops.
|
|
1543
1556
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -428,7 +428,11 @@ declare class BoardService<TGameModes extends AnyGameModes = AnyGameModes, TSymb
|
|
|
428
428
|
/**
|
|
429
429
|
* Draws a board using specified reel stops.
|
|
430
430
|
*/
|
|
431
|
-
drawBoardWithForcedStops(
|
|
431
|
+
drawBoardWithForcedStops(opts: {
|
|
432
|
+
reels: Reels;
|
|
433
|
+
forcedStops: Record<string, number>;
|
|
434
|
+
randomOffset?: boolean;
|
|
435
|
+
}): void;
|
|
432
436
|
/**
|
|
433
437
|
* Draws a board using random reel stops.
|
|
434
438
|
*/
|
|
@@ -609,7 +613,7 @@ declare class ReelSet {
|
|
|
609
613
|
reels: Reels;
|
|
610
614
|
protected rng: RandomNumberGenerator;
|
|
611
615
|
constructor(opts: ReelSetOptions);
|
|
612
|
-
generateReels(
|
|
616
|
+
generateReels(config: GameConfig): ReelSet;
|
|
613
617
|
/**
|
|
614
618
|
* Reads a reelset CSV file and returns the reels as arrays of GameSymbols.
|
|
615
619
|
*/
|
|
@@ -687,6 +691,11 @@ interface GameModeOpts {
|
|
|
687
691
|
|
|
688
692
|
declare class GameService<TGameModes extends AnyGameModes = AnyGameModes, TSymbols extends AnySymbols = AnySymbols, TUserState extends AnyUserData = AnyUserData> extends AbstractService {
|
|
689
693
|
constructor(ctx: () => GameContext<TGameModes, TSymbols, TUserState>);
|
|
694
|
+
/**
|
|
695
|
+
* Intended for internal use only.\
|
|
696
|
+
* Generates reels for all reel sets in the game configuration.
|
|
697
|
+
*/
|
|
698
|
+
_generateReels(): void;
|
|
690
699
|
/**
|
|
691
700
|
* Retrieves a reel set by its ID within a specific game mode.
|
|
692
701
|
*/
|
|
@@ -1344,7 +1353,7 @@ declare class GeneratedReelSet extends ReelSet {
|
|
|
1344
1353
|
* Checks if a symbol can be placed at the target index without violating spacing rules.
|
|
1345
1354
|
*/
|
|
1346
1355
|
private violatesSpacing;
|
|
1347
|
-
generateReels(
|
|
1356
|
+
generateReels(config: GameConfig): this;
|
|
1348
1357
|
}
|
|
1349
1358
|
interface GeneratedReelSetOptions extends ReelSetOptions {
|
|
1350
1359
|
/**
|
|
@@ -1458,7 +1467,7 @@ declare class StaticReelSet extends ReelSet {
|
|
|
1458
1467
|
private _strReels;
|
|
1459
1468
|
constructor(opts: StaticReelSetOptions);
|
|
1460
1469
|
private validateConfig;
|
|
1461
|
-
generateReels(
|
|
1470
|
+
generateReels(config: GameConfig): this;
|
|
1462
1471
|
}
|
|
1463
1472
|
interface StaticReelSetOptions extends ReelSetOptions {
|
|
1464
1473
|
reels?: string[][];
|
|
@@ -1537,7 +1546,11 @@ declare class StandaloneBoard {
|
|
|
1537
1546
|
/**
|
|
1538
1547
|
* Draws a board using specified reel stops.
|
|
1539
1548
|
*/
|
|
1540
|
-
drawBoardWithForcedStops(
|
|
1549
|
+
drawBoardWithForcedStops(opts: {
|
|
1550
|
+
reels: Reels;
|
|
1551
|
+
forcedStops: Record<string, number>;
|
|
1552
|
+
randomOffset?: boolean;
|
|
1553
|
+
}): void;
|
|
1541
1554
|
/**
|
|
1542
1555
|
* Draws a board using random reel stops.
|
|
1543
1556
|
*/
|
package/dist/index.js
CHANGED
|
@@ -650,7 +650,11 @@ var Board = class {
|
|
|
650
650
|
for (const [r, stopPos] of Object.entries(opts.forcedStops)) {
|
|
651
651
|
const reelIdx = Number(r);
|
|
652
652
|
const symCount = symbolsPerReel[reelIdx];
|
|
653
|
-
|
|
653
|
+
if (opts.forcedStopsOffset !== false) {
|
|
654
|
+
finalReelStops[reelIdx] = stopPos - Math.round(opts.ctx.services.rng.randomFloat(0, symCount - 1));
|
|
655
|
+
} else {
|
|
656
|
+
finalReelStops[reelIdx] = stopPos;
|
|
657
|
+
}
|
|
654
658
|
if (finalReelStops[reelIdx] < 0) {
|
|
655
659
|
finalReelStops[reelIdx] = opts.reels[reelIdx].length + finalReelStops[reelIdx];
|
|
656
660
|
}
|
|
@@ -693,7 +697,8 @@ var Board = class {
|
|
|
693
697
|
);
|
|
694
698
|
}
|
|
695
699
|
const reels = this.lastUsedReels;
|
|
696
|
-
opts.symbolsToDelete.
|
|
700
|
+
const sortedDeletions = [...opts.symbolsToDelete].sort((a, b) => b.rowIdx - a.rowIdx);
|
|
701
|
+
sortedDeletions.forEach(({ reelIdx, rowIdx }) => {
|
|
697
702
|
this.reels[reelIdx].splice(rowIdx, 1);
|
|
698
703
|
});
|
|
699
704
|
const newFirstSymbolPositions = {};
|
|
@@ -719,6 +724,7 @@ var Board = class {
|
|
|
719
724
|
}
|
|
720
725
|
for (let ridx = 0; ridx < reelsAmount; ridx++) {
|
|
721
726
|
const firstSymbolPos = newFirstSymbolPositions[ridx];
|
|
727
|
+
if (firstSymbolPos === void 0) continue;
|
|
722
728
|
for (let p = 1; p <= padSymbols; p++) {
|
|
723
729
|
const topPos = (firstSymbolPos - p + reels[ridx].length) % reels[ridx].length;
|
|
724
730
|
const padSymbol = reels[ridx][topPos];
|
|
@@ -845,8 +851,8 @@ var BoardService = class extends AbstractService {
|
|
|
845
851
|
/**
|
|
846
852
|
* Draws a board using specified reel stops.
|
|
847
853
|
*/
|
|
848
|
-
drawBoardWithForcedStops(
|
|
849
|
-
this.drawBoardMixed(reels, forcedStops);
|
|
854
|
+
drawBoardWithForcedStops(opts) {
|
|
855
|
+
this.drawBoardMixed(opts.reels, opts.forcedStops, opts.randomOffset);
|
|
850
856
|
}
|
|
851
857
|
/**
|
|
852
858
|
* Draws a board using random reel stops.
|
|
@@ -854,11 +860,12 @@ var BoardService = class extends AbstractService {
|
|
|
854
860
|
drawBoardWithRandomStops(reels) {
|
|
855
861
|
this.drawBoardMixed(reels);
|
|
856
862
|
}
|
|
857
|
-
drawBoardMixed(reels, forcedStops) {
|
|
863
|
+
drawBoardMixed(reels, forcedStops, forcedStopsOffset) {
|
|
858
864
|
this.board.drawBoardMixed({
|
|
859
865
|
ctx: this.ctx(),
|
|
860
866
|
reels,
|
|
861
|
-
forcedStops
|
|
867
|
+
forcedStops,
|
|
868
|
+
forcedStopsOffset
|
|
862
869
|
});
|
|
863
870
|
}
|
|
864
871
|
/**
|
|
@@ -958,6 +965,25 @@ var GameService = class extends AbstractService {
|
|
|
958
965
|
constructor(ctx) {
|
|
959
966
|
super(ctx);
|
|
960
967
|
}
|
|
968
|
+
/**
|
|
969
|
+
* Intended for internal use only.\
|
|
970
|
+
* Generates reels for all reel sets in the game configuration.
|
|
971
|
+
*/
|
|
972
|
+
_generateReels() {
|
|
973
|
+
const config = this.ctx().config;
|
|
974
|
+
for (const mode of Object.values(config.gameModes)) {
|
|
975
|
+
if (mode.reelSets && mode.reelSets.length > 0) {
|
|
976
|
+
for (const reelSet of Object.values(mode.reelSets)) {
|
|
977
|
+
reelSet.associatedGameModeName = mode.name;
|
|
978
|
+
reelSet.generateReels(config);
|
|
979
|
+
}
|
|
980
|
+
} else {
|
|
981
|
+
throw new Error(
|
|
982
|
+
`Game mode "${mode.name}" has no reel sets defined. Cannot generate reelset files.`
|
|
983
|
+
);
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
}
|
|
961
987
|
/**
|
|
962
988
|
* Retrieves a reel set by its ID within a specific game mode.
|
|
963
989
|
*/
|
|
@@ -1839,7 +1865,7 @@ Simulating game mode: ${mode}`);
|
|
|
1839
1865
|
if (mode.reelSets && mode.reelSets.length > 0) {
|
|
1840
1866
|
for (const reelSet of Object.values(mode.reelSets)) {
|
|
1841
1867
|
reelSet.associatedGameModeName = mode.name;
|
|
1842
|
-
reelSet.generateReels(this);
|
|
1868
|
+
reelSet.generateReels(this.gameConfig);
|
|
1843
1869
|
}
|
|
1844
1870
|
} else {
|
|
1845
1871
|
throw new Error(
|
|
@@ -3013,7 +3039,7 @@ var ReelSet = class {
|
|
|
3013
3039
|
this.rng = new RandomNumberGenerator();
|
|
3014
3040
|
this.rng.setSeed(opts.seed ?? 0);
|
|
3015
3041
|
}
|
|
3016
|
-
generateReels(
|
|
3042
|
+
generateReels(config) {
|
|
3017
3043
|
throw new Error("Not implemented");
|
|
3018
3044
|
}
|
|
3019
3045
|
/**
|
|
@@ -3185,7 +3211,7 @@ var GeneratedReelSet = class extends ReelSet {
|
|
|
3185
3211
|
}
|
|
3186
3212
|
return false;
|
|
3187
3213
|
}
|
|
3188
|
-
generateReels(
|
|
3214
|
+
generateReels(config) {
|
|
3189
3215
|
this.validateConfig(config);
|
|
3190
3216
|
const gameMode = config.gameModes[this.associatedGameModeName];
|
|
3191
3217
|
if (!gameMode) {
|
|
@@ -3200,7 +3226,7 @@ var GeneratedReelSet = class extends ReelSet {
|
|
|
3200
3226
|
const exists = import_fs5.default.existsSync(filePath);
|
|
3201
3227
|
if (exists && !this.overrideExisting) {
|
|
3202
3228
|
this.reels = this.parseReelsetCSV(filePath, config);
|
|
3203
|
-
return;
|
|
3229
|
+
return this;
|
|
3204
3230
|
}
|
|
3205
3231
|
if (!exists && this.symbolWeights.size === 0) {
|
|
3206
3232
|
throw new Error(
|
|
@@ -3347,6 +3373,7 @@ var GeneratedReelSet = class extends ReelSet {
|
|
|
3347
3373
|
`Generated reelset ${this.id} for game mode ${this.associatedGameModeName}`
|
|
3348
3374
|
);
|
|
3349
3375
|
}
|
|
3376
|
+
return this;
|
|
3350
3377
|
}
|
|
3351
3378
|
};
|
|
3352
3379
|
|
|
@@ -3382,7 +3409,7 @@ var StaticReelSet = class extends ReelSet {
|
|
|
3382
3409
|
);
|
|
3383
3410
|
}
|
|
3384
3411
|
}
|
|
3385
|
-
generateReels(
|
|
3412
|
+
generateReels(config) {
|
|
3386
3413
|
this.validateConfig(config);
|
|
3387
3414
|
if (this._strReels.length > 0) {
|
|
3388
3415
|
this.reels = this._strReels.map((reel) => {
|
|
@@ -3400,6 +3427,7 @@ var StaticReelSet = class extends ReelSet {
|
|
|
3400
3427
|
if (this.csvPath) {
|
|
3401
3428
|
this.reels = this.parseReelsetCSV(this.csvPath, config);
|
|
3402
3429
|
}
|
|
3430
|
+
return this;
|
|
3403
3431
|
}
|
|
3404
3432
|
};
|
|
3405
3433
|
|
|
@@ -3524,8 +3552,8 @@ var StandaloneBoard = class {
|
|
|
3524
3552
|
/**
|
|
3525
3553
|
* Draws a board using specified reel stops.
|
|
3526
3554
|
*/
|
|
3527
|
-
drawBoardWithForcedStops(
|
|
3528
|
-
this.drawBoardMixed(reels, forcedStops);
|
|
3555
|
+
drawBoardWithForcedStops(opts) {
|
|
3556
|
+
this.drawBoardMixed(opts.reels, opts.forcedStops, opts.randomOffset);
|
|
3529
3557
|
}
|
|
3530
3558
|
/**
|
|
3531
3559
|
* Draws a board using random reel stops.
|
|
@@ -3533,11 +3561,12 @@ var StandaloneBoard = class {
|
|
|
3533
3561
|
drawBoardWithRandomStops(reels) {
|
|
3534
3562
|
this.drawBoardMixed(reels);
|
|
3535
3563
|
}
|
|
3536
|
-
drawBoardMixed(reels, forcedStops) {
|
|
3564
|
+
drawBoardMixed(reels, forcedStops, forcedStopsOffset) {
|
|
3537
3565
|
this.board.drawBoardMixed({
|
|
3538
3566
|
ctx: this.ctx,
|
|
3539
3567
|
reels,
|
|
3540
3568
|
forcedStops,
|
|
3569
|
+
forcedStopsOffset,
|
|
3541
3570
|
reelsAmount: this.reelsAmount,
|
|
3542
3571
|
symbolsPerReel: this.symbolsPerReel,
|
|
3543
3572
|
padSymbols: this.padSymbols
|