25 lines
1.0 KiB
TypeScript
Raw Normal View History

2024-12-11 17:26:36 +01:00
import { useAppDispatch, useAppSelector } from "./useStore"
2024-12-13 00:02:58 +01:00
import { GamePayload, PenaltyPayload, setPlayerId, updateActiveChallengeId, updateGameState, updateMoney, updatePenalty } from "@/utils/features/game/gameSlice"
2024-12-11 17:26:36 +01:00
export const useGame = () => useAppSelector((state) => state.game)
export const useSetPlayerId = () => {
const dispath = useAppDispatch()
return (playerId: number) => dispath(setPlayerId(playerId))
}
export const useUpdateMoney = () => {
const dispatch = useAppDispatch()
return (money: number) => dispatch(updateMoney(money))
}
export const useUpdateActiveChallengeId = () => {
const dispatch = useAppDispatch()
return (challengeActionId: number) => dispatch(updateActiveChallengeId(challengeActionId))
}
export const useUpdateGameState = () => {
const dispatch = useAppDispatch()
return (game: GamePayload) => dispatch(updateGameState(game))
}
2024-12-13 00:02:58 +01:00
export const useUpdatePenalty = () => {
const dispatch = useAppDispatch()
return (penalty: PenaltyPayload) => dispatch(updatePenalty(penalty))
}