shufflecom-calculations 4.2.3 → 4.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/lib/games/baccarat.d.ts +1 -0
- package/lib/games/baccarat.js +19 -0
- package/lib/games/baccarat.js.map +1 -1
- package/lib/games/blackjack.d.ts +16 -0
- package/lib/games/blackjack.js +34 -4
- package/lib/games/blackjack.js.map +1 -1
- package/lib/games/coinflip/coinflip-classic-progressive.d.ts +1 -0
- package/lib/games/coinflip/coinflip-classic-progressive.js +4 -0
- package/lib/games/coinflip/coinflip-classic-progressive.js.map +1 -1
- package/lib/games/hilo.d.ts +6 -0
- package/lib/games/hilo.js +25 -1
- package/lib/games/hilo.js.map +1 -1
- package/lib/games/keno.d.ts +1 -0
- package/lib/games/keno.js +7 -0
- package/lib/games/keno.js.map +1 -1
- package/lib/games/plinko.d.ts +1 -0
- package/lib/games/plinko.js +7 -0
- package/lib/games/plinko.js.map +1 -1
- package/lib/games/roulette.d.ts +1 -0
- package/lib/games/roulette.js +3 -0
- package/lib/games/roulette.js.map +1 -1
- package/lib/games/wheel.d.ts +1 -0
- package/lib/games/wheel.js +3 -0
- package/lib/games/wheel.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils/getExternalTxLinkOfChain.js +1 -1
- package/lib/utils/getExternalTxLinkOfChain.js.map +1 -1
- package/package.json +2 -2
- package/src/games/baccarat.spec.ts +60 -5
- package/src/games/baccarat.ts +21 -1
- package/src/games/blackjack.spec.ts +100 -0
- package/src/games/blackjack.ts +78 -8
- package/src/games/coinflip/coinflip-classic-progressive.spec.ts +9 -0
- package/src/games/coinflip/coinflip-classic-progressive.ts +5 -0
- package/src/games/hilo.spec.ts +54 -1
- package/src/games/hilo.ts +35 -1
- package/src/games/keno.spec.ts +20 -1
- package/src/games/keno.ts +8 -0
- package/src/games/plinko.spec.ts +19 -0
- package/src/games/plinko.ts +8 -0
- package/src/games/roulette.spec.ts +22 -2
- package/src/games/roulette.ts +4 -0
- package/src/games/wheel.spec.ts +9 -0
- package/src/games/wheel.ts +4 -0
- package/src/utils/getExternalTxLinkOfChain.ts +1 -1
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
isValidSplit,
|
|
21
21
|
isValidStreet,
|
|
22
22
|
parityPayout,
|
|
23
|
+
RouletteInput,
|
|
23
24
|
splitPayout,
|
|
24
25
|
straightPayout,
|
|
25
26
|
straightValue,
|
|
@@ -35,7 +36,7 @@ function arrayEquals<T>(arr1: T, arr2: T) {
|
|
|
35
36
|
describe('Roulette', () => {
|
|
36
37
|
it('getResult should return 0-36 inclusive', () => {
|
|
37
38
|
const hexStrArr = generateDigestHex({ serverSeed: 'test', clientSeed: 'test', nonce: '0', rounds: 100000 });
|
|
38
|
-
const results = hexStrArr.map(
|
|
39
|
+
const results = hexStrArr.map(hexStr => Roulette.getResult(hexStr));
|
|
39
40
|
const uniqueResults = [...new Set(results)].sort((a, b) => a - b) as readonly straightValue[];
|
|
40
41
|
arrayEquals(uniqueResults, STRAIGHT_VALUES);
|
|
41
42
|
});
|
|
@@ -500,6 +501,25 @@ describe('Roulette', () => {
|
|
|
500
501
|
});
|
|
501
502
|
});
|
|
502
503
|
|
|
504
|
+
describe('Roulette.getMaxPayout', () => {
|
|
505
|
+
it('returns the maximum payout across all 37 wheel results', () => {
|
|
506
|
+
const inputs = {
|
|
507
|
+
parityValues: [],
|
|
508
|
+
colorValues: [],
|
|
509
|
+
halfValues: [],
|
|
510
|
+
columnValues: [],
|
|
511
|
+
dozenValues: [],
|
|
512
|
+
straightValues: [{ straightNumber: 7, amount: new BigNumber(1) }],
|
|
513
|
+
splitValues: [],
|
|
514
|
+
streetValues: [],
|
|
515
|
+
cornerValues: [],
|
|
516
|
+
doubleStreetValues: [],
|
|
517
|
+
} as RouletteInput;
|
|
518
|
+
const max = Roulette.getMaxPayout(inputs);
|
|
519
|
+
expect(max.toNumber()).toBe(36);
|
|
520
|
+
});
|
|
521
|
+
});
|
|
522
|
+
|
|
503
523
|
function generateDigestHex({
|
|
504
524
|
serverSeed,
|
|
505
525
|
clientSeed,
|
|
@@ -511,7 +531,7 @@ function generateDigestHex({
|
|
|
511
531
|
nonce: string;
|
|
512
532
|
rounds?: number;
|
|
513
533
|
}): string[] {
|
|
514
|
-
const results = Array.from(Array(rounds).keys()).map(
|
|
534
|
+
const results = Array.from(Array(rounds).keys()).map(round => {
|
|
515
535
|
const hmac = createHmac('sha256', serverSeed);
|
|
516
536
|
hmac.update(`${clientSeed}:${nonce}:${round}`);
|
|
517
537
|
return hmac.digest('hex');
|
package/src/games/roulette.ts
CHANGED
|
@@ -416,6 +416,10 @@ export class Roulette {
|
|
|
416
416
|
return resultNum;
|
|
417
417
|
}
|
|
418
418
|
|
|
419
|
+
static getMaxPayout(inputs: RouletteInput): BigNumber {
|
|
420
|
+
return BigNumber.max(...STRAIGHT_VALUES.map(result => Roulette.getPayout(inputs, result)));
|
|
421
|
+
}
|
|
422
|
+
|
|
419
423
|
static getPayout(inputs: RouletteInput, result: straightValue): BigNumber {
|
|
420
424
|
if (!this.validateInputs(inputs)) {
|
|
421
425
|
throw new Error('Invalid inputs');
|
package/src/games/wheel.spec.ts
CHANGED
|
@@ -127,6 +127,15 @@ describe('Wheel', () => {
|
|
|
127
127
|
});
|
|
128
128
|
});
|
|
129
129
|
|
|
130
|
+
describe('Wheel.getMaxMultiplier', () => {
|
|
131
|
+
it('returns the largest multiplier in the segment/risk table', () => {
|
|
132
|
+
const max = Wheel.getMaxMultiplier(WheelSegments.TEN, WheelRiskLevel.HIGH);
|
|
133
|
+
// HIGH risk always includes the top multiplier; must be > any other entry.
|
|
134
|
+
expect(max.isGreaterThan(0)).toBe(true);
|
|
135
|
+
expect(max.toNumber()).toBe(Math.max(...WHEEL_MULTIPLIERS[WheelSegments.TEN][WheelRiskLevel.HIGH]));
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
|
|
130
139
|
function generateDigestHex({
|
|
131
140
|
serverSeed,
|
|
132
141
|
clientSeed,
|
package/src/games/wheel.ts
CHANGED
|
@@ -70,6 +70,10 @@ export const WHEEL_SEGMENTS_TO_NUMBER: Record<WheelSegments, number> = {
|
|
|
70
70
|
};
|
|
71
71
|
|
|
72
72
|
export class Wheel {
|
|
73
|
+
static getMaxMultiplier(segments: WheelSegments, risk: WheelRiskLevel): BigNumber {
|
|
74
|
+
return BigNumber.max(...WHEEL_MULTIPLIERS[segments][risk].map(v => new BigNumber(v)));
|
|
75
|
+
}
|
|
76
|
+
|
|
73
77
|
static getResult(hexStr: string, segments: WheelSegments, risk: WheelRiskLevel): { resultSegment: number; multiplier: BigNumber } {
|
|
74
78
|
const resultSegment = this.getRandomNumberFromHexStr(hexStr).multipliedBy(WHEEL_SEGMENTS_TO_NUMBER[segments]).integerValue(BigNumber.ROUND_DOWN).toNumber();
|
|
75
79
|
const multiplier = BigNumber(WHEEL_MULTIPLIERS[segments][risk][resultSegment]);
|
|
@@ -31,7 +31,7 @@ export const TX_LINK_PREFIXES_MAINNET: Record<Chain, string> = {
|
|
|
31
31
|
[Chain.AVAXC]: 'https://snowtrace.io/tx/{txId}',
|
|
32
32
|
[Chain.ARBITRUM]: 'https://arbiscan.io/tx/{txId}',
|
|
33
33
|
[Chain.BASE]: 'https://basescan.org/tx/{txId}',
|
|
34
|
-
[Chain.RHC]: 'https://robinhoodchain.blockscout.com/{txId}',
|
|
34
|
+
[Chain.RHC]: 'https://robinhoodchain.blockscout.com/tx/{txId}',
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
export const ADDRESS_LINK_PREFIXES_TESTNET: Record<Chain, string> = {
|