Pénalité lorsqu'on échoue un défi
This commit is contained in:
@ -1,5 +1,4 @@
|
||||
import { createSlice, PayloadAction } from '@reduxjs/toolkit'
|
||||
import { ChallengeAction } from '../challengeActions/challengeActionsSlice'
|
||||
|
||||
export interface RunPayload {
|
||||
id: number
|
||||
@ -16,6 +15,11 @@ export interface GamePayload {
|
||||
currentRun: RunPayload | null
|
||||
}
|
||||
|
||||
export interface PenaltyPayload {
|
||||
penaltyStart: number | null
|
||||
penaltyEnd: number | null
|
||||
}
|
||||
|
||||
export interface GameState {
|
||||
playerId: number | null
|
||||
gameStarted: boolean
|
||||
@ -59,10 +63,14 @@ export const gameSlice = createSlice({
|
||||
state.chaseFreeTime = null
|
||||
else if (game.currentRun)
|
||||
state.chaseFreeTime = new Date(game.currentRun?.start).getTime() + 45 * 60 * 1000
|
||||
},
|
||||
updatePenalty: (state, action: PayloadAction<PenaltyPayload>) => {
|
||||
state.penaltyStart = action.payload.penaltyStart
|
||||
state.penaltyEnd = action.payload.penaltyEnd
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
export const { setPlayerId, updateMoney, updateActiveChallengeId, updateGameState } = gameSlice.actions
|
||||
export const { setPlayerId, updateMoney, updateActiveChallengeId, updateGameState, updatePenalty } = gameSlice.actions
|
||||
|
||||
export default gameSlice.reducer
|
||||
|
Reference in New Issue
Block a user