refactor(0.1.14-P1): 内核归位——game/ 按引擎架构重排(零行为漂移)
结构(旧 game/core+engine → 新 engine/ 域): - engine/kernel/ 时钟/随机/插件协议/fxqueue/timesense/format/urgency/guide/names(原 core) - engine/narrative/ legacy/报告/列传/谱系/年轴(原 core 叙事族) - engine/runtime/ World/creation/pcgen/ApiFacade/capabilities/pluginManager/boot/clocks + Systems/*(12 系统) - engine/sim/ Market(未来 WorldSim 同行) - 旧 game/core、engine/systems、engine/world.ts 等路径全部废弃(无 re-export 兼容层) 验证:35 套件/967 测试全绿(金钟罩三档零漂移=纯搬迁无行为变化) typecheck 0 error
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { World } from '../engine/world'
|
||||
import type { World } from '../runtime/World'
|
||||
|
||||
/**
|
||||
* 统一时轮调度:所有系统以 phase 注册,由时钟按固定顺序驱动。
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { World } from '../engine/world'
|
||||
import type { World } from '../runtime/World'
|
||||
|
||||
export interface GuideStep {
|
||||
id: string
|
||||
@@ -1,7 +1,7 @@
|
||||
import { GameClock, SystemHook } from './clock'
|
||||
import { DataPack } from '../data/registry'
|
||||
import { EventDef } from '../data/events'
|
||||
import type { World } from '../engine/world'
|
||||
import { DataPack } from '../../data/registry'
|
||||
import { EventDef } from '../../data/events'
|
||||
import type { World } from '../runtime/World'
|
||||
|
||||
export type PluginKind = 'system' | 'data' | 'events' | 'content'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { RngState } from '../types/domain'
|
||||
import type { RngState } from '../../types/domain'
|
||||
|
||||
function xmur3(str: string): () => number {
|
||||
let h = 1779033703 ^ str.length
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Season } from '../data/season'
|
||||
import { Season } from '../../data/season'
|
||||
|
||||
export const TIDES: string[] = [
|
||||
'立春', '雨水', '惊蛰', '春分', '清明', '谷雨',
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { World } from '../engine/world'
|
||||
import type { World } from '../runtime/World'
|
||||
|
||||
export interface Urgency {
|
||||
blockedCount: number
|
||||
+5
-5
@@ -1,8 +1,8 @@
|
||||
import { GameState } from '../types/domain'
|
||||
import { TECHNIQUES } from '../data/techniques'
|
||||
import { describeRealm } from '../data/realms'
|
||||
import { aspirationById } from '../data/aspirations'
|
||||
import { postById } from '../data/posts'
|
||||
import { GameState } from '../../types/domain'
|
||||
import { TECHNIQUES } from '../../data/techniques'
|
||||
import { describeRealm } from '../../data/realms'
|
||||
import { aspirationById } from '../../data/aspirations'
|
||||
import { postById } from '../../data/posts'
|
||||
|
||||
export interface BioLine {
|
||||
at?: number
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
import { Character } from '../types/domain'
|
||||
import type { World } from '../engine/world'
|
||||
import { Character } from '../../types/domain'
|
||||
import type { World } from '../runtime/World'
|
||||
|
||||
export interface FamilyUnit {
|
||||
parents: [Character | undefined, Character | undefined]
|
||||
@@ -1,5 +1,5 @@
|
||||
import { GameState } from '../types/domain'
|
||||
import { MAJOR_ORDER } from '../data/realms'
|
||||
import { GameState } from '../../types/domain'
|
||||
import { MAJOR_ORDER } from '../../data/realms'
|
||||
|
||||
export interface LegacyDims {
|
||||
renXing: number
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { GameState } from '../types/domain'
|
||||
import { GameState } from '../../types/domain'
|
||||
|
||||
export interface LegacyReport {
|
||||
years: number[]
|
||||
@@ -1,4 +1,4 @@
|
||||
import { GameState } from '../types/domain'
|
||||
import { GameState } from '../../types/domain'
|
||||
|
||||
export interface AxisEvent {
|
||||
year: number
|
||||
@@ -1,14 +1,14 @@
|
||||
import type { World } from './world'
|
||||
import { WorldEventBus } from './world'
|
||||
import { YearlyReport, BattleLog, ChronicleEntry, SaveMeta } from '../types/domain'
|
||||
import { marketPrice, buyItem, sellItem, buyTechnique } from './market'
|
||||
import { sendMission, recallAll } from './systems/missions'
|
||||
import { giftNpc, makePeace, marryNpcFamily } from './systems/diplomacy'
|
||||
import { combatPowerOf } from './systems/combat'
|
||||
import type { LogKind } from './world'
|
||||
import { computeLegacy, resolveLegacy, LegacyArch } from '../core/legacy'
|
||||
import { yearAxis, AxisCell } from '../core/yearaxis'
|
||||
import { PACK } from '../data/registry'
|
||||
import type { World } from './World'
|
||||
import { WorldEventBus } from './World'
|
||||
import { YearlyReport, BattleLog, ChronicleEntry, SaveMeta } from '../../types/domain'
|
||||
import { marketPrice, buyItem, sellItem, buyTechnique } from '../sim/Market'
|
||||
import { sendMission, recallAll } from './Systems/missions'
|
||||
import { giftNpc, makePeace, marryNpcFamily } from './Systems/diplomacy'
|
||||
import { combatPowerOf } from './Systems/combat'
|
||||
import type { LogKind } from './World'
|
||||
import { computeLegacy, resolveLegacy, LegacyArch } from '../narrative/legacy'
|
||||
import { yearAxis, AxisCell } from '../narrative/yearaxis'
|
||||
import { PACK } from '../../data/registry'
|
||||
|
||||
export type ActName =
|
||||
| 'head.set'
|
||||
+9
-9
@@ -1,14 +1,14 @@
|
||||
import type { World } from '../world'
|
||||
import { Character, BattleLog } from '../../types/domain'
|
||||
import { basePower, describeRealm } from '../../data/realms'
|
||||
import { pack } from '../../data/registry'
|
||||
import { techniqueById } from '../../data/techniques'
|
||||
import { EnemyDef, LootDef } from '../../data/secrets'
|
||||
import type { World } from '../World'
|
||||
import { Character, BattleLog } from '../../../types/domain'
|
||||
import { basePower, describeRealm } from '../../../data/realms'
|
||||
import { pack } from '../../../data/registry'
|
||||
import { techniqueById } from '../../../data/techniques'
|
||||
import { EnemyDef, LootDef } from '../../../data/secrets'
|
||||
|
||||
import { traitBonuses } from '../pcgen'
|
||||
import { npcById } from '../../data/npcs'
|
||||
import { aspirationById, fitBonusOf } from '../../data/aspirations'
|
||||
import { formationById, FormationId } from '../../data/formations'
|
||||
import { npcById } from '../../../data/npcs'
|
||||
import { aspirationById, fitBonusOf } from '../../../data/aspirations'
|
||||
import { formationById, FormationId } from '../../../data/formations'
|
||||
|
||||
export function combatPowerOf(w: World, c: Character): number {
|
||||
if (!c.alive) return 0
|
||||
+10
-10
@@ -1,16 +1,16 @@
|
||||
import type { World } from '../world'
|
||||
import { Character } from '../../types/domain'
|
||||
import { ROOT_GRADES } from '../../data/elements'
|
||||
import { masteryRateOfMajor } from '../../data/pacing'
|
||||
import { aspirationById, fitBonusOf } from '../../data/aspirations'
|
||||
import { techniqueById } from '../../data/techniques'
|
||||
import { nextRealm, breakthroughBaseChance, realmDeathChance, describeRealm, MAJOR_ORDER } from '../../data/realms'
|
||||
import type { World } from '../World'
|
||||
import { Character } from '../../../types/domain'
|
||||
import { ROOT_GRADES } from '../../../data/elements'
|
||||
import { masteryRateOfMajor } from '../../../data/pacing'
|
||||
import { aspirationById, fitBonusOf } from '../../../data/aspirations'
|
||||
import { techniqueById } from '../../../data/techniques'
|
||||
import { nextRealm, breakthroughBaseChance, realmDeathChance, describeRealm, MAJOR_ORDER } from '../../../data/realms'
|
||||
import { lifespanOf } from './lifecycle'
|
||||
import { traitBonuses } from '../pcgen'
|
||||
import { newCharacter } from '../pcgen'
|
||||
import { MALE_GIVEN, FEMALE_GIVEN } from '../../core/names'
|
||||
import { ASPIRATION_IDS } from '../../data/aspirations'
|
||||
import { seasonMod } from '../../data/season'
|
||||
import { MALE_GIVEN, FEMALE_GIVEN } from '../../kernel/names'
|
||||
import { ASPIRATION_IDS } from '../../../data/aspirations'
|
||||
import { seasonMod } from '../../../data/season'
|
||||
import { needsTribulation, tribulationEventId } from './tribulation'
|
||||
|
||||
export function monthlyRate(w: World, c: Character): number {
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
import type { World } from '../world'
|
||||
import { npcById } from '../../data/npcs'
|
||||
import type { World } from '../World'
|
||||
import { npcById } from '../../../data/npcs'
|
||||
import { findEvent, fire } from './events'
|
||||
|
||||
export function diplomacyTick(w: World): void {
|
||||
+7
-7
@@ -1,16 +1,16 @@
|
||||
import type { World } from '../world'
|
||||
import { Character } from '../../types/domain'
|
||||
import { Cond, EffectDef, EventDef, EVENTS, MemberEffect } from '../../data/events'
|
||||
import { MAJOR_ORDER } from '../../data/realms'
|
||||
import type { World } from '../World'
|
||||
import { Character } from '../../../types/domain'
|
||||
import { Cond, EffectDef, EventDef, EVENTS, MemberEffect } from '../../../data/events'
|
||||
import { MAJOR_ORDER } from '../../../data/realms'
|
||||
|
||||
|
||||
import { npcById } from '../../data/npcs'
|
||||
import { npcById } from '../../../data/npcs'
|
||||
import { resolveRaid } from './combat'
|
||||
import { sendMission } from './missions'
|
||||
import { pack } from '../../data/registry'
|
||||
import { pack } from '../../../data/registry'
|
||||
import { findInheritor } from '../creation'
|
||||
import { resolveTribulation } from './tribulation'
|
||||
import { nextRealm, describeRealm } from '../../data/realms'
|
||||
import { nextRealm, describeRealm } from '../../../data/realms'
|
||||
|
||||
const ALL_EVENTS: EventDef[] = [...EVENTS]
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
import type { World } from '../world'
|
||||
import { MAJORS } from '../../data/realms'
|
||||
import type { World } from '../World'
|
||||
import { MAJORS } from '../../../data/realms'
|
||||
import { calcLifespan } from '../pcgen'
|
||||
|
||||
export function lifespanOf(w: World, c: { realm: { major: keyof typeof MAJORS }; physique: number }): number {
|
||||
+4
-4
@@ -1,9 +1,9 @@
|
||||
import type { World } from '../world'
|
||||
import { Character } from '../../types/domain'
|
||||
import type { World } from '../World'
|
||||
import { Character } from '../../../types/domain'
|
||||
import { produceOffspring } from './cultivation'
|
||||
import { yearGrowth } from './diplomacy'
|
||||
import { MALE_GIVEN, FEMALE_GIVEN } from '../../core/names'
|
||||
import { aspirationById } from '../../data/aspirations'
|
||||
import { MALE_GIVEN, FEMALE_GIVEN } from '../../kernel/names'
|
||||
import { aspirationById } from '../../../data/aspirations'
|
||||
|
||||
export function yearStartMarriage(w: World): void {
|
||||
yearGrowth(w)
|
||||
+6
-6
@@ -1,10 +1,10 @@
|
||||
import type { World } from '../world'
|
||||
import { MissionState } from '../../types/domain'
|
||||
import { FormationId } from '../../data/formations'
|
||||
import { missionById, MissionDef, ENEMIES } from '../../data/secrets'
|
||||
import type { World } from '../World'
|
||||
import { MissionState } from '../../../types/domain'
|
||||
import { FormationId } from '../../../data/formations'
|
||||
import { missionById, MissionDef, ENEMIES } from '../../../data/secrets'
|
||||
import { resolveEncounter, rollWarbooty } from './combat'
|
||||
import { techniqueById } from '../../data/techniques'
|
||||
import { describeRealm } from '../../data/realms'
|
||||
import { techniqueById } from '../../../data/techniques'
|
||||
import { describeRealm } from '../../../data/realms'
|
||||
|
||||
export function missionTick(w: World): void {
|
||||
const active = w.state.missions.filter((m) => !m.done)
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
import type { World } from '../world'
|
||||
import { aspirationById } from '../../data/aspirations'
|
||||
import { seasonMod } from '../../data/season'
|
||||
import type { World } from '../World'
|
||||
import { aspirationById } from '../../../data/aspirations'
|
||||
import { seasonMod } from '../../../data/season'
|
||||
|
||||
export function productionTick(w: World): void {
|
||||
const fam = w.state.family
|
||||
+4
-4
@@ -1,10 +1,10 @@
|
||||
import type { World } from '../world'
|
||||
import { Character } from '../../types/domain'
|
||||
import { ENEMIES, EnemyDef } from '../../data/secrets'
|
||||
import type { World } from '../World'
|
||||
import { Character } from '../../../types/domain'
|
||||
import { ENEMIES, EnemyDef } from '../../../data/secrets'
|
||||
import { resolveEncounter } from './combat'
|
||||
import { rankPower } from './events'
|
||||
import { resolveBreakthrough } from './cultivation'
|
||||
import { FormationId } from '../../data/formations'
|
||||
import { FormationId } from '../../../data/formations'
|
||||
|
||||
export const SECTS = ['云栖宗', '太谷书院', '玄微剑阁', '丹霞洞天']
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
import type { World } from '../world'
|
||||
import { Character } from '../../types/domain'
|
||||
import { nextRealm, MAJOR_ORDER, realmDeathChance, describeRealm } from '../../data/realms'
|
||||
import type { World } from '../World'
|
||||
import { Character } from '../../../types/domain'
|
||||
import { nextRealm, MAJOR_ORDER, realmDeathChance, describeRealm } from '../../../data/realms'
|
||||
|
||||
export const TRIB_MAJORS: string[] = ['foundation', 'core', 'nascent', 'spirit']
|
||||
|
||||
@@ -7,25 +7,25 @@ import {
|
||||
LogItem,
|
||||
Realm,
|
||||
YearlyReport
|
||||
} from '../types/domain'
|
||||
import { Rng } from '../core/rng'
|
||||
import { BUILDINGS } from '../data/buildings'
|
||||
import { POSTS } from '../data/posts'
|
||||
import { aspirationById as aspirationOf } from '../data/aspirations'
|
||||
import { computeLegacy, resolveLegacy, peakRealmIndex, grandTechniqueCount, LegacyArch } from '../core/legacy'
|
||||
} from '../../types/domain'
|
||||
import { Rng } from '../kernel/rng'
|
||||
import { BUILDINGS } from '../../data/buildings'
|
||||
import { POSTS } from '../../data/posts'
|
||||
import { aspirationById as aspirationOf } from '../../data/aspirations'
|
||||
import { computeLegacy, resolveLegacy, peakRealmIndex, grandTechniqueCount, LegacyArch } from '../narrative/legacy'
|
||||
import { createWorldState, findInheritor } from './creation'
|
||||
import { SYSTEM_DEFS, SystemDef } from './capabilities'
|
||||
import { emptyClock } from './clocks'
|
||||
import { CotycPlugin, PluginContext, PluginStatus } from '../core/plugin'
|
||||
import { CotycPlugin, PluginContext, PluginStatus } from '../kernel/plugin'
|
||||
import { PluginManager } from './pluginManager'
|
||||
import { EventDef } from '../data/events'
|
||||
import { pack, DEFAULT_PACK, PACK } from '../data/registry'
|
||||
import { EventDef } from '../../data/events'
|
||||
import { pack, DEFAULT_PACK, PACK } from '../../data/registry'
|
||||
import { CORE_PLUGINS } from './plugin-bootstrap'
|
||||
import { GameClock } from '../core/clock'
|
||||
import { SystemHook } from '../core/clock'
|
||||
import { resolveBreakthrough } from './systems/cultivation'
|
||||
import { applyEventChoice } from './systems/events'
|
||||
import { combatPowerOf } from './systems/combat'
|
||||
import { GameClock } from '../kernel/clock'
|
||||
import { SystemHook } from '../kernel/clock'
|
||||
import { resolveBreakthrough } from './Systems/cultivation'
|
||||
import { applyEventChoice } from './Systems/events'
|
||||
import { combatPowerOf } from './Systems/combat'
|
||||
|
||||
export type LogKind = LogItem['kind']
|
||||
|
||||
@@ -138,7 +138,7 @@ export class World {
|
||||
}
|
||||
}
|
||||
|
||||
private packOverride(partial: Partial<import('../data/registry').DataPack>): void {
|
||||
private packOverride(partial: Partial<import('../../data/registry').DataPack>): void {
|
||||
PACK.override(partial)
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import type { PhaseId } from '../core/clock'
|
||||
import type { PhaseId } from '../kernel/clock'
|
||||
|
||||
export interface SystemDef {
|
||||
id: string
|
||||
@@ -1,13 +1,13 @@
|
||||
import { GameClock } from '../core/clock'
|
||||
import { PluginContext } from '../core/plugin'
|
||||
import type { World } from './world'
|
||||
import { productionTick } from './systems/production'
|
||||
import { deathTick, woundHealTick } from './systems/lifecycle'
|
||||
import { cultivationTick } from './systems/cultivation'
|
||||
import { missionTick } from './systems/missions'
|
||||
import { eventRoll } from './systems/events'
|
||||
import { diplomacyTick } from './systems/diplomacy'
|
||||
import { yearStartMarriage } from './systems/marriage'
|
||||
import { GameClock } from '../kernel/clock'
|
||||
import { PluginContext } from '../kernel/plugin'
|
||||
import type { World } from './World'
|
||||
import { productionTick } from './Systems/production'
|
||||
import { deathTick, woundHealTick } from './Systems/lifecycle'
|
||||
import { cultivationTick } from './Systems/cultivation'
|
||||
import { missionTick } from './Systems/missions'
|
||||
import { eventRoll } from './Systems/events'
|
||||
import { diplomacyTick } from './Systems/diplomacy'
|
||||
import { yearStartMarriage } from './Systems/marriage'
|
||||
|
||||
/** 原语义保留:满门凋零后仅存生产/寿元与收尾 */
|
||||
function ifAlive(fn: (w: World) => void): (w: World) => void {
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Character, GameState, NpcFamilyState, RealmMajor } from '../types/domain'
|
||||
import { Rng, seedToRng } from '../core/rng'
|
||||
import { randomSurname, MALE_GIVEN, FEMALE_GIVEN } from '../core/names'
|
||||
import { Character, GameState, NpcFamilyState, RealmMajor } from '../../types/domain'
|
||||
import { Rng, seedToRng } from '../kernel/rng'
|
||||
import { randomSurname, MALE_GIVEN, FEMALE_GIVEN } from '../kernel/names'
|
||||
import { newCharacter } from './pcgen'
|
||||
import { NPCS } from '../data/npcs'
|
||||
import { World } from './world'
|
||||
import { NPCS } from '../../data/npcs'
|
||||
import { World } from './World'
|
||||
|
||||
export interface NewGameOptions {
|
||||
seed: string
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { CotycPlugin } from '../core/plugin'
|
||||
import { CotycPlugin } from '../kernel/plugin'
|
||||
|
||||
/** 示例内容插件:注入事件池 + 一个护山能力(开发范本) */
|
||||
export const examplePlugin: CotycPlugin = {
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Character, Element, Gender, Realm, RealmMajor } from '../types/domain'
|
||||
import { Rng } from '../core/rng'
|
||||
import { ELEMENT_LIST, ROOT_GRADES } from '../data/elements'
|
||||
import { MAJORS } from '../data/realms'
|
||||
import { TRAIT_POOL, TRAITS } from '../data/traits'
|
||||
import { Character, Element, Gender, Realm, RealmMajor } from '../../types/domain'
|
||||
import { Rng } from '../kernel/rng'
|
||||
import { ELEMENT_LIST, ROOT_GRADES } from '../../data/elements'
|
||||
import { MAJORS } from '../../data/realms'
|
||||
import { TRAIT_POOL, TRAITS } from '../../data/traits'
|
||||
|
||||
export function rollRoots(rng: Rng, parents?: { m?: Character; f?: Character }): { grade: number; primary: Element; secondary: Element[] } {
|
||||
let grade: number
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
import { CotycPlugin } from '../core/plugin'
|
||||
import { CotycPlugin } from '../kernel/plugin'
|
||||
import { installCoreSystems } from './clocks'
|
||||
import { EVENTS } from '../data/events'
|
||||
import { DEFAULT_PACK } from '../data/registry'
|
||||
import { EVENTS } from '../../data/events'
|
||||
import { DEFAULT_PACK } from '../../data/registry'
|
||||
|
||||
/** 内置插件一:镇族基石(12 能力卡与时轮钩子) */
|
||||
export function makeCoreSystemsPlugin(): CotycPlugin {
|
||||
+5
-5
@@ -1,8 +1,8 @@
|
||||
import { CotycPlugin, PluginContext, PluginStatus, PluginChange } from '../core/plugin'
|
||||
import { SystemDef, SYSTEM_DEFS } from '../engine/capabilities'
|
||||
import type { World } from '../engine/world'
|
||||
import { SystemHook } from '../core/clock'
|
||||
import { GameClock } from '../core/clock'
|
||||
import { CotycPlugin, PluginContext, PluginStatus, PluginChange } from '../kernel/plugin'
|
||||
import { SystemDef, SYSTEM_DEFS } from './capabilities'
|
||||
import type { World } from './World'
|
||||
import { SystemHook } from '../kernel/clock'
|
||||
import { GameClock } from '../kernel/clock'
|
||||
|
||||
interface RuntimePlugin {
|
||||
plugin: CotycPlugin
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { World } from './world'
|
||||
import { pack } from '../data/registry'
|
||||
import { traitBonuses } from './pcgen'
|
||||
import type { World } from '../runtime/World'
|
||||
import { pack } from '../../data/registry'
|
||||
import { traitBonuses } from '../runtime/pcgen'
|
||||
|
||||
export function marketPrice(w: World, itemId: string): number {
|
||||
const item = pack().items[itemId]
|
||||
@@ -48,7 +48,7 @@ export function techniquePrice(techId: string): number {
|
||||
return TECH_GRADE_BASE[techId] ?? 200
|
||||
}
|
||||
|
||||
import { TECHNIQUES } from '../data/techniques'
|
||||
import { TECHNIQUES } from '../../data/techniques'
|
||||
|
||||
const TECHNIQUE_GRADE_PRICE: Record<number, number> = { 1: 120, 2: 300, 3: 700, 4: 1600 }
|
||||
const TECH_GRADE_BASE: Record<string, number> = Object.fromEntries(
|
||||
@@ -1,5 +1,5 @@
|
||||
import { GameState } from '../types/domain'
|
||||
import { normalizeGameState } from '../engine/world'
|
||||
import { normalizeGameState } from '../engine/runtime/World'
|
||||
|
||||
export const CURRENT_SCHEMA = 2
|
||||
export const APP_ID = 'cotyc'
|
||||
|
||||
Reference in New Issue
Block a user