update: hooks, web

This commit is contained in:
Vick Scarlet
2026-08-16 20:06:16 +08:00
committed by 神戸小鳥
parent 2f91709d1e
commit 322f775796
67 changed files with 2339 additions and 2243 deletions
+26 -39
View File
@@ -1,26 +1,23 @@
import ages from '@remake/data/age'
import { propsEffect } from '@/state'
import { enableMapSet, produce } from 'immer'
import type { Achievement, Event, Talent } from '@remake/data'
import { ages, AchievementOpportunity as Ao } from '@remake/data'
import type { Allocation, GameState, ProfileState } from './state'
import { createState, nextProfile, propsEffect } from './state'
import { summary as stateSummary } from './state'
import type { PullOptions, ReplacementResult } from './talent'
import type { AdditionalPoint, AdditionalPoints } from './talent'
import { pull, exclude, replacement, additionalPoints } from './talent'
import { trigger as ttr } from './talent'
import { trigger as atr } from './achievement'
import { trigger as etr, check as ec } from './event'
import type { RNG } from '@remake/vitex'
import { pickWeight } from '@remake/vitex'
import { produce, enableMapSet } from 'immer'
enableMapSet()
export type * as achievement from '@/achievement'
export type * as event from '@/event'
export type * as talent from '@/talent'
export type * as state from '@/state'
import type { GameState, ProfileState } from '@/state'
export type { GameState, ProfileState }
export interface TriggerResult<T> {
state: GameState
triggers: T[]
}
export { pull } from '@/talent'
// export { summary, nextProfile } from '@/state'
import { replacement, additionalPoints } from '@/talent'
import type { ReplacementResult, AdditionalPoints } from '@/talent'
import type { RNG } from '@remake/vitex'
export interface TalentsPickedResult {
talents: ReplacementResult
additionalPoints: AdditionalPoints
@@ -34,8 +31,6 @@ export function talentsPicked(
return { talents: r, additionalPoints: ap }
}
import { createState } from '@/state'
export interface StartResult {
state: GameState
achievements: Achievement['id'][]
@@ -45,19 +40,9 @@ export function start(
...args: Parameters<typeof createState>
): StartResult {
const state = createState(...args)
const ar = achievementTrigger('START', state, profile)
const ar = atr(Ao.Start, state, profile)
return { state: ar.state, achievements: ar.triggers }
}
import type { Achievement } from '@remake/data/achievement'
import type { Event } from '@remake/data/event'
import type { Talent } from '@remake/data/talent'
import { trigger as achievementTrigger } from '@/achievement'
import { trigger as eventTrigger } from '@/event'
import { trigger as talentTrigger } from '@/talent'
import { check as eventCheck } from '@/event'
import { pickWeight } from '@remake/vitex'
export interface NextResult {
state: GameState
age: number
@@ -76,13 +61,13 @@ export function next(
draft.props = propsEffect(state.props, { age: 1 })
})
const age = s.props.current.age
const tr = talentTrigger(s, profile, rng)
const tr = ttr(s, profile, rng)
const events = ages
.get(age)!
.event.filter(([e]) => eventCheck(e, tr.state, profile))
.event.filter(([e]) => ec(e, tr.state, profile))
const event = pickWeight(events, rng)!
const er = eventTrigger(event, tr.state, profile)
const ar = achievementTrigger('TRAJECTORY', er.state, profile)
const er = etr(event, tr.state, profile)
const ar = atr(Ao.Trajectory, er.state, profile)
const end = ar.state.life < 1
return {
state: ar.state,
@@ -94,8 +79,6 @@ export function next(
}
}
import { summary as stateSummary } from '@/state'
export interface SummaryResult {
state: GameState
summary: number
@@ -105,12 +88,11 @@ export function summary(
state: GameState,
profile: ProfileState,
): SummaryResult {
const ar = achievementTrigger('SUMMARY', state, profile)
const ar = atr(Ao.Summary, state, profile)
const s = stateSummary(ar.state)
return { state: ar.state, summary: s, achievements: ar.triggers }
}
import { nextProfile } from '@/state'
export interface EndResult {
profile: ProfileState
achievements: Achievement['id'][]
@@ -121,7 +103,12 @@ export function end(
profile: ProfileState,
lockedTalent?: Talent['id'],
) {
const ar = achievementTrigger('END', state, profile)
const ar = atr(Ao.End, state, profile)
const p = nextProfile(profile, ar.state, lockedTalent)
return { profile: p, achievements: ar.triggers }
}
export { pull, exclude }
export type { GameState, ProfileState, Allocation, RNG }
export type { PullOptions, ReplacementResult }
export type { AdditionalPoint, AdditionalPoints }