2024-12-19 15:47:41 +00:00
|
|
|
import { Accuracy } from "expo-location"
|
2024-12-11 16:26:36 +00:00
|
|
|
import { useAppDispatch, useAppSelector } from "./useStore"
|
2024-12-19 15:47:41 +00:00
|
|
|
import { GamePayload, PenaltyPayload, setLocationAccuracy, setPlayerId, updateActiveChallengeId, updateGameState, updateMoney, updatePenalty } from "@/utils/features/game/gameSlice"
|
2024-12-11 16:26:36 +00:00
|
|
|
|
|
|
|
export const useGame = () => useAppSelector((state) => state.game)
|
2024-12-19 15:47:41 +00:00
|
|
|
export const useSettings = () => useAppSelector((state) => state.game.settings)
|
2024-12-11 16:26:36 +00:00
|
|
|
export const useSetPlayerId = () => {
|
|
|
|
const dispath = useAppDispatch()
|
|
|
|
return (playerId: number) => dispath(setPlayerId(playerId))
|
|
|
|
}
|
|
|
|
export const useUpdateMoney = () => {
|
|
|
|
const dispatch = useAppDispatch()
|
|
|
|
return (money: number) => dispatch(updateMoney(money))
|
|
|
|
}
|
2024-12-12 21:55:59 +00:00
|
|
|
export const useUpdateActiveChallengeId = () => {
|
|
|
|
const dispatch = useAppDispatch()
|
|
|
|
return (challengeActionId: number) => dispatch(updateActiveChallengeId(challengeActionId))
|
|
|
|
}
|
2024-12-11 20:33:51 +00:00
|
|
|
export const useUpdateGameState = () => {
|
|
|
|
const dispatch = useAppDispatch()
|
|
|
|
return (game: GamePayload) => dispatch(updateGameState(game))
|
|
|
|
}
|
2024-12-12 23:02:58 +00:00
|
|
|
export const useUpdatePenalty = () => {
|
|
|
|
const dispatch = useAppDispatch()
|
|
|
|
return (penalty: PenaltyPayload) => dispatch(updatePenalty(penalty))
|
|
|
|
}
|
2024-12-19 15:47:41 +00:00
|
|
|
export const useSetLocationAccuracy = () => {
|
|
|
|
const dispatch = useAppDispatch()
|
|
|
|
return (accuracy: Accuracy | null) => dispatch(setLocationAccuracy(accuracy))
|
|
|
|
}
|