gambling-bot-shared 0.1.44 → 0.1.45

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.
@@ -1,13 +1,15 @@
1
+ import { defaultCasinoSettings } from './defaultConfig';
1
2
  export declare const PLINKO_BIN_COUNT = 9;
2
3
  export declare const PLINKO_ROW_COUNT: number;
3
4
  export declare const PLINKO_CENTER_BIN = 5;
4
5
  export declare const PLINKO_EDITABLE_BINS: readonly [1, 2, 3, 4, 5];
5
6
  export type PlinkoEditableBin = (typeof PLINKO_EDITABLE_BINS)[number];
7
+ export type PlinkoBinMultipliers = (typeof defaultCasinoSettings)['plinko']['binMultipliers'];
6
8
  export declare const getPlinkoMirrorBin: (bin: number) => number;
7
9
  export declare const pathIndexToPlinkoBin: (pathIndex: number) => number;
8
10
  export declare const plinkoBinToPathIndex: (bin: number) => number;
9
- export declare const expandPlinkoBinMultipliers: (editable: Record<string | number, number | string>) => Record<string, number>;
11
+ export declare const expandPlinkoBinMultipliers: (editable: Record<string | number, number | string>) => PlinkoBinMultipliers;
10
12
  /** Migrate legacy 0-indexed bins and enforce symmetric 1–9 layout. */
11
- export declare const normalizePlinkoBinMultipliers: (input: Record<string | number, number | string> | null | undefined) => Record<string, number>;
13
+ export declare const normalizePlinkoBinMultipliers: (input: Record<string | number, number | string> | null | undefined) => PlinkoBinMultipliers;
12
14
  export declare const getPlinkoMultiplierAtPathIndex: (binMultipliers: Record<string | number, number | string>, pathIndex: number) => number;
13
15
  export declare const formatPlinkoBinMultipliersForDisplay: (binMultipliers: Record<string | number, number | string>) => Record<string, number>;
@@ -19,12 +19,13 @@ const toNumber = (val) => {
19
19
  return val;
20
20
  return 0;
21
21
  };
22
+ const plinkoBinAt = (multipliers, bin) => multipliers[bin] ?? 0;
22
23
  const defaultBinMultipliers = () => defaultConfig_1.defaultCasinoSettings.plinko.binMultipliers;
23
24
  const expandPlinkoBinMultipliers = (editable) => {
24
25
  const defaults = defaultBinMultipliers();
25
26
  const result = {};
26
27
  for (const bin of exports.PLINKO_EDITABLE_BINS) {
27
- result[String(bin)] = toNumber(editable[bin] ?? editable[String(bin)] ?? defaults[String(bin)] ?? 0);
28
+ result[String(bin)] = toNumber(editable[bin] ?? editable[String(bin)] ?? plinkoBinAt(defaults, bin));
28
29
  }
29
30
  for (let bin = exports.PLINKO_CENTER_BIN + 1; bin <= exports.PLINKO_BIN_COUNT; bin++) {
30
31
  const mirror = (0, exports.getPlinkoMirrorBin)(bin);
@@ -50,12 +51,12 @@ const normalizePlinkoBinMultipliers = (input) => {
50
51
  const defaults = defaultBinMultipliers();
51
52
  if (usesZeroIndex) {
52
53
  for (let bin = 1; bin <= exports.PLINKO_CENTER_BIN; bin++) {
53
- editable[bin] = raw[bin - 1] ?? toNumber(defaults[String(bin)]);
54
+ editable[bin] = raw[bin - 1] ?? plinkoBinAt(defaults, bin);
54
55
  }
55
56
  }
56
57
  else {
57
58
  for (const bin of exports.PLINKO_EDITABLE_BINS) {
58
- editable[bin] = raw[bin] ?? toNumber(defaults[String(bin)]);
59
+ editable[bin] = raw[bin] ?? plinkoBinAt(defaults, bin);
59
60
  }
60
61
  }
61
62
  return (0, exports.expandPlinkoBinMultipliers)(editable);
@@ -63,11 +64,11 @@ const normalizePlinkoBinMultipliers = (input) => {
63
64
  exports.normalizePlinkoBinMultipliers = normalizePlinkoBinMultipliers;
64
65
  const getPlinkoMultiplierAtPathIndex = (binMultipliers, pathIndex) => {
65
66
  const normalized = (0, exports.normalizePlinkoBinMultipliers)(binMultipliers);
66
- return normalized[String((0, exports.pathIndexToPlinkoBin)(pathIndex))] ?? 0;
67
+ return plinkoBinAt(normalized, (0, exports.pathIndexToPlinkoBin)(pathIndex));
67
68
  };
68
69
  exports.getPlinkoMultiplierAtPathIndex = getPlinkoMultiplierAtPathIndex;
69
70
  const formatPlinkoBinMultipliersForDisplay = (binMultipliers) => {
70
71
  const normalized = (0, exports.normalizePlinkoBinMultipliers)(binMultipliers);
71
- return Object.fromEntries(exports.PLINKO_EDITABLE_BINS.map((bin) => [String(bin), normalized[String(bin)]]));
72
+ return Object.fromEntries(exports.PLINKO_EDITABLE_BINS.map((bin) => [String(bin), plinkoBinAt(normalized, bin)]));
72
73
  };
73
74
  exports.formatPlinkoBinMultipliersForDisplay = formatPlinkoBinMultipliersForDisplay;
@@ -81,7 +81,17 @@ export declare const casinoSettingsSchema: z.ZodObject<{
81
81
  casinoCut: z.ZodNumber;
82
82
  }, z.core.$strip>;
83
83
  plinko: z.ZodObject<{
84
- binMultipliers: z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodNumber>, z.ZodTransform<Record<string, number>, Record<string, number>>>;
84
+ binMultipliers: z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodNumber>, z.ZodTransform<{
85
+ 1: number;
86
+ 2: number;
87
+ 3: number;
88
+ 4: number;
89
+ 5: number;
90
+ 6: number;
91
+ 7: number;
92
+ 8: number;
93
+ 9: number;
94
+ }, Record<string, number>>>;
85
95
  minBet: z.ZodNumber;
86
96
  maxBet: z.ZodNumber;
87
97
  }, z.core.$strip>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gambling-bot-shared",
3
- "version": "0.1.44",
3
+ "version": "0.1.45",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "license": "MIT",