@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.mjs
CHANGED
|
@@ -1419,19 +1419,6 @@ var Book = class {
|
|
|
1419
1419
|
data: copy(event.data)
|
|
1420
1420
|
});
|
|
1421
1421
|
}
|
|
1422
|
-
/**
|
|
1423
|
-
* Intended for internal use only.
|
|
1424
|
-
*/
|
|
1425
|
-
_serialize() {
|
|
1426
|
-
return {
|
|
1427
|
-
id: this.id,
|
|
1428
|
-
criteria: this.criteria,
|
|
1429
|
-
events: this.events,
|
|
1430
|
-
payout: this.payout,
|
|
1431
|
-
basegameWins: this.basegameWins,
|
|
1432
|
-
freespinsWins: this.freespinsWins
|
|
1433
|
-
};
|
|
1434
|
-
}
|
|
1435
1422
|
};
|
|
1436
1423
|
|
|
1437
1424
|
// src/wallet/index.ts
|
|
@@ -1600,7 +1587,7 @@ var Wallet = class {
|
|
|
1600
1587
|
this.currentWin = process2(this.currentWin);
|
|
1601
1588
|
this.cumulativeWins += this.currentWin;
|
|
1602
1589
|
let spinTypeWins = 0;
|
|
1603
|
-
for (const spinType
|
|
1590
|
+
for (const spinType in this.currentWinPerSpinType) {
|
|
1604
1591
|
const st = spinType;
|
|
1605
1592
|
const spinTypeWin = process2(this.currentWinPerSpinType[st]);
|
|
1606
1593
|
this.cumulativeWinsPerSpinType[st] += spinTypeWin;
|
|
@@ -2405,9 +2392,9 @@ var Simulation = class {
|
|
|
2405
2392
|
}
|
|
2406
2393
|
const chunkIndex = this.bookChunkIndexes.get(index);
|
|
2407
2394
|
const bookChunkPath = this.PATHS.booksChunk(mode, index, chunkIndex);
|
|
2408
|
-
const
|
|
2395
|
+
const bookLines = this.bookBuffers.get(index);
|
|
2409
2396
|
await pipeline(
|
|
2410
|
-
Readable.from(
|
|
2397
|
+
Readable.from(bookLines),
|
|
2411
2398
|
zlib.createZstdCompress(),
|
|
2412
2399
|
fs3.createWriteStream(bookChunkPath)
|
|
2413
2400
|
);
|
|
@@ -2488,50 +2475,51 @@ var Simulation = class {
|
|
|
2488
2475
|
}
|
|
2489
2476
|
}
|
|
2490
2477
|
writeChain = writeChain.then(async () => {
|
|
2491
|
-
const
|
|
2492
|
-
const
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2478
|
+
const bookId = msg.bookId;
|
|
2479
|
+
const bookCriteria = msg.bookCriteria;
|
|
2480
|
+
const bookPayout = msg.bookPayout;
|
|
2481
|
+
const bookBasegameWins = msg.bookBasegameWins;
|
|
2482
|
+
const bookFreespinsWins = msg.bookFreespinsWins;
|
|
2483
|
+
const bookLine = msg.bookLine;
|
|
2484
|
+
const bookLineWithNewline = bookLine + "\n";
|
|
2485
|
+
if (!this.summary[mode]?.criteria[bookCriteria]) {
|
|
2486
|
+
this.summary[mode].criteria[bookCriteria] = {
|
|
2499
2487
|
numSims: 0,
|
|
2500
2488
|
bsWins: 0,
|
|
2501
2489
|
fsWins: 0,
|
|
2502
2490
|
rtp: 0
|
|
2503
2491
|
};
|
|
2504
2492
|
}
|
|
2505
|
-
const bsWins = round(
|
|
2506
|
-
const fsWins = round(
|
|
2507
|
-
this.summary[mode].criteria[
|
|
2493
|
+
const bsWins = round(bookBasegameWins, 4);
|
|
2494
|
+
const fsWins = round(bookFreespinsWins, 4);
|
|
2495
|
+
const criteria = this.summary[mode].criteria[bookCriteria];
|
|
2496
|
+
criteria.numSims += 1;
|
|
2508
2497
|
this.summary[mode].total.bsWins += bsWins;
|
|
2509
2498
|
this.summary[mode].total.fsWins += fsWins;
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
const
|
|
2513
|
-
const lineSize = Buffer.byteLength(bookLine + "\n", "utf8");
|
|
2499
|
+
criteria.bsWins += bsWins;
|
|
2500
|
+
criteria.fsWins += fsWins;
|
|
2501
|
+
const lineSize = Buffer.byteLength(bookLineWithNewline, "utf8");
|
|
2514
2502
|
if (this.bookBuffers.has(index)) {
|
|
2515
|
-
this.bookBuffers.get(index).push(
|
|
2503
|
+
this.bookBuffers.get(index).push(bookLineWithNewline);
|
|
2516
2504
|
this.bookBufferSizes.set(
|
|
2517
2505
|
index,
|
|
2518
2506
|
this.bookBufferSizes.get(index) + lineSize
|
|
2519
2507
|
);
|
|
2520
2508
|
} else {
|
|
2521
|
-
this.bookBuffers.set(index, [
|
|
2509
|
+
this.bookBuffers.set(index, [bookLineWithNewline]);
|
|
2522
2510
|
this.bookBufferSizes.set(index, lineSize);
|
|
2523
2511
|
}
|
|
2524
2512
|
if (!this.tempBookIndexPaths.includes(booksIndexPath)) {
|
|
2525
2513
|
this.tempBookIndexPaths.push(booksIndexPath);
|
|
2526
2514
|
}
|
|
2527
2515
|
booksIndexBatch.push(
|
|
2528
|
-
`${
|
|
2516
|
+
`${bookId},${index},${this.bookChunkIndexes.get(index) || 0}
|
|
2529
2517
|
`
|
|
2530
2518
|
);
|
|
2531
|
-
lookupBatch.push(`${
|
|
2519
|
+
lookupBatch.push(`${bookId},1,${Math.round(bookPayout)}
|
|
2532
2520
|
`);
|
|
2533
2521
|
lookupSegBatch.push(
|
|
2534
|
-
`${
|
|
2522
|
+
`${bookId},${bookCriteria},${bookBasegameWins},${bookFreespinsWins}
|
|
2535
2523
|
`
|
|
2536
2524
|
);
|
|
2537
2525
|
if (booksIndexBatch.length >= WRITE_BATCH_SIZE) {
|
|
@@ -2540,15 +2528,10 @@ var Simulation = class {
|
|
|
2540
2528
|
if (this.bookBufferSizes.get(index) >= 10 * 1024 * 1024) {
|
|
2541
2529
|
await flushBookChunk();
|
|
2542
2530
|
}
|
|
2543
|
-
if (this.recordsWriteStream) {
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
this.recordsWriteStream,
|
|
2548
|
-
recordPrefix + JSON.stringify(record)
|
|
2549
|
-
);
|
|
2550
|
-
this.hasWrittenRecord = true;
|
|
2551
|
-
}
|
|
2531
|
+
if (this.recordsWriteStream && typeof msg.recordsLines === "string" && msg.recordsLines.length) {
|
|
2532
|
+
const recordPrefix = this.hasWrittenRecord ? "\n" : "";
|
|
2533
|
+
await write(this.recordsWriteStream, recordPrefix + msg.recordsLines);
|
|
2534
|
+
this.hasWrittenRecord = true;
|
|
2552
2535
|
}
|
|
2553
2536
|
this.wallet.mergeSerialized(msg.wallet);
|
|
2554
2537
|
worker.postMessage({ type: "credit", amount: 1 });
|
|
@@ -2639,9 +2622,11 @@ var Simulation = class {
|
|
|
2639
2622
|
});
|
|
2640
2623
|
}
|
|
2641
2624
|
}
|
|
2642
|
-
ctx.services.wallet._getWallet()
|
|
2643
|
-
|
|
2644
|
-
|
|
2625
|
+
const wallet = ctx.services.wallet._getWallet();
|
|
2626
|
+
wallet.writePayoutToBook(ctx);
|
|
2627
|
+
wallet.confirmWins(ctx);
|
|
2628
|
+
const book = ctx.services.data._getBook();
|
|
2629
|
+
if (book.payout >= ctx.config.maxWinX) {
|
|
2645
2630
|
ctx.state.triggeredMaxWin = true;
|
|
2646
2631
|
}
|
|
2647
2632
|
ctx.services.data.record({
|
|
@@ -2649,12 +2634,24 @@ var Simulation = class {
|
|
|
2649
2634
|
});
|
|
2650
2635
|
ctx.config.hooks.onSimulationAccepted?.(ctx);
|
|
2651
2636
|
this.confirmRecords(ctx);
|
|
2637
|
+
const bookLine = JSON.stringify({
|
|
2638
|
+
id: book.id,
|
|
2639
|
+
payoutMultiplier: book.payout,
|
|
2640
|
+
events: book.events
|
|
2641
|
+
});
|
|
2642
|
+
const records = ctx.services.data._getRecords();
|
|
2643
|
+
const recordsLines = records.length > 0 ? records.map((r) => JSON.stringify(r)).join("\n") : "";
|
|
2652
2644
|
parentPort2?.postMessage({
|
|
2653
2645
|
type: "complete",
|
|
2654
2646
|
simId,
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2647
|
+
bookLine,
|
|
2648
|
+
bookId: book.id,
|
|
2649
|
+
bookCriteria: book.criteria,
|
|
2650
|
+
bookPayout: book.payout,
|
|
2651
|
+
bookBasegameWins: book.basegameWins,
|
|
2652
|
+
bookFreespinsWins: book.freespinsWins,
|
|
2653
|
+
wallet: wallet.serialize(),
|
|
2654
|
+
recordsLines
|
|
2658
2655
|
});
|
|
2659
2656
|
}
|
|
2660
2657
|
initCreditListener() {
|