@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.mjs
CHANGED
|
@@ -598,7 +598,11 @@ var Board = class {
|
|
|
598
598
|
for (const [r, stopPos] of Object.entries(opts.forcedStops)) {
|
|
599
599
|
const reelIdx = Number(r);
|
|
600
600
|
const symCount = symbolsPerReel[reelIdx];
|
|
601
|
-
|
|
601
|
+
if (opts.forcedStopsOffset !== false) {
|
|
602
|
+
finalReelStops[reelIdx] = stopPos - Math.round(opts.ctx.services.rng.randomFloat(0, symCount - 1));
|
|
603
|
+
} else {
|
|
604
|
+
finalReelStops[reelIdx] = stopPos;
|
|
605
|
+
}
|
|
602
606
|
if (finalReelStops[reelIdx] < 0) {
|
|
603
607
|
finalReelStops[reelIdx] = opts.reels[reelIdx].length + finalReelStops[reelIdx];
|
|
604
608
|
}
|
|
@@ -641,7 +645,8 @@ var Board = class {
|
|
|
641
645
|
);
|
|
642
646
|
}
|
|
643
647
|
const reels = this.lastUsedReels;
|
|
644
|
-
opts.symbolsToDelete.
|
|
648
|
+
const sortedDeletions = [...opts.symbolsToDelete].sort((a, b) => b.rowIdx - a.rowIdx);
|
|
649
|
+
sortedDeletions.forEach(({ reelIdx, rowIdx }) => {
|
|
645
650
|
this.reels[reelIdx].splice(rowIdx, 1);
|
|
646
651
|
});
|
|
647
652
|
const newFirstSymbolPositions = {};
|
|
@@ -667,6 +672,7 @@ var Board = class {
|
|
|
667
672
|
}
|
|
668
673
|
for (let ridx = 0; ridx < reelsAmount; ridx++) {
|
|
669
674
|
const firstSymbolPos = newFirstSymbolPositions[ridx];
|
|
675
|
+
if (firstSymbolPos === void 0) continue;
|
|
670
676
|
for (let p = 1; p <= padSymbols; p++) {
|
|
671
677
|
const topPos = (firstSymbolPos - p + reels[ridx].length) % reels[ridx].length;
|
|
672
678
|
const padSymbol = reels[ridx][topPos];
|
|
@@ -793,8 +799,8 @@ var BoardService = class extends AbstractService {
|
|
|
793
799
|
/**
|
|
794
800
|
* Draws a board using specified reel stops.
|
|
795
801
|
*/
|
|
796
|
-
drawBoardWithForcedStops(
|
|
797
|
-
this.drawBoardMixed(reels, forcedStops);
|
|
802
|
+
drawBoardWithForcedStops(opts) {
|
|
803
|
+
this.drawBoardMixed(opts.reels, opts.forcedStops, opts.randomOffset);
|
|
798
804
|
}
|
|
799
805
|
/**
|
|
800
806
|
* Draws a board using random reel stops.
|
|
@@ -802,11 +808,12 @@ var BoardService = class extends AbstractService {
|
|
|
802
808
|
drawBoardWithRandomStops(reels) {
|
|
803
809
|
this.drawBoardMixed(reels);
|
|
804
810
|
}
|
|
805
|
-
drawBoardMixed(reels, forcedStops) {
|
|
811
|
+
drawBoardMixed(reels, forcedStops, forcedStopsOffset) {
|
|
806
812
|
this.board.drawBoardMixed({
|
|
807
813
|
ctx: this.ctx(),
|
|
808
814
|
reels,
|
|
809
|
-
forcedStops
|
|
815
|
+
forcedStops,
|
|
816
|
+
forcedStopsOffset
|
|
810
817
|
});
|
|
811
818
|
}
|
|
812
819
|
/**
|
|
@@ -906,6 +913,25 @@ var GameService = class extends AbstractService {
|
|
|
906
913
|
constructor(ctx) {
|
|
907
914
|
super(ctx);
|
|
908
915
|
}
|
|
916
|
+
/**
|
|
917
|
+
* Intended for internal use only.\
|
|
918
|
+
* Generates reels for all reel sets in the game configuration.
|
|
919
|
+
*/
|
|
920
|
+
_generateReels() {
|
|
921
|
+
const config = this.ctx().config;
|
|
922
|
+
for (const mode of Object.values(config.gameModes)) {
|
|
923
|
+
if (mode.reelSets && mode.reelSets.length > 0) {
|
|
924
|
+
for (const reelSet of Object.values(mode.reelSets)) {
|
|
925
|
+
reelSet.associatedGameModeName = mode.name;
|
|
926
|
+
reelSet.generateReels(config);
|
|
927
|
+
}
|
|
928
|
+
} else {
|
|
929
|
+
throw new Error(
|
|
930
|
+
`Game mode "${mode.name}" has no reel sets defined. Cannot generate reelset files.`
|
|
931
|
+
);
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
}
|
|
909
935
|
/**
|
|
910
936
|
* Retrieves a reel set by its ID within a specific game mode.
|
|
911
937
|
*/
|
|
@@ -1787,7 +1813,7 @@ Simulating game mode: ${mode}`);
|
|
|
1787
1813
|
if (mode.reelSets && mode.reelSets.length > 0) {
|
|
1788
1814
|
for (const reelSet of Object.values(mode.reelSets)) {
|
|
1789
1815
|
reelSet.associatedGameModeName = mode.name;
|
|
1790
|
-
reelSet.generateReels(this);
|
|
1816
|
+
reelSet.generateReels(this.gameConfig);
|
|
1791
1817
|
}
|
|
1792
1818
|
} else {
|
|
1793
1819
|
throw new Error(
|
|
@@ -2961,7 +2987,7 @@ var ReelSet = class {
|
|
|
2961
2987
|
this.rng = new RandomNumberGenerator();
|
|
2962
2988
|
this.rng.setSeed(opts.seed ?? 0);
|
|
2963
2989
|
}
|
|
2964
|
-
generateReels(
|
|
2990
|
+
generateReels(config) {
|
|
2965
2991
|
throw new Error("Not implemented");
|
|
2966
2992
|
}
|
|
2967
2993
|
/**
|
|
@@ -3133,7 +3159,7 @@ var GeneratedReelSet = class extends ReelSet {
|
|
|
3133
3159
|
}
|
|
3134
3160
|
return false;
|
|
3135
3161
|
}
|
|
3136
|
-
generateReels(
|
|
3162
|
+
generateReels(config) {
|
|
3137
3163
|
this.validateConfig(config);
|
|
3138
3164
|
const gameMode = config.gameModes[this.associatedGameModeName];
|
|
3139
3165
|
if (!gameMode) {
|
|
@@ -3148,7 +3174,7 @@ var GeneratedReelSet = class extends ReelSet {
|
|
|
3148
3174
|
const exists = fs5.existsSync(filePath);
|
|
3149
3175
|
if (exists && !this.overrideExisting) {
|
|
3150
3176
|
this.reels = this.parseReelsetCSV(filePath, config);
|
|
3151
|
-
return;
|
|
3177
|
+
return this;
|
|
3152
3178
|
}
|
|
3153
3179
|
if (!exists && this.symbolWeights.size === 0) {
|
|
3154
3180
|
throw new Error(
|
|
@@ -3295,6 +3321,7 @@ var GeneratedReelSet = class extends ReelSet {
|
|
|
3295
3321
|
`Generated reelset ${this.id} for game mode ${this.associatedGameModeName}`
|
|
3296
3322
|
);
|
|
3297
3323
|
}
|
|
3324
|
+
return this;
|
|
3298
3325
|
}
|
|
3299
3326
|
};
|
|
3300
3327
|
|
|
@@ -3330,7 +3357,7 @@ var StaticReelSet = class extends ReelSet {
|
|
|
3330
3357
|
);
|
|
3331
3358
|
}
|
|
3332
3359
|
}
|
|
3333
|
-
generateReels(
|
|
3360
|
+
generateReels(config) {
|
|
3334
3361
|
this.validateConfig(config);
|
|
3335
3362
|
if (this._strReels.length > 0) {
|
|
3336
3363
|
this.reels = this._strReels.map((reel) => {
|
|
@@ -3348,6 +3375,7 @@ var StaticReelSet = class extends ReelSet {
|
|
|
3348
3375
|
if (this.csvPath) {
|
|
3349
3376
|
this.reels = this.parseReelsetCSV(this.csvPath, config);
|
|
3350
3377
|
}
|
|
3378
|
+
return this;
|
|
3351
3379
|
}
|
|
3352
3380
|
};
|
|
3353
3381
|
|
|
@@ -3472,8 +3500,8 @@ var StandaloneBoard = class {
|
|
|
3472
3500
|
/**
|
|
3473
3501
|
* Draws a board using specified reel stops.
|
|
3474
3502
|
*/
|
|
3475
|
-
drawBoardWithForcedStops(
|
|
3476
|
-
this.drawBoardMixed(reels, forcedStops);
|
|
3503
|
+
drawBoardWithForcedStops(opts) {
|
|
3504
|
+
this.drawBoardMixed(opts.reels, opts.forcedStops, opts.randomOffset);
|
|
3477
3505
|
}
|
|
3478
3506
|
/**
|
|
3479
3507
|
* Draws a board using random reel stops.
|
|
@@ -3481,11 +3509,12 @@ var StandaloneBoard = class {
|
|
|
3481
3509
|
drawBoardWithRandomStops(reels) {
|
|
3482
3510
|
this.drawBoardMixed(reels);
|
|
3483
3511
|
}
|
|
3484
|
-
drawBoardMixed(reels, forcedStops) {
|
|
3512
|
+
drawBoardMixed(reels, forcedStops, forcedStopsOffset) {
|
|
3485
3513
|
this.board.drawBoardMixed({
|
|
3486
3514
|
ctx: this.ctx,
|
|
3487
3515
|
reels,
|
|
3488
3516
|
forcedStops,
|
|
3517
|
+
forcedStopsOffset,
|
|
3489
3518
|
reelsAmount: this.reelsAmount,
|
|
3490
3519
|
symbolsPerReel: this.symbolsPerReel,
|
|
3491
3520
|
padSymbols: this.padSymbols
|