@slot-engine/core 0.2.1 → 0.2.2

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.mjs CHANGED
@@ -429,8 +429,18 @@ var Board = class {
429
429
  * Used for triggering anticipation effects.
430
430
  */
431
431
  anticipation;
432
+ /**
433
+ * The most recent stop positions for the reels.
434
+ */
432
435
  lastDrawnReelStops;
436
+ /**
437
+ * The reel set used in the most recent draw.
438
+ */
433
439
  lastUsedReels;
440
+ /**
441
+ * Indicates whether each reel is locked or not.
442
+ */
443
+ reelsLocked;
434
444
  constructor() {
435
445
  this.reels = [];
436
446
  this.paddingTop = [];
@@ -438,6 +448,7 @@ var Board = class {
438
448
  this.anticipation = [];
439
449
  this.lastDrawnReelStops = [];
440
450
  this.lastUsedReels = [];
451
+ this.reelsLocked = [];
441
452
  }
442
453
  getSymbol(reelIndex, rowIndex) {
443
454
  return this.reels[reelIndex]?.[rowIndex];
@@ -585,14 +596,19 @@ var Board = class {
585
596
  return reelSet;
586
597
  }
587
598
  resetReels(opts) {
588
- const length = opts.reelsAmount ?? opts.ctx.services.game.getCurrentGameMode().reelsAmount;
599
+ const { ctx, reelsAmount, reelsLocked } = opts;
600
+ const length = reelsAmount ?? ctx.services.game.getCurrentGameMode().reelsAmount;
589
601
  this.reels = this.makeEmptyReels(opts);
590
602
  this.anticipation = Array.from({ length }, () => false);
603
+ this.reelsLocked = reelsLocked ?? Array.from({ length }, () => false);
591
604
  this.paddingTop = this.makeEmptyReels(opts);
592
605
  this.paddingBottom = this.makeEmptyReels(opts);
593
606
  }
594
607
  drawBoardMixed(opts) {
595
- this.resetReels(opts);
608
+ this.resetReels({
609
+ ...opts,
610
+ ...this.reelsLocked.length && { reelsLocked: this.reelsLocked }
611
+ });
596
612
  const reelsAmount = opts.reelsAmount ?? opts.ctx.services.game.getCurrentGameMode().reelsAmount;
597
613
  const symbolsPerReel = opts.symbolsPerReel ?? opts.ctx.services.game.getCurrentGameMode().symbolsPerReel;
598
614
  const padSymbols = opts.padSymbols ?? opts.ctx.config.padSymbols;
@@ -621,6 +637,18 @@ var Board = class {
621
637
  );
622
638
  }
623
639
  }
640
+ if (this.reelsLocked.some((locked) => locked) && this.lastDrawnReelStops.length == 0) {
641
+ throw new Error(
642
+ "Cannot draw board with locked reels before drawing it at least once."
643
+ );
644
+ }
645
+ if (this.reelsLocked.some((locked) => locked)) {
646
+ for (let ridx = 0; ridx < reelsAmount; ridx++) {
647
+ if (this.reelsLocked[ridx]) {
648
+ finalReelStops[ridx] = this.lastDrawnReelStops[ridx];
649
+ }
650
+ }
651
+ }
624
652
  this.lastDrawnReelStops = finalReelStops.map((pos) => pos);
625
653
  this.lastUsedReels = opts.reels;
626
654
  for (let ridx = 0; ridx < reelsAmount; ridx++) {
@@ -782,6 +810,9 @@ var BoardService = class extends AbstractService {
782
810
  getAnticipation() {
783
811
  return this.board.anticipation;
784
812
  }
813
+ getLockedReels() {
814
+ return this.board.reelsLocked;
815
+ }
785
816
  /**
786
817
  * Gets the symbol at the specified reel and row index.
787
818
  */
@@ -811,6 +842,12 @@ var BoardService = class extends AbstractService {
811
842
  setAnticipationForReel(reelIndex, value) {
812
843
  this.board.anticipation[reelIndex] = value;
813
844
  }
845
+ /**
846
+ * Sets the locked state for a specific reel.
847
+ */
848
+ setReelLocked(reelIndex, value) {
849
+ this.board.reelsLocked[reelIndex] = value;
850
+ }
814
851
  /**
815
852
  * Counts how many symbols matching the criteria are on a specific reel.
816
853
  */
@@ -4543,6 +4580,12 @@ var StandaloneBoard = class {
4543
4580
  getPaddingBottom() {
4544
4581
  return this.board.paddingBottom;
4545
4582
  }
4583
+ getAnticipation() {
4584
+ return this.board.anticipation;
4585
+ }
4586
+ getLockedReels() {
4587
+ return this.board.reelsLocked;
4588
+ }
4546
4589
  /**
4547
4590
  * Gets the symbol at the specified reel and row index.
4548
4591
  */
@@ -4572,6 +4615,12 @@ var StandaloneBoard = class {
4572
4615
  setAnticipationForReel(reelIndex, value) {
4573
4616
  this.board.anticipation[reelIndex] = value;
4574
4617
  }
4618
+ /**
4619
+ * Sets the locked state for a specific reel.
4620
+ */
4621
+ setReelLocked(reelIndex, value) {
4622
+ this.board.reelsLocked[reelIndex] = value;
4623
+ }
4575
4624
  /**
4576
4625
  * Counts how many symbols matching the criteria are on a specific reel.
4577
4626
  */