react-native-monflowts 0.5.2 → 0.5.4

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 (92) hide show
  1. package/android/src/main/java/com/monflowts/MonflowtsLottieView.kt +12 -4
  2. package/android/src/main/java/com/monflowts/MonflowtsStackView.kt +15 -2
  3. package/android/src/main/java/com/monflowts/MonflowtsWebView.kt +35 -11
  4. package/android/src/main/java/com/monflowts/MonflowtsWebViewManager.kt +10 -0
  5. package/ios/MonflowtsWebBridge.m +1 -0
  6. package/ios/MonflowtsWebUIView.swift +21 -0
  7. package/lib/module/NativeWebView.js.map +1 -1
  8. package/lib/module/components/AbandonPolicyNotice.js +4 -4
  9. package/lib/module/components/AbandonPolicyNotice.js.map +1 -1
  10. package/lib/module/components/GameRulesModal.js +5 -5
  11. package/lib/module/components/GameRulesModal.js.map +1 -1
  12. package/lib/module/components/InsufficientFundsOverlay.js +2 -2
  13. package/lib/module/components/InsufficientFundsOverlay.js.map +1 -1
  14. package/lib/module/components/JackpotNearMiss.js +1 -1
  15. package/lib/module/components/JackpotNearMiss.js.map +1 -1
  16. package/lib/module/components/JackpotTeaser.js +8 -8
  17. package/lib/module/components/JackpotTeaser.js.map +1 -1
  18. package/lib/module/components/MonflowtsButton.js +7 -4
  19. package/lib/module/components/MonflowtsButton.js.map +1 -1
  20. package/lib/module/components/QuitConfirmModal.js +5 -5
  21. package/lib/module/components/QuitConfirmModal.js.map +1 -1
  22. package/lib/module/components/SideDemoTab.js +2 -2
  23. package/lib/module/components/SideDemoTab.js.map +1 -1
  24. package/lib/module/components/StakeInput.js +4 -4
  25. package/lib/module/components/StakeInput.js.map +1 -1
  26. package/lib/module/theme.js +11 -11
  27. package/lib/module/theme.js.map +1 -1
  28. package/lib/module/views/DepositSelect.js +5 -5
  29. package/lib/module/views/DepositSelect.js.map +1 -1
  30. package/lib/module/views/DiceBattle.js +457 -168
  31. package/lib/module/views/DiceBattle.js.map +1 -1
  32. package/lib/module/views/DiceLobby.js +18 -46
  33. package/lib/module/views/DiceLobby.js.map +1 -1
  34. package/lib/module/views/FortuneWheel.js +1 -1
  35. package/lib/module/views/Freefall.js +2 -2
  36. package/lib/module/views/Freefall.js.map +1 -1
  37. package/lib/module/views/History.js +7 -7
  38. package/lib/module/views/History.js.map +1 -1
  39. package/lib/module/views/Home.js +76 -44
  40. package/lib/module/views/Home.js.map +1 -1
  41. package/lib/module/views/Jetstream.js +4 -4
  42. package/lib/module/views/Jetstream.js.map +1 -1
  43. package/lib/module/views/Leaderboard.js +14 -14
  44. package/lib/module/views/Leaderboard.js.map +1 -1
  45. package/lib/module/views/MillionaireHunter.js +10 -10
  46. package/lib/module/views/MillionaireHunter.js.map +1 -1
  47. package/lib/module/views/Minefield.js +1 -1
  48. package/lib/module/views/Minefield.js.map +1 -1
  49. package/lib/module/views/PaymentWebView.js +3 -3
  50. package/lib/module/views/PaymentWebView.js.map +1 -1
  51. package/lib/module/views/PlayerCard.js +2 -2
  52. package/lib/module/views/Profile.js +8 -8
  53. package/lib/module/views/Profile.js.map +1 -1
  54. package/lib/module/views/RaffleDraw.js +21 -21
  55. package/lib/module/views/RaffleDraw.js.map +1 -1
  56. package/lib/module/views/RevealWin.js +10 -10
  57. package/lib/module/views/RevealWin.js.map +1 -1
  58. package/lib/module/views/Success.js +1 -1
  59. package/lib/module/views/Success.js.map +1 -1
  60. package/lib/module/views/TriviaLobby.js +14 -25
  61. package/lib/module/views/TriviaLobby.js.map +1 -1
  62. package/lib/module/views/TriviaMaster.js +5 -5
  63. package/lib/module/views/TriviaMaster.js.map +1 -1
  64. package/lib/module/views/Wallet.js +16 -16
  65. package/lib/module/views/Wallet.js.map +1 -1
  66. package/lib/module/views/WithdrawFlow.js +3 -3
  67. package/lib/module/views/WithdrawFlow.js.map +1 -1
  68. package/lib/module/views/dice3d/DiceTable3D.js +131 -0
  69. package/lib/module/views/dice3d/DiceTable3D.js.map +1 -0
  70. package/lib/module/views/dice3d/diceScene.js +873 -0
  71. package/lib/module/views/dice3d/diceScene.js.map +1 -0
  72. package/lib/module/views/dice3d/diceSim.js +300 -0
  73. package/lib/module/views/dice3d/diceSim.js.map +1 -0
  74. package/lib/module/views/diceDuel.js +0 -9
  75. package/lib/module/views/diceDuel.js.map +1 -1
  76. package/lib/typescript/src/NativeWebView.d.ts +1 -0
  77. package/lib/typescript/src/NativeWebView.d.ts.map +1 -1
  78. package/lib/typescript/src/components/MonflowtsButton.d.ts.map +1 -1
  79. package/lib/typescript/src/theme.d.ts +3 -3
  80. package/lib/typescript/src/views/DiceBattle.d.ts.map +1 -1
  81. package/lib/typescript/src/views/DiceLobby.d.ts.map +1 -1
  82. package/lib/typescript/src/views/Home.d.ts.map +1 -1
  83. package/lib/typescript/src/views/TriviaLobby.d.ts.map +1 -1
  84. package/lib/typescript/src/views/dice3d/DiceTable3D.d.ts +41 -0
  85. package/lib/typescript/src/views/dice3d/DiceTable3D.d.ts.map +1 -0
  86. package/lib/typescript/src/views/dice3d/diceScene.d.ts +2 -0
  87. package/lib/typescript/src/views/dice3d/diceScene.d.ts.map +1 -0
  88. package/lib/typescript/src/views/dice3d/diceSim.d.ts +2 -0
  89. package/lib/typescript/src/views/dice3d/diceSim.d.ts.map +1 -0
  90. package/lib/typescript/src/views/diceDuel.d.ts +0 -7
  91. package/lib/typescript/src/views/diceDuel.d.ts.map +1 -1
  92. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  import React, { useState, useCallback, useRef, useEffect, useMemo } from 'react';
4
- import { View, Text, ScrollView, StyleSheet, Alert, Animated } from 'react-native';
4
+ import { View, Text, ScrollView, StyleSheet, Alert, Animated, ActivityIndicator } from 'react-native';
5
5
  import { scaledStyles } from "../utils/scale.js";
6
6
  import CoinFlyOverlay from "../components/CoinFlyOverlay.js";
7
7
  import MonflowtsPressable from "../components/MonflowtsPressable.js";
@@ -10,6 +10,7 @@ import { COLORS } from "../constants.js";
10
10
  import QuitConfirmModal from "../components/QuitConfirmModal.js";
11
11
  import SideDemoTab, { SIDE_DEMO_TAB_WIDTH } from "../components/SideDemoTab.js";
12
12
  import { sounds } from "../SoundManager.js";
13
+ import { haptics } from "../HapticsManager.js";
13
14
  import { useBackGuard } from "../navigation/hooks.js";
14
15
  import HypeCallout from "../components/HypeCallout.js";
15
16
  import { HYPE_PHRASES, pickPhrase } from "../effects/hypePhrases.js";
@@ -24,8 +25,10 @@ import { useCurrency } from "../hooks/useCurrency.js";
24
25
  import { useGameStore } from "../stores/gameStore.js";
25
26
  import { randomMessageKey } from "../content.js";
26
27
  import { t, formatNumber, errorText } from "../i18n.js";
27
- import { diceBattleLayout, diceWinMultiplier } from "./diceDuel.js";
28
+ import { diceWinMultiplier } from "./diceDuel.js";
29
+ import DiceTable3D from "./dice3d/DiceTable3D.js";
28
30
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
31
+ const ROUND_WATCHDOG_MS = 25000;
29
32
  function rollSingle() {
30
33
  return {
31
34
  die1: Math.ceil(Math.random() * 6),
@@ -67,21 +70,17 @@ const DiceBattle = ({
67
70
  const [sessionComplete, setSessionComplete] = useState(false);
68
71
  const [showResultOverlay, setShowResultOverlay] = useState(false);
69
72
  const [lastRoll, setLastRoll] = useState(null);
70
- const [box, setBox] = useState({
71
- width: 0,
72
- height: 0
73
- });
74
- const onContainerLayout = useCallback(e => {
75
- const {
76
- width,
77
- height
78
- } = e.nativeEvent.layout;
79
- setBox(b => b.width === width && b.height === height ? b : {
80
- width,
81
- height
82
- });
83
- }, []);
84
- const layout = diceBattleLayout(box.width, box.height);
73
+ const [sceneMode, setSceneMode] = useState('loading');
74
+ const [hintVisible, setHintVisible] = useState(true);
75
+ const tableRef = useRef(null);
76
+ const pendingRef = useRef(null);
77
+ const watchdogRef = useRef(null);
78
+ const lastImpactRef = useRef(0);
79
+ const [tableLayout, setTableLayout] = useState(null);
80
+ const p1Pop = useRef(new Animated.Value(1)).current;
81
+ const p2Pop = useRef(new Animated.Value(1)).current;
82
+ const [diceInAir, setDiceInAir] = useState(false);
83
+ const boardOpacity = useRef(new Animated.Value(1)).current;
85
84
  const winMultiplier = diceWinMultiplier(game?.gameplayRules?.winMultiplier);
86
85
  const demoTabShown = !!game?.demoConfig?.enabled;
87
86
  const diceLive = isRolling || roundNum > 0 && !sessionComplete && !showResultOverlay;
@@ -122,20 +121,108 @@ const DiceBattle = ({
122
121
  }
123
122
  }, [demoMode, initPlay]); // eslint-disable-line react-hooks/exhaustive-deps
124
123
 
125
- const rollDice = useCallback(async () => {
126
- if (isRolling || !game) return;
124
+ useEffect(() => () => {
125
+ if (intervalRef.current) clearInterval(intervalRef.current);
126
+ if (watchdogRef.current) clearTimeout(watchdogRef.current);
127
+ }, []);
128
+ const finishRound = useCallback(pending => {
129
+ if (watchdogRef.current) clearTimeout(watchdogRef.current);
130
+ const {
131
+ finalP1,
132
+ finalP2,
133
+ serverResult,
134
+ round,
135
+ totalWonBefore
136
+ } = pending;
137
+ const gameResult = serverResult?.gameResult;
138
+ const p1Sum = finalP1.die1 + finalP1.die2;
139
+ const p2Sum = finalP2.die1 + finalP2.die2;
140
+ // Winner follows the SERVER's decision (the amount it actually paid),
141
+ // not a local dice comparison — the server's win logic is RNG/win-control
142
+ // gated, so local sums can disagree with the money. A dice-equal result
143
+ // is shown as a draw only when no money was won.
144
+ const amountWon = (serverResult?.amountWonKobo ?? 0) / 100;
145
+ const winner = amountWon > 0 ? 'p1' : p1Sum === p2Sum ? 'draw' : 'p2';
146
+ setP1Dice(finalP1);
147
+ setP2Dice(finalP2);
148
+ setP1Score(p1Sum);
149
+ setP2Score(p2Sum);
150
+ setLastRoll({
151
+ player: p1Sum,
152
+ bot: p2Sum,
153
+ isDraw: p1Sum === p2Sum,
154
+ nonce: typeof gameResult?.nonce === 'number' ? gameResult.nonce : null,
155
+ hash: typeof gameResult?.serverSeedHash === 'string' && gameResult.serverSeedHash !== 'demo' ? gameResult.serverSeedHash : null
156
+ });
157
+ setRounds(prev => [{
158
+ id: round,
159
+ p1: finalP1,
160
+ p2: finalP2,
161
+ winner
162
+ }, ...prev]);
163
+ setIsRolling(false);
164
+ tableRef.current?.outcome(winner === 'p1' ? 'player' : winner === 'p2' ? 'house' : 'draw');
165
+ if (amountWon > 0) {
166
+ sounds.playWinChime();
167
+ haptics.trigger('success');
168
+ hypeRef.current?.show(pickPhrase(amountWon >= 5000 ? HYPE_PHRASES.dice.bigWin : HYPE_PHRASES.dice.win), amountWon >= 5000 ? 'boost' : 'win');
169
+ // Coin fly animation — skip in demo mode (no real money)
170
+ if (!demoMode) {
171
+ coinFlyRef.current?.measureTarget();
172
+ cardsAreaRef.current?.measureInWindow?.((x, y, w, h) => {
173
+ coinFlyRef.current?.fly(x + w / 2, y + h / 2);
174
+ });
175
+ }
176
+ } else {
177
+ sounds.playDrawSound();
178
+ hypeRef.current?.show(pickPhrase(HYPE_PHRASES.dice.loss), 'loss');
179
+ }
180
+ if (isMultiRound) {
181
+ // Multi-round session: accumulate results
182
+ if (amountWon > 0) {
183
+ setSessionWins(w => w + 1);
184
+ setSessionTotalWon(total => total + amountWon);
185
+ }
186
+ const isLastRound = gameResult?.session?.isLastRound ?? round >= stakeCount;
187
+ if (isLastRound) {
188
+ // Session complete — show result overlay after a delay so user can see last round
189
+ setLastAmountWon(totalWonBefore + amountWon);
190
+ setTimeout(() => {
191
+ setSessionComplete(true);
192
+ setShowResultOverlay(true);
193
+ }, 3000);
194
+ }
195
+ } else {
196
+ // Single round: show result overlay after a delay so user can see the dice
197
+ setLastAmountWon(amountWon);
198
+ setTimeout(() => setShowResultOverlay(true), 3000);
199
+ }
200
+ }, [demoMode, isMultiRound, stakeCount]);
201
+ const beginRoll = useCallback(async source => {
202
+ const useScene = sceneMode === 'ready';
203
+ const refuse = () => {
204
+ if (source === 'grab') tableRef.current?.cancel();
205
+ };
206
+ if (isRolling || !game) return refuse();
127
207
 
128
208
  // Block if session expired (two-phase mode)
129
- if (initPlay.enabled && initPlay.isExpired) return;
209
+ if (initPlay.enabled && initPlay.isExpired) return refuse();
130
210
 
131
211
  // Check sufficient balance (non-two-phase mode)
132
212
  if (!demoMode && !initPlay.session && balance < initialStake) {
213
+ refuse();
133
214
  setShowFundsOverlay(true);
134
215
  return;
135
216
  }
136
217
  sounds.resume();
218
+ haptics.trigger(source === 'grab' ? 'selection' : 'light');
219
+ const round = roundNum + 1;
137
220
  setIsRolling(true);
138
- setRoundNum(r => r + 1);
221
+ setHintVisible(false);
222
+ setRoundNum(round);
223
+ setP1Score(0);
224
+ setP2Score(0);
225
+ if (useScene && source === 'button') tableRef.current?.autoThrow();
139
226
 
140
227
  // ── Call server to determine outcome ──
141
228
  let serverResult = null;
@@ -154,6 +241,7 @@ const DiceBattle = ({
154
241
  }
155
242
  } catch (e) {
156
243
  console.warn('[DiceBattle] play failed:', e?.message ?? e);
244
+ if (useScene) tableRef.current?.cancel();
157
245
  const msg = (e?.message || '').toLowerCase();
158
246
  if (msg.includes('insufficient') || msg.includes('balance')) {
159
247
  setShowFundsOverlay(true);
@@ -167,14 +255,29 @@ const DiceBattle = ({
167
255
 
168
256
  // Parse server dice values
169
257
  const gameResult = serverResult?.gameResult;
170
- const finalP1 = gameResult?.playerDice ? {
171
- die1: gameResult.playerDice[0],
172
- die2: gameResult.playerDice[1]
173
- } : rollSingle();
174
- const finalP2 = gameResult?.botDice ? {
175
- die1: gameResult.botDice[0],
176
- die2: gameResult.botDice[1]
177
- } : rollSingle();
258
+ const pending = {
259
+ finalP1: gameResult?.playerDice ? {
260
+ die1: gameResult.playerDice[0],
261
+ die2: gameResult.playerDice[1]
262
+ } : rollSingle(),
263
+ finalP2: gameResult?.botDice ? {
264
+ die1: gameResult.botDice[0],
265
+ die2: gameResult.botDice[1]
266
+ } : rollSingle(),
267
+ serverResult,
268
+ round,
269
+ totalWonBefore: sessionTotalWon
270
+ };
271
+ pendingRef.current = pending;
272
+ watchdogRef.current = setTimeout(() => {
273
+ if (pendingRef.current !== pending) return;
274
+ pendingRef.current = null;
275
+ finishRound(pending);
276
+ }, ROUND_WATCHDOG_MS);
277
+ if (useScene) {
278
+ tableRef.current?.deliver([pending.finalP1.die1, pending.finalP1.die2], [pending.finalP2.die1, pending.finalP2.die2]);
279
+ return;
280
+ }
178
281
 
179
282
  // ── Tumble animation (12 ticks of random dice) ──
180
283
  let ticks = 0;
@@ -185,86 +288,104 @@ const DiceBattle = ({
185
288
  ticks++;
186
289
  if (ticks >= 12) {
187
290
  if (intervalRef.current) clearInterval(intervalRef.current);
188
- const p1Sum = finalP1.die1 + finalP1.die2;
189
- const p2Sum = finalP2.die1 + finalP2.die2;
190
- // Winner follows the SERVER's decision (the amount it actually paid),
191
- // not a local dice comparison — the server's win logic is RNG/win-control
192
- // gated, so local sums can disagree with the money. A dice-equal result
193
- // is shown as a draw only when no money was won.
194
- const serverAmountWon = (serverResult?.amountWonKobo ?? 0) / 100;
195
- const winner = serverAmountWon > 0 ? 'p1' : p1Sum === p2Sum ? 'draw' : 'p2';
196
- setP1Dice(finalP1);
197
- setP2Dice(finalP2);
198
- setP1Score(p1Sum);
199
- setP2Score(p2Sum);
200
- setLastRoll({
201
- player: p1Sum,
202
- bot: p2Sum,
203
- isDraw: p1Sum === p2Sum,
204
- nonce: typeof gameResult?.nonce === 'number' ? gameResult.nonce : null,
205
- hash: typeof gameResult?.serverSeedHash === 'string' && gameResult.serverSeedHash !== 'demo' ? gameResult.serverSeedHash : null
206
- });
207
- const round = {
208
- id: roundNum + 1,
209
- p1: finalP1,
210
- p2: finalP2,
211
- winner
212
- };
213
- setRounds(prev => [round, ...prev]);
214
- setIsRolling(false);
215
- const amountWon = (serverResult?.amountWonKobo ?? 0) / 100;
216
- const session = gameResult?.session;
217
- const isLastRound = session?.isLastRound ?? roundNum + 1 >= stakeCount;
218
- if (isMultiRound) {
219
- // Multi-round session: accumulate results
220
- if (amountWon > 0) {
221
- setSessionWins(w => w + 1);
222
- setSessionTotalWon(t => t + amountWon);
223
- sounds.playWinChime();
224
- hypeRef.current?.show(pickPhrase(amountWon >= 5000 ? HYPE_PHRASES.dice.bigWin : HYPE_PHRASES.dice.win), amountWon >= 5000 ? 'boost' : 'win');
225
- // Coin fly animation — skip in demo mode (no real money)
226
- if (!demoMode) {
227
- coinFlyRef.current?.measureTarget();
228
- cardsAreaRef.current?.measureInWindow?.((x, y, w, h) => {
229
- coinFlyRef.current?.fly(x + w / 2, y + h / 2);
230
- });
231
- }
232
- } else {
233
- sounds.playDrawSound();
234
- hypeRef.current?.show(pickPhrase(HYPE_PHRASES.dice.loss), 'loss');
235
- }
236
- if (isLastRound) {
237
- // Session complete — show result overlay after a delay so user can see last round
238
- const totalWon = sessionTotalWon + amountWon;
239
- setLastAmountWon(totalWon);
240
- setTimeout(() => {
241
- setSessionComplete(true);
242
- setShowResultOverlay(true);
243
- }, 3000);
244
- }
245
- } else {
246
- // Single round: show result overlay after a delay so user can see the dice
247
- setLastAmountWon(amountWon);
248
- if (amountWon > 0) {
249
- sounds.playWinChime();
250
- hypeRef.current?.show(pickPhrase(amountWon >= 5000 ? HYPE_PHRASES.dice.bigWin : HYPE_PHRASES.dice.win), amountWon >= 5000 ? 'boost' : 'win');
251
- if (!demoMode) {
252
- coinFlyRef.current?.measureTarget();
253
- cardsAreaRef.current?.measureInWindow?.((x, y, w, h) => {
254
- coinFlyRef.current?.fly(x + w / 2, y + h / 2);
255
- });
256
- }
257
- } else {
258
- sounds.playDrawSound();
259
- hypeRef.current?.show(pickPhrase(HYPE_PHRASES.dice.loss), 'loss');
260
- }
261
- setTimeout(() => {
262
- setShowResultOverlay(true);
263
- }, 3000);
264
- }
291
+ if (pendingRef.current !== pending) return;
292
+ pendingRef.current = null;
293
+ finishRound(pending);
265
294
  }
266
295
  }, 80);
267
- }, [isRolling, roundNum, initialStake, stakeCount, isMultiRound, sessionTotalWon, game, play, initPlay, balance, demoMode]);
296
+ }, [sceneMode, isRolling, roundNum, initialStake, stakeCount, isMultiRound, sessionTotalWon, game, play, initPlay, balance, demoMode, finishRound]);
297
+ const handleGrab = useCallback(() => {
298
+ setDiceInAir(true);
299
+ void beginRoll('grab');
300
+ }, [beginRoll]);
301
+ const handleThrow = useCallback(side => {
302
+ if (side === 'player') setDiceInAir(true);
303
+ }, []);
304
+ const handleSceneReady = useCallback(() => setSceneMode('ready'), []);
305
+ const handleSceneUnsupported = useCallback(() => {
306
+ setSceneMode('fallback');
307
+ const pending = pendingRef.current;
308
+ if (!pending) return;
309
+ pendingRef.current = null;
310
+ finishRound(pending);
311
+ }, [finishRound]);
312
+ const handleShake = useCallback(() => {
313
+ sounds.playRollTick();
314
+ haptics.trigger('selection');
315
+ }, []);
316
+ const handleImpact = useCallback(strength => {
317
+ const now = Date.now();
318
+ if (now - lastImpactRef.current < 60) return;
319
+ lastImpactRef.current = now;
320
+ sounds.playRollTick();
321
+ haptics.trigger(strength > 0.55 ? 'medium' : 'light');
322
+ }, []);
323
+ const handleSettled = useCallback((side, _values) => {
324
+ setDiceInAir(false);
325
+ const pending = pendingRef.current;
326
+ if (!pending) return;
327
+ if (side === 'player') {
328
+ setP1Dice(pending.finalP1);
329
+ setP1Score(pending.finalP1.die1 + pending.finalP1.die2);
330
+ sounds.playSelect();
331
+ haptics.trigger('medium');
332
+ return;
333
+ }
334
+ pendingRef.current = null;
335
+ finishRound(pending);
336
+ }, [finishRound]);
337
+ const youLabel = t('dice.battle.you');
338
+ const houseLabel = t('dice.battle.house');
339
+ const canGrab = sceneMode === 'ready' && !!game && !isRolling && !sessionComplete && !showResultOverlay && !showFundsOverlay && !quitVisible && !rulesVisible && !(initPlay.enabled && initPlay.isExpired);
340
+ const scene = useMemo(() => ({
341
+ you: youLabel,
342
+ house: houseLabel,
343
+ player: COLORS.primary,
344
+ playerInk: '#331B00',
345
+ houseColor: COLORS.blue,
346
+ houseInk: '#1B1433',
347
+ felt: '#1B1930',
348
+ rail: COLORS.slateDarker,
349
+ accent: COLORS.gold,
350
+ background: COLORS.backgroundDark,
351
+ canGrab,
352
+ faces: rounds.length > 0 ? [p1Dice.die1, p1Dice.die2, p2Dice.die1, p2Dice.die2] : [6, 5, 4, 3]
353
+ }), [youLabel, houseLabel, canGrab, rounds.length, p1Dice, p2Dice]);
354
+ const latestWinner = !isRolling ? rounds[0]?.winner : undefined;
355
+ const resultTone = latestWinner === 'p1' ? 'win' : latestWinner === 'p2' ? 'loss' : latestWinner === 'draw' ? 'draw' : null;
356
+ useEffect(() => {
357
+ if (p1Score <= 0) return;
358
+ p1Pop.setValue(1.7);
359
+ Animated.spring(p1Pop, {
360
+ toValue: 1,
361
+ friction: 4,
362
+ tension: 120,
363
+ useNativeDriver: true
364
+ }).start();
365
+ }, [p1Score, p1Pop]);
366
+ useEffect(() => {
367
+ if (p2Score <= 0) return;
368
+ p2Pop.setValue(1.7);
369
+ Animated.spring(p2Pop, {
370
+ toValue: 1,
371
+ friction: 4,
372
+ tension: 120,
373
+ useNativeDriver: true
374
+ }).start();
375
+ }, [p2Score, p2Pop]);
376
+ useEffect(() => {
377
+ if (!isRolling) setDiceInAir(false);
378
+ }, [isRolling]);
379
+ useEffect(() => {
380
+ Animated.timing(boardOpacity, {
381
+ toValue: diceInAir ? 0 : 1,
382
+ duration: 160,
383
+ useNativeDriver: true
384
+ }).start();
385
+ }, [diceInAir, boardOpacity]);
386
+ const centerStyle = tableLayout ? {
387
+ top: tableLayout.centerY - 18
388
+ } : styles.centerFallback;
268
389
  const resultMsg = useMemo(() => randomMessageKey(lastAmountWon > 0 ? 'dice.battle.win' : 'dice.battle.loss'), [showResultOverlay] // eslint-disable-line react-hooks/exhaustive-deps
269
390
  );
270
391
  const handleResultPlayAgain = useCallback(() => {
@@ -290,11 +411,10 @@ const DiceBattle = ({
290
411
  }, [lastAmountWon, onWin, onLose]);
291
412
  return /*#__PURE__*/_jsxs(View, {
292
413
  style: styles.container,
293
- onLayout: onContainerLayout,
294
414
  children: [/*#__PURE__*/_jsx(HypeCallout, {
295
415
  ref: hypeRef,
296
416
  style: {
297
- top: layout.sideBySide ? 120 : 240
417
+ top: 170
298
418
  }
299
419
  }), /*#__PURE__*/_jsx(SideDemoTab, {
300
420
  enabled: !!game?.demoConfig?.enabled
@@ -365,11 +485,8 @@ const DiceBattle = ({
365
485
  })
366
486
  })]
367
487
  })]
368
- }), /*#__PURE__*/_jsxs(ScrollView, {
488
+ }), /*#__PURE__*/_jsxs(View, {
369
489
  style: styles.body,
370
- contentContainerStyle: styles.bodyContent,
371
- bounces: false,
372
- showsVerticalScrollIndicator: false,
373
490
  children: [/*#__PURE__*/_jsx(AbandonPolicyNotice, {
374
491
  abandonPolicy: abandonPolicy
375
492
  }), initPlay.enabled && initPlay.error && !initPlay.session && /*#__PURE__*/_jsxs(View, {
@@ -394,7 +511,7 @@ const DiceBattle = ({
394
511
  })]
395
512
  }), /*#__PURE__*/_jsxs(Animated.View, {
396
513
  ref: stakePillRef,
397
- style: [styles.stakeBar, layout.sideBySide && demoTabShown && {
514
+ style: [styles.stakeBar, demoTabShown && {
398
515
  marginRight: 20 + SIDE_DEMO_TAB_WIDTH
399
516
  }, {
400
517
  transform: [{
@@ -417,54 +534,129 @@ const DiceBattle = ({
417
534
  currency
418
535
  }) : t('dice.battle.winPrizes')
419
536
  })]
420
- }), /*#__PURE__*/_jsxs(View, {
537
+ }), /*#__PURE__*/_jsx(View, {
421
538
  ref: cardsAreaRef,
422
- style: [styles.cardsArea, layout.sideBySide && styles.cardsAreaRow, demoTabShown && {
423
- paddingRight: 20 + SIDE_DEMO_TAB_WIDTH
424
- }],
425
- children: [/*#__PURE__*/_jsx(View, {
426
- style: layout.sideBySide ? styles.cardSlot : undefined,
427
- children: /*#__PURE__*/_jsx(PlayerCard, {
539
+ style: styles.tableArea,
540
+ children: sceneMode === 'fallback' ? /*#__PURE__*/_jsxs(ScrollView, {
541
+ contentContainerStyle: styles.cardsArea,
542
+ bounces: false,
543
+ showsVerticalScrollIndicator: false,
544
+ children: [/*#__PURE__*/_jsx(PlayerCard, {
428
545
  playerNumber: 1,
429
546
  title: t('dice.battle.you'),
430
547
  subtitle: t('dice.battle.player'),
431
548
  score: p1Score,
432
549
  dice: p1Dice,
433
- isWinner: !isRolling && rounds[0]?.winner === 'p1',
550
+ isWinner: latestWinner === 'p1',
434
551
  bgColor: "#4f46e5",
435
552
  isRolling: isRolling
436
- })
437
- }), /*#__PURE__*/_jsx(View, {
438
- style: styles.vsSeparator,
439
- children: /*#__PURE__*/_jsx(Text, {
440
- style: styles.vsText,
441
- children: t('dice.battle.vs')
442
- })
443
- }), /*#__PURE__*/_jsx(View, {
444
- style: layout.sideBySide ? styles.cardSlot : undefined,
445
- children: /*#__PURE__*/_jsx(PlayerCard, {
553
+ }), /*#__PURE__*/_jsx(View, {
554
+ style: styles.vsSeparator,
555
+ children: /*#__PURE__*/_jsx(Text, {
556
+ style: styles.vsText,
557
+ children: t('dice.battle.vs')
558
+ })
559
+ }), /*#__PURE__*/_jsx(PlayerCard, {
446
560
  playerNumber: 2,
447
561
  title: t('dice.battle.bot'),
448
562
  subtitle: t('dice.battle.monflowtsAi'),
449
563
  score: p2Score,
450
564
  dice: p2Dice,
451
- isWinner: !isRolling && rounds[0]?.winner === 'p2',
565
+ isWinner: latestWinner === 'p2',
452
566
  bgColor: "#0f766e",
453
567
  isRolling: isRolling
454
- })
455
- })]
456
- }), rounds.length > 0 && /*#__PURE__*/_jsxs(View, {
568
+ })]
569
+ }) : /*#__PURE__*/_jsxs(_Fragment, {
570
+ children: [/*#__PURE__*/_jsx(DiceTable3D, {
571
+ ref: tableRef,
572
+ scene: scene,
573
+ onReady: handleSceneReady,
574
+ onUnsupported: handleSceneUnsupported,
575
+ onGrab: handleGrab,
576
+ onThrow: handleThrow,
577
+ onShake: handleShake,
578
+ onImpact: handleImpact,
579
+ onSettled: handleSettled,
580
+ onTableLayout: setTableLayout,
581
+ style: styles.tableFill
582
+ }), sceneMode === 'loading' ? /*#__PURE__*/_jsx(ActivityIndicator, {
583
+ style: styles.tableLoading,
584
+ color: COLORS.primary
585
+ }) : /*#__PURE__*/_jsx(_Fragment, {
586
+ children: hintVisible && canGrab ? /*#__PURE__*/_jsxs(View, {
587
+ pointerEvents: "none",
588
+ style: [styles.hint, centerStyle],
589
+ children: [/*#__PURE__*/_jsx(SvgIcon, {
590
+ name: "dice",
591
+ size: 14,
592
+ color: COLORS.primary
593
+ }), /*#__PURE__*/_jsx(Text, {
594
+ style: styles.hintText,
595
+ children: t('dice.battle.flickHint')
596
+ })]
597
+ }) : /*#__PURE__*/_jsxs(Animated.View, {
598
+ pointerEvents: "none",
599
+ style: [styles.scoreboard, centerStyle, resultTone === 'win' && styles.scoreboardWin, resultTone === 'loss' && styles.scoreboardLoss, {
600
+ opacity: boardOpacity
601
+ }],
602
+ children: [/*#__PURE__*/_jsxs(View, {
603
+ style: styles.scoreSide,
604
+ children: [/*#__PURE__*/_jsx(View, {
605
+ style: [styles.scoreDot, {
606
+ backgroundColor: COLORS.primary
607
+ }]
608
+ }), /*#__PURE__*/_jsx(Text, {
609
+ style: styles.scoreLabel,
610
+ numberOfLines: 1,
611
+ children: youLabel
612
+ }), /*#__PURE__*/_jsx(Animated.Text, {
613
+ style: [styles.scoreValue, {
614
+ color: COLORS.primary,
615
+ transform: [{
616
+ scale: p1Pop
617
+ }]
618
+ }],
619
+ children: p1Score > 0 ? p1Score : '–'
620
+ })]
621
+ }), /*#__PURE__*/_jsx(View, {
622
+ style: [styles.scoreMid, resultTone === 'win' && styles.scoreMidWin, resultTone === 'loss' && styles.scoreMidLoss, resultTone === 'draw' && styles.scoreMidDraw],
623
+ children: /*#__PURE__*/_jsx(Text, {
624
+ style: [styles.scoreMidText, resultTone === 'win' && styles.scoreMidTextWin, resultTone === 'loss' && styles.scoreMidTextLoss],
625
+ numberOfLines: 1,
626
+ children: resultTone ? t(`dice.battle.${resultTone}`) : t('dice.battle.vs')
627
+ })
628
+ }), /*#__PURE__*/_jsxs(View, {
629
+ style: styles.scoreSide,
630
+ children: [/*#__PURE__*/_jsx(Animated.Text, {
631
+ style: [styles.scoreValue, {
632
+ color: COLORS.blue,
633
+ transform: [{
634
+ scale: p2Pop
635
+ }]
636
+ }],
637
+ children: p2Score > 0 ? p2Score : '–'
638
+ }), /*#__PURE__*/_jsx(Text, {
639
+ style: styles.scoreLabel,
640
+ numberOfLines: 1,
641
+ children: houseLabel
642
+ }), /*#__PURE__*/_jsx(View, {
643
+ style: [styles.scoreDot, {
644
+ backgroundColor: COLORS.blue
645
+ }]
646
+ })]
647
+ })]
648
+ })
649
+ })]
650
+ })
651
+ }), sceneMode !== 'fallback' || rounds.length > 0 ? /*#__PURE__*/_jsx(View, {
457
652
  style: styles.historySection,
458
- children: [/*#__PURE__*/_jsx(Text, {
459
- style: styles.historyTitle,
460
- children: t('dice.battle.matchHistory')
461
- }), /*#__PURE__*/_jsx(ScrollView, {
653
+ children: /*#__PURE__*/_jsx(ScrollView, {
462
654
  horizontal: true,
463
655
  showsHorizontalScrollIndicator: false,
464
- children: rounds.slice(0, 5).map(r => /*#__PURE__*/_jsxs(View, {
656
+ children: rounds.slice(0, 8).map(r => /*#__PURE__*/_jsxs(View, {
465
657
  style: [styles.historyCard, r.winner === 'p1' && {
466
- backgroundColor: 'rgba(127,19,236,0.15)',
467
- borderColor: 'rgba(127,19,236,0.3)'
658
+ backgroundColor: 'rgba(255, 199, 48, 0.15)',
659
+ borderColor: 'rgba(255, 199, 48, 0.3)'
468
660
  }, r.winner === 'p2' && {
469
661
  backgroundColor: 'rgba(239,68,68,0.1)',
470
662
  borderColor: 'rgba(239,68,68,0.2)'
@@ -485,8 +677,8 @@ const DiceBattle = ({
485
677
  children: r.winner === 'p1' ? t('dice.battle.win') : r.winner === 'p2' ? t('dice.battle.loss') : t('dice.battle.draw')
486
678
  })]
487
679
  }, r.id))
488
- })]
489
- })]
680
+ })
681
+ }) : null]
490
682
  }), /*#__PURE__*/_jsx(View, {
491
683
  style: styles.footer,
492
684
  children: sessionComplete ? /*#__PURE__*/_jsxs(View, {
@@ -524,11 +716,13 @@ const DiceBattle = ({
524
716
  icon: /*#__PURE__*/_jsx(SvgIcon, {
525
717
  name: "dice",
526
718
  size: 18,
527
- color: "#ffffff"
719
+ color: "#331B00"
528
720
  }),
529
721
  loading: isRolling,
530
722
  loadingText: t('dice.battle.rolling'),
531
- onPress: rollDice,
723
+ onPress: () => {
724
+ void beginRoll('button');
725
+ },
532
726
  textStyle: styles.rollBtnText
533
727
  })
534
728
  }), /*#__PURE__*/_jsx(InsufficientFundsOverlay, {
@@ -612,7 +806,7 @@ const DiceBattle = ({
612
806
  icon: /*#__PURE__*/_jsx(SvgIcon, {
613
807
  name: "lightning",
614
808
  size: 16,
615
- color: "#ffffff"
809
+ color: "#331B00"
616
810
  }),
617
811
  onPress: () => {
618
812
  toggleDemoMode();
@@ -638,7 +832,7 @@ const DiceBattle = ({
638
832
  icon: /*#__PURE__*/_jsx(SvgIcon, {
639
833
  name: "refresh",
640
834
  size: 16,
641
- color: "#ffffff"
835
+ color: "#331B00"
642
836
  }),
643
837
  onPress: handleResultPlayAgain
644
838
  }), /*#__PURE__*/_jsx(MonflowtsButton, {
@@ -672,7 +866,7 @@ const styles = scaledStyles({
672
866
  width: 40,
673
867
  height: 40,
674
868
  borderRadius: 20,
675
- backgroundColor: 'rgba(15,23,42,0.6)',
869
+ backgroundColor: 'rgba(23, 22, 31, 0.6)',
676
870
  borderWidth: 1,
677
871
  borderColor: COLORS.white10,
678
872
  alignItems: 'center',
@@ -737,19 +931,121 @@ const styles = scaledStyles({
737
931
  body: {
738
932
  flex: 1
739
933
  },
740
- bodyContent: {
741
- flexGrow: 1
934
+ tableArea: {
935
+ flex: 1,
936
+ minHeight: 240,
937
+ marginHorizontal: 8,
938
+ marginBottom: 8
742
939
  },
743
- cardsArea: {
744
- flexGrow: 1,
745
- paddingHorizontal: 20
940
+ tableFill: {
941
+ ...StyleSheet.absoluteFill
746
942
  },
747
- cardsAreaRow: {
943
+ tableLoading: {
944
+ ...StyleSheet.absoluteFill
945
+ },
946
+ centerFallback: {
947
+ top: '50%',
948
+ marginTop: -18
949
+ },
950
+ scoreboard: {
951
+ position: 'absolute',
952
+ alignSelf: 'center',
748
953
  flexDirection: 'row',
749
- alignItems: 'center'
954
+ alignItems: 'center',
955
+ gap: 10,
956
+ height: 36,
957
+ paddingHorizontal: 12,
958
+ borderRadius: 18,
959
+ backgroundColor: 'rgba(12, 11, 18, 0.82)',
960
+ borderWidth: 1,
961
+ borderColor: COLORS.white10,
962
+ maxWidth: '94%'
750
963
  },
751
- cardSlot: {
752
- flex: 1
964
+ scoreboardWin: {
965
+ borderColor: COLORS.primary,
966
+ backgroundColor: 'rgba(40, 32, 10, 0.9)'
967
+ },
968
+ scoreboardLoss: {
969
+ borderColor: 'rgba(239, 68, 68, 0.5)'
970
+ },
971
+ scoreSide: {
972
+ flexDirection: 'row',
973
+ alignItems: 'center',
974
+ gap: 6,
975
+ flexShrink: 1
976
+ },
977
+ scoreDot: {
978
+ width: 8,
979
+ height: 8,
980
+ borderRadius: 4
981
+ },
982
+ scoreLabel: {
983
+ fontSize: 10,
984
+ fontWeight: '800',
985
+ color: COLORS.slateLight,
986
+ letterSpacing: 1,
987
+ textTransform: 'uppercase',
988
+ flexShrink: 1
989
+ },
990
+ scoreValue: {
991
+ fontSize: 20,
992
+ fontWeight: '900',
993
+ minWidth: 16,
994
+ textAlign: 'center'
995
+ },
996
+ scoreMid: {
997
+ paddingHorizontal: 8,
998
+ height: 22,
999
+ borderRadius: 11,
1000
+ justifyContent: 'center',
1001
+ backgroundColor: COLORS.white05
1002
+ },
1003
+ scoreMidWin: {
1004
+ backgroundColor: COLORS.primary
1005
+ },
1006
+ scoreMidLoss: {
1007
+ backgroundColor: 'rgba(239, 68, 68, 0.2)'
1008
+ },
1009
+ scoreMidDraw: {
1010
+ backgroundColor: COLORS.white10
1011
+ },
1012
+ scoreMidText: {
1013
+ fontSize: 10,
1014
+ fontWeight: '900',
1015
+ color: COLORS.slateLight,
1016
+ letterSpacing: 1
1017
+ },
1018
+ scoreMidTextWin: {
1019
+ color: '#331B00'
1020
+ },
1021
+ scoreMidTextLoss: {
1022
+ color: COLORS.lossRed
1023
+ },
1024
+ hint: {
1025
+ position: 'absolute',
1026
+ alignSelf: 'center',
1027
+ flexDirection: 'row',
1028
+ alignItems: 'center',
1029
+ gap: 6,
1030
+ paddingHorizontal: 14,
1031
+ minHeight: 36,
1032
+ paddingVertical: 6,
1033
+ borderRadius: 18,
1034
+ backgroundColor: 'rgba(12, 11, 18, 0.82)',
1035
+ borderWidth: 1,
1036
+ borderColor: 'rgba(255, 199, 48, 0.35)',
1037
+ maxWidth: '86%'
1038
+ },
1039
+ hintText: {
1040
+ fontSize: 12,
1041
+ fontWeight: '700',
1042
+ color: '#fff',
1043
+ flexShrink: 1
1044
+ },
1045
+ cardsArea: {
1046
+ flexGrow: 1,
1047
+ paddingHorizontal: 12,
1048
+ paddingVertical: 8
753
1049
  },
754
1050
  vsSeparator: {
755
1051
  alignItems: 'center',
@@ -763,16 +1059,9 @@ const styles = scaledStyles({
763
1059
  fontStyle: 'italic'
764
1060
  },
765
1061
  historySection: {
1062
+ height: 46,
766
1063
  paddingHorizontal: 20,
767
- marginBottom: 12
768
- },
769
- historyTitle: {
770
- fontSize: 10,
771
- fontWeight: '700',
772
- color: COLORS.slateDark,
773
- letterSpacing: 2,
774
- marginBottom: 8,
775
- textTransform: 'uppercase'
1064
+ marginBottom: 4
776
1065
  },
777
1066
  historyCard: {
778
1067
  paddingHorizontal: 14,