Structure de données jeu client
This commit is contained in:
38
client/utils/features/game/gameSlice.ts
Normal file
38
client/utils/features/game/gameSlice.ts
Normal file
@ -0,0 +1,38 @@
|
||||
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<number>) => {
|
||||
state.playerId = action.payload
|
||||
},
|
||||
updateMoney: (state, action: PayloadAction<number>) => {
|
||||
state.money = action.payload
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
export const { setPlayerId, updateMoney } = gameSlice.actions
|
||||
|
||||
export default gameSlice.reducer
|
Reference in New Issue
Block a user