shufflecom-calculations 4.2.4 → 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.
Files changed (42) hide show
  1. package/lib/games/baccarat.d.ts +1 -0
  2. package/lib/games/baccarat.js +19 -0
  3. package/lib/games/baccarat.js.map +1 -1
  4. package/lib/games/blackjack.d.ts +16 -0
  5. package/lib/games/blackjack.js +34 -4
  6. package/lib/games/blackjack.js.map +1 -1
  7. package/lib/games/coinflip/coinflip-classic-progressive.d.ts +1 -0
  8. package/lib/games/coinflip/coinflip-classic-progressive.js +4 -0
  9. package/lib/games/coinflip/coinflip-classic-progressive.js.map +1 -1
  10. package/lib/games/hilo.d.ts +6 -0
  11. package/lib/games/hilo.js +25 -1
  12. package/lib/games/hilo.js.map +1 -1
  13. package/lib/games/keno.d.ts +1 -0
  14. package/lib/games/keno.js +7 -0
  15. package/lib/games/keno.js.map +1 -1
  16. package/lib/games/plinko.d.ts +1 -0
  17. package/lib/games/plinko.js +7 -0
  18. package/lib/games/plinko.js.map +1 -1
  19. package/lib/games/roulette.d.ts +1 -0
  20. package/lib/games/roulette.js +3 -0
  21. package/lib/games/roulette.js.map +1 -1
  22. package/lib/games/wheel.d.ts +1 -0
  23. package/lib/games/wheel.js +3 -0
  24. package/lib/games/wheel.js.map +1 -1
  25. package/lib/tsconfig.tsbuildinfo +1 -1
  26. package/package.json +2 -2
  27. package/src/games/baccarat.spec.ts +60 -5
  28. package/src/games/baccarat.ts +21 -1
  29. package/src/games/blackjack.spec.ts +100 -0
  30. package/src/games/blackjack.ts +78 -8
  31. package/src/games/coinflip/coinflip-classic-progressive.spec.ts +9 -0
  32. package/src/games/coinflip/coinflip-classic-progressive.ts +5 -0
  33. package/src/games/hilo.spec.ts +54 -1
  34. package/src/games/hilo.ts +35 -1
  35. package/src/games/keno.spec.ts +20 -1
  36. package/src/games/keno.ts +8 -0
  37. package/src/games/plinko.spec.ts +19 -0
  38. package/src/games/plinko.ts +8 -0
  39. package/src/games/roulette.spec.ts +22 -2
  40. package/src/games/roulette.ts +4 -0
  41. package/src/games/wheel.spec.ts +9 -0
  42. package/src/games/wheel.ts +4 -0
@@ -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((hexStr) => Roulette.getResult(hexStr));
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((round) => {
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');
@@ -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');
@@ -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,
@@ -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]);