import { createSlice, PayloadAction } from '@reduxjs/toolkit' export interface GameState { playerId: number | null gameStarted: boolean money: number currentRunner: boolean chaseFreeTime: Date | null penaltyStart: Date | null penaltyEnd: Date | null } const initialState: GameState = { playerId: null, gameStarted: false, money: 0, currentRunner: false, chaseFreeTime: null, penaltyStart: null, penaltyEnd: null, } export const gameSlice = createSlice({ name: 'game', initialState: initialState, reducers: { setPlayerId: (state, action: PayloadAction) => { state.playerId = action.payload }, updateMoney: (state, action: PayloadAction) => { state.money = action.payload }, }, }) export const { setPlayerId, updateMoney } = gameSlice.actions export default gameSlice.reducer