Changeset d0ef259 for components/roulette/RouletteHeader.jsx
- Timestamp:
- 07/12/22 00:13:20 (2 years ago)
- Branches:
- main
- Children:
- e9f11ac
- Parents:
- 95ce58b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
components/roulette/RouletteHeader.jsx
r95ce58b rd0ef259 24 24 25 25 useEffect(() => { 26 function spin_wheel(magicNumber, winningBets) { 27 document.getElementById('rouletteWheelImg').classList.add('spin'); 28 29 setTimeout(() => { 30 document.getElementById('rouletteWheelImg').classList.remove('spin'); 31 32 const extraSpin = ( 5 + numbersOfWheel.indexOf(playerState.rouletteGame.game?.magicNumber) * (360 / 37.0) ) + 'deg'; 33 document.getElementById('rouletteWheelImg').style.transform = `translate(-50%, -50%) rotateZ(${extraSpin})`; 34 35 setTimeout(() => { 36 dispatch(setStyle({ 37 ...styleState.style, 38 alert: { 39 show: true, 40 title: `Winning number: ${magicNumber}`, 41 subtitle: `Winning bets: [${winningBets.join(', ')}]`, 42 button: { 43 text: 'Continue', 44 action: '', 45 } 46 } 47 })) 48 }, 2000); 49 }, 4000); 50 } 51 26 52 // display loading screen 27 53 dispatch(setStyle({ … … 29 55 displayLoadingScreen: true, 30 56 })); 57 58 let interval = null; 31 59 32 60 axios.get(`/api/roulette?action=get_player_info_on_enter&session_id=${localStorage.CAESSINO_SESSION_ID}`).then(res => { … … 39 67 })); 40 68 41 dispatch(setRouletteGame(res.data?.game)); 69 interval = setInterval(() => { 70 axios.get(`/api/roulette?action=update_state&session_id=${localStorage.CAESSINO_SESSION_ID}`).then(newRes => { 71 if (newRes.data?.success) { 72 dispatch(setRouletteGame(newRes.data?.rouletteGame)); 73 74 if (newRes.data?.extraAction === "spin_wheel") { 75 spin_wheel(newRes.data.magicNumber ?? -1, newRes.data.winningBets ?? -1); 76 } 77 78 if (newRes.data?.rouletteGame?.player?.credits !== playerState.player.credits && newRes.data?.rouletteGame?.player?.credits > 0) { 79 dispatch(setPlayer({ 80 ...playerState.player, 81 credits: newRes.data?.rouletteGame?.player?.credits, 82 })) 83 } 84 } 85 }); 86 }, 1000); 42 87 43 88 dispatch(setRoulette({ … … 91 136 } 92 137 138 // 10 starts from 5deg 139 const numbersOfWheel = [10, 23, 8, 30, 11, 36, 13, 27, 6, 34, 17, 25, 2, 21, 4, 19, 15, 32, 0, 26, 3, 35, 12, 28, 7, 29, 18, 22, 9, 31, 14, 20, 1, 33, 16, 24, 5]; 140 93 141 export default RouletteHeader
Note:
See TracChangeset
for help on using the changeset viewer.