mirror of
https://github.com/VickScarlet/lifeRestart.git
synced 2026-08-27 08:46:48 +08:00
feature: lock only one use radio mode
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user