mirror of
https://github.com/VickScarlet/lifeRestart.git
synced 2026-08-29 18:14:41 +08:00
add: mode & character page
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
import { useEffect } from 'react'
|
import { useEffect } from 'react'
|
||||||
import { useInit, useSaver } from '@/hooks/storage'
|
import { useInit, useSaver } from '@/hooks/storage'
|
||||||
import { useStep, Step } from '@remake/hooks'
|
import { useStep } from '@remake/hooks'
|
||||||
import Home from '@/containers/Home'
|
import Home from '@/containers/Home'
|
||||||
|
import Mode from '@/containers/Mode'
|
||||||
|
import Chara from '@/containers/Chara'
|
||||||
import Pick from '@/containers/TalentPick'
|
import Pick from '@/containers/TalentPick'
|
||||||
import Alloc from '@/containers/Alloc'
|
import Alloc from '@/containers/Alloc'
|
||||||
import Play from '@/containers/Play'
|
import Play from '@/containers/Play'
|
||||||
@@ -12,7 +14,7 @@ import './Game.css'
|
|||||||
export function Game() {
|
export function Game() {
|
||||||
const [inited, init] = useInit()
|
const [inited, init] = useInit()
|
||||||
const saver = useSaver()
|
const saver = useSaver()
|
||||||
const step = useStep()
|
const [step, Step] = useStep()
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!inited) init()
|
if (!inited) init()
|
||||||
}, [inited])
|
}, [inited])
|
||||||
@@ -24,6 +26,9 @@ export function Game() {
|
|||||||
case Step.Idle:
|
case Step.Idle:
|
||||||
return <Home />
|
return <Home />
|
||||||
case Step.Mode:
|
case Step.Mode:
|
||||||
|
return <Mode />
|
||||||
|
case Step.Chara:
|
||||||
|
return <Chara />
|
||||||
case Step.Pick:
|
case Step.Pick:
|
||||||
return <Pick />
|
return <Pick />
|
||||||
case Step.Alloc:
|
case Step.Alloc:
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
.screen.chara {}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import './Chara.css'
|
||||||
|
|
||||||
|
export function Chara() {
|
||||||
|
return <div className="screen chara"></div>
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Chara
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
.screen.mode {
|
||||||
|
gap: 1rem;
|
||||||
|
button {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
height: 10rem;
|
||||||
|
gap: 0.5rem;
|
||||||
|
.name {
|
||||||
|
font-size: 3.5rem;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
.description {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
gap: 1rem;
|
||||||
|
span {
|
||||||
|
font-size: 1rem;
|
||||||
|
&::before { content: '['; }
|
||||||
|
&::after { content: ']'; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import { PullCount } from '@/config'
|
||||||
|
import { useModeChoose } from '@remake/hooks'
|
||||||
|
import './Mode.css'
|
||||||
|
|
||||||
|
export function Mode() {
|
||||||
|
const [Mode, choose] = useModeChoose()
|
||||||
|
return (
|
||||||
|
<div className="screen mode">
|
||||||
|
<button onClick={() => choose(Mode.Classic)}>
|
||||||
|
<div className="name">经典模式</div>
|
||||||
|
<div className="description">
|
||||||
|
<span>{PullCount} 连抽天赋</span>
|
||||||
|
<span>自由分配属性</span>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
<button onClick={() => choose(Mode.Celebrity)}>
|
||||||
|
<div className="name">名人模式</div>
|
||||||
|
<div className="description">
|
||||||
|
<span>前世古代名人,重开到了现代</span>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Mode
|
||||||
@@ -11,12 +11,18 @@ import type { Talent } from '@remake/data/talent'
|
|||||||
export enum Step {
|
export enum Step {
|
||||||
Idle = 'idle',
|
Idle = 'idle',
|
||||||
Mode = 'mode',
|
Mode = 'mode',
|
||||||
|
Chara = 'chara',
|
||||||
Pick = 'pick',
|
Pick = 'pick',
|
||||||
Alloc = 'alloc',
|
Alloc = 'alloc',
|
||||||
Play = 'play',
|
Play = 'play',
|
||||||
Summary = 'summary',
|
Summary = 'summary',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum Mode {
|
||||||
|
Classic = 'classic',
|
||||||
|
Celebrity = 'celebrity',
|
||||||
|
}
|
||||||
|
|
||||||
export type Log = Omit<NextResult, 'state'> & {
|
export type Log = Omit<NextResult, 'state'> & {
|
||||||
props: Omit<Properties, 'age'>
|
props: Omit<Properties, 'age'>
|
||||||
}
|
}
|
||||||
@@ -47,8 +53,8 @@ export const useGameReset = () => {
|
|||||||
}, [resetTalent, resetAlloc, resetState, resetLogs])
|
}, [resetTalent, resetAlloc, resetState, resetLogs])
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useStep = () => useAtomValue(stepAtom)
|
export const useStep = () => [useAtomValue(stepAtom), Step] as const
|
||||||
export const useSetStep = () => useSetAtom(stepAtom)
|
export const useSetStep = () => [useSetAtom(stepAtom), Step] as const
|
||||||
export const useGameState = () => useAtomValue(gameStateAtom)
|
export const useGameState = () => useAtomValue(gameStateAtom)
|
||||||
export const useSummary = () => useAtomValue(summaryAtom)
|
export const useSummary = () => useAtomValue(summaryAtom)
|
||||||
export const useLogs = () => useAtomValue(logsAtom)
|
export const useLogs = () => useAtomValue(logsAtom)
|
||||||
@@ -64,6 +70,24 @@ export const useRemake = () => {
|
|||||||
}, [mode, times, setStep, reset])
|
}, [mode, times, setStep, reset])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const useModeChoose = () => {
|
||||||
|
const setStep = useSetAtom(stepAtom)
|
||||||
|
const choose = useCallback(
|
||||||
|
(mode: Mode) => {
|
||||||
|
switch (mode) {
|
||||||
|
case Mode.Classic:
|
||||||
|
setStep(Step.Pick)
|
||||||
|
break
|
||||||
|
case Mode.Celebrity:
|
||||||
|
setStep(Step.Chara)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[setStep],
|
||||||
|
)
|
||||||
|
return [Mode, choose] as const
|
||||||
|
}
|
||||||
|
|
||||||
export const useStart = () => {
|
export const useStart = () => {
|
||||||
const { spirit } = useConfig()
|
const { spirit } = useConfig()
|
||||||
const [profile] = useProfile()
|
const [profile] = useProfile()
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { useState, useCallback } from 'react'
|
|||||||
import { atom, useAtom, useAtomValue, useSetAtom } from 'jotai'
|
import { atom, useAtom, useAtomValue, useSetAtom } from 'jotai'
|
||||||
import { useConfig } from './config'
|
import { useConfig } from './config'
|
||||||
import { useProfile } from './profile'
|
import { useProfile } from './profile'
|
||||||
import { useSetStep, Step } from './play'
|
import { useSetStep } from './play'
|
||||||
import { pull, exclude, talentsPicked } from '@remake/core'
|
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'
|
||||||
@@ -93,13 +93,13 @@ export const useTalentSubmit = () => {
|
|||||||
const picked = useAtomValue(pickedAtom)
|
const picked = useAtomValue(pickedAtom)
|
||||||
const setReplaced = useSetAtom(replacedAtom)
|
const setReplaced = useSetAtom(replacedAtom)
|
||||||
const { enabled } = useSubmitIsEnable()
|
const { enabled } = useSubmitIsEnable()
|
||||||
const next = useSetStep()
|
const [setStep, Step] = useSetStep()
|
||||||
return useCallback(
|
return useCallback(
|
||||||
(rng?: RNG) => {
|
(rng?: RNG) => {
|
||||||
if (!enabled) throw new Error('Not enough talents picked')
|
if (!enabled) throw new Error('Not enough talents picked')
|
||||||
setReplaced(talentsPicked(picked, rng))
|
setReplaced(talentsPicked(picked, rng))
|
||||||
next(Step.Alloc)
|
setStep(Step.Alloc)
|
||||||
},
|
},
|
||||||
[enabled, picked, setReplaced, next],
|
[enabled, picked, setReplaced, setStep],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user