2024-12-11 16:26:36 +00:00
|
|
|
import { useAppDispatch, useAppSelector } from "./useStore"
|
2024-12-11 20:33:51 +00:00
|
|
|
import { GamePayload, setPlayerId, updateGameState, updateMoney } from "@/utils/features/game/gameSlice"
|
2024-12-11 16:26:36 +00: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))
|
|
|
|
}
|
2024-12-11 20:33:51 +00:00
|
|
|
export const useUpdateGameState = () => {
|
|
|
|
const dispatch = useAppDispatch()
|
|
|
|
return (game: GamePayload) => dispatch(updateGameState(game))
|
|
|
|
}
|