Ignore:
Timestamp:
06/23/22 00:08:35 (2 years ago)
Author:
anastasovv <simon@…>
Branches:
main
Children:
ace7865
Parents:
285c3cc
Message:

Roulette place a bet functionality

Location:
components/blackjack
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • components/blackjack/Blackjack.jsx

    r285c3cc r9bd09b0  
    11import React from 'react'
    22
     3import Head from 'next/head'
     4
    35import BlackjackHeader from './BlackjackHeader'
    4 
    5 import Head from 'next/head'
    66import PlayButtons from '../../components/blackjack/PlayButtons'
    77import Cards from '../../components/blackjack/Cards'
     
    1313const Blackjack = () => {
    1414  return (
    15     <div className="app" style={{backgroundImage: 'url("/images/blackjack-bg.png")', backgroundPosition: '0% 30%'}}>
     15    <div className="app blackjackMainContainer" style={{backgroundImage: 'url("/images/blackjack-bg.png")', backgroundPosition: '0% 30%'}}>
    1616      <Head>
    1717        <title>Caessino - Blackjack</title>
  • components/blackjack/BlackjackHeader.jsx

    r285c3cc r9bd09b0  
    1010import { useDispatch, useSelector } from 'react-redux'
    1111
    12 import { setGame, setPlayer } from '../../redux/reducers/playerSlice'
     12import { setBlackjackGame, setPlayer } from '../../redux/reducers/playerSlice'
    1313import { setBlackjack, setStyle } from '../../redux/reducers/styleSlice'
    1414
     
    5050                }));
    5151
    52                 dispatch(setGame({
    53                     ...playerState.game,
     52                dispatch(setBlackjackGame({
     53                    ...playerState.blackjackGame,
    5454                    status: res.data?.status,
    5555                    playerCards: res.data?.playerCards,
     
    224224                            initialBet: {
    225225                                ...styleState.blackjack.inputControls.initialBet,
    226                                 chosenCredits: parseInt(postgreRes.data?.credits/2),
     226                                chosenCredits: parseInt(res.data?.credits/2),
    227227                            }
    228228                        },
  • components/blackjack/Cards.jsx

    r285c3cc r9bd09b0  
    2222  return (
    2323    <div className="blackjackCards">
    24       {playerState?.game?.playerCards?.map((card, i) => (
     24      {playerState?.blackjackGame?.playerCards?.map((card, i) => (
    2525        <Card key={card} card={card} rotateZ={i*splitCardsMultiplyByInt} pos={{left: playerPos.left+i*splitCardsMultiplyByInt, top: playerPos.top}}/>
    2626      ))}
    27       {playerState?.game?.dealerCards?.map((card, i) => (
     27      {playerState?.blackjackGame?.dealerCards?.map((card, i) => (
    2828        <Card key={card} card={card} rotateZ={i*splitCardsMultiplyByInt} pos={{left: dealerPos.left+i*splitCardsMultiplyByInt, top: dealerPos.top}}/>
    2929      ))}
  • components/blackjack/DisplayBet.jsx

    r285c3cc r9bd09b0  
    77  const styleState = useSelector(state => state.style);
    88
    9   let display = parseInt(playerState.game.status.substr(1, 1)) >= 2 ? 'block' : 'none';
    10   let displaySideBet = ( parseInt(playerState.game.status.substr(1, 1)) >= 3 && parseInt(styleState.blackjack.inputControls.sideBet.chosenCredits) > 0 ) ? 'block' : 'none';
     9  let display = parseInt(playerState.blackjackGame.status.substr(1, 1)) >= 2 ? 'block' : 'none';
     10  let displaySideBet = ( parseInt(playerState.blackjackGame.status.substr(1, 1)) >= 3 && parseInt(styleState.blackjack.inputControls.sideBet.chosenCredits) > 0 ) ? 'block' : 'none';
    1111
    1212  return (
  • components/blackjack/PlayButtons.jsx

    r285c3cc r9bd09b0  
    44import { AiFillCheckCircle } from 'react-icons/ai'
    55
    6 import { setGame, setPlayer } from '../../redux/reducers/playerSlice';
     6import { setBlackjackGame, setPlayer } from '../../redux/reducers/playerSlice';
    77import { setBlackjack, setStyle } from '../../redux/reducers/styleSlice';
    88
     
    4646        axios.get(`/api/blackjack?action=make_initial_bet&session_id=${localStorage.CAESSINO_SESSION_ID}&bet=${styleState.blackjack.inputControls.initialBet.chosenCredits}`).then(res => {
    4747            if (res.data?.success) {
    48                 dispatch(setGame({
    49                     ...playerState.game,
     48                dispatch(setBlackjackGame({
     49                    ...playerState.blackjackGame,
    5050                    status: res.data?.status,
    5151                }))
     
    124124        const texts = splitTexts(e.target.innerHTML);
    125125
    126         dispatch(setGame({
    127             ...playerState.game,
     126        dispatch(setBlackjackGame({
     127            ...playerState.blackjackGame,
    128128            sideBetName: sideBetName
    129129        }))
     
    145145
    146146    function placeSideBetClicked() {
    147         axios.get(`/api/blackjack?action=make_side_bet&session_id=${localStorage.CAESSINO_SESSION_ID}&bet=${styleState.blackjack.inputControls.sideBet.chosenCredits}&betName=${playerState.game.sideBetName}`).then(res => {
    148             if (res.data?.success) {
    149                 dispatch(setGame({
    150                     ...playerState.game,
     147        axios.get(`/api/blackjack?action=make_side_bet&session_id=${localStorage.CAESSINO_SESSION_ID}&bet=${styleState.blackjack.inputControls.sideBet.chosenCredits}&betName=${playerState.blackjackGame.sideBetName}`).then(res => {
     148            if (res.data?.success) {
     149                dispatch(setBlackjackGame({
     150                    ...playerState.blackjackGame,
    151151                    status: res.data?.status,
    152152                }))
     
    201201        axios.get(`/api/blackjack?action=get_initial_cards&session_id=${localStorage.CAESSINO_SESSION_ID}`).then(res => {
    202202            if (res.data?.success) {
    203                 dispatch(setGame({
    204                     ...playerState.game,
     203                dispatch(setBlackjackGame({
     204                    ...playerState.blackjackGame,
    205205                    status: res.data?.status,
    206206                    playerCards: res.data?.playerCards,
     
    210210                if (res.data?.sideBetOutcome !== '') {
    211211                    if (res.data.sideBetOutcome === 'side_bet_won') {
    212                         dispatch(setGame({
    213                             ...playerState.game,
     212                        dispatch(setBlackjackGame({
     213                            ...playerState.blackjackGame,
    214214                            credits: res.data?.credits,
    215215                        }))
     
    250250        axios.get(`/api/blackjack?action=hit_a_card&session_id=${localStorage.CAESSINO_SESSION_ID}`).then(res => {
    251251            if (res.data?.success) {
    252                 dispatch(setGame({
    253                     ...playerState.game,
     252                dispatch(setBlackjackGame({
     253                    ...playerState.blackjackGame,
    254254                    status: res.data?.status,
    255255                    playerCards: res.data?.playerCards,
     
    284284        axios.get(`/api/blackjack?action=stand&session_id=${localStorage.CAESSINO_SESSION_ID}`).then(res => {
    285285            if (res.data?.success) {
    286                 dispatch(setGame({
    287                     ...playerState.game,
     286                dispatch(setBlackjackGame({
     287                    ...playerState.blackjackGame,
    288288                    status: res.data?.status,
    289289                    playerCards: res.data?.playerCards,
Note: See TracChangeset for help on using the changeset viewer.