@slot-engine/core 0.2.2 → 0.2.3

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
@@ -462,6 +462,14 @@ var Board = class {
462
462
  this.reels[reelIndex].splice(rowIndex, 1);
463
463
  }
464
464
  }
465
+ updateSymbol(reelIndex, rowIndex, properties) {
466
+ const symbol = this.getSymbol(reelIndex, rowIndex);
467
+ if (symbol) {
468
+ for (const [key, value] of Object.entries(properties)) {
469
+ symbol.properties.set(key, value);
470
+ }
471
+ }
472
+ }
465
473
  makeEmptyReels(opts) {
466
474
  const length = opts.reelsAmount ?? opts.ctx.services.game.getCurrentGameMode().reelsAmount;
467
475
  assert3(length, "Cannot make empty reels without context or reelsAmount.");
@@ -831,6 +839,12 @@ var BoardService = class extends AbstractService {
831
839
  removeSymbol(reelIndex, rowIndex) {
832
840
  this.board.removeSymbol(reelIndex, rowIndex);
833
841
  }
842
+ /**
843
+ * Updates properties of the symbol at the specified reel and row index.
844
+ */
845
+ updateSymbol(reelIndex, rowIndex, properties) {
846
+ this.board.updateSymbol(reelIndex, rowIndex, properties);
847
+ }
834
848
  resetReels() {
835
849
  this.board.resetReels({
836
850
  ctx: this.ctx()
@@ -4056,27 +4070,36 @@ var ManywaysWinType = class extends WinType {
4056
4070
  * Calculates wins based on the defined paylines and provided board state.\
4057
4071
  * Retrieve the results using `getWins()` after.
4058
4072
  */
4059
- evaluateWins(board) {
4073
+ evaluateWins(board, opts = {}) {
4060
4074
  this.validateConfig();
4075
+ const { jumpGaps = false } = opts;
4061
4076
  const waysWins = [];
4062
4077
  const reels = board;
4063
4078
  const possibleWaysWins = /* @__PURE__ */ new Map();
4064
4079
  const candidateSymbols = /* @__PURE__ */ new Map();
4065
- let searchReelIdx = 0;
4066
- let searchActive = true;
4067
- while (searchActive && searchReelIdx < reels.length) {
4068
- const reel = reels[searchReelIdx];
4069
- let hasWild = false;
4070
- for (const symbol of reel) {
4071
- candidateSymbols.set(symbol.id, symbol);
4072
- if (this.isWild(symbol)) {
4073
- hasWild = true;
4080
+ if (jumpGaps) {
4081
+ for (const reel of reels) {
4082
+ for (const symbol of reel) {
4083
+ candidateSymbols.set(symbol.id, symbol);
4074
4084
  }
4075
4085
  }
4076
- if (!hasWild) {
4077
- searchActive = false;
4086
+ } else {
4087
+ let searchReelIdx = 0;
4088
+ let searchActive = true;
4089
+ while (searchActive && searchReelIdx < reels.length) {
4090
+ const reel = reels[searchReelIdx];
4091
+ let hasWild = false;
4092
+ for (const symbol of reel) {
4093
+ candidateSymbols.set(symbol.id, symbol);
4094
+ if (this.isWild(symbol)) {
4095
+ hasWild = true;
4096
+ }
4097
+ }
4098
+ if (!hasWild) {
4099
+ searchActive = false;
4100
+ }
4101
+ searchReelIdx++;
4078
4102
  }
4079
- searchReelIdx++;
4080
4103
  }
4081
4104
  for (const baseSymbol of candidateSymbols.values()) {
4082
4105
  let symbolList = {};
@@ -4092,7 +4115,7 @@ var ManywaysWinType = class extends WinType {
4092
4115
  symbolList[ridx].push({ reel: ridx, row: sidx, symbol });
4093
4116
  }
4094
4117
  }
4095
- if (!symbolList[ridx]) {
4118
+ if (!symbolList[ridx] && !jumpGaps) {
4096
4119
  isInterrupted = true;
4097
4120
  break;
4098
4121
  }
@@ -4108,7 +4131,7 @@ var ManywaysWinType = class extends WinType {
4108
4131
  for (const [baseSymbolId, symbolList] of possibleWaysWins.entries()) {
4109
4132
  const wayLength = this.getWayLength(symbolList);
4110
4133
  let baseSymbol = Object.values(symbolList).flatMap((l) => l.map((s) => s)).find((s) => !this.isWild(s.symbol))?.symbol;
4111
- if (!baseSymbol) baseSymbol = symbolList[0][0].symbol;
4134
+ if (!baseSymbol) baseSymbol = symbolList[Object.keys(symbolList)[0]][0].symbol;
4112
4135
  const singleWayPayout = this.getSymbolPayout(baseSymbol, wayLength);
4113
4136
  const totalWays = Object.values(symbolList).reduce(
4114
4137
  (ways, syms) => ways * syms.length,
@@ -4142,7 +4165,7 @@ var ManywaysWinType = class extends WinType {
4142
4165
  return this;
4143
4166
  }
4144
4167
  getWayLength(symbolList) {
4145
- return Math.max(...Object.keys(symbolList).map((k) => parseInt(k, 10))) + 1;
4168
+ return Object.keys(symbolList).length;
4146
4169
  }
4147
4170
  };
4148
4171
 
@@ -4604,6 +4627,12 @@ var StandaloneBoard = class {
4604
4627
  removeSymbol(reelIndex, rowIndex) {
4605
4628
  this.board.removeSymbol(reelIndex, rowIndex);
4606
4629
  }
4630
+ /**
4631
+ * Updates properties of the symbol at the specified reel and row index.
4632
+ */
4633
+ updateSymbol(reelIndex, rowIndex, properties) {
4634
+ this.board.updateSymbol(reelIndex, rowIndex, properties);
4635
+ }
4607
4636
  resetReels() {
4608
4637
  this.board.resetReels({
4609
4638
  ctx: this.ctx