diff --git a/client/app/(tabs)/challenges.tsx b/client/app/(tabs)/challenges.tsx
index 127f0c1..f6db360 100644
--- a/client/app/(tabs)/challenges.tsx
+++ b/client/app/(tabs)/challenges.tsx
@@ -70,7 +70,7 @@ function ChallengeScreenBody() {
challenge={currentChallenge}
onSuccess={() => { setLoading(true); endChallenge.mutate({ success: true }) }}
onFail={() => endChallenge.mutate({ success: false })} />}
- {!loading && !currentChallenge && game.currentRunner && <>
+ {!loading && !game.penaltyEnd && !currentChallenge && game.currentRunner && <>
{onFail && }
{onSuccess &&
diff --git a/client/hooks/useGame.ts b/client/hooks/useGame.ts
index 2e746ea..eb44269 100644
--- a/client/hooks/useGame.ts
+++ b/client/hooks/useGame.ts
@@ -1,5 +1,5 @@
import { useAppDispatch, useAppSelector } from "./useStore"
-import { GamePayload, setPlayerId, updateActiveChallengeId, updateGameState, updateMoney } from "@/utils/features/game/gameSlice"
+import { GamePayload, PenaltyPayload, setPlayerId, updateActiveChallengeId, updateGameState, updateMoney, updatePenalty } from "@/utils/features/game/gameSlice"
export const useGame = () => useAppSelector((state) => state.game)
export const useSetPlayerId = () => {
@@ -18,3 +18,7 @@ export const useUpdateGameState = () => {
const dispatch = useAppDispatch()
return (game: GamePayload) => dispatch(updateGameState(game))
}
+export const useUpdatePenalty = () => {
+ const dispatch = useAppDispatch()
+ return (penalty: PenaltyPayload) => dispatch(updatePenalty(penalty))
+}
diff --git a/client/utils/features/game/gameSlice.ts b/client/utils/features/game/gameSlice.ts
index 39711a6..7c6cf5c 100644
--- a/client/utils/features/game/gameSlice.ts
+++ b/client/utils/features/game/gameSlice.ts
@@ -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) => {
+ 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