Pénalité lorsqu'on échoue un défi

This commit is contained in:
2024-12-13 00:02:58 +01:00
parent 63ad84eb8c
commit 4cb2677f45
6 changed files with 34 additions and 9 deletions

View File

@ -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