From c3f4c58f4ff6860b7621ff1ceae90b3f23177fca Mon Sep 17 00:00:00 2001 From: Hide_D Date: Sat, 24 Jan 2026 19:10:00 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=A1=9C=EA=B7=B8=20=EC=88=98=EC=A7=91?= =?UTF-8?q?=20=EA=B8=B0=EB=8A=A5=20=EA=B0=9C=EC=84=A0=20=EB=B0=8F=20?= =?UTF-8?q?=EB=8F=84=EC=8B=9C=20=ED=8E=98=EB=84=90=ED=8B=B0=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test/helpers/turnTestHarness.ts | 3 ++ .../test/npcNationUprisingUnification.test.ts | 53 +++++++++++++++---- 2 files changed, 45 insertions(+), 11 deletions(-) diff --git a/app/game-engine/test/helpers/turnTestHarness.ts b/app/game-engine/test/helpers/turnTestHarness.ts index b0b7b22..a2ddf2f 100644 --- a/app/game-engine/test/helpers/turnTestHarness.ts +++ b/app/game-engine/test/helpers/turnTestHarness.ts @@ -185,6 +185,9 @@ export const createTurnTestHarness = async (options: TurnTestHarnessOptions) => runOneTick, runUntil, getCollectedLogs: () => [...collectedLogs], + getCollectedLogsCount: () => collectedLogs.length, + getCollectedLogsRange: (start: number, end?: number) => + collectedLogs.slice(start, end ?? collectedLogs.length), 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 1ee5af4..a28c44c 100644 --- a/app/game-engine/test/npcNationUprisingUnification.test.ts +++ b/app/game-engine/test/npcNationUprisingUnification.test.ts @@ -83,6 +83,30 @@ const boostNationOneCities = (world: InMemoryTurnWorld) => { } }; +const applyPost200Penalty = (world: InMemoryTurnWorld) => { + const { currentYear } = world.getState(); + if (currentYear < 200) { + return; + } + const cities = world.listCities(); + for (const city of cities) { + if (city.nationId === 1) { + continue; + } + const meta = city.meta ?? {}; + const trust = typeof meta.trust === 'number' ? Math.floor(meta.trust * 0.9) : undefined; + world.updateCity(city.id, { + population: Math.floor(city.population * 0.9), + agriculture: Math.floor(city.agriculture * 0.9), + commerce: Math.floor(city.commerce * 0.9), + security: Math.floor(city.security * 0.9), + defence: Math.floor(city.defence * 0.9), + wall: Math.floor(city.wall * 0.9), + meta: trust !== undefined ? { ...meta, trust } : meta, + }); + } +}; + const dumpWorldStatus = (world: InMemoryTurnWorld, label: string) => { const state = world.getState(); const cities = world.listCities(); @@ -252,6 +276,7 @@ describe('NPC 건국/통일 장기 시뮬레이션', () => { return; } boostNationOneCities(world); + applyPost200Penalty(world); const meta = world.getState().meta as Record; if (typeof meta.isUnited === 'number' && meta.isUnited !== 0) { return; @@ -277,7 +302,7 @@ describe('NPC 건국/통일 장기 시뮬레이션', () => { const lastNationAiState = new Map(); let declarationCount = 0; - const { runUntil, getCollectedLogs, getAndClearCollectedLogs } = await createTurnTestHarness({ + const { runUntil, getCollectedLogs, getCollectedLogsCount, getCollectedLogsRange } = await createTurnTestHarness({ snapshot, state, schedule, @@ -298,23 +323,29 @@ describe('NPC 건국/통일 장기 시뮬레이션', () => { }, }); + let monthlyLogCursor = 0; + const maxMonthlyLogEntries = 20; const dumpMonthlyLogs = (label: string) => { - const logs = getAndClearCollectedLogs(); + const end = getCollectedLogsCount(); + if (end <= monthlyLogCursor) { + return; + } + const logs = getCollectedLogsRange(monthlyLogCursor, end); + monthlyLogCursor = end; if (logs.length === 0) { return; } - const globalLogs = logs.filter((log) => log.category === LogCategory.HISTORY); - if (globalLogs.length === 0) { + const historyLogs = logs.filter((log) => log.category === LogCategory.HISTORY); + if (historyLogs.length === 0) { return; } - console.log('[DEBUG] month global logs', { + const limitedLogs = historyLogs.slice(0, maxMonthlyLogEntries); + const truncated = historyLogs.length - limitedLogs.length; + console.log('[DEBUG] month history logs', { label, - total: globalLogs.length, - logs: globalLogs.map((log) => ({ - category: log.category, - format: log.format, - text: log.text, - })), + total: historyLogs.length, + truncated, + logs: limitedLogs.map((log) => log.text), }); };