1 | import React from 'react'
|
---|
2 |
|
---|
3 | import { useSelector, useDispatch } from 'react-redux'
|
---|
4 |
|
---|
5 | import { setStyle } from '../redux/reducers/styleSlice';
|
---|
6 | import FreeflowCard from './FreeflowCard';
|
---|
7 | import Calculations from './admin/Calculations';
|
---|
8 |
|
---|
9 | const GamesHistory = () => {
|
---|
10 | const dispatch = useDispatch();
|
---|
11 |
|
---|
12 | const styleState = useSelector(state => state.style);
|
---|
13 |
|
---|
14 | function hideGamesHistoryScreen() {
|
---|
15 | dispatch(setStyle({
|
---|
16 | ...styleState.style,
|
---|
17 | displayGamesHistoryScreen: false,
|
---|
18 | }))
|
---|
19 | }
|
---|
20 |
|
---|
21 | if (styleState.style.displayGamesHistoryScreen) {
|
---|
22 | return (
|
---|
23 | <div className="fullscreen top-to-bottom-centered gamesHistoryScreen">
|
---|
24 | <div>
|
---|
25 | <p className="link" onClick={() => hideGamesHistoryScreen()}>⬅ Go Back</p>
|
---|
26 |
|
---|
27 | <h3>These are all the games you've played.</h3>
|
---|
28 |
|
---|
29 | <div className="liveGamesMegaContainer">
|
---|
30 | <div className="liveBlackjackGames liveGamesContainer">
|
---|
31 | <h3>Blackjack Games:</h3>
|
---|
32 | { styleState.style.gamesHistory.blackjack?.rooms?.map((room, roomIdx) => (
|
---|
33 | <div key={room.id + roomIdx} className="liveBlackjackGame">
|
---|
34 | <div>
|
---|
35 | <div>
|
---|
36 | { room?.playerCards?.map((card, i) => (
|
---|
37 | <FreeflowCard key={`playercard${i}`} card={card}/>
|
---|
38 | ))}
|
---|
39 | <h5><Calculations action="calculateHandValue" cards={room.playerCards}/></h5>
|
---|
40 | </div>
|
---|
41 | <p>Player {room?.displayName} (${parseInt(room.initialBet) + parseInt(room.sideBet)})</p>
|
---|
42 | </div>
|
---|
43 | <div>
|
---|
44 | <div>
|
---|
45 | <h6><span>Played on:<br/>{room.finished}</span></h6>
|
---|
46 | { room?.outcome?.lenght > 0 && <h6><span>Outcome:</span><br/>{room.outcome}</h6> }
|
---|
47 | { room?.sideBetOutcome.lenght > 0 && <h6><span>Side Bet Outcome:</span><br/>{room.sideBetOutcome}</h6> }
|
---|
48 | </div>
|
---|
49 | </div>
|
---|
50 | <div>
|
---|
51 | <div>
|
---|
52 | <h5><Calculations action="calculateHandValue" cards={room.dealerCards}/></h5>
|
---|
53 | { room?.dealerCards?.map((card, i) => (
|
---|
54 | <FreeflowCard key={`dealercard${i}`} card={card}/>
|
---|
55 | ))}
|
---|
56 | </div>
|
---|
57 | <p>Dealer {room.dealerName}</p>
|
---|
58 | </div>
|
---|
59 | </div>
|
---|
60 | )) }
|
---|
61 | </div>
|
---|
62 |
|
---|
63 | <div className="liveRouletteGame liveGamesContainer">
|
---|
64 | <h3>Roulette Games:</h3>
|
---|
65 | { styleState.style.gamesHistory.roulette?.games?.map((game, gameIdx) => (
|
---|
66 | <div key={`roulettegame${gameIdx}`}>
|
---|
67 | <h6>
|
---|
68 | <span>Played on: {game?.finished}</span><br/>
|
---|
69 | <span>Ball on number: </span>{game?.magicNumber}
|
---|
70 | <span>Winning bets: </span>{game?.winningBets?.join(", ")}
|
---|
71 | </h6>
|
---|
72 | <h6 style={{marginTop: '2rem'}}><span>Players:</span></h6>
|
---|
73 | { game?.players?.map((player, i) => (
|
---|
74 | <div key={player.session_id} className="playerInLiveRouletteGame">
|
---|
75 | <div>
|
---|
76 | <h6><span>Player {i+1} -></span></h6>
|
---|
77 | </div>
|
---|
78 | <div>
|
---|
79 | <h6><span>{player.name} (</span>${player.betAmount}<span>)</span></h6>
|
---|
80 | </div>
|
---|
81 | <div>
|
---|
82 | <h6><span>Betted on: </span>{player.whichBets.join(", ")}</h6>
|
---|
83 | </div>
|
---|
84 | <div>
|
---|
85 | <h6><span>Outcome: </span>{player.outcome}</h6>
|
---|
86 | </div>
|
---|
87 | </div>
|
---|
88 | )) }
|
---|
89 | </div>
|
---|
90 | )) }
|
---|
91 | </div>
|
---|
92 |
|
---|
93 | <div className="livePokerGames liveGamesContainer">
|
---|
94 | <h3>Poker Games:</h3>
|
---|
95 | { styleState.style.gamesHistory.poker?.tables?.map(table => (
|
---|
96 | <div key={table.id} className="livePokerGame">
|
---|
97 | <h6>
|
---|
98 | <span>Played on: {table?.finished}</span><br/>
|
---|
99 | <span>Pot: </span>${table?.pot}
|
---|
100 | <span>Winners: </span>{table?.winners?.map(e=>e?.displayName)?.join(", ")}
|
---|
101 | </h6>
|
---|
102 | <div className="cardsOnTable" style={{marginTop: '2rem'}}>
|
---|
103 | { table?.cards?.map((card, i) => (
|
---|
104 | <FreeflowCard key={`tablecard${i}`} card={card}/>
|
---|
105 | ))}
|
---|
106 | </div>
|
---|
107 | <h6 style={{marginTop: '2rem'}}><span>Players:</span></h6>
|
---|
108 | {table.players?.map(player => (
|
---|
109 | <div key={player.id} className="playerInLivePokerGame">
|
---|
110 | <div>
|
---|
111 | <h6><span>Player {player?.displayName} (</span>${player.betAmount}<span>)</span></h6>
|
---|
112 | </div>
|
---|
113 | <div className="cards">
|
---|
114 | { player?.cards?.map((card, i) => (
|
---|
115 | <FreeflowCard key={`playercard${i}`} card={card}/>
|
---|
116 | ))}
|
---|
117 | </div>
|
---|
118 | <div>
|
---|
119 | <h6><span>Hand: </span><Calculations action="getBestHandDetails" cards={player.cards} cards2={table.cards}/></h6>
|
---|
120 | </div>
|
---|
121 | </div>
|
---|
122 | ))}
|
---|
123 | </div>
|
---|
124 | )) }
|
---|
125 | </div>
|
---|
126 | </div>
|
---|
127 | </div>
|
---|
128 | </div>
|
---|
129 | )}
|
---|
130 | else {
|
---|
131 | return <></>
|
---|
132 | }
|
---|
133 | }
|
---|
134 |
|
---|
135 | export default GamesHistory |
---|