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
+1 -1
View File
@@ -13,7 +13,7 @@ const init: UserAllocation = {
strength: 0, strength: 0,
money: 0, money: 0,
} }
const allocAtom = atom<UserAllocation>({ ...init }) export const allocAtom = atom<UserAllocation>({ ...init })
const alloced = (alloc: UserAllocation) => const alloced = (alloc: UserAllocation) =>
Object.values(alloc).reduce((a, b) => a + b, 0) Object.values(alloc).reduce((a, b) => a + b, 0)
+7 -5
View File
@@ -21,10 +21,10 @@ export type Log = Omit<NextResult, 'state'> & {
props: Omit<Properties, 'age'> props: Omit<Properties, 'age'>
} }
const stepAtom = atom<Step>(Step.Idle) export const stepAtom = atom<Step>(Step.Idle)
const gameStateAtom = atom<GameState | null>(null) export const gameStateAtom = atom<GameState | null>(null)
const logsAtom = atom<Log[]>([]) export const logsAtom = atom<Log[]>([])
const summaryAtom = atom(0) export const summaryAtom = atom(0)
export const useStateReset = () => { export const useStateReset = () => {
const setGameState = useSetAtom(gameStateAtom) const setGameState = useSetAtom(gameStateAtom)
@@ -129,11 +129,13 @@ export const useEnd = () => {
const picker = useCallback( const picker = useCallback(
(talent: Talent['id']) => { (talent: Talent['id']) => {
setLocked(prev => { setLocked(prev => {
if (prev.has(talent)) {
const next = new Set(prev) const next = new Set(prev)
if (next.has(talent)) {
next.delete(talent) next.delete(talent)
return next return next
} }
if (lock == 1) return new Set([talent])
const next = new Set(prev)
if (next.size >= lock) return prev if (next.size >= lock) return prev
next.add(talent) next.add(talent)
return next return next
+1 -1
View File
@@ -2,7 +2,7 @@ import { useCallback } from 'react'
import { atom, useAtom, useSetAtom } from 'jotai' import { atom, useAtom, useSetAtom } from 'jotai'
import type { ProfileState } from '@remake/core' import type { ProfileState } from '@remake/core'
const profileAtom = atom<ProfileState | null>(null) export const profileAtom = atom<ProfileState | null>(null)
export const useRawProfile = () => useAtom(profileAtom) 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 { TalentsPickedResult, RNG } from '@remake/core'
import type { Talent } from '@remake/data/talent' import type { Talent } from '@remake/data/talent'
const pickedAtom = atom(new Set<Talent['id']>()) export const pickedAtom = atom(new Set<Talent['id']>())
const replacedAtom = atom<TalentsPickedResult | null>(null) export const replacedAtom = atom<TalentsPickedResult | null>(null)
export const useTalentReset = () => { export const useTalentReset = () => {
const setPicked = useSetAtom(pickedAtom) const setPicked = useSetAtom(pickedAtom)