source: redux/reducers/playerSlice.js@ d0ef259

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

Roulette rethought with 1 second update calls

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