@devrongx/games 0.4.16 → 0.4.17

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devrongx/games",
3
- "version": "0.4.16",
3
+ "version": "0.4.17",
4
4
  "description": "Game UI components for sports prediction markets",
5
5
  "license": "MIT",
6
6
  "main": "./src/index.ts",
@@ -132,7 +132,7 @@ export const PreMatchBetsPopup = ({ poolId, matchId: _matchId, match: matchProp
132
132
  const mIdx = config.markets.findIndex((m) => m.backendChallengeId === bet.challenge_id);
133
133
  if (mIdx < 0) continue;
134
134
  const oIdx = config.markets[mIdx].options.findIndex(
135
- (o) => o.label.toLowerCase().replace(/\s+/g, "_") === bet.selected_option,
135
+ (o) => (o.key ?? o.label.toLowerCase().replace(/\s+/g, "_")) === bet.selected_option,
136
136
  );
137
137
  if (oIdx < 0) continue;
138
138
  loaded[mIdx] = { optionIdx: oIdx, amount: bet.coin_amount, parlaySlot: null };
@@ -158,7 +158,7 @@ export const PreMatchBetsPopup = ({ poolId, matchId: _matchId, match: matchProp
158
158
  const mIdx = config.markets.findIndex((m) => m.backendChallengeId === d.challenge_id);
159
159
  if (mIdx < 0) continue;
160
160
  const optionIdx = config.markets[mIdx].options.findIndex(
161
- (o) => o.label.toLowerCase().replace(/\s+/g, "_") === d.selected_option,
161
+ (o) => (o.key ?? o.label.toLowerCase().replace(/\s+/g, "_")) === d.selected_option,
162
162
  );
163
163
  if (optionIdx < 0) continue;
164
164
  restored[mIdx] = { optionIdx, amount: d.coin_amount, parlaySlot: null };
@@ -194,7 +194,7 @@ export const PreMatchBetsPopup = ({ poolId, matchId: _matchId, match: matchProp
194
194
  if (!option) return null;
195
195
  return {
196
196
  challenge_id: m.backendChallengeId,
197
- selected_option: option.label.toLowerCase().replace(/\s+/g, "_"),
197
+ selected_option: option.key ?? option.label.toLowerCase().replace(/\s+/g, "_"),
198
198
  coin_amount: b.amount,
199
199
  };
200
200
  })
@@ -272,7 +272,7 @@ export const PreMatchBetsPopup = ({ poolId, matchId: _matchId, match: matchProp
272
272
  const market = config.markets[Number(mIdxStr)];
273
273
  return {
274
274
  challenge_id: market.backendChallengeId!,
275
- selected_option: market.options[b.optionIdx].label.toLowerCase().replace(/\s+/g, "_"),
275
+ selected_option: market.options[b.optionIdx].key ?? market.options[b.optionIdx].label.toLowerCase().replace(/\s+/g, "_"),
276
276
  coin_amount: b.amount,
277
277
  };
278
278
  })
@@ -8,6 +8,7 @@ import seedrandom from "seedrandom";
8
8
  // ────── Types ──────
9
9
 
10
10
  export interface IChallengeOption {
11
+ key?: string; // Backend option key (authoritative for API calls) — absent on hardcoded demo data
11
12
  label: string;
12
13
  odds: number; // Decimal odds (e.g., 1.40 = 40% profit, 3.2 = 220% profit)
13
14
  entry: number; // Points to bet on this option
@@ -33,6 +33,7 @@ export function buildPMBConfig(pool: ITDPoolDetail, match: ITDMatch): IChallenge
33
33
  category: c.category,
34
34
  backendChallengeId: c.id,
35
35
  options: c.options.map((o) => ({
36
+ key: o.key,
36
37
  label: o.label,
37
38
  odds: o.odds,
38
39
  entry: o.entry,