diff --git a/packages/hooks/src/alloc.ts b/packages/hooks/src/alloc.ts index f4b45c4..bf89c62 100644 --- a/packages/hooks/src/alloc.ts +++ b/packages/hooks/src/alloc.ts @@ -13,7 +13,7 @@ const init: UserAllocation = { strength: 0, money: 0, } -const allocAtom = atom({ ...init }) +export const allocAtom = atom({ ...init }) const alloced = (alloc: UserAllocation) => Object.values(alloc).reduce((a, b) => a + b, 0) diff --git a/packages/hooks/src/play.ts b/packages/hooks/src/play.ts index 8b0b70f..cf59119 100644 --- a/packages/hooks/src/play.ts +++ b/packages/hooks/src/play.ts @@ -21,10 +21,10 @@ export type Log = Omit & { props: Omit } -const stepAtom = atom(Step.Idle) -const gameStateAtom = atom(null) -const logsAtom = atom([]) -const summaryAtom = atom(0) +export const stepAtom = atom(Step.Idle) +export const gameStateAtom = atom(null) +export const logsAtom = atom([]) +export const summaryAtom = atom(0) export const useStateReset = () => { const setGameState = useSetAtom(gameStateAtom) @@ -129,11 +129,13 @@ export const useEnd = () => { const picker = useCallback( (talent: Talent['id']) => { setLocked(prev => { - const next = new Set(prev) - if (next.has(talent)) { + if (prev.has(talent)) { + const next = new Set(prev) next.delete(talent) return next } + if (lock == 1) return new Set([talent]) + const next = new Set(prev) if (next.size >= lock) return prev next.add(talent) return next diff --git a/packages/hooks/src/profile.ts b/packages/hooks/src/profile.ts index 94b9f9c..55fbc75 100644 --- a/packages/hooks/src/profile.ts +++ b/packages/hooks/src/profile.ts @@ -2,7 +2,7 @@ import { useCallback } from 'react' import { atom, useAtom, useSetAtom } from 'jotai' import type { ProfileState } from '@remake/core' -const profileAtom = atom(null) +export const profileAtom = atom(null) export const useRawProfile = () => useAtom(profileAtom) diff --git a/packages/hooks/src/talent.ts b/packages/hooks/src/talent.ts index 5de9201..11f3c85 100644 --- a/packages/hooks/src/talent.ts +++ b/packages/hooks/src/talent.ts @@ -7,8 +7,8 @@ import { pull, exclude, talentsPicked } from '@remake/core' import type { TalentsPickedResult, RNG } from '@remake/core' import type { Talent } from '@remake/data/talent' -const pickedAtom = atom(new Set()) -const replacedAtom = atom(null) +export const pickedAtom = atom(new Set()) +export const replacedAtom = atom(null) export const useTalentReset = () => { const setPicked = useSetAtom(pickedAtom)