From 5d5ed9ee2a87ece652068cd50e83c23b6a80d10e Mon Sep 17 00:00:00 2001 From: Hide_D Date: Sun, 25 Jan 2026 05:48:56 +0000 Subject: [PATCH] feat: add killturn to general meta and update related tests - Introduced a new meta property `killturn` to the GeneralMeta interface. - Implemented a function `readMetaNumber` to handle the retrieval of numeric values from meta. - Updated the `mapGeneralRow` function to ensure `killturn` is required and properly handled. - Modified various tests to include the `killturn` property in the general's meta data. - Adjusted related action files to utilize the new GeneralMeta type for better type safety. - Ensured backward compatibility by updating existing test cases across multiple scenarios. --- app/game-api/src/battleSim/processor.ts | 1 + app/game-api/src/turns/commandTable.ts | 24 +++++++++++++++- app/game-engine/src/turn/worldLoader.ts | 24 +++++++++++++++- .../test/nationCollapseOnConquest.test.ts | 2 +- .../test/npcNationGrowthScenario.test.ts | 2 +- .../test/npcNationTechResearch.test.ts | 2 +- .../test/npcNationUprisingUnification.test.ts | 2 +- .../test/npcNationWarDeclaration.test.ts | 2 +- app/game-engine/test/npcWarPrepTurns.test.ts | 2 +- .../test/reservedTurnExecution.test.ts | 16 +++++------ app/game-engine/test/turnOrder.test.ts | 2 +- .../src/actions/turn/general/che_상업투자.ts | 4 +-- .../src/actions/turn/general/che_인재탐색.ts | 18 +++++++----- .../src/actions/turn/general/che_주민선정.ts | 4 +-- .../src/actions/turn/general/che_징병.ts | 8 ++---- .../src/actions/turn/general/che_화계.ts | 15 ++++++---- .../src/actions/turn/general/recruitment.ts | 6 ++-- .../logic/src/actions/turn/nation/che_발령.ts | 14 ++++++---- .../src/actions/turn/nation/che_의병모집.ts | 7 +++-- packages/logic/src/domain/entities.ts | 6 +++- packages/logic/src/economy/nationIncome.ts | 2 +- packages/logic/src/world/bootstrap.ts | 13 +++++++-- .../actions/instant/nationStopWar.test.ts | 2 +- .../logic/test/actions/turn/nation.test.ts | 2 +- .../test/actions/turn/nationMissing.test.ts | 2 +- packages/logic/test/crewType.test.ts | 2 +- packages/logic/test/dispatchWarAction.test.ts | 2 +- .../logic/test/scenarios/diplomacy.test.ts | 2 +- .../logic/test/scenarios/domestic.test.ts | 4 +-- .../scenarios/general/che_NPC능동.test.ts | 4 +-- .../test/scenarios/general/che_강행.test.ts | 12 ++++---- .../test/scenarios/general/che_귀환.test.ts | 16 +++++------ .../scenarios/general/che_등용수락.test.ts | 28 +++++++++---------- .../test/scenarios/general/che_이동.test.ts | 2 +- .../scenarios/general_commands_new.test.ts | 2 +- packages/logic/test/scenarios/troops.test.ts | 2 +- packages/logic/test/specialActions.test.ts | 2 +- packages/logic/test/warAftermath.test.ts | 2 +- packages/logic/test/warEngine.test.ts | 1 + 39 files changed, 164 insertions(+), 99 deletions(-) diff --git a/app/game-api/src/battleSim/processor.ts b/app/game-api/src/battleSim/processor.ts index 345bd05..b806a89 100644 --- a/app/game-api/src/battleSim/processor.ts +++ b/app/game-api/src/battleSim/processor.ts @@ -122,6 +122,7 @@ const mapGeneralPayload = (payload: BattleSimJobPayload['attackerGeneral']): Gen meta: payload.inheritBuff ? { inheritBuff: JSON.stringify(payload.inheritBuff) } : {}, }, meta: { + killturn: 24, explevel: payload.explevel, turnTime: payload.turntime, recentWar: payload.recent_war ?? '', diff --git a/app/game-api/src/turns/commandTable.ts b/app/game-api/src/turns/commandTable.ts index b280513..36a2372 100644 --- a/app/game-api/src/turns/commandTable.ts +++ b/app/game-api/src/turns/commandTable.ts @@ -77,6 +77,28 @@ const DEFAULT_CREW_TYPE_ID = 1100; const asTriggerRecord = (value: unknown): Record => isRecord(value) ? (value as Record) : {}; +const readMetaNumber = (meta: Record, key: string): number | null => { + const value = meta[key]; + if (typeof value === 'number' && Number.isFinite(value)) { + return value; + } + if (typeof value === 'string') { + const parsed = Number(value); + if (Number.isFinite(parsed)) { + return parsed; + } + } + return null; +}; + +const ensureGeneralMeta = (meta: Record, generalId: number): General['meta'] => { + const killturn = readMetaNumber(meta, 'killturn'); + if (killturn === null) { + throw new Error(`general.meta.killturn is required (generalId=${generalId}).`); + } + return { ...meta, killturn } as General['meta']; +}; + const normalizeCode = (value: string | null | undefined): string | null => { if (!value || value === 'None') { return null; @@ -238,7 +260,7 @@ const mapGeneralRow = (row: GeneralRow): General => ({ modifiers: {}, meta: {}, }, - meta: asTriggerRecord(row.meta), + meta: ensureGeneralMeta(asTriggerRecord(row.meta), row.id), }); const mapCityRow = (row: CityRow): City => { diff --git a/app/game-engine/src/turn/worldLoader.ts b/app/game-engine/src/turn/worldLoader.ts index 24f8b60..ef05b2a 100644 --- a/app/game-engine/src/turn/worldLoader.ts +++ b/app/game-engine/src/turn/worldLoader.ts @@ -38,6 +38,20 @@ const normalizeCode = (value: string | null | undefined): string | null => { return value; }; +const readMetaNumber = (meta: Record, key: string): number | null => { + const value = meta[key]; + if (typeof value === 'number' && Number.isFinite(value)) { + return value; + } + if (typeof value === 'string') { + const parsed = Number(value); + if (Number.isFinite(parsed)) { + return parsed; + } + } + return null; +}; + const zScenarioStatBlock = z.object({ total: z.number(), min: z.number(), @@ -120,6 +134,14 @@ const mapScenarioConfig = (raw: JsonValue): ScenarioConfig => { }; const mapGeneralRow = (row: TurnEngineGeneralRow): TurnGeneral => ({ + ...((): { meta: TurnGeneral['meta'] } => { + const meta = asTriggerRecord(row.meta) as Record; + const killturn = readMetaNumber(meta, 'killturn'); + if (killturn === null) { + throw new Error(`general.meta.killturn is required (generalId=${row.id}).`); + } + return { meta: { ...meta, killturn } as TurnGeneral['meta'] }; + })(), id: row.id, name: row.name, nationId: row.nationId, @@ -159,7 +181,7 @@ const mapGeneralRow = (row: TurnEngineGeneralRow): TurnGeneral => ({ modifiers: {}, meta: {}, }, - meta: asTriggerRecord(row.meta), + // meta는 상단에서 보장 처리됨. turnTime: row.turnTime, recentWarTime: row.recentWarTime ?? null, }); diff --git a/app/game-engine/test/nationCollapseOnConquest.test.ts b/app/game-engine/test/nationCollapseOnConquest.test.ts index 77872da..5111783 100644 --- a/app/game-engine/test/nationCollapseOnConquest.test.ts +++ b/app/game-engine/test/nationCollapseOnConquest.test.ts @@ -30,7 +30,7 @@ const createNpcGeneral = ( specialWar: null, }, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: {}, + meta: { killturn: 800 }, officerLevel, experience: 0, dedication: 0, diff --git a/app/game-engine/test/npcNationGrowthScenario.test.ts b/app/game-engine/test/npcNationGrowthScenario.test.ts index d4dd802..5683efa 100644 --- a/app/game-engine/test/npcNationGrowthScenario.test.ts +++ b/app/game-engine/test/npcNationGrowthScenario.test.ts @@ -40,7 +40,7 @@ const createNpcGeneral = ( specialWar: null, }, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: {}, + meta: { killturn: 800 }, officerLevel: 1, experience: 0, dedication: 0, diff --git a/app/game-engine/test/npcNationTechResearch.test.ts b/app/game-engine/test/npcNationTechResearch.test.ts index 26eb8ae..1eeff69 100644 --- a/app/game-engine/test/npcNationTechResearch.test.ts +++ b/app/game-engine/test/npcNationTechResearch.test.ts @@ -30,7 +30,7 @@ const createNpcGeneral = ( specialWar: null, }, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: {}, + meta: { killturn: 800 }, officerLevel, experience: 0, dedication: 0, diff --git a/app/game-engine/test/npcNationUprisingUnification.test.ts b/app/game-engine/test/npcNationUprisingUnification.test.ts index b613970..305edb1 100644 --- a/app/game-engine/test/npcNationUprisingUnification.test.ts +++ b/app/game-engine/test/npcNationUprisingUnification.test.ts @@ -27,7 +27,7 @@ const createNpcGeneral = ( specialWar: null, }, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: {}, + meta: { killturn: 800 }, officerLevel: 1, experience: 0, dedication: 0, diff --git a/app/game-engine/test/npcNationWarDeclaration.test.ts b/app/game-engine/test/npcNationWarDeclaration.test.ts index 6a44056..616fe94 100644 --- a/app/game-engine/test/npcNationWarDeclaration.test.ts +++ b/app/game-engine/test/npcNationWarDeclaration.test.ts @@ -29,7 +29,7 @@ const createNpcGeneral = ( specialWar: null, }, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: {}, + meta: { killturn: 800 }, officerLevel, experience: 0, dedication: 0, diff --git a/app/game-engine/test/npcWarPrepTurns.test.ts b/app/game-engine/test/npcWarPrepTurns.test.ts index 788a28d..db50701 100644 --- a/app/game-engine/test/npcWarPrepTurns.test.ts +++ b/app/game-engine/test/npcWarPrepTurns.test.ts @@ -28,7 +28,7 @@ const createNpcGeneral = ( specialWar: null, }, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: {}, + meta: { killturn: 800 }, officerLevel, experience: 0, dedication: 0, diff --git a/app/game-engine/test/reservedTurnExecution.test.ts b/app/game-engine/test/reservedTurnExecution.test.ts index 60ed52e..d1fa7c5 100644 --- a/app/game-engine/test/reservedTurnExecution.test.ts +++ b/app/game-engine/test/reservedTurnExecution.test.ts @@ -93,7 +93,7 @@ describe('Reserved Turn Execution Integration', () => { specialWar: null, }, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: {}, + meta: { killturn: 800 }, officerLevel: 5, experience: 0, dedication: 0, @@ -122,7 +122,7 @@ describe('Reserved Turn Execution Integration', () => { specialWar: null, }, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: {}, + meta: { killturn: 800 }, officerLevel: 5, experience: 0, dedication: 0, @@ -340,7 +340,7 @@ describe('Reserved Turn Execution Integration', () => { specialWar: null, }, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: {}, + meta: { killturn: 800 }, officerLevel: 5, experience: 0, dedication: 0, @@ -480,7 +480,7 @@ describe('Reserved Turn Execution Integration', () => { specialWar: null, }, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: {}, + meta: { killturn: 800 }, officerLevel: 5, experience: 0, dedication: 0, @@ -646,7 +646,7 @@ describe('Reserved Turn Execution Integration', () => { specialWar: null, }, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: {}, + meta: { killturn: 24 }, officerLevel: 5, experience: 0, dedication: 0, @@ -675,7 +675,7 @@ describe('Reserved Turn Execution Integration', () => { specialWar: null, }, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: {}, + meta: { killturn: 24 }, officerLevel: 5, experience: 0, dedication: 0, @@ -947,7 +947,7 @@ describe('Reserved Turn Execution Integration', () => { specialWar: null, }, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: {}, + meta: { killturn: 24 }, officerLevel: 5, experience: 0, dedication: 0, @@ -976,7 +976,7 @@ describe('Reserved Turn Execution Integration', () => { specialWar: null, }, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: {}, + meta: { killturn: 24 }, officerLevel: 5, experience: 0, dedication: 0, diff --git a/app/game-engine/test/turnOrder.test.ts b/app/game-engine/test/turnOrder.test.ts index 555c066..0800080 100644 --- a/app/game-engine/test/turnOrder.test.ts +++ b/app/game-engine/test/turnOrder.test.ts @@ -21,7 +21,7 @@ const buildGeneral = (id: number, turnTime: Date): TurnGeneral => ({ specialWar: null, }, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: {}, + meta: { killturn: 24 }, officerLevel: 5, experience: 0, dedication: 0, diff --git a/packages/logic/src/actions/turn/general/che_상업투자.ts b/packages/logic/src/actions/turn/general/che_상업투자.ts index 45e1caa..a8c4598 100644 --- a/packages/logic/src/actions/turn/general/che_상업투자.ts +++ b/packages/logic/src/actions/turn/general/che_상업투자.ts @@ -1,5 +1,5 @@ import type { RandomGenerator } from '@sammo-ts/common'; -import type { City, General, GeneralTriggerState, Nation } from '@sammo-ts/logic/domain/entities.js'; +import type { City, General, GeneralMeta, GeneralTriggerState, Nation } from '@sammo-ts/logic/domain/entities.js'; import type { Constraint, ConstraintContext, RequirementKey, StateView } from '@sammo-ts/logic/constraints/types.js'; import { notBeNeutral, @@ -85,7 +85,7 @@ const pickByWeight = (rng: RandomGenerator, weights: Record, key: string, delta: number): Record => { +const addMetaNumber = (meta: GeneralMeta, key: string, delta: number): GeneralMeta => { const current = getMetaNumber(meta, key) ?? 0; return { ...meta, [key]: current + delta }; }; diff --git a/packages/logic/src/actions/turn/general/che_인재탐색.ts b/packages/logic/src/actions/turn/general/che_인재탐색.ts index 22cd06e..9599575 100644 --- a/packages/logic/src/actions/turn/general/che_인재탐색.ts +++ b/packages/logic/src/actions/turn/general/che_인재탐색.ts @@ -1,5 +1,12 @@ import type { RandomGenerator } from '@sammo-ts/common'; -import type { City, General, GeneralTriggerState, StatBlock, TriggerValue } from '@sammo-ts/logic/domain/entities.js'; +import type { + City, + General, + GeneralMeta, + GeneralTriggerState, + StatBlock, + TriggerValue, +} from '@sammo-ts/logic/domain/entities.js'; import type { Constraint, ConstraintContext } from '@sammo-ts/logic/constraints/types.js'; import { reqGeneralGold, reqGeneralRice } from '@sammo-ts/logic/constraints/presets.js'; import { GeneralActionPipeline, type GeneralActionModule } from '@sammo-ts/logic/triggers/general-action.js'; @@ -90,11 +97,7 @@ const addMetaValue = ( meta[key] = value; }; -const addMetaNumber = ( - meta: Record, - key: StatExpKey, - delta: number -): Record => { +const addMetaNumber = (meta: GeneralMeta, key: StatExpKey, delta: number): GeneralMeta => { const current = typeof meta[key] === 'number' ? (meta[key] as number) : 0; return { ...meta, [key]: current + delta }; }; @@ -298,7 +301,8 @@ export class ActionResolver< const name = this.env.decorateName ? this.env.decorateName(resolvedCandidate.name, NPC_TYPE) : resolvedCandidate.name; - const meta: Record = { + const meta: GeneralMeta = { + killturn: context.general.meta.killturn, npcType: NPC_TYPE, crewTypeId: this.env.defaultCrewTypeId, }; diff --git a/packages/logic/src/actions/turn/general/che_주민선정.ts b/packages/logic/src/actions/turn/general/che_주민선정.ts index 80d8546..78003a8 100644 --- a/packages/logic/src/actions/turn/general/che_주민선정.ts +++ b/packages/logic/src/actions/turn/general/che_주민선정.ts @@ -1,5 +1,5 @@ import type { RandomGenerator } from '@sammo-ts/common'; -import type { City, General, GeneralTriggerState, Nation } from '@sammo-ts/logic/domain/entities.js'; +import type { City, General, GeneralMeta, GeneralTriggerState, Nation } from '@sammo-ts/logic/domain/entities.js'; import type { Constraint, ConstraintContext, RequirementKey } from '@sammo-ts/logic/constraints/types.js'; import { notBeNeutral, @@ -42,7 +42,7 @@ const getMetaNumber = (meta: Record, key: string): number | nul return typeof raw === 'number' ? raw : null; }; -const addMetaNumber = (meta: Record, key: string, delta: number): Record => { +const addMetaNumber = (meta: GeneralMeta, key: string, delta: number): GeneralMeta => { const current = getMetaNumber(meta, key) ?? 0; return { ...meta, [key]: current + delta }; }; diff --git a/packages/logic/src/actions/turn/general/che_징병.ts b/packages/logic/src/actions/turn/general/che_징병.ts index dee3052..47e3e11 100644 --- a/packages/logic/src/actions/turn/general/che_징병.ts +++ b/packages/logic/src/actions/turn/general/che_징병.ts @@ -1,4 +1,4 @@ -import type { City, General, GeneralTriggerState, Nation, TriggerValue } from '@sammo-ts/logic/domain/entities.js'; +import type { City, General, GeneralMeta, GeneralTriggerState, Nation } from '@sammo-ts/logic/domain/entities.js'; import type { Constraint, ConstraintContext, RequirementKey, StateView } from '@sammo-ts/logic/constraints/types.js'; import { notBeNeutral, @@ -105,11 +105,7 @@ const readCityTrust = (city: City, fallback: number): number => { return typeof trust === 'number' ? trust : fallback; }; -const addMetaNumber = ( - meta: Record, - key: string, - delta: number -): Record => { +const addMetaNumber = (meta: GeneralMeta, key: string, delta: number): GeneralMeta => { const current = typeof meta[key] === 'number' ? (meta[key] as number) : 0; return { ...meta, [key]: current + delta }; }; diff --git a/packages/logic/src/actions/turn/general/che_화계.ts b/packages/logic/src/actions/turn/general/che_화계.ts index 3a284bb..3405f9c 100644 --- a/packages/logic/src/actions/turn/general/che_화계.ts +++ b/packages/logic/src/actions/turn/general/che_화계.ts @@ -1,5 +1,12 @@ import type { RandomGenerator } from '@sammo-ts/common'; -import type { City, General, GeneralTriggerState, Nation, TriggerValue } from '@sammo-ts/logic/domain/entities.js'; +import type { + City, + General, + GeneralMeta, + GeneralTriggerState, + Nation, + TriggerValue, +} from '@sammo-ts/logic/domain/entities.js'; import type { Constraint, ConstraintContext } from '@sammo-ts/logic/constraints/types.js'; import { disallowDiplomacyBetweenStatus, @@ -103,11 +110,7 @@ const getStatValue = (general: General, statKey: 'leadership' | 'strength' | 'in return general.stats.intelligence; }; -const addMetaNumber = ( - meta: Record, - key: string, - delta: number -): Record => { +const addMetaNumber = (meta: GeneralMeta, key: string, delta: number): GeneralMeta => { const current = typeof meta[key] === 'number' ? (meta[key] as number) : 0; return { ...meta, [key]: current + delta }; }; diff --git a/packages/logic/src/actions/turn/general/recruitment.ts b/packages/logic/src/actions/turn/general/recruitment.ts index 9ea7392..0e4ae4b 100644 --- a/packages/logic/src/actions/turn/general/recruitment.ts +++ b/packages/logic/src/actions/turn/general/recruitment.ts @@ -1,9 +1,9 @@ import type { General, + GeneralMeta, GeneralRole, GeneralTriggerState, StatBlock, - TriggerValue, } from '@sammo-ts/logic/domain/entities.js'; export interface GeneralRecruitmentInput { @@ -26,7 +26,7 @@ export interface GeneralRecruitmentInput; + meta: GeneralMeta; triggerState?: TriggerState; } @@ -76,5 +76,5 @@ export const buildRecruitmentGeneral = { return yearMonth; }; -const addMetaValue = ( - meta: Record, - key: string, - value: TriggerValue -): Record => ({ +const addMetaValue = (meta: GeneralMeta, key: string, value: TriggerValue): GeneralMeta => ({ ...meta, [key]: value, }); diff --git a/packages/logic/src/actions/turn/nation/che_의병모집.ts b/packages/logic/src/actions/turn/nation/che_의병모집.ts index 23135cf..35dc71f 100644 --- a/packages/logic/src/actions/turn/nation/che_의병모집.ts +++ b/packages/logic/src/actions/turn/nation/che_의병모집.ts @@ -1,5 +1,5 @@ import type { RandomGenerator } from '@sammo-ts/common'; -import type { GeneralTriggerState, StatBlock, TriggerValue } from '@sammo-ts/logic/domain/entities.js'; +import type { GeneralMeta, GeneralTriggerState, StatBlock, TriggerValue } from '@sammo-ts/logic/domain/entities.js'; import type { Constraint, ConstraintContext } from '@sammo-ts/logic/constraints/types.js'; import { availableStrategicCommand, @@ -268,7 +268,8 @@ export class ActionResolver< const birthYear = context.currentYear - baseAge; const deathYear = context.currentYear + deathYears; const stats = resolveStats(context, context.rng, this.env, candidate); - const meta: Record = { + const meta: GeneralMeta = { + killturn: randomRangeInt(context.rng, killTurnMin, killTurnMax), npcType: NPC_TYPE, crewTypeId: this.env.defaultCrewTypeId, }; @@ -278,7 +279,7 @@ export class ActionResolver< addMetaValue(meta, 'deathYear', deathYear); addMetaValue(meta, 'specAge', DEFAULT_SPEC_AGE); addMetaValue(meta, 'specAge2', DEFAULT_SPEC_AGE); - addMetaValue(meta, 'killturn', randomRangeInt(context.rng, killTurnMin, killTurnMax)); + addMetaValue(meta, 'killturn', meta.killturn); addMetaValue(meta, 'text', candidate.text ?? null); const newGeneral = buildRecruitmentGeneral({ diff --git a/packages/logic/src/domain/entities.ts b/packages/logic/src/domain/entities.ts index 9c138de..6b6c672 100644 --- a/packages/logic/src/domain/entities.ts +++ b/packages/logic/src/domain/entities.ts @@ -44,6 +44,10 @@ export interface GeneralRole { items: GeneralItemSlots; } +export type GeneralMeta = Record & { + killturn: number; +}; + export interface General { id: GeneralId; name: string; @@ -65,7 +69,7 @@ export interface General; + meta: GeneralMeta; } export interface City { diff --git a/packages/logic/src/economy/nationIncome.ts b/packages/logic/src/economy/nationIncome.ts index 0bed118..0651bcf 100644 --- a/packages/logic/src/economy/nationIncome.ts +++ b/packages/logic/src/economy/nationIncome.ts @@ -82,7 +82,7 @@ export const createIncomeActionContext = (nation: Nation): GeneralActionContext modifiers: {}, meta: {}, }, - meta: {}, + meta: { killturn: 0 }, }; return { general, nation }; }; diff --git a/packages/logic/src/world/bootstrap.ts b/packages/logic/src/world/bootstrap.ts index 67b1b2d..6c4b816 100644 --- a/packages/logic/src/world/bootstrap.ts +++ b/packages/logic/src/world/bootstrap.ts @@ -1,4 +1,11 @@ -import type { City, General, GeneralTriggerState, Nation, TriggerValue } from '@sammo-ts/logic/domain/entities.js'; +import type { + City, + General, + GeneralMeta, + GeneralTriggerState, + Nation, + TriggerValue, +} from '@sammo-ts/logic/domain/entities.js'; import type { ScenarioDefinition, ScenarioGeneral } from '@sammo-ts/logic/scenario/types.js'; import type { CitySeed, @@ -56,6 +63,7 @@ const DEFAULT_NEUTRAL_NATION_COLOR = '#000000'; const DEFAULT_GENERAL_GOLD = 1000; const DEFAULT_GENERAL_RICE = 1000; const DEFAULT_CREWTYPE_ID = 1100; +const DEFAULT_GENERAL_KILLTURN = 24; const DEFAULT_CITY_TRUST = 50; const DEFAULT_CITY_TRADE = 100; const DEFAULT_CITY_SUPPLY_STATE = 1; @@ -290,7 +298,8 @@ const buildGeneralSeeds = ( }; seeds.push(seed); - const generalMeta: Record = { + const generalMeta: GeneralMeta = { + killturn: DEFAULT_GENERAL_KILLTURN, npcType, crewTypeId: defaultCrewTypeId, }; diff --git a/packages/logic/test/actions/instant/nationStopWar.test.ts b/packages/logic/test/actions/instant/nationStopWar.test.ts index c6fca26..eb306ae 100644 --- a/packages/logic/test/actions/instant/nationStopWar.test.ts +++ b/packages/logic/test/actions/instant/nationStopWar.test.ts @@ -85,7 +85,7 @@ const buildGeneral = (id: number, nationId: number, cityId: number, name = 'Test modifiers: {}, meta: {}, }, - meta: {}, + meta: { killturn: 24 }, }); const buildCity = (id: number, nationId: number): City => ({ diff --git a/packages/logic/test/actions/turn/nation.test.ts b/packages/logic/test/actions/turn/nation.test.ts index f483dfd..904dfb1 100644 --- a/packages/logic/test/actions/turn/nation.test.ts +++ b/packages/logic/test/actions/turn/nation.test.ts @@ -50,7 +50,7 @@ const buildGeneral = (id: number, nationId: number, cityId: number, name = 'Test modifiers: {}, meta: {}, }, - meta: {}, + meta: { killturn: 24 }, }); const buildCity = (id: number, nationId: number): City => ({ diff --git a/packages/logic/test/actions/turn/nationMissing.test.ts b/packages/logic/test/actions/turn/nationMissing.test.ts index 3f2e0a6..47dd8fa 100644 --- a/packages/logic/test/actions/turn/nationMissing.test.ts +++ b/packages/logic/test/actions/turn/nationMissing.test.ts @@ -105,7 +105,7 @@ const buildGeneral = (id: number, nationId: number, cityId: number, name = 'Test modifiers: {}, meta: {}, }, - meta: {}, + meta: { killturn: 24 }, }); const buildCity = (id: number, nationId: number, name = `City${id}`): City => ({ diff --git a/packages/logic/test/crewType.test.ts b/packages/logic/test/crewType.test.ts index 9c7dcd2..45a8a28 100644 --- a/packages/logic/test/crewType.test.ts +++ b/packages/logic/test/crewType.test.ts @@ -92,7 +92,7 @@ const buildGeneral = (): General => ({ modifiers: {}, meta: {}, }, - meta: {}, + meta: { killturn: 24 }, }); const buildCities = (): City[] => [ diff --git a/packages/logic/test/dispatchWarAction.test.ts b/packages/logic/test/dispatchWarAction.test.ts index 3e02f61..c92377c 100644 --- a/packages/logic/test/dispatchWarAction.test.ts +++ b/packages/logic/test/dispatchWarAction.test.ts @@ -48,7 +48,7 @@ const buildGeneral = (id: number, nationId: number, cityId: number): General => modifiers: {}, meta: {}, }, - meta: {}, + meta: { killturn: 24 }, }); const buildCity = (id: number, nationId: number): City => ({ diff --git a/packages/logic/test/scenarios/diplomacy.test.ts b/packages/logic/test/scenarios/diplomacy.test.ts index 03e3cd7..9e2fd6b 100644 --- a/packages/logic/test/scenarios/diplomacy.test.ts +++ b/packages/logic/test/scenarios/diplomacy.test.ts @@ -117,7 +117,7 @@ describe('Diplomacy Scenario', () => { items: { horse: null, weapon: null, book: null, item: null }, }, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: {}, + meta: { killturn: 24 }, }; const snapshot: WorldSnapshot = { diff --git a/packages/logic/test/scenarios/domestic.test.ts b/packages/logic/test/scenarios/domestic.test.ts index e6762ec..3ed7c71 100644 --- a/packages/logic/test/scenarios/domestic.test.ts +++ b/packages/logic/test/scenarios/domestic.test.ts @@ -74,7 +74,7 @@ describe('Domestic Affairs Scenario', () => { items: { horse: null, weapon: null, book: null, item: null }, }, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: {}, + meta: { killturn: 24 }, }; const snapshot: WorldSnapshot = { @@ -208,7 +208,7 @@ describe('Domestic Affairs Scenario', () => { items: { horse: null, weapon: null, book: null, item: null }, }, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: {}, + meta: { killturn: 24 }, }; const snapshot: WorldSnapshot = { diff --git a/packages/logic/test/scenarios/general/che_NPC능동.test.ts b/packages/logic/test/scenarios/general/che_NPC능동.test.ts index e0b67ac..18b5239 100644 --- a/packages/logic/test/scenarios/general/che_NPC능동.test.ts +++ b/packages/logic/test/scenarios/general/che_NPC능동.test.ts @@ -140,7 +140,7 @@ describe('che_NPC능동', () => { age: 20, npcState: 2, // NPC triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: {}, + meta: { killturn: 24 }, }; world.snapshot.generals.push(general); @@ -195,7 +195,7 @@ describe('che_NPC능동', () => { age: 20, npcState: 0, // Human triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: {}, + meta: { killturn: 24 }, }; world.snapshot.generals.push(general); diff --git a/packages/logic/test/scenarios/general/che_강행.test.ts b/packages/logic/test/scenarios/general/che_강행.test.ts index ab17a63..c747a1a 100644 --- a/packages/logic/test/scenarios/general/che_강행.test.ts +++ b/packages/logic/test/scenarios/general/che_강행.test.ts @@ -201,7 +201,7 @@ describe('che_강행', () => { age: 20, npcState: 0, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: {}, + meta: { killturn: 24 }, }; const nation: Nation = { id: 1, @@ -214,7 +214,7 @@ describe('che_강행', () => { power: 0, level: 1, typeCode: 'che_def', - meta: {}, + meta: { killturn: 24 }, }; world.snapshot.generals.push(general); world.snapshot.nations.push(nation); @@ -285,7 +285,7 @@ describe('che_강행', () => { age: 20, npcState: 0, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: {}, + meta: { killturn: 24 }, }; const nation: Nation = { id: 1, @@ -298,7 +298,7 @@ describe('che_강행', () => { power: 0, level: 1, typeCode: 'che_def', - meta: {}, + meta: { killturn: 24 }, }; world.snapshot.generals.push(general); world.snapshot.nations.push(nation); @@ -362,7 +362,7 @@ describe('che_강행', () => { age: 20, npcState: 0, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: {}, + meta: { killturn: 24 }, }; const sub: General = { @@ -391,7 +391,7 @@ describe('che_강행', () => { age: 20, npcState: 0, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: {}, + meta: { killturn: 24 }, }; const nation: Nation = { diff --git a/packages/logic/test/scenarios/general/che_귀환.test.ts b/packages/logic/test/scenarios/general/che_귀환.test.ts index 91d128c..9819375 100644 --- a/packages/logic/test/scenarios/general/che_귀환.test.ts +++ b/packages/logic/test/scenarios/general/che_귀환.test.ts @@ -180,7 +180,7 @@ describe('che_귀환', () => { age: 20, npcState: 0, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: {}, + meta: { killturn: 24 }, }; const nation: Nation = { id: 1, @@ -193,7 +193,7 @@ describe('che_귀환', () => { power: 0, level: 1, typeCode: 'che_def', - meta: {}, + meta: { killturn: 24 }, }; world.snapshot.generals.push(general); world.snapshot.nations.push(nation); @@ -252,7 +252,7 @@ describe('che_귀환', () => { age: 20, npcState: 0, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: { officer_city: 103 }, + meta: { killturn: 24, officer_city: 103 }, }; const nation: Nation = { id: 1, @@ -265,7 +265,7 @@ describe('che_귀환', () => { power: 0, level: 1, typeCode: 'che_def', - meta: {}, + meta: { killturn: 24 }, }; world.snapshot.generals.push(general); world.snapshot.nations.push(nation); @@ -318,7 +318,7 @@ describe('che_귀환', () => { age: 20, npcState: 0, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: {}, + meta: { killturn: 24 }, }; const nation: Nation = { id: 1, @@ -331,7 +331,7 @@ describe('che_귀환', () => { power: 0, level: 1, typeCode: 'che_def', - meta: {}, + meta: { killturn: 24 }, }; world.snapshot.generals.push(general); world.snapshot.nations.push(nation); @@ -400,7 +400,7 @@ describe('che_귀환', () => { age: 20, npcState: 0, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: { officer_city: 103 }, + meta: { killturn: 24, officer_city: 103 }, }; const nation: Nation = { id: 1, @@ -413,7 +413,7 @@ describe('che_귀환', () => { power: 0, level: 1, typeCode: 'che_def', - meta: {}, + meta: { killturn: 24 }, }; world.snapshot.generals.push(general); world.snapshot.nations.push(nation); diff --git a/packages/logic/test/scenarios/general/che_등용수락.test.ts b/packages/logic/test/scenarios/general/che_등용수락.test.ts index 07a9a21..6e3da2f 100644 --- a/packages/logic/test/scenarios/general/che_등용수락.test.ts +++ b/packages/logic/test/scenarios/general/che_등용수락.test.ts @@ -172,7 +172,7 @@ describe('che_등용수락', () => { age: 20, npcState: 0, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: {}, + meta: { killturn: 24 }, }; const recruiterGen: General = { @@ -201,7 +201,7 @@ describe('che_등용수락', () => { age: 20, npcState: 0, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: {}, + meta: { killturn: 24 }, }; const nation2: Nation = { @@ -215,7 +215,7 @@ describe('che_등용수락', () => { power: 0, level: 1, typeCode: 'che_def', - meta: {}, + meta: { killturn: 24 }, }; world.snapshot.generals.push(neutralGen); @@ -284,7 +284,7 @@ describe('che_등용수락', () => { age: 20, npcState: 0, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: { betray: 1 }, + meta: { killturn: 24, betray: 1 }, }; const nation1: Nation = { id: 1, @@ -297,7 +297,7 @@ describe('che_등용수락', () => { power: 0, level: 1, typeCode: 'che_def', - meta: {}, + meta: { killturn: 24 }, }; const recruiterGen: General = { @@ -326,7 +326,7 @@ describe('che_등용수락', () => { age: 20, npcState: 0, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: {}, + meta: { killturn: 24 }, }; const nation2: Nation = { id: 2, @@ -339,7 +339,7 @@ describe('che_등용수락', () => { power: 0, level: 1, typeCode: 'che_def', - meta: {}, + meta: { killturn: 24 }, }; world.snapshot.generals.push(betrayer); @@ -408,7 +408,7 @@ describe('che_등용수락', () => { age: 20, npcState: 0, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: {}, + meta: { killturn: 24 }, }; const nation1: Nation = { id: 1, @@ -421,7 +421,7 @@ describe('che_등용수락', () => { power: 0, level: 1, typeCode: 'che_def', - meta: {}, + meta: { killturn: 24 }, }; const recruiterGen: General = { id: 2, @@ -444,7 +444,7 @@ describe('che_등용수락', () => { age: 20, npcState: 0, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: {}, + meta: { killturn: 24 }, }; const nation2: Nation = { id: 2, @@ -457,7 +457,7 @@ describe('che_등용수락', () => { power: 0, level: 1, typeCode: 'che_def', - meta: {}, + meta: { killturn: 24 }, }; world.snapshot.generals.push(monarch); @@ -512,7 +512,7 @@ describe('che_등용수락', () => { age: 20, npcState: 0, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: {}, + meta: { killturn: 24 }, }; const nation1: Nation = { id: 1, @@ -525,7 +525,7 @@ describe('che_등용수락', () => { power: 0, level: 1, typeCode: 'che_def', - meta: {}, + meta: { killturn: 24 }, }; const recruiterGen: General = { id: 2, @@ -548,7 +548,7 @@ describe('che_등용수락', () => { age: 20, npcState: 0, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: {}, + meta: { killturn: 24 }, }; world.snapshot.generals.push(general); diff --git a/packages/logic/test/scenarios/general/che_이동.test.ts b/packages/logic/test/scenarios/general/che_이동.test.ts index 6fe94e2..8a8916d 100644 --- a/packages/logic/test/scenarios/general/che_이동.test.ts +++ b/packages/logic/test/scenarios/general/che_이동.test.ts @@ -92,7 +92,7 @@ describe('che_이동', () => { age: 20, npcState: 0, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: {}, + meta: { killturn: 24 }, }; const nation: Nation = { id: 1, diff --git a/packages/logic/test/scenarios/general_commands_new.test.ts b/packages/logic/test/scenarios/general_commands_new.test.ts index 445925e..396f921 100644 --- a/packages/logic/test/scenarios/general_commands_new.test.ts +++ b/packages/logic/test/scenarios/general_commands_new.test.ts @@ -131,7 +131,7 @@ describe('General Commands New Scenario', () => { items: { horse: null, weapon: null, book: null, item: null }, }, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: {}, + meta: { killturn: 24 }, }; const snapshot: WorldSnapshot = { diff --git a/packages/logic/test/scenarios/troops.test.ts b/packages/logic/test/scenarios/troops.test.ts index 7829fec..52f1799 100644 --- a/packages/logic/test/scenarios/troops.test.ts +++ b/packages/logic/test/scenarios/troops.test.ts @@ -76,7 +76,7 @@ describe('Troop Management Scenario', () => { items: { horse: null, weapon: null, book: null, item: null }, }, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, - meta: {}, + meta: { killturn: 24 }, }; const snapshot: WorldSnapshot = { diff --git a/packages/logic/test/specialActions.test.ts b/packages/logic/test/specialActions.test.ts index 27e523f..0200adc 100644 --- a/packages/logic/test/specialActions.test.ts +++ b/packages/logic/test/specialActions.test.ts @@ -60,7 +60,7 @@ const buildGeneral = (overrides: Partial = {}): General => ({ modifiers: {}, meta: {}, }, - meta: {}, + meta: { killturn: 24 }, ...overrides, }); diff --git a/packages/logic/test/warAftermath.test.ts b/packages/logic/test/warAftermath.test.ts index b6b5984..f8aec15 100644 --- a/packages/logic/test/warAftermath.test.ts +++ b/packages/logic/test/warAftermath.test.ts @@ -123,7 +123,7 @@ const buildGeneral = (id: number, nationId: number, cityId: number): General => modifiers: {}, meta: {}, }, - meta: {}, + meta: { killturn: 24 }, }); describe('war aftermath', () => { diff --git a/packages/logic/test/warEngine.test.ts b/packages/logic/test/warEngine.test.ts index b0bbdb4..2365cad 100644 --- a/packages/logic/test/warEngine.test.ts +++ b/packages/logic/test/warEngine.test.ts @@ -153,6 +153,7 @@ const buildGeneral = (strength: number): General => ({ meta: {}, }, meta: { + killturn: 24, dex1: 5000, }, });