mirror of
https://github.com/VickScarlet/lifeRestart.git
synced 2026-08-29 10:04:43 +08:00
feature: lock only one use radio mode
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
@@ -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 => {
|
||||||
const next = new Set(prev)
|
if (prev.has(talent)) {
|
||||||
if (next.has(talent)) {
|
const next = new Set(prev)
|
||||||
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
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user