[e903234] | 1 | import React from 'react'
|
---|
| 2 |
|
---|
| 3 | import { useEffect } from 'react';
|
---|
| 4 |
|
---|
| 5 | import { useSelector, useDispatch } from 'react-redux'
|
---|
| 6 |
|
---|
| 7 | import axios from 'axios';
|
---|
| 8 | import { setAdminInformation } from '../../redux/reducers/adminInformationSlice';
|
---|
| 9 | import { setAdmin } from '../../redux/reducers/adminSlice';
|
---|
[faff334] | 10 | import FreeflowCard from '../FreeflowCard';
|
---|
| 11 | import Calculations from './Calculations';
|
---|
[e903234] | 12 |
|
---|
| 13 | const LiveGames = () => {
|
---|
| 14 | const dispatch = useDispatch();
|
---|
| 15 |
|
---|
| 16 | const adminState = useSelector(state => state.admin);
|
---|
| 17 | const adminInformationState = useSelector(state => state.adminInformation);
|
---|
| 18 |
|
---|
| 19 | useEffect(() => {
|
---|
[faff334] | 20 | let interval = setInterval(() => {
|
---|
| 21 | axios.get(`/api/postgre?action=get_live_games_as_admin&admin_id=${localStorage.CAESSINO_ADMIN_ID}`).then(res => {
|
---|
| 22 | if (res.data?.success) {
|
---|
| 23 | dispatch(setAdminInformation({
|
---|
| 24 | ...adminInformationState.adminInformation,
|
---|
| 25 | liveGames: {
|
---|
| 26 | blackjack: {
|
---|
| 27 | rooms: res.data?.blackjack,
|
---|
| 28 | },
|
---|
| 29 | roulette: res.data?.roulette,
|
---|
| 30 | poker: {
|
---|
| 31 | tables: res.data?.poker,
|
---|
| 32 | },
|
---|
| 33 | }
|
---|
| 34 | }))
|
---|
| 35 | }
|
---|
| 36 | })
|
---|
| 37 | }, 1000);
|
---|
| 38 |
|
---|
| 39 | return () => {
|
---|
| 40 | if (interval !== null) clearInterval(interval);
|
---|
| 41 | };
|
---|
[e903234] | 42 | }, [])
|
---|
| 43 |
|
---|
| 44 | function hideLiveGamesScreen() {
|
---|
| 45 | dispatch(setAdmin({
|
---|
| 46 | ...adminState.admin,
|
---|
| 47 | displays: {
|
---|
| 48 | ...adminState.admin.displays,
|
---|
| 49 | liveGamesScreen: false,
|
---|
| 50 | }
|
---|
| 51 | }))
|
---|
| 52 | }
|
---|
| 53 |
|
---|
| 54 | return (
|
---|
[faff334] | 55 | <div className="fullscreen top-to-bottom-centered admin liveGamesScreen">
|
---|
[e903234] | 56 | <div>
|
---|
[faff334] | 57 | <p className="link" onClick={() => hideLiveGamesScreen()}>⬅ Go Back</p>
|
---|
[e903234] | 58 |
|
---|
[faff334] | 59 | <h3>These are the current live games.</h3>
|
---|
[e903234] | 60 |
|
---|
[faff334] | 61 | <div className="liveGamesMegaContainer">
|
---|
| 62 | <div className="liveBlackjackGames liveGamesContainer">
|
---|
| 63 | <h3>Live BLackjack Games:</h3>
|
---|
| 64 | { adminInformationState.adminInformation.liveGames.blackjack?.rooms?.map(room => (
|
---|
| 65 | <div key={room.id} className="liveBlackjackGame">
|
---|
| 66 | <div>
|
---|
| 67 | <div>
|
---|
| 68 | { room?.playerCards?.map((card, i) => (
|
---|
| 69 | <FreeflowCard key={`playercard${i}`} card={card}/>
|
---|
| 70 | ))}
|
---|
| 71 | <h5><Calculations action="calculateHandValue" cards={room.playerCards}/></h5>
|
---|
| 72 | </div>
|
---|
[22367db] | 73 | <p>Player {room?.displayName} (${parseInt(room.initialBet) + parseInt(room.sideBet)})</p>
|
---|
[faff334] | 74 | </div>
|
---|
| 75 | <div>
|
---|
| 76 | <div>
|
---|
| 77 | <h6><span>Status:</span><br/>{room.status}</h6>
|
---|
[22367db] | 78 | { room?.outcome?.length > 0 && <h6><span>Outcome:</span><br/>{room.outcome}</h6> }
|
---|
| 79 | { room?.sideBetOutcome?.length > 0 && <h6><span>Side Bet Outcome:</span><br/>{room.sideBetOutcome}</h6> }
|
---|
[faff334] | 80 | </div>
|
---|
| 81 | </div>
|
---|
| 82 | <div>
|
---|
| 83 | <div>
|
---|
| 84 | <h5><Calculations action="calculateHandValue" cards={room.dealerCards}/></h5>
|
---|
| 85 | { room?.dealerCards?.map((card, i) => (
|
---|
| 86 | <FreeflowCard key={`dealercard${i}`} card={card}/>
|
---|
| 87 | ))}
|
---|
| 88 | </div>
|
---|
| 89 | <p>Dealer {room.dealerName}</p>
|
---|
| 90 | </div>
|
---|
| 91 | </div>
|
---|
| 92 | )) }
|
---|
| 93 | </div>
|
---|
| 94 |
|
---|
| 95 | <div className="liveRouletteGame liveGamesContainer">
|
---|
| 96 | <h3>Live Roulette Game:</h3>
|
---|
| 97 | <div>
|
---|
| 98 | <h6>
|
---|
| 99 | <span>Status: </span>{adminInformationState.adminInformation?.liveGames?.roulette?.status}
|
---|
| 100 | <span>Time to start: </span>{adminInformationState.adminInformation?.liveGames?.roulette?.timeToStart}
|
---|
[22367db] | 101 | { adminInformationState.adminInformation?.liveGames?.roulette?.magicNumber != -1 && <><span>Ball on number: </span>{adminInformationState.adminInformation?.liveGames?.roulette?.magicNumber} </> }
|
---|
| 102 | { adminInformationState.adminInformation?.liveGames?.roulette?.magicNumber != -1 && <><span>Winning bets: </span>{adminInformationState.adminInformation?.liveGames?.roulette?.winningBets?.join(", ")}</> }
|
---|
[faff334] | 103 | </h6>
|
---|
| 104 | <h6 style={{marginTop: '2rem'}}><span>Players:</span></h6>
|
---|
| 105 | { adminInformationState.adminInformation?.liveGames?.roulette?.players?.map((player, i) => (
|
---|
| 106 | <div key={player.session_id} className="playerInLiveRouletteGame">
|
---|
| 107 | <div>
|
---|
| 108 | <h6><span>Player {i+1} -></span></h6>
|
---|
| 109 | </div>
|
---|
| 110 | <div>
|
---|
[22367db] | 111 | <h6><span>{player.name} (${player?.betAmount})</span></h6>
|
---|
[faff334] | 112 | </div>
|
---|
| 113 | <div>
|
---|
[22367db] | 114 | { player?.whichBets?.length > 0 && <h6><span>Betted on: </span>{player?.whichBets?.join(", ")}</h6> }
|
---|
[faff334] | 115 | </div>
|
---|
| 116 | <div>
|
---|
[22367db] | 117 | { adminInformationState.adminInformation?.liveGames?.roulette?.magicNumber != -1 && player?.whichBets?.length > 0 && <h6><span>Outcome: </span>{player.outcome}</h6> }
|
---|
[faff334] | 118 | </div>
|
---|
| 119 | </div>
|
---|
| 120 | )) }
|
---|
[e903234] | 121 | </div>
|
---|
[faff334] | 122 | </div>
|
---|
| 123 |
|
---|
| 124 | <div className="livePokerGames liveGamesContainer">
|
---|
| 125 | <h3>Live Poker Games:</h3>
|
---|
| 126 | { adminInformationState.adminInformation.liveGames.poker?.tables?.map(table => (
|
---|
| 127 | <div key={table.id} className="livePokerGame">
|
---|
| 128 | <h6>
|
---|
| 129 | <span>Round: </span>{table?.round}/4
|
---|
| 130 | <span>Started: </span>{table?.started}
|
---|
[22367db] | 131 | <span>Player on turn: </span>{table.players[table.turnIdx]?.displayName ?? '-'}
|
---|
| 132 | <span>Pot: </span>${table?.pot}
|
---|
| 133 | { table?.winners?.length > 0 && <><span>Winners: </span>{table?.winners?.map(e=>e?.displayName)?.join(", ")}</> }
|
---|
[faff334] | 134 | </h6>
|
---|
| 135 | <div className="cardsOnTable" style={{marginTop: '2rem'}}>
|
---|
| 136 | { table?.cards?.map((card, i) => (
|
---|
| 137 | <FreeflowCard key={`tablecard${i}`} card={card}/>
|
---|
| 138 | ))}
|
---|
| 139 | </div>
|
---|
| 140 | <h6 style={{marginTop: '2rem'}}><span>Players:</span></h6>
|
---|
| 141 | {table.players?.map(player => (
|
---|
| 142 | <div key={player.id} className="playerInLivePokerGame">
|
---|
| 143 | <div>
|
---|
[22367db] | 144 | <h6><span>Player {player?.displayName} (${player.betAmount})</span></h6>
|
---|
[faff334] | 145 | </div>
|
---|
| 146 | <div className="cards">
|
---|
| 147 | { player?.cards?.map((card, i) => (
|
---|
| 148 | <FreeflowCard key={`playercard${i}`} card={card}/>
|
---|
| 149 | ))}
|
---|
| 150 | </div>
|
---|
| 151 | <div>
|
---|
[22367db] | 152 | { table?.cards?.length > 0 && <h6><span>Hand: </span><Calculations action="getBestHandDetails" cards={player.cards} cards2={table.cards}/></h6> }
|
---|
[faff334] | 153 | </div>
|
---|
| 154 | </div>
|
---|
| 155 | ))}
|
---|
| 156 | </div>
|
---|
| 157 | )) }
|
---|
| 158 | </div>
|
---|
| 159 | </div>
|
---|
[e903234] | 160 | </div>
|
---|
| 161 | </div>
|
---|
| 162 | )
|
---|
| 163 | }
|
---|
| 164 |
|
---|
| 165 | export default LiveGames |
---|