@slot-engine/core 0.2.4 → 0.2.5
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.js +24 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -448,11 +448,11 @@ var GameSymbol = class _GameSymbol {
|
|
|
448
448
|
* Creates a clone of this GameSymbol.
|
|
449
449
|
*/
|
|
450
450
|
clone() {
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
451
|
+
const cloned = Object.create(_GameSymbol.prototype);
|
|
452
|
+
cloned.id = this.id;
|
|
453
|
+
cloned.pays = this.pays;
|
|
454
|
+
cloned.properties = this.properties.size > 0 ? new Map(this.properties) : /* @__PURE__ */ new Map();
|
|
455
|
+
return cloned;
|
|
456
456
|
}
|
|
457
457
|
};
|
|
458
458
|
|
|
@@ -505,6 +505,9 @@ var Board = class {
|
|
|
505
505
|
setSymbol(reelIndex, rowIndex, symbol) {
|
|
506
506
|
this.reels[reelIndex] = this.reels[reelIndex] || [];
|
|
507
507
|
this.reels[reelIndex][rowIndex] = symbol;
|
|
508
|
+
this.updateSymbol(reelIndex, rowIndex, {
|
|
509
|
+
position: [reelIndex, rowIndex]
|
|
510
|
+
});
|
|
508
511
|
}
|
|
509
512
|
removeSymbol(reelIndex, rowIndex) {
|
|
510
513
|
if (this.reels[reelIndex]) {
|
|
@@ -713,16 +716,19 @@ var Board = class {
|
|
|
713
716
|
const reelLength = opts.reels[ridx].length;
|
|
714
717
|
for (let p = padSymbols - 1; p >= 0; p--) {
|
|
715
718
|
const topPos = ((reelPos - (p + 1)) % reelLength + reelLength) % reelLength;
|
|
716
|
-
this.paddingTop[ridx].push(opts.reels[ridx][topPos]);
|
|
719
|
+
this.paddingTop[ridx].push(opts.reels[ridx][topPos].clone());
|
|
717
720
|
const bottomPos = (reelPos + symbolsPerReel[ridx] + p) % reelLength;
|
|
718
|
-
this.paddingBottom[ridx].unshift(opts.reels[ridx][bottomPos]);
|
|
721
|
+
this.paddingBottom[ridx].unshift(opts.reels[ridx][bottomPos].clone());
|
|
719
722
|
}
|
|
720
723
|
for (let row = 0; row < symbolsPerReel[ridx]; row++) {
|
|
721
724
|
const symbol = opts.reels[ridx][(reelPos + row) % reelLength];
|
|
722
725
|
if (!symbol) {
|
|
723
726
|
throw new Error(`Failed to get symbol at pos ${reelPos + row} on reel ${ridx}`);
|
|
724
727
|
}
|
|
725
|
-
this.reels[ridx][row] = symbol;
|
|
728
|
+
this.reels[ridx][row] = symbol.clone();
|
|
729
|
+
this.updateSymbol(ridx, row, {
|
|
730
|
+
position: [ridx, row]
|
|
731
|
+
});
|
|
726
732
|
}
|
|
727
733
|
}
|
|
728
734
|
return {
|
|
@@ -790,6 +796,7 @@ var Board = class {
|
|
|
790
796
|
newSymbol = forcedSym;
|
|
791
797
|
}
|
|
792
798
|
(0, import_assert3.default)(newSymbol, "Failed to get new symbol for tumbling.");
|
|
799
|
+
newSymbol = newSymbol.clone();
|
|
793
800
|
this.reels[ridx].unshift(newSymbol);
|
|
794
801
|
newFirstSymbolPositions[ridx] = symbolPos;
|
|
795
802
|
if (!newBoardSymbols[ridx]) {
|
|
@@ -803,7 +810,7 @@ var Board = class {
|
|
|
803
810
|
if (firstSymbolPos === void 0) continue;
|
|
804
811
|
for (let p = 1; p <= padSymbols; p++) {
|
|
805
812
|
const topPos = (firstSymbolPos - p + reels[ridx].length) % reels[ridx].length;
|
|
806
|
-
const padSymbol = reels[ridx][topPos];
|
|
813
|
+
const padSymbol = reels[ridx][topPos]?.clone();
|
|
807
814
|
(0, import_assert3.default)(padSymbol, "Failed to get new padding symbol for tumbling.");
|
|
808
815
|
this.paddingTop[ridx].unshift(padSymbol);
|
|
809
816
|
if (!newPaddingTopSymbols[ridx]) {
|
|
@@ -817,6 +824,14 @@ var Board = class {
|
|
|
817
824
|
return newFirstSymbolPositions[ridx] ?? stop;
|
|
818
825
|
});
|
|
819
826
|
}
|
|
827
|
+
for (let ridx = 0; ridx < reelsAmount; ridx++) {
|
|
828
|
+
const reel = this.reels[ridx];
|
|
829
|
+
for (let rowIdx = 0; rowIdx < reel.length; rowIdx++) {
|
|
830
|
+
this.updateSymbol(ridx, rowIdx, {
|
|
831
|
+
position: [ridx, rowIdx]
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
}
|
|
820
835
|
return {
|
|
821
836
|
newBoardSymbols,
|
|
822
837
|
newPaddingTopSymbols
|