react-native-monflowts 0.5.1 → 0.5.3

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 (269) hide show
  1. package/README.md +37 -3
  2. package/android/build.gradle +1 -0
  3. package/android/src/main/java/com/monflowts/MonflowtsLottieView.kt +12 -4
  4. package/android/src/main/java/com/monflowts/MonflowtsNavigationModule.kt +43 -0
  5. package/android/src/main/java/com/monflowts/MonflowtsPackage.kt +10 -1
  6. package/android/src/main/java/com/monflowts/MonflowtsStackView.kt +456 -0
  7. package/android/src/main/java/com/monflowts/MonflowtsStackViewManager.kt +70 -0
  8. package/android/src/main/java/com/monflowts/MonflowtsWebView.kt +35 -11
  9. package/android/src/main/java/com/monflowts/MonflowtsWebViewManager.kt +10 -0
  10. package/ios/MonflowtsNavigationBridge.m +10 -0
  11. package/ios/MonflowtsNavigationModule.swift +28 -0
  12. package/ios/MonflowtsStackBridge.m +17 -0
  13. package/ios/MonflowtsStackUIView.swift +409 -0
  14. package/ios/MonflowtsStackViewManager.swift +14 -0
  15. package/ios/MonflowtsWebBridge.m +1 -0
  16. package/ios/MonflowtsWebUIView.swift +21 -0
  17. package/lib/module/HubContent.js +259 -219
  18. package/lib/module/HubContent.js.map +1 -1
  19. package/lib/module/MonflowtsHub.js +42 -3
  20. package/lib/module/MonflowtsHub.js.map +1 -1
  21. package/lib/module/NativeWebView.js.map +1 -1
  22. package/lib/module/api/mutations.js +4 -0
  23. package/lib/module/api/mutations.js.map +1 -1
  24. package/lib/module/api/queries.js +9 -3
  25. package/lib/module/api/queries.js.map +1 -1
  26. package/lib/module/components/AbandonPolicyNotice.js +7 -6
  27. package/lib/module/components/AbandonPolicyNotice.js.map +1 -1
  28. package/lib/module/components/CoinFlyOverlay.js +27 -20
  29. package/lib/module/components/CoinFlyOverlay.js.map +1 -1
  30. package/lib/module/components/GameRulesModal.js +13 -11
  31. package/lib/module/components/GameRulesModal.js.map +1 -1
  32. package/lib/module/components/HypeCallout.js +5 -5
  33. package/lib/module/components/HypeCallout.js.map +1 -1
  34. package/lib/module/components/InsufficientFundsOverlay.js +4 -3
  35. package/lib/module/components/InsufficientFundsOverlay.js.map +1 -1
  36. package/lib/module/components/JackpotNearMiss.js +4 -3
  37. package/lib/module/components/JackpotNearMiss.js.map +1 -1
  38. package/lib/module/components/JackpotTeaser.js +10 -9
  39. package/lib/module/components/JackpotTeaser.js.map +1 -1
  40. package/lib/module/components/MonflowtsButton.js +7 -4
  41. package/lib/module/components/MonflowtsButton.js.map +1 -1
  42. package/lib/module/components/QuitConfirmModal.js +8 -7
  43. package/lib/module/components/QuitConfirmModal.js.map +1 -1
  44. package/lib/module/components/SessionTimer.js +3 -2
  45. package/lib/module/components/SessionTimer.js.map +1 -1
  46. package/lib/module/components/ShopArtView.js +105 -0
  47. package/lib/module/components/ShopArtView.js.map +1 -0
  48. package/lib/module/components/SideDemoTab.js +22 -4
  49. package/lib/module/components/SideDemoTab.js.map +1 -1
  50. package/lib/module/components/StakeInput.js +7 -6
  51. package/lib/module/components/StakeInput.js.map +1 -1
  52. package/lib/module/content.js.map +1 -1
  53. package/lib/module/hooks/useAvailableGames.js +7 -2
  54. package/lib/module/hooks/useAvailableGames.js.map +1 -1
  55. package/lib/module/hooks/useLeaderboard.js.map +1 -1
  56. package/lib/module/hooks/usePlayGame.js +11 -5
  57. package/lib/module/hooks/usePlayGame.js.map +1 -1
  58. package/lib/module/hooks/useRaffleDrawState.js +4 -1
  59. package/lib/module/hooks/useRaffleDrawState.js.map +1 -1
  60. package/lib/module/index.js +15 -0
  61. package/lib/module/index.js.map +1 -1
  62. package/lib/module/navigation/NativeStackView.js +5 -0
  63. package/lib/module/navigation/NativeStackView.js.map +1 -0
  64. package/lib/module/navigation/Navigator.js +250 -0
  65. package/lib/module/navigation/Navigator.js.map +1 -0
  66. package/lib/module/navigation/engine.js +466 -0
  67. package/lib/module/navigation/engine.js.map +1 -0
  68. package/lib/module/navigation/hooks.js +29 -0
  69. package/lib/module/navigation/hooks.js.map +1 -0
  70. package/lib/module/navigation/index.js +7 -0
  71. package/lib/module/navigation/index.js.map +1 -0
  72. package/lib/module/navigation/routes.js +111 -0
  73. package/lib/module/navigation/routes.js.map +1 -0
  74. package/lib/module/theme.js +13 -13
  75. package/lib/module/theme.js.map +1 -1
  76. package/lib/module/utils/scale.js +35 -0
  77. package/lib/module/utils/scale.js.map +1 -0
  78. package/lib/module/views/DepositSelect.js +8 -7
  79. package/lib/module/views/DepositSelect.js.map +1 -1
  80. package/lib/module/views/DiceBattle.js +589 -218
  81. package/lib/module/views/DiceBattle.js.map +1 -1
  82. package/lib/module/views/DiceLobby.js +113 -74
  83. package/lib/module/views/DiceLobby.js.map +1 -1
  84. package/lib/module/views/FortuneWheel.js +417 -271
  85. package/lib/module/views/FortuneWheel.js.map +1 -1
  86. package/lib/module/views/Freefall.js +149 -90
  87. package/lib/module/views/Freefall.js.map +1 -1
  88. package/lib/module/views/History.js +10 -9
  89. package/lib/module/views/History.js.map +1 -1
  90. package/lib/module/views/Home.js +1058 -401
  91. package/lib/module/views/Home.js.map +1 -1
  92. package/lib/module/views/Jetstream.js +47 -23
  93. package/lib/module/views/Jetstream.js.map +1 -1
  94. package/lib/module/views/Leaderboard.js +112 -103
  95. package/lib/module/views/Leaderboard.js.map +1 -1
  96. package/lib/module/views/MillionaireHunter.js +752 -578
  97. package/lib/module/views/MillionaireHunter.js.map +1 -1
  98. package/lib/module/views/Minefield.js +41 -19
  99. package/lib/module/views/Minefield.js.map +1 -1
  100. package/lib/module/views/PaymentWebView.js +7 -6
  101. package/lib/module/views/PaymentWebView.js.map +1 -1
  102. package/lib/module/views/PlayerCard.js +5 -4
  103. package/lib/module/views/PlayerCard.js.map +1 -1
  104. package/lib/module/views/Profile.js +11 -10
  105. package/lib/module/views/Profile.js.map +1 -1
  106. package/lib/module/views/RaffleDraw.js +37 -27
  107. package/lib/module/views/RaffleDraw.js.map +1 -1
  108. package/lib/module/views/RevealWin.js +161 -34
  109. package/lib/module/views/RevealWin.js.map +1 -1
  110. package/lib/module/views/Splash.js +3 -2
  111. package/lib/module/views/Splash.js.map +1 -1
  112. package/lib/module/views/Success.js +6 -3
  113. package/lib/module/views/Success.js.map +1 -1
  114. package/lib/module/views/TicketShop.js +1067 -236
  115. package/lib/module/views/TicketShop.js.map +1 -1
  116. package/lib/module/views/TriviaLobby.js +57 -31
  117. package/lib/module/views/TriviaLobby.js.map +1 -1
  118. package/lib/module/views/TriviaMaster.js +28 -23
  119. package/lib/module/views/TriviaMaster.js.map +1 -1
  120. package/lib/module/views/Wallet.js +18 -17
  121. package/lib/module/views/Wallet.js.map +1 -1
  122. package/lib/module/views/WithdrawFlow.js +6 -5
  123. package/lib/module/views/WithdrawFlow.js.map +1 -1
  124. package/lib/module/views/dice3d/DiceTable3D.js +131 -0
  125. package/lib/module/views/dice3d/DiceTable3D.js.map +1 -0
  126. package/lib/module/views/dice3d/diceScene.js +873 -0
  127. package/lib/module/views/dice3d/diceScene.js.map +1 -0
  128. package/lib/module/views/dice3d/diceSim.js +300 -0
  129. package/lib/module/views/dice3d/diceSim.js.map +1 -0
  130. package/lib/module/views/diceDuel.js +35 -0
  131. package/lib/module/views/diceDuel.js.map +1 -0
  132. package/lib/module/views/freefallDrop.js +66 -0
  133. package/lib/module/views/freefallDrop.js.map +1 -0
  134. package/lib/module/views/homeLayout.js +47 -0
  135. package/lib/module/views/homeLayout.js.map +1 -0
  136. package/lib/module/views/launchFeatured.js +43 -0
  137. package/lib/module/views/launchFeatured.js.map +1 -0
  138. package/lib/module/views/leaderboardPhase.js +52 -0
  139. package/lib/module/views/leaderboardPhase.js.map +1 -0
  140. package/lib/module/views/lobbyKit.js +224 -0
  141. package/lib/module/views/lobbyKit.js.map +1 -0
  142. package/lib/module/views/raffleContent.js +11 -0
  143. package/lib/module/views/raffleContent.js.map +1 -0
  144. package/lib/module/views/rafflePhase.js +15 -0
  145. package/lib/module/views/rafflePhase.js.map +1 -0
  146. package/lib/module/views/revealWinHelpers.js +19 -0
  147. package/lib/module/views/revealWinHelpers.js.map +1 -1
  148. package/lib/module/views/shopArtMotion.js +25 -0
  149. package/lib/module/views/shopArtMotion.js.map +1 -0
  150. package/lib/module/views/ticketBundlePresets.js +15 -12
  151. package/lib/module/views/ticketBundlePresets.js.map +1 -1
  152. package/lib/module/views/ticketShopArt.js +391 -0
  153. package/lib/module/views/ticketShopArt.js.map +1 -0
  154. package/lib/module/views/treasureHunt.js +81 -0
  155. package/lib/module/views/treasureHunt.js.map +1 -0
  156. package/lib/module/views/wheelLayout.js +47 -0
  157. package/lib/module/views/wheelLayout.js.map +1 -0
  158. package/lib/typescript/src/HubContent.d.ts.map +1 -1
  159. package/lib/typescript/src/MonflowtsHub.d.ts.map +1 -1
  160. package/lib/typescript/src/NativeWebView.d.ts +1 -0
  161. package/lib/typescript/src/NativeWebView.d.ts.map +1 -1
  162. package/lib/typescript/src/api/gameTypes.d.ts +18 -2
  163. package/lib/typescript/src/api/gameTypes.d.ts.map +1 -1
  164. package/lib/typescript/src/api/mutations.d.ts.map +1 -1
  165. package/lib/typescript/src/api/queries.d.ts.map +1 -1
  166. package/lib/typescript/src/api/sdkTypes.d.ts +3 -0
  167. package/lib/typescript/src/api/sdkTypes.d.ts.map +1 -1
  168. package/lib/typescript/src/components/AbandonPolicyNotice.d.ts.map +1 -1
  169. package/lib/typescript/src/components/CoinFlyOverlay.d.ts.map +1 -1
  170. package/lib/typescript/src/components/GameRulesModal.d.ts +1 -0
  171. package/lib/typescript/src/components/GameRulesModal.d.ts.map +1 -1
  172. package/lib/typescript/src/components/HypeCallout.d.ts.map +1 -1
  173. package/lib/typescript/src/components/InsufficientFundsOverlay.d.ts.map +1 -1
  174. package/lib/typescript/src/components/JackpotNearMiss.d.ts.map +1 -1
  175. package/lib/typescript/src/components/JackpotTeaser.d.ts.map +1 -1
  176. package/lib/typescript/src/components/MonflowtsButton.d.ts.map +1 -1
  177. package/lib/typescript/src/components/QuitConfirmModal.d.ts.map +1 -1
  178. package/lib/typescript/src/components/SessionTimer.d.ts.map +1 -1
  179. package/lib/typescript/src/components/ShopArtView.d.ts +11 -0
  180. package/lib/typescript/src/components/ShopArtView.d.ts.map +1 -0
  181. package/lib/typescript/src/components/SideDemoTab.d.ts +1 -0
  182. package/lib/typescript/src/components/SideDemoTab.d.ts.map +1 -1
  183. package/lib/typescript/src/components/StakeInput.d.ts.map +1 -1
  184. package/lib/typescript/src/content.d.ts +1 -0
  185. package/lib/typescript/src/content.d.ts.map +1 -1
  186. package/lib/typescript/src/hooks/useAvailableGames.d.ts +3 -0
  187. package/lib/typescript/src/hooks/useAvailableGames.d.ts.map +1 -1
  188. package/lib/typescript/src/hooks/useLeaderboard.d.ts +4 -0
  189. package/lib/typescript/src/hooks/useLeaderboard.d.ts.map +1 -1
  190. package/lib/typescript/src/hooks/usePlayGame.d.ts +1 -1
  191. package/lib/typescript/src/hooks/usePlayGame.d.ts.map +1 -1
  192. package/lib/typescript/src/hooks/useRaffleDrawState.d.ts.map +1 -1
  193. package/lib/typescript/src/index.d.ts +16 -0
  194. package/lib/typescript/src/index.d.ts.map +1 -1
  195. package/lib/typescript/src/navigation/NativeStackView.d.ts +41 -0
  196. package/lib/typescript/src/navigation/NativeStackView.d.ts.map +1 -0
  197. package/lib/typescript/src/navigation/Navigator.d.ts +13 -0
  198. package/lib/typescript/src/navigation/Navigator.d.ts.map +1 -0
  199. package/lib/typescript/src/navigation/engine.d.ts +69 -0
  200. package/lib/typescript/src/navigation/engine.d.ts.map +1 -0
  201. package/lib/typescript/src/navigation/hooks.d.ts +6 -0
  202. package/lib/typescript/src/navigation/hooks.d.ts.map +1 -0
  203. package/lib/typescript/src/navigation/index.d.ts +7 -0
  204. package/lib/typescript/src/navigation/index.d.ts.map +1 -0
  205. package/lib/typescript/src/navigation/routes.d.ts +80 -0
  206. package/lib/typescript/src/navigation/routes.d.ts.map +1 -0
  207. package/lib/typescript/src/theme.d.ts +3 -3
  208. package/lib/typescript/src/types.d.ts +0 -9
  209. package/lib/typescript/src/types.d.ts.map +1 -1
  210. package/lib/typescript/src/utils/scale.d.ts +12 -0
  211. package/lib/typescript/src/utils/scale.d.ts.map +1 -0
  212. package/lib/typescript/src/views/DiceBattle.d.ts.map +1 -1
  213. package/lib/typescript/src/views/DiceLobby.d.ts.map +1 -1
  214. package/lib/typescript/src/views/FortuneWheel.d.ts.map +1 -1
  215. package/lib/typescript/src/views/Freefall.d.ts.map +1 -1
  216. package/lib/typescript/src/views/History.d.ts.map +1 -1
  217. package/lib/typescript/src/views/Home.d.ts +2 -2
  218. package/lib/typescript/src/views/Home.d.ts.map +1 -1
  219. package/lib/typescript/src/views/Jetstream.d.ts.map +1 -1
  220. package/lib/typescript/src/views/Leaderboard.d.ts.map +1 -1
  221. package/lib/typescript/src/views/MillionaireHunter.d.ts.map +1 -1
  222. package/lib/typescript/src/views/Minefield.d.ts.map +1 -1
  223. package/lib/typescript/src/views/PlayerCard.d.ts.map +1 -1
  224. package/lib/typescript/src/views/Profile.d.ts.map +1 -1
  225. package/lib/typescript/src/views/RaffleDraw.d.ts +2 -1
  226. package/lib/typescript/src/views/RaffleDraw.d.ts.map +1 -1
  227. package/lib/typescript/src/views/RevealWin.d.ts.map +1 -1
  228. package/lib/typescript/src/views/Splash.d.ts.map +1 -1
  229. package/lib/typescript/src/views/Success.d.ts.map +1 -1
  230. package/lib/typescript/src/views/TicketShop.d.ts +1 -0
  231. package/lib/typescript/src/views/TicketShop.d.ts.map +1 -1
  232. package/lib/typescript/src/views/TriviaLobby.d.ts.map +1 -1
  233. package/lib/typescript/src/views/TriviaMaster.d.ts.map +1 -1
  234. package/lib/typescript/src/views/Wallet.d.ts.map +1 -1
  235. package/lib/typescript/src/views/dice3d/DiceTable3D.d.ts +41 -0
  236. package/lib/typescript/src/views/dice3d/DiceTable3D.d.ts.map +1 -0
  237. package/lib/typescript/src/views/dice3d/diceScene.d.ts +2 -0
  238. package/lib/typescript/src/views/dice3d/diceScene.d.ts.map +1 -0
  239. package/lib/typescript/src/views/dice3d/diceSim.d.ts +2 -0
  240. package/lib/typescript/src/views/dice3d/diceSim.d.ts.map +1 -0
  241. package/lib/typescript/src/views/diceDuel.d.ts +15 -0
  242. package/lib/typescript/src/views/diceDuel.d.ts.map +1 -0
  243. package/lib/typescript/src/views/freefallDrop.d.ts +19 -0
  244. package/lib/typescript/src/views/freefallDrop.d.ts.map +1 -0
  245. package/lib/typescript/src/views/homeLayout.d.ts +15 -0
  246. package/lib/typescript/src/views/homeLayout.d.ts.map +1 -0
  247. package/lib/typescript/src/views/launchFeatured.d.ts +2 -0
  248. package/lib/typescript/src/views/launchFeatured.d.ts.map +1 -0
  249. package/lib/typescript/src/views/leaderboardPhase.d.ts +6 -0
  250. package/lib/typescript/src/views/leaderboardPhase.d.ts.map +1 -0
  251. package/lib/typescript/src/views/lobbyKit.d.ts +45 -0
  252. package/lib/typescript/src/views/lobbyKit.d.ts.map +1 -0
  253. package/lib/typescript/src/views/raffleContent.d.ts +3 -0
  254. package/lib/typescript/src/views/raffleContent.d.ts.map +1 -0
  255. package/lib/typescript/src/views/rafflePhase.d.ts +9 -0
  256. package/lib/typescript/src/views/rafflePhase.d.ts.map +1 -0
  257. package/lib/typescript/src/views/revealWinHelpers.d.ts +9 -0
  258. package/lib/typescript/src/views/revealWinHelpers.d.ts.map +1 -1
  259. package/lib/typescript/src/views/shopArtMotion.d.ts +13 -0
  260. package/lib/typescript/src/views/shopArtMotion.d.ts.map +1 -0
  261. package/lib/typescript/src/views/ticketBundlePresets.d.ts +3 -17
  262. package/lib/typescript/src/views/ticketBundlePresets.d.ts.map +1 -1
  263. package/lib/typescript/src/views/ticketShopArt.d.ts +27 -0
  264. package/lib/typescript/src/views/ticketShopArt.d.ts.map +1 -0
  265. package/lib/typescript/src/views/treasureHunt.d.ts +29 -0
  266. package/lib/typescript/src/views/treasureHunt.d.ts.map +1 -0
  267. package/lib/typescript/src/views/wheelLayout.d.ts +30 -0
  268. package/lib/typescript/src/views/wheelLayout.d.ts.map +1 -0
  269. package/package.json +1 -1
@@ -1,14 +1,17 @@
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, BackHandler } from 'react-native';
4
+ import { View, Text, ScrollView, StyleSheet, Alert, Animated, ActivityIndicator } from 'react-native';
5
+ import { scaledStyles } from "../utils/scale.js";
5
6
  import CoinFlyOverlay from "../components/CoinFlyOverlay.js";
6
7
  import MonflowtsPressable from "../components/MonflowtsPressable.js";
7
8
  import PlayerCard from "./PlayerCard.js";
8
9
  import { COLORS } from "../constants.js";
9
10
  import QuitConfirmModal from "../components/QuitConfirmModal.js";
10
- import SideDemoTab from "../components/SideDemoTab.js";
11
+ import SideDemoTab, { SIDE_DEMO_TAB_WIDTH } from "../components/SideDemoTab.js";
11
12
  import { sounds } from "../SoundManager.js";
13
+ import { haptics } from "../HapticsManager.js";
14
+ import { useBackGuard } from "../navigation/hooks.js";
12
15
  import HypeCallout from "../components/HypeCallout.js";
13
16
  import { HYPE_PHRASES, pickPhrase } from "../effects/hypePhrases.js";
14
17
  import SvgIcon from "../Icons.js";
@@ -17,13 +20,15 @@ import SessionTimer from "../components/SessionTimer.js";
17
20
  import AbandonPolicyNotice from "../components/AbandonPolicyNotice.js";
18
21
  import InsufficientFundsOverlay from "../components/InsufficientFundsOverlay.js";
19
22
  import GameRulesModal from "../components/GameRulesModal.js";
20
- import JackpotNearMiss from "../components/JackpotNearMiss.js";
21
23
  import { usePlayGame, useInitPlay } from "../hooks/usePlayGame.js";
22
24
  import { useCurrency } from "../hooks/useCurrency.js";
23
25
  import { useGameStore } from "../stores/gameStore.js";
24
26
  import { randomMessageKey } from "../content.js";
25
27
  import { t, formatNumber, errorText } from "../i18n.js";
28
+ import { diceWinMultiplier } from "./diceDuel.js";
29
+ import DiceTable3D from "./dice3d/DiceTable3D.js";
26
30
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
31
+ const ROUND_WATCHDOG_MS = 25000;
27
32
  function rollSingle() {
28
33
  return {
29
34
  die1: Math.ceil(Math.random() * 6),
@@ -42,6 +47,7 @@ const DiceBattle = ({
42
47
  }) => {
43
48
  const currency = useCurrency();
44
49
  const demoMode = useGameStore(s => s.demoMode);
50
+ const creditDemoBalance = useGameStore(s => s.creditDemoBalance);
45
51
  const toggleDemoMode = useGameStore(s => s.toggleDemoMode);
46
52
  const isMultiRound = stakeCount > 1;
47
53
  const [isRolling, setIsRolling] = useState(false);
@@ -63,6 +69,20 @@ const DiceBattle = ({
63
69
  const [sessionTotalWon, setSessionTotalWon] = useState(0);
64
70
  const [sessionComplete, setSessionComplete] = useState(false);
65
71
  const [showResultOverlay, setShowResultOverlay] = useState(false);
72
+ const [lastRoll, setLastRoll] = useState(null);
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;
84
+ const winMultiplier = diceWinMultiplier(game?.gameplayRules?.winMultiplier);
85
+ const demoTabShown = !!game?.demoConfig?.enabled;
66
86
  const diceLive = isRolling || roundNum > 0 && !sessionComplete && !showResultOverlay;
67
87
  const [quitVisible, setQuitVisible] = useState(false);
68
88
  const handleBack = useCallback(() => {
@@ -72,13 +92,7 @@ const DiceBattle = ({
72
92
  }
73
93
  setQuitVisible(true);
74
94
  }, [diceLive, onBack]);
75
- useEffect(() => {
76
- const sub = BackHandler.addEventListener('hardwareBackPress', () => {
77
- handleBack();
78
- return true;
79
- });
80
- return () => sub.remove();
81
- }, [handleBack]);
95
+ useBackGuard(diceLive, handleBack);
82
96
  const [lastAmountWon, setLastAmountWon] = useState(0);
83
97
  const intervalRef = useRef(null);
84
98
 
@@ -107,20 +121,108 @@ const DiceBattle = ({
107
121
  }
108
122
  }, [demoMode, initPlay]); // eslint-disable-line react-hooks/exhaustive-deps
109
123
 
110
- const rollDice = useCallback(async () => {
111
- 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();
112
207
 
113
208
  // Block if session expired (two-phase mode)
114
- if (initPlay.enabled && initPlay.isExpired) return;
209
+ if (initPlay.enabled && initPlay.isExpired) return refuse();
115
210
 
116
211
  // Check sufficient balance (non-two-phase mode)
117
212
  if (!demoMode && !initPlay.session && balance < initialStake) {
213
+ refuse();
118
214
  setShowFundsOverlay(true);
119
215
  return;
120
216
  }
121
217
  sounds.resume();
218
+ haptics.trigger(source === 'grab' ? 'selection' : 'light');
219
+ const round = roundNum + 1;
122
220
  setIsRolling(true);
123
- setRoundNum(r => r + 1);
221
+ setHintVisible(false);
222
+ setRoundNum(round);
223
+ setP1Score(0);
224
+ setP2Score(0);
225
+ if (useScene && source === 'button') tableRef.current?.autoThrow();
124
226
 
125
227
  // ── Call server to determine outcome ──
126
228
  let serverResult = null;
@@ -139,26 +241,43 @@ const DiceBattle = ({
139
241
  }
140
242
  } catch (e) {
141
243
  console.warn('[DiceBattle] play failed:', e?.message ?? e);
244
+ if (useScene) tableRef.current?.cancel();
142
245
  const msg = (e?.message || '').toLowerCase();
143
246
  if (msg.includes('insufficient') || msg.includes('balance')) {
144
247
  setShowFundsOverlay(true);
145
248
  } else {
146
249
  Alert.alert(t('dice.battle.playErrorTitle'), errorText(e, 'dice.battle.playFailed'));
147
250
  }
251
+ setRoundNum(r => Math.max(0, r - 1));
148
252
  setIsRolling(false);
149
253
  return;
150
254
  }
151
255
 
152
256
  // Parse server dice values
153
257
  const gameResult = serverResult?.gameResult;
154
- const finalP1 = gameResult?.playerDice ? {
155
- die1: gameResult.playerDice[0],
156
- die2: gameResult.playerDice[1]
157
- } : rollSingle();
158
- const finalP2 = gameResult?.botDice ? {
159
- die1: gameResult.botDice[0],
160
- die2: gameResult.botDice[1]
161
- } : 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
+ }
162
281
 
163
282
  // ── Tumble animation (12 ticks of random dice) ──
164
283
  let ticks = 0;
@@ -169,95 +288,120 @@ const DiceBattle = ({
169
288
  ticks++;
170
289
  if (ticks >= 12) {
171
290
  if (intervalRef.current) clearInterval(intervalRef.current);
172
- const p1Sum = finalP1.die1 + finalP1.die2;
173
- const p2Sum = finalP2.die1 + finalP2.die2;
174
- // Winner follows the SERVER's decision (the amount it actually paid),
175
- // not a local dice comparison — the server's win logic is RNG/win-control
176
- // gated, so local sums can disagree with the money. A dice-equal result
177
- // is shown as a draw only when no money was won.
178
- const serverAmountWon = (serverResult?.amountWonKobo ?? 0) / 100;
179
- const winner = serverAmountWon > 0 ? 'p1' : p1Sum === p2Sum ? 'draw' : 'p2';
180
- setP1Dice(finalP1);
181
- setP2Dice(finalP2);
182
- const newP1Score = p1Score + p1Sum;
183
- const newP2Score = p2Score + p2Sum;
184
- setP1Score(newP1Score);
185
- setP2Score(newP2Score);
186
- const round = {
187
- id: roundNum + 1,
188
- p1: finalP1,
189
- p2: finalP2,
190
- winner
191
- };
192
- setRounds(prev => [round, ...prev]);
193
- setIsRolling(false);
194
- const amountWon = (serverResult?.amountWonKobo ?? 0) / 100;
195
- const session = gameResult?.session;
196
- const isLastRound = session?.isLastRound ?? true;
197
- if (isMultiRound) {
198
- // Multi-round session: accumulate results
199
- if (amountWon > 0) {
200
- setSessionWins(w => w + 1);
201
- setSessionTotalWon(t => t + amountWon);
202
- sounds.playWinChime();
203
- hypeRef.current?.show(pickPhrase(amountWon >= 5000 ? HYPE_PHRASES.dice.bigWin : HYPE_PHRASES.dice.win), amountWon >= 5000 ? 'boost' : 'win');
204
- // Coin fly animation — skip in demo mode (no real money)
205
- if (!demoMode) {
206
- coinFlyRef.current?.measureTarget();
207
- cardsAreaRef.current?.measureInWindow?.((x, y, w, h) => {
208
- coinFlyRef.current?.fly(x + w / 2, y + h / 2);
209
- });
210
- }
211
- } else {
212
- sounds.playDrawSound();
213
- hypeRef.current?.show(pickPhrase(HYPE_PHRASES.dice.loss), 'loss');
214
- }
215
- if (isLastRound) {
216
- // Session complete — show result overlay after a delay so user can see last round
217
- const totalWon = sessionTotalWon + amountWon;
218
- setLastAmountWon(totalWon);
219
- setTimeout(() => {
220
- setSessionComplete(true);
221
- setShowResultOverlay(true);
222
- }, 3000);
223
- }
224
- } else {
225
- // Single round: show result overlay after a delay so user can see the dice
226
- setLastAmountWon(amountWon);
227
- if (amountWon > 0) {
228
- sounds.playWinChime();
229
- hypeRef.current?.show(pickPhrase(amountWon >= 5000 ? HYPE_PHRASES.dice.bigWin : HYPE_PHRASES.dice.win), amountWon >= 5000 ? 'boost' : 'win');
230
- if (!demoMode) {
231
- coinFlyRef.current?.measureTarget();
232
- cardsAreaRef.current?.measureInWindow?.((x, y, w, h) => {
233
- coinFlyRef.current?.fly(x + w / 2, y + h / 2);
234
- });
235
- }
236
- } else {
237
- sounds.playDrawSound();
238
- hypeRef.current?.show(pickPhrase(HYPE_PHRASES.dice.loss), 'loss');
239
- }
240
- setTimeout(() => {
241
- setShowResultOverlay(true);
242
- }, 3000);
243
- }
291
+ if (pendingRef.current !== pending) return;
292
+ pendingRef.current = null;
293
+ finishRound(pending);
244
294
  }
245
295
  }, 80);
246
- }, [isRolling, p1Score, p2Score, roundNum, initialStake, stakeCount, isMultiRound, sessionTotalWon, onWin, onLose, game, play, initPlay, balance, currency]);
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;
247
389
  const resultMsg = useMemo(() => randomMessageKey(lastAmountWon > 0 ? 'dice.battle.win' : 'dice.battle.loss'), [showResultOverlay] // eslint-disable-line react-hooks/exhaustive-deps
248
390
  );
249
391
  const handleResultPlayAgain = useCallback(() => {
392
+ if (demoMode && lastAmountWon > 0) creditDemoBalance(lastAmountWon);
250
393
  setShowResultOverlay(false);
251
394
  setSessionComplete(false);
252
395
  setRoundNum(0);
253
396
  setRounds([]);
254
397
  setP1Score(0);
255
398
  setP2Score(0);
399
+ setLastRoll(null);
256
400
  setSessionWins(0);
257
401
  setSessionTotalWon(0);
258
402
  setLastAmountWon(0);
259
403
  if (initPlay.enabled) initPlay.reset();
260
- }, [initPlay]);
404
+ }, [initPlay, demoMode, lastAmountWon, creditDemoBalance]);
261
405
  const handleResultExit = useCallback(() => {
262
406
  if (lastAmountWon > 0) {
263
407
  onWin(lastAmountWon);
@@ -270,7 +414,7 @@ const DiceBattle = ({
270
414
  children: [/*#__PURE__*/_jsx(HypeCallout, {
271
415
  ref: hypeRef,
272
416
  style: {
273
- top: 240
417
+ top: 170
274
418
  }
275
419
  }), /*#__PURE__*/_jsx(SideDemoTab, {
276
420
  enabled: !!game?.demoConfig?.enabled
@@ -341,109 +485,200 @@ const DiceBattle = ({
341
485
  })
342
486
  })]
343
487
  })]
344
- }), /*#__PURE__*/_jsx(AbandonPolicyNotice, {
345
- abandonPolicy: abandonPolicy
346
- }), initPlay.enabled && initPlay.error && !initPlay.session && /*#__PURE__*/_jsxs(View, {
347
- style: {
348
- padding: 12,
349
- backgroundColor: '#fef2f2',
350
- borderRadius: 8,
351
- margin: 8,
352
- alignItems: 'center'
353
- },
354
- children: [/*#__PURE__*/_jsx(Text, {
488
+ }), /*#__PURE__*/_jsxs(View, {
489
+ style: styles.body,
490
+ children: [/*#__PURE__*/_jsx(AbandonPolicyNotice, {
491
+ abandonPolicy: abandonPolicy
492
+ }), initPlay.enabled && initPlay.error && !initPlay.session && /*#__PURE__*/_jsxs(View, {
355
493
  style: {
356
- color: '#b91c1c',
357
- fontSize: 13,
358
- marginBottom: 8,
359
- textAlign: 'center'
494
+ padding: 12,
495
+ backgroundColor: '#fef2f2',
496
+ borderRadius: 8,
497
+ margin: 8,
498
+ alignItems: 'center'
360
499
  },
361
- children: initPlay.error
362
- }), /*#__PURE__*/_jsx(MonflowtsButton, {
363
- title: t('dice.battle.retry'),
364
- onPress: () => initPlay.reset()
365
- })]
366
- }), /*#__PURE__*/_jsxs(Animated.View, {
367
- ref: stakePillRef,
368
- style: [styles.stakeBar, {
369
- transform: [{
370
- scale: balancePulse
371
- }]
372
- }],
373
- children: [/*#__PURE__*/_jsx(Text, {
374
- style: styles.stakeLabel,
375
- children: t('dice.battle.stake', {
376
- amount: initialStake,
377
- currency
378
- })
379
- }), /*#__PURE__*/_jsx(Text, {
380
- style: styles.stakePrize,
381
- children: isMultiRound ? t('dice.battle.won', {
382
- amount: sessionTotalWon,
383
- currency
384
- }) : t('dice.battle.winPrizes')
385
- })]
386
- }), /*#__PURE__*/_jsxs(View, {
387
- ref: cardsAreaRef,
388
- style: styles.cardsArea,
389
- children: [/*#__PURE__*/_jsx(PlayerCard, {
390
- playerNumber: 1,
391
- title: t('dice.battle.you'),
392
- subtitle: t('dice.battle.player'),
393
- score: p1Score,
394
- dice: p1Dice,
395
- isWinner: !isRolling && rounds[0]?.winner === 'p1',
396
- bgColor: "#4f46e5",
397
- isRolling: isRolling
500
+ children: [/*#__PURE__*/_jsx(Text, {
501
+ style: {
502
+ color: '#b91c1c',
503
+ fontSize: 13,
504
+ marginBottom: 8,
505
+ textAlign: 'center'
506
+ },
507
+ children: initPlay.error
508
+ }), /*#__PURE__*/_jsx(MonflowtsButton, {
509
+ title: t('dice.battle.retry'),
510
+ onPress: () => initPlay.reset()
511
+ })]
512
+ }), /*#__PURE__*/_jsxs(Animated.View, {
513
+ ref: stakePillRef,
514
+ style: [styles.stakeBar, demoTabShown && {
515
+ marginRight: 20 + SIDE_DEMO_TAB_WIDTH
516
+ }, {
517
+ transform: [{
518
+ scale: balancePulse
519
+ }]
520
+ }],
521
+ children: [/*#__PURE__*/_jsx(Text, {
522
+ style: styles.stakeLabel,
523
+ children: t('dice.battle.stake', {
524
+ amount: initialStake,
525
+ currency
526
+ })
527
+ }), /*#__PURE__*/_jsx(Text, {
528
+ style: styles.stakePrize,
529
+ children: isMultiRound ? t('dice.battle.won', {
530
+ amount: sessionTotalWon,
531
+ currency
532
+ }) : winMultiplier ? t('dice.battle.winPays', {
533
+ amount: formatNumber(Math.round(initialStake * winMultiplier * 100) / 100),
534
+ currency
535
+ }) : t('dice.battle.winPrizes')
536
+ })]
398
537
  }), /*#__PURE__*/_jsx(View, {
399
- style: styles.vsSeparator,
400
- children: /*#__PURE__*/_jsx(Text, {
401
- style: styles.vsText,
402
- children: t('dice.battle.vs')
403
- })
404
- }), /*#__PURE__*/_jsx(PlayerCard, {
405
- playerNumber: 2,
406
- title: t('dice.battle.bot'),
407
- subtitle: t('dice.battle.monflowtsAi'),
408
- score: p2Score,
409
- dice: p2Dice,
410
- isWinner: !isRolling && rounds[0]?.winner === 'p2',
411
- bgColor: "#0f766e",
412
- isRolling: isRolling
413
- })]
414
- }), rounds.length > 0 && /*#__PURE__*/_jsxs(View, {
415
- style: styles.historySection,
416
- children: [/*#__PURE__*/_jsx(Text, {
417
- style: styles.historyTitle,
418
- children: t('dice.battle.matchHistory')
419
- }), /*#__PURE__*/_jsx(ScrollView, {
420
- horizontal: true,
421
- showsHorizontalScrollIndicator: false,
422
- children: rounds.slice(0, 5).map(r => /*#__PURE__*/_jsxs(View, {
423
- style: [styles.historyCard, r.winner === 'p1' && {
424
- backgroundColor: 'rgba(127,19,236,0.15)',
425
- borderColor: 'rgba(127,19,236,0.3)'
426
- }, r.winner === 'p2' && {
427
- backgroundColor: 'rgba(239,68,68,0.1)',
428
- borderColor: 'rgba(239,68,68,0.2)'
429
- }],
430
- children: [/*#__PURE__*/_jsx(Text, {
431
- style: styles.historyRound,
432
- children: t('dice.battle.roundShort', {
433
- round: r.id
538
+ ref: cardsAreaRef,
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, {
545
+ playerNumber: 1,
546
+ title: t('dice.battle.you'),
547
+ subtitle: t('dice.battle.player'),
548
+ score: p1Score,
549
+ dice: p1Dice,
550
+ isWinner: latestWinner === 'p1',
551
+ bgColor: "#4f46e5",
552
+ isRolling: isRolling
553
+ }), /*#__PURE__*/_jsx(View, {
554
+ style: styles.vsSeparator,
555
+ children: /*#__PURE__*/_jsx(Text, {
556
+ style: styles.vsText,
557
+ children: t('dice.battle.vs')
434
558
  })
435
- }), /*#__PURE__*/_jsx(Text, {
436
- style: [styles.historyResult, r.winner === 'p1' ? {
437
- color: COLORS.primary
438
- } : r.winner === 'p2' ? {
439
- color: COLORS.lossRed
440
- } : {
441
- color: COLORS.slateLight
442
- }],
443
- children: r.winner === 'p1' ? t('dice.battle.win') : r.winner === 'p2' ? t('dice.battle.loss') : t('dice.battle.draw')
559
+ }), /*#__PURE__*/_jsx(PlayerCard, {
560
+ playerNumber: 2,
561
+ title: t('dice.battle.bot'),
562
+ subtitle: t('dice.battle.monflowtsAi'),
563
+ score: p2Score,
564
+ dice: p2Dice,
565
+ isWinner: latestWinner === 'p2',
566
+ bgColor: "#0f766e",
567
+ isRolling: isRolling
444
568
  })]
445
- }, r.id))
446
- })]
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, {
652
+ style: styles.historySection,
653
+ children: /*#__PURE__*/_jsx(ScrollView, {
654
+ horizontal: true,
655
+ showsHorizontalScrollIndicator: false,
656
+ children: rounds.slice(0, 8).map(r => /*#__PURE__*/_jsxs(View, {
657
+ style: [styles.historyCard, r.winner === 'p1' && {
658
+ backgroundColor: 'rgba(255, 199, 48, 0.15)',
659
+ borderColor: 'rgba(255, 199, 48, 0.3)'
660
+ }, r.winner === 'p2' && {
661
+ backgroundColor: 'rgba(239,68,68,0.1)',
662
+ borderColor: 'rgba(239,68,68,0.2)'
663
+ }],
664
+ children: [/*#__PURE__*/_jsx(Text, {
665
+ style: styles.historyRound,
666
+ children: t('dice.battle.roundShort', {
667
+ round: r.id
668
+ })
669
+ }), /*#__PURE__*/_jsx(Text, {
670
+ style: [styles.historyResult, r.winner === 'p1' ? {
671
+ color: COLORS.primary
672
+ } : r.winner === 'p2' ? {
673
+ color: COLORS.lossRed
674
+ } : {
675
+ color: COLORS.slateLight
676
+ }],
677
+ children: r.winner === 'p1' ? t('dice.battle.win') : r.winner === 'p2' ? t('dice.battle.loss') : t('dice.battle.draw')
678
+ })]
679
+ }, r.id))
680
+ })
681
+ }) : null]
447
682
  }), /*#__PURE__*/_jsx(View, {
448
683
  style: styles.footer,
449
684
  children: sessionComplete ? /*#__PURE__*/_jsxs(View, {
@@ -481,11 +716,13 @@ const DiceBattle = ({
481
716
  icon: /*#__PURE__*/_jsx(SvgIcon, {
482
717
  name: "dice",
483
718
  size: 18,
484
- color: "#ffffff"
719
+ color: "#331B00"
485
720
  }),
486
721
  loading: isRolling,
487
722
  loadingText: t('dice.battle.rolling'),
488
- onPress: rollDice,
723
+ onPress: () => {
724
+ void beginRoll('button');
725
+ },
489
726
  textStyle: styles.rollBtnText
490
727
  })
491
728
  }), /*#__PURE__*/_jsx(InsufficientFundsOverlay, {
@@ -545,10 +782,22 @@ const DiceBattle = ({
545
782
  }), /*#__PURE__*/_jsx(Text, {
546
783
  style: styles.resultSubtitle,
547
784
  children: t(`${resultMsg}.sub`)
548
- }), /*#__PURE__*/_jsx(JackpotNearMiss, {
549
- jackpotAmountKobo: game?.gameplayRules?.jackpotAmountKobo ?? 0,
550
- currency: currency
551
- }), demoMode ? /*#__PURE__*/_jsxs(_Fragment, {
785
+ }), !isMultiRound && lastRoll ? /*#__PURE__*/_jsx(Text, {
786
+ style: styles.resultDetail,
787
+ children: t('dice.battle.totals', {
788
+ player: lastRoll.player,
789
+ bot: lastRoll.bot
790
+ })
791
+ }) : null, !isMultiRound && lastRoll?.isDraw ? /*#__PURE__*/_jsx(Text, {
792
+ style: styles.resultDetail,
793
+ children: t('dice.battle.tieNote')
794
+ }) : null, lastRoll?.hash && lastRoll.nonce !== null ? /*#__PURE__*/_jsx(Text, {
795
+ style: styles.fairnessText,
796
+ children: t('dice.battle.fairness', {
797
+ nonce: lastRoll.nonce,
798
+ hash: lastRoll.hash.slice(0, 12)
799
+ })
800
+ }) : null, demoMode ? /*#__PURE__*/_jsxs(_Fragment, {
552
801
  children: [/*#__PURE__*/_jsx(Text, {
553
802
  style: styles.demoHookText,
554
803
  children: lastAmountWon > 0 ? t('dice.battle.demoHookWin') : t('dice.battle.demoHookLoss')
@@ -557,7 +806,7 @@ const DiceBattle = ({
557
806
  icon: /*#__PURE__*/_jsx(SvgIcon, {
558
807
  name: "lightning",
559
808
  size: 16,
560
- color: "#ffffff"
809
+ color: "#331B00"
561
810
  }),
562
811
  onPress: () => {
563
812
  toggleDemoMode();
@@ -583,7 +832,7 @@ const DiceBattle = ({
583
832
  icon: /*#__PURE__*/_jsx(SvgIcon, {
584
833
  name: "refresh",
585
834
  size: 16,
586
- color: "#ffffff"
835
+ color: "#331B00"
587
836
  }),
588
837
  onPress: handleResultPlayAgain
589
838
  }), /*#__PURE__*/_jsx(MonflowtsButton, {
@@ -600,7 +849,7 @@ const DiceBattle = ({
600
849
  })]
601
850
  });
602
851
  };
603
- const styles = StyleSheet.create({
852
+ const styles = scaledStyles({
604
853
  container: {
605
854
  flex: 1,
606
855
  backgroundColor: COLORS.backgroundDark,
@@ -617,7 +866,7 @@ const styles = StyleSheet.create({
617
866
  width: 40,
618
867
  height: 40,
619
868
  borderRadius: 20,
620
- backgroundColor: 'rgba(15,23,42,0.6)',
869
+ backgroundColor: 'rgba(23, 22, 31, 0.6)',
621
870
  borderWidth: 1,
622
871
  borderColor: COLORS.white10,
623
872
  alignItems: 'center',
@@ -679,14 +928,130 @@ const styles = StyleSheet.create({
679
928
  fontWeight: '700',
680
929
  color: COLORS.gold
681
930
  },
682
- cardsArea: {
931
+ body: {
932
+ flex: 1
933
+ },
934
+ tableArea: {
683
935
  flex: 1,
684
- paddingHorizontal: 20
936
+ minHeight: 240,
937
+ marginHorizontal: 8,
938
+ marginBottom: 8
685
939
  },
686
- vsSeparator: {
940
+ tableFill: {
941
+ ...StyleSheet.absoluteFill
942
+ },
943
+ tableLoading: {
944
+ ...StyleSheet.absoluteFill
945
+ },
946
+ centerFallback: {
947
+ top: '50%',
948
+ marginTop: -18
949
+ },
950
+ scoreboard: {
951
+ position: 'absolute',
952
+ alignSelf: 'center',
953
+ flexDirection: 'row',
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%'
963
+ },
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',
687
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,
688
1048
  paddingVertical: 8
689
1049
  },
1050
+ vsSeparator: {
1051
+ alignItems: 'center',
1052
+ justifyContent: 'center',
1053
+ padding: 8
1054
+ },
690
1055
  vsText: {
691
1056
  fontSize: 14,
692
1057
  fontWeight: '800',
@@ -694,16 +1059,9 @@ const styles = StyleSheet.create({
694
1059
  fontStyle: 'italic'
695
1060
  },
696
1061
  historySection: {
1062
+ height: 46,
697
1063
  paddingHorizontal: 20,
698
- marginBottom: 12
699
- },
700
- historyTitle: {
701
- fontSize: 10,
702
- fontWeight: '700',
703
- color: COLORS.slateDark,
704
- letterSpacing: 2,
705
- marginBottom: 8,
706
- textTransform: 'uppercase'
1064
+ marginBottom: 4
707
1065
  },
708
1066
  historyCard: {
709
1067
  paddingHorizontal: 14,
@@ -727,6 +1085,7 @@ const styles = StyleSheet.create({
727
1085
  },
728
1086
  footer: {
729
1087
  paddingHorizontal: 20,
1088
+ paddingTop: 8,
730
1089
  paddingBottom: 30
731
1090
  },
732
1091
  rollBtnText: {
@@ -790,9 +1149,21 @@ const styles = StyleSheet.create({
790
1149
  fontSize: 14,
791
1150
  color: COLORS.slateLight,
792
1151
  textAlign: 'center',
793
- marginBottom: 24,
1152
+ marginBottom: 12,
794
1153
  lineHeight: 20
795
1154
  },
1155
+ resultDetail: {
1156
+ fontSize: 13,
1157
+ color: '#e5e7eb',
1158
+ textAlign: 'center',
1159
+ marginBottom: 6
1160
+ },
1161
+ fairnessText: {
1162
+ fontSize: 11,
1163
+ color: COLORS.slateDark,
1164
+ textAlign: 'center',
1165
+ marginBottom: 18
1166
+ },
796
1167
  demoHookText: {
797
1168
  fontSize: 15,
798
1169
  fontWeight: '800',