feat: NPC 전쟁 상태 확인 로직 개선 및 로그 수집 기능 수정

This commit is contained in:
2026-01-24 19:16:51 +00:00
parent c3f4c58f4f
commit d48b040e74
2 changed files with 17 additions and 15 deletions
@@ -96,12 +96,12 @@ const applyPost200Penalty = (world: InMemoryTurnWorld) => {
const meta = city.meta ?? {}; const meta = city.meta ?? {};
const trust = typeof meta.trust === 'number' ? Math.floor(meta.trust * 0.9) : undefined; const trust = typeof meta.trust === 'number' ? Math.floor(meta.trust * 0.9) : undefined;
world.updateCity(city.id, { world.updateCity(city.id, {
population: Math.floor(city.population * 0.9), population: Math.floor(city.population * 0.85),
agriculture: Math.floor(city.agriculture * 0.9), agriculture: Math.floor(city.agriculture * 0.85),
commerce: Math.floor(city.commerce * 0.9), commerce: Math.floor(city.commerce * 0.85),
security: Math.floor(city.security * 0.9), security: Math.floor(city.security * 0.85),
defence: Math.floor(city.defence * 0.9), defence: Math.floor(city.defence * 0.85),
wall: Math.floor(city.wall * 0.9), wall: Math.floor(city.wall * 0.85),
meta: trust !== undefined ? { ...meta, trust } : meta, meta: trust !== undefined ? { ...meta, trust } : meta,
}); });
} }
@@ -325,7 +325,7 @@ describe('NPC 건국/통일 장기 시뮬레이션', () => {
let monthlyLogCursor = 0; let monthlyLogCursor = 0;
const maxMonthlyLogEntries = 20; const maxMonthlyLogEntries = 20;
const dumpMonthlyLogs = (label: string) => { const _dumpMonthlyLogs = (label: string) => {
const end = getCollectedLogsCount(); const end = getCollectedLogsCount();
if (end <= monthlyLogCursor) { if (end <= monthlyLogCursor) {
return; return;
@@ -480,7 +480,7 @@ describe('NPC 건국/통일 장기 시뮬레이션', () => {
current.currentYear > target.year || current.currentYear > target.year ||
(current.currentYear === target.year && current.currentMonth >= target.month) (current.currentYear === target.year && current.currentMonth >= target.month)
); );
dumpMonthlyLogs(`${target.year}-${String(target.month).padStart(2, '0')}`); //_dumpMonthlyLogs(`${target.year}-${String(target.month).padStart(2, '0')}`);
const activeNationCount = world const activeNationCount = world
.listNations() .listNations()
@@ -386,16 +386,18 @@ describe('NPC 선전포고·개전·통일 흐름 테스트', () => {
(current.currentYear === next.year && current.currentMonth >= next.month) (current.currentYear === next.year && current.currentMonth >= next.month)
); );
const warLoopEntry = findDiplomacyEntry(world);
if (!warLoopEntry) {
debug.dumpWatched('개전 이후 외교 상태 누락');
throw new Error('missing diplomacy entry');
}
expect(warLoopEntry.state).toBe(DIPLOMACY_STATE.WAR);
const nowNation1Cities = countCities(1, world); const nowNation1Cities = countCities(1, world);
const nowNation2Cities = countCities(2, world); const nowNation2Cities = countCities(2, world);
if (nowNation1Cities > 0 && nowNation2Cities > 0) {
const warLoopEntry = findDiplomacyEntry(world);
if (!warLoopEntry) {
debug.dumpWatched('개전 이후 외교 상태 누락');
throw new Error('missing diplomacy entry');
}
expect(warLoopEntry.state).toBe(DIPLOMACY_STATE.WAR);
}
expect(nowNation1Cities).toBeLessThanOrEqual(prevNation1Cities); expect(nowNation1Cities).toBeLessThanOrEqual(prevNation1Cities);
expect(nowNation2Cities).toBeGreaterThanOrEqual(prevNation2Cities); expect(nowNation2Cities).toBeGreaterThanOrEqual(prevNation2Cities);