@slot-engine/core 0.2.10 → 0.2.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 +0 -11
- package/dist/index.d.ts +0 -11
- package/dist/index.js +48 -51
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48 -51
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -723,17 +723,6 @@ declare class Book {
|
|
|
723
723
|
* Adds an event to the book.
|
|
724
724
|
*/
|
|
725
725
|
addEvent(event: Omit<BookEvent, "index">): void;
|
|
726
|
-
/**
|
|
727
|
-
* Intended for internal use only.
|
|
728
|
-
*/
|
|
729
|
-
_serialize(): {
|
|
730
|
-
id: number;
|
|
731
|
-
criteria: string;
|
|
732
|
-
events: BookEvent[];
|
|
733
|
-
payout: number;
|
|
734
|
-
basegameWins: number;
|
|
735
|
-
freespinsWins: number;
|
|
736
|
-
};
|
|
737
726
|
}
|
|
738
727
|
interface BookEvent {
|
|
739
728
|
index: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -723,17 +723,6 @@ declare class Book {
|
|
|
723
723
|
* Adds an event to the book.
|
|
724
724
|
*/
|
|
725
725
|
addEvent(event: Omit<BookEvent, "index">): void;
|
|
726
|
-
/**
|
|
727
|
-
* Intended for internal use only.
|
|
728
|
-
*/
|
|
729
|
-
_serialize(): {
|
|
730
|
-
id: number;
|
|
731
|
-
criteria: string;
|
|
732
|
-
events: BookEvent[];
|
|
733
|
-
payout: number;
|
|
734
|
-
basegameWins: number;
|
|
735
|
-
freespinsWins: number;
|
|
736
|
-
};
|
|
737
726
|
}
|
|
738
727
|
interface BookEvent {
|
|
739
728
|
index: number;
|
package/dist/index.js
CHANGED
|
@@ -1468,19 +1468,6 @@ var Book = class {
|
|
|
1468
1468
|
data: copy(event.data)
|
|
1469
1469
|
});
|
|
1470
1470
|
}
|
|
1471
|
-
/**
|
|
1472
|
-
* Intended for internal use only.
|
|
1473
|
-
*/
|
|
1474
|
-
_serialize() {
|
|
1475
|
-
return {
|
|
1476
|
-
id: this.id,
|
|
1477
|
-
criteria: this.criteria,
|
|
1478
|
-
events: this.events,
|
|
1479
|
-
payout: this.payout,
|
|
1480
|
-
basegameWins: this.basegameWins,
|
|
1481
|
-
freespinsWins: this.freespinsWins
|
|
1482
|
-
};
|
|
1483
|
-
}
|
|
1484
1471
|
};
|
|
1485
1472
|
|
|
1486
1473
|
// src/wallet/index.ts
|
|
@@ -1649,7 +1636,7 @@ var Wallet = class {
|
|
|
1649
1636
|
this.currentWin = process2(this.currentWin);
|
|
1650
1637
|
this.cumulativeWins += this.currentWin;
|
|
1651
1638
|
let spinTypeWins = 0;
|
|
1652
|
-
for (const spinType
|
|
1639
|
+
for (const spinType in this.currentWinPerSpinType) {
|
|
1653
1640
|
const st = spinType;
|
|
1654
1641
|
const spinTypeWin = process2(this.currentWinPerSpinType[st]);
|
|
1655
1642
|
this.cumulativeWinsPerSpinType[st] += spinTypeWin;
|
|
@@ -2454,9 +2441,9 @@ var Simulation = class {
|
|
|
2454
2441
|
}
|
|
2455
2442
|
const chunkIndex = this.bookChunkIndexes.get(index);
|
|
2456
2443
|
const bookChunkPath = this.PATHS.booksChunk(mode, index, chunkIndex);
|
|
2457
|
-
const
|
|
2444
|
+
const bookLines = this.bookBuffers.get(index);
|
|
2458
2445
|
await (0, import_promises.pipeline)(
|
|
2459
|
-
import_stream.Readable.from(
|
|
2446
|
+
import_stream.Readable.from(bookLines),
|
|
2460
2447
|
import_zlib.default.createZstdCompress(),
|
|
2461
2448
|
import_fs3.default.createWriteStream(bookChunkPath)
|
|
2462
2449
|
);
|
|
@@ -2537,50 +2524,51 @@ var Simulation = class {
|
|
|
2537
2524
|
}
|
|
2538
2525
|
}
|
|
2539
2526
|
writeChain = writeChain.then(async () => {
|
|
2540
|
-
const
|
|
2541
|
-
const
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2527
|
+
const bookId = msg.bookId;
|
|
2528
|
+
const bookCriteria = msg.bookCriteria;
|
|
2529
|
+
const bookPayout = msg.bookPayout;
|
|
2530
|
+
const bookBasegameWins = msg.bookBasegameWins;
|
|
2531
|
+
const bookFreespinsWins = msg.bookFreespinsWins;
|
|
2532
|
+
const bookLine = msg.bookLine;
|
|
2533
|
+
const bookLineWithNewline = bookLine + "\n";
|
|
2534
|
+
if (!this.summary[mode]?.criteria[bookCriteria]) {
|
|
2535
|
+
this.summary[mode].criteria[bookCriteria] = {
|
|
2548
2536
|
numSims: 0,
|
|
2549
2537
|
bsWins: 0,
|
|
2550
2538
|
fsWins: 0,
|
|
2551
2539
|
rtp: 0
|
|
2552
2540
|
};
|
|
2553
2541
|
}
|
|
2554
|
-
const bsWins = round(
|
|
2555
|
-
const fsWins = round(
|
|
2556
|
-
this.summary[mode].criteria[
|
|
2542
|
+
const bsWins = round(bookBasegameWins, 4);
|
|
2543
|
+
const fsWins = round(bookFreespinsWins, 4);
|
|
2544
|
+
const criteria = this.summary[mode].criteria[bookCriteria];
|
|
2545
|
+
criteria.numSims += 1;
|
|
2557
2546
|
this.summary[mode].total.bsWins += bsWins;
|
|
2558
2547
|
this.summary[mode].total.fsWins += fsWins;
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
const
|
|
2562
|
-
const lineSize = Buffer.byteLength(bookLine + "\n", "utf8");
|
|
2548
|
+
criteria.bsWins += bsWins;
|
|
2549
|
+
criteria.fsWins += fsWins;
|
|
2550
|
+
const lineSize = Buffer.byteLength(bookLineWithNewline, "utf8");
|
|
2563
2551
|
if (this.bookBuffers.has(index)) {
|
|
2564
|
-
this.bookBuffers.get(index).push(
|
|
2552
|
+
this.bookBuffers.get(index).push(bookLineWithNewline);
|
|
2565
2553
|
this.bookBufferSizes.set(
|
|
2566
2554
|
index,
|
|
2567
2555
|
this.bookBufferSizes.get(index) + lineSize
|
|
2568
2556
|
);
|
|
2569
2557
|
} else {
|
|
2570
|
-
this.bookBuffers.set(index, [
|
|
2558
|
+
this.bookBuffers.set(index, [bookLineWithNewline]);
|
|
2571
2559
|
this.bookBufferSizes.set(index, lineSize);
|
|
2572
2560
|
}
|
|
2573
2561
|
if (!this.tempBookIndexPaths.includes(booksIndexPath)) {
|
|
2574
2562
|
this.tempBookIndexPaths.push(booksIndexPath);
|
|
2575
2563
|
}
|
|
2576
2564
|
booksIndexBatch.push(
|
|
2577
|
-
`${
|
|
2565
|
+
`${bookId},${index},${this.bookChunkIndexes.get(index) || 0}
|
|
2578
2566
|
`
|
|
2579
2567
|
);
|
|
2580
|
-
lookupBatch.push(`${
|
|
2568
|
+
lookupBatch.push(`${bookId},1,${Math.round(bookPayout)}
|
|
2581
2569
|
`);
|
|
2582
2570
|
lookupSegBatch.push(
|
|
2583
|
-
`${
|
|
2571
|
+
`${bookId},${bookCriteria},${bookBasegameWins},${bookFreespinsWins}
|
|
2584
2572
|
`
|
|
2585
2573
|
);
|
|
2586
2574
|
if (booksIndexBatch.length >= WRITE_BATCH_SIZE) {
|
|
@@ -2589,15 +2577,10 @@ var Simulation = class {
|
|
|
2589
2577
|
if (this.bookBufferSizes.get(index) >= 10 * 1024 * 1024) {
|
|
2590
2578
|
await flushBookChunk();
|
|
2591
2579
|
}
|
|
2592
|
-
if (this.recordsWriteStream) {
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
this.recordsWriteStream,
|
|
2597
|
-
recordPrefix + JSON.stringify(record)
|
|
2598
|
-
);
|
|
2599
|
-
this.hasWrittenRecord = true;
|
|
2600
|
-
}
|
|
2580
|
+
if (this.recordsWriteStream && typeof msg.recordsLines === "string" && msg.recordsLines.length) {
|
|
2581
|
+
const recordPrefix = this.hasWrittenRecord ? "\n" : "";
|
|
2582
|
+
await write(this.recordsWriteStream, recordPrefix + msg.recordsLines);
|
|
2583
|
+
this.hasWrittenRecord = true;
|
|
2601
2584
|
}
|
|
2602
2585
|
this.wallet.mergeSerialized(msg.wallet);
|
|
2603
2586
|
worker.postMessage({ type: "credit", amount: 1 });
|
|
@@ -2688,9 +2671,11 @@ var Simulation = class {
|
|
|
2688
2671
|
});
|
|
2689
2672
|
}
|
|
2690
2673
|
}
|
|
2691
|
-
ctx.services.wallet._getWallet()
|
|
2692
|
-
|
|
2693
|
-
|
|
2674
|
+
const wallet = ctx.services.wallet._getWallet();
|
|
2675
|
+
wallet.writePayoutToBook(ctx);
|
|
2676
|
+
wallet.confirmWins(ctx);
|
|
2677
|
+
const book = ctx.services.data._getBook();
|
|
2678
|
+
if (book.payout >= ctx.config.maxWinX) {
|
|
2694
2679
|
ctx.state.triggeredMaxWin = true;
|
|
2695
2680
|
}
|
|
2696
2681
|
ctx.services.data.record({
|
|
@@ -2698,12 +2683,24 @@ var Simulation = class {
|
|
|
2698
2683
|
});
|
|
2699
2684
|
ctx.config.hooks.onSimulationAccepted?.(ctx);
|
|
2700
2685
|
this.confirmRecords(ctx);
|
|
2686
|
+
const bookLine = JSON.stringify({
|
|
2687
|
+
id: book.id,
|
|
2688
|
+
payoutMultiplier: book.payout,
|
|
2689
|
+
events: book.events
|
|
2690
|
+
});
|
|
2691
|
+
const records = ctx.services.data._getRecords();
|
|
2692
|
+
const recordsLines = records.length > 0 ? records.map((r) => JSON.stringify(r)).join("\n") : "";
|
|
2701
2693
|
import_worker_threads2.parentPort?.postMessage({
|
|
2702
2694
|
type: "complete",
|
|
2703
2695
|
simId,
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2696
|
+
bookLine,
|
|
2697
|
+
bookId: book.id,
|
|
2698
|
+
bookCriteria: book.criteria,
|
|
2699
|
+
bookPayout: book.payout,
|
|
2700
|
+
bookBasegameWins: book.basegameWins,
|
|
2701
|
+
bookFreespinsWins: book.freespinsWins,
|
|
2702
|
+
wallet: wallet.serialize(),
|
|
2703
|
+
recordsLines
|
|
2707
2704
|
});
|
|
2708
2705
|
}
|
|
2709
2706
|
initCreditListener() {
|