Les pénalités ne se suivent pas d'une tentative à une autre
This commit is contained in:
parent
979362d012
commit
cb1222d9cf
@ -101,7 +101,7 @@ export default function GameProvider({ children }: { children: ReactNode }) {
|
|||||||
const activeChallenge: ChallengeAction | undefined = challengeActions
|
const activeChallenge: ChallengeAction | undefined = challengeActions
|
||||||
.find(challengeAction => challengeAction.penaltyStart && challengeAction.penaltyEnd
|
.find(challengeAction => challengeAction.penaltyStart && challengeAction.penaltyEnd
|
||||||
&& challengeAction.penaltyStart <= now && now <= challengeAction.penaltyEnd)
|
&& challengeAction.penaltyStart <= now && now <= challengeAction.penaltyEnd)
|
||||||
if (!activeChallenge || !game.currentRunner)
|
if (!activeChallenge || !game.currentRunner || game.runId !== activeChallenge.runId)
|
||||||
updatePenalty({ penaltyStart: null, penaltyEnd: null })
|
updatePenalty({ penaltyStart: null, penaltyEnd: null })
|
||||||
else if (activeChallenge && (activeChallenge.penaltyStart !== game.penaltyStart || activeChallenge.penaltyEnd)) {
|
else if (activeChallenge && (activeChallenge.penaltyStart !== game.penaltyStart || activeChallenge.penaltyEnd)) {
|
||||||
updatePenalty({ penaltyStart: activeChallenge.penaltyStart, penaltyEnd: activeChallenge.penaltyEnd })
|
updatePenalty({ penaltyStart: activeChallenge.penaltyStart, penaltyEnd: activeChallenge.penaltyEnd })
|
||||||
|
@ -9,6 +9,7 @@ export interface ChallengeAction {
|
|||||||
end: number | null, // date
|
end: number | null, // date
|
||||||
penaltyStart: number | null, // date
|
penaltyStart: number | null, // date
|
||||||
penaltyEnd: number | null, // date
|
penaltyEnd: number | null, // date
|
||||||
|
runId: number,
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ActionsState {
|
export interface ActionsState {
|
||||||
@ -28,6 +29,7 @@ export interface ChallengeActionPayload {
|
|||||||
end: string | null,
|
end: string | null,
|
||||||
penaltyStart: string | null,
|
penaltyStart: string | null,
|
||||||
penaltyEnd: string | null,
|
penaltyEnd: string | null,
|
||||||
|
runId: number,
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ChallengeActionsPayload {
|
export interface ChallengeActionsPayload {
|
||||||
@ -51,6 +53,7 @@ export const challengeActionsSlice = createSlice({
|
|||||||
end: dlChallenge.action.end ? new Date(dlChallenge.action.end).getTime() : null,
|
end: dlChallenge.action.end ? new Date(dlChallenge.action.end).getTime() : null,
|
||||||
penaltyStart: dlChallenge.action.penaltyStart ? new Date(dlChallenge.action.penaltyStart).getTime() : null,
|
penaltyStart: dlChallenge.action.penaltyStart ? new Date(dlChallenge.action.penaltyStart).getTime() : null,
|
||||||
penaltyEnd: dlChallenge.action.penaltyEnd ? new Date(dlChallenge.action.penaltyEnd).getTime() : null,
|
penaltyEnd: dlChallenge.action.penaltyEnd ? new Date(dlChallenge.action.penaltyEnd).getTime() : null,
|
||||||
|
runId: dlChallenge.action.runId,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
state.challengeActions.sort((c1, c2) => c2.id - c1.id)
|
state.challengeActions.sort((c1, c2) => c2.id - c1.id)
|
||||||
|
@ -22,6 +22,7 @@ export interface PenaltyPayload {
|
|||||||
|
|
||||||
export interface GameState {
|
export interface GameState {
|
||||||
playerId: number | null
|
playerId: number | null
|
||||||
|
runId: number | null
|
||||||
gameStarted: boolean
|
gameStarted: boolean
|
||||||
money: number
|
money: number
|
||||||
currentRunner: boolean
|
currentRunner: boolean
|
||||||
@ -33,6 +34,7 @@ export interface GameState {
|
|||||||
|
|
||||||
const initialState: GameState = {
|
const initialState: GameState = {
|
||||||
playerId: null,
|
playerId: null,
|
||||||
|
runId: null,
|
||||||
gameStarted: false,
|
gameStarted: false,
|
||||||
money: 0,
|
money: 0,
|
||||||
currentRunner: false,
|
currentRunner: false,
|
||||||
@ -58,6 +60,7 @@ export const gameSlice = createSlice({
|
|||||||
updateGameState: (state, action: PayloadAction<GamePayload>) => {
|
updateGameState: (state, action: PayloadAction<GamePayload>) => {
|
||||||
const game: GamePayload = action.payload
|
const game: GamePayload = action.payload
|
||||||
state.gameStarted = game.started
|
state.gameStarted = game.started
|
||||||
|
state.runId = game.currentRunId
|
||||||
state.currentRunner = state.playerId === game.currentRun?.runnerId
|
state.currentRunner = state.playerId === game.currentRun?.runnerId
|
||||||
if (state.currentRunner)
|
if (state.currentRunner)
|
||||||
state.chaseFreeTime = null
|
state.chaseFreeTime = null
|
||||||
|
Loading…
Reference in New Issue
Block a user