feature: lock only one use radio mode

This commit is contained in:
Vick Scarlet
2026-08-12 17:41:51 +08:00
parent 5a4821433a
commit f439141ded
4 changed files with 12 additions and 10 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ const init: UserAllocation = {
strength: 0,
money: 0,
}
const allocAtom = atom<UserAllocation>({ ...init })
export const allocAtom = atom<UserAllocation>({ ...init })
const alloced = (alloc: UserAllocation) =>
Object.values(alloc).reduce((a, b) => a + b, 0)
+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
+1 -1
View File
@@ -2,7 +2,7 @@ import { useCallback } from 'react'
import { atom, useAtom, useSetAtom } from 'jotai'
import type { ProfileState } from '@remake/core'
const profileAtom = atom<ProfileState | null>(null)
export const profileAtom = atom<ProfileState | null>(null)
export const useRawProfile = () => useAtom(profileAtom)
+2 -2
View File
@@ -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<Talent['id']>())
const replacedAtom = atom<TalentsPickedResult | null>(null)
export const pickedAtom = atom(new Set<Talent['id']>())
export const replacedAtom = atom<TalentsPickedResult | null>(null)
export const useTalentReset = () => {
const setPicked = useSetAtom(pickedAtom)