From c83795716b8ecd5f57b03167cb4350a8f9c545e5 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Sat, 24 Jan 2026 17:14:59 +0000 Subject: [PATCH] feat: add log clearing functionality to turn test harness and enhance NPC simulation logging --- .../test/helpers/turnTestHarness.ts | 1 + .../test/npcNationUprisingUnification.test.ts | 23 ++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/app/game-engine/test/helpers/turnTestHarness.ts b/app/game-engine/test/helpers/turnTestHarness.ts index db0c223..b0b7b22 100644 --- a/app/game-engine/test/helpers/turnTestHarness.ts +++ b/app/game-engine/test/helpers/turnTestHarness.ts @@ -185,6 +185,7 @@ export const createTurnTestHarness = async (options: TurnTestHarnessOptions) => runOneTick, runUntil, getCollectedLogs: () => [...collectedLogs], + getAndClearCollectedLogs: () => collectedLogs.splice(0, collectedLogs.length), }; }; diff --git a/app/game-engine/test/npcNationUprisingUnification.test.ts b/app/game-engine/test/npcNationUprisingUnification.test.ts index 873c558..c59ab42 100644 --- a/app/game-engine/test/npcNationUprisingUnification.test.ts +++ b/app/game-engine/test/npcNationUprisingUnification.test.ts @@ -239,7 +239,7 @@ describe('NPC 건국/통일 장기 시뮬레이션', () => { }, }; - const { runUntil, getCollectedLogs } = await createTurnTestHarness({ + const { runUntil, getCollectedLogs, getAndClearCollectedLogs } = await createTurnTestHarness({ snapshot, state, schedule, @@ -249,6 +249,26 @@ describe('NPC 건국/통일 장기 시뮬레이션', () => { collectLogs: true, }); + const dumpMonthlyLogs = (label: string) => { + const logs = getAndClearCollectedLogs(); + if (logs.length === 0) { + return; + } + const globalLogs = logs.filter((log) => log.scope === LogScope.SYSTEM); + if (globalLogs.length === 0) { + return; + } + console.log('[DEBUG] month global logs', { + label, + total: globalLogs.length, + logs: globalLogs.map((log) => ({ + category: log.category, + format: log.format, + text: log.text, + })), + }); + }; + try { await runUntil((current) => current.currentYear > 182 || (current.currentYear === 182 && current.currentMonth >= 1) @@ -281,6 +301,7 @@ describe('NPC 건국/통일 장기 시뮬레이션', () => { current.currentYear > target.year || (current.currentYear === target.year && current.currentMonth >= target.month) ); + dumpMonthlyLogs(`${target.year}-${String(target.month).padStart(2, '0')}`); const activeNationCount = world .listNations()