feature: lock only one use radio mode

This commit is contained in:
Vick Scarlet
2026-08-16 20:06:16 +08:00
committed by 神戸小鳥
parent 533e705fae
commit cd82d175c2
4 changed files with 12 additions and 10 deletions
+8 -6
View File
@@ -21,10 +21,10 @@ export type Log = Omit<NextResult, 'state'> & {
props: Omit<Properties, 'age'>
}
const stepAtom = atom<Step>(Step.Idle)
const gameStateAtom = atom<GameState | null>(null)
const logsAtom = atom<Log[]>([])
const summaryAtom = atom(0)
export const stepAtom = atom<Step>(Step.Idle)
export const gameStateAtom = atom<GameState | null>(null)
export const logsAtom = atom<Log[]>([])
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