Amélioration Géolocalisation
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import { createSlice, PayloadAction } from '@reduxjs/toolkit'
|
||||
import { Accuracy } from 'expo-location'
|
||||
|
||||
export interface RunPayload {
|
||||
id: number
|
||||
@ -37,6 +38,11 @@ export interface GameState {
|
||||
chaseFreeTime: number | null // date
|
||||
penaltyStart: number | null // date
|
||||
penaltyEnd: number | null //date
|
||||
settings: Settings
|
||||
}
|
||||
|
||||
export interface Settings {
|
||||
locationAccuracy: Accuracy | null
|
||||
}
|
||||
|
||||
const initialState: GameState = {
|
||||
@ -49,6 +55,9 @@ const initialState: GameState = {
|
||||
chaseFreeTime: null,
|
||||
penaltyStart: null,
|
||||
penaltyEnd: null,
|
||||
settings: {
|
||||
locationAccuracy: Accuracy.Highest,
|
||||
}
|
||||
}
|
||||
|
||||
export const gameSlice = createSlice({
|
||||
@ -77,10 +86,13 @@ export const gameSlice = createSlice({
|
||||
updatePenalty: (state, action: PayloadAction<PenaltyPayload>) => {
|
||||
state.penaltyStart = action.payload.penaltyStart
|
||||
state.penaltyEnd = action.payload.penaltyEnd
|
||||
},
|
||||
setLocationAccuracy: (state, action: PayloadAction<Accuracy | null>) => {
|
||||
state.settings.locationAccuracy = action.payload
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
export const { setPlayerId, updateMoney, updateActiveChallengeId, updateGameState, updatePenalty } = gameSlice.actions
|
||||
export const { setLocationAccuracy, setPlayerId, updateMoney, updateActiveChallengeId, updateGameState, updatePenalty } = gameSlice.actions
|
||||
|
||||
export default gameSlice.reducer
|
||||
|
Reference in New Issue
Block a user