source: redux/reducers/playerSlice.js

main
Last change on this file was 55701f0, checked in by anastasovv <simon@…>, 2 years ago

Added 1 second update_state calls in blackjack

  • Property mode set to 100644
File size: 2.4 KB
Line 
1import { createSlice } from '@reduxjs/toolkit';
2
3const initialState = {
4 player: {
5 displayName: '',
6 username: '',
7 session_id: '',
8 room_id: '',
9 credits: 0,
10 },
11 blackjackGame: {
12 status: '',
13 playerCards: [],
14 dealerCards: [],
15 sideBetName: '',
16 betAmount: 0,
17 sideBetAmount: 0,
18 },
19 rouletteGame: {
20 game: {
21 status: '_1_ongoing_timer',
22 timeToStart: 30,
23 COUNTDOWN_FROM: 30,
24 WAIT_BEFORE: 20,
25 magicNumber: -1,
26 winningBets: [],
27 players: [],
28 },
29 player: {
30 session_id: '',
31 name: '',
32 whichBets: [],
33 coinPlaced: {
34 x: -1,
35 y: -1,
36 },
37 credits: -1,
38 betAmount: 0,
39 wonAmount: 0,
40 status: '_1_',
41 outcome: 'none',
42 gotResults: false,
43 },
44 },
45 pokerGame: {
46 tables: [],
47 table: {
48 id: '',
49 name: '',
50 status: '',
51 creator: '',
52 started: false,
53 round: 0,
54 turnIdx: 0,
55 lastBet: 0,
56 turnsSinceLastBet: 0,
57 players: [{
58 id: '',
59 table: '',
60 status: '',
61 displayName: '',
62 cards: [],
63 betAmount: 0,
64 isSatDown: false,
65 iSCoordinator: false,
66 }],
67 cards: [],
68 },
69 player: {
70 status: '',
71 cards: [],
72 table: '',
73 isSatDown: false,
74 isCoordinator: false,
75 },
76 },
77}
78
79export const playerSlice = createSlice({
80 name: 'player',
81 initialState,
82 reducers: {
83 setPlayer: (state, action) => {
84 state.player = action.payload;
85 },
86 setBlackjackGame: (state, action) => {
87 state.blackjackGame = action.payload;
88 },
89 setRouletteGame: (state, action) => {
90 state.rouletteGame = action.payload;
91 },
92 setPokerGame: (state, action) => {
93 state.pokerGame = action.payload;
94 },
95 }
96})
97
98export const { setPlayer, setBlackjackGame, setRouletteGame, setPokerGame } = playerSlice.actions
99
100export default playerSlice.reducer
Note: See TracBrowser for help on using the repository browser.