feat: add log clearing functionality to turn test harness and enhance NPC simulation logging
This commit is contained in:
@@ -185,6 +185,7 @@ export const createTurnTestHarness = async (options: TurnTestHarnessOptions) =>
|
|||||||
runOneTick,
|
runOneTick,
|
||||||
runUntil,
|
runUntil,
|
||||||
getCollectedLogs: () => [...collectedLogs],
|
getCollectedLogs: () => [...collectedLogs],
|
||||||
|
getAndClearCollectedLogs: () => collectedLogs.splice(0, collectedLogs.length),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ describe('NPC 건국/통일 장기 시뮬레이션', () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const { runUntil, getCollectedLogs } = await createTurnTestHarness({
|
const { runUntil, getCollectedLogs, getAndClearCollectedLogs } = await createTurnTestHarness({
|
||||||
snapshot,
|
snapshot,
|
||||||
state,
|
state,
|
||||||
schedule,
|
schedule,
|
||||||
@@ -249,6 +249,26 @@ describe('NPC 건국/통일 장기 시뮬레이션', () => {
|
|||||||
collectLogs: true,
|
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 {
|
try {
|
||||||
await runUntil((current) =>
|
await runUntil((current) =>
|
||||||
current.currentYear > 182 || (current.currentYear === 182 && current.currentMonth >= 1)
|
current.currentYear > 182 || (current.currentYear === 182 && current.currentMonth >= 1)
|
||||||
@@ -281,6 +301,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')}`);
|
||||||
|
|
||||||
const activeNationCount = world
|
const activeNationCount = world
|
||||||
.listNations()
|
.listNations()
|
||||||
|
|||||||
Reference in New Issue
Block a user