vv
This commit is contained in:
@@ -22,6 +22,7 @@ import { createFrontStateHandler } from '../src/turn/frontStateHandler.js';
|
|||||||
import { composeCalendarHandlers } from '../src/turn/calendarHandlers.js';
|
import { composeCalendarHandlers } from '../src/turn/calendarHandlers.js';
|
||||||
import { buildCommandEnv, buildReservedTurnDefinitions } from '../src/turn/reservedTurnCommands.js';
|
import { buildCommandEnv, buildReservedTurnDefinitions } from '../src/turn/reservedTurnCommands.js';
|
||||||
import { LARGE_TEST_MAP, buildLargeTestCities } from './fixtures/largeTestMap.js';
|
import { LARGE_TEST_MAP, buildLargeTestCities } from './fixtures/largeTestMap.js';
|
||||||
|
import { round } from 'es-toolkit';
|
||||||
|
|
||||||
const mockDate = new Date('0179-08-01T00:00:00Z');
|
const mockDate = new Date('0179-08-01T00:00:00Z');
|
||||||
|
|
||||||
@@ -224,7 +225,13 @@ describe('NPC 대형 시뮬레이션', () => {
|
|||||||
type TurnTrace = {
|
type TurnTrace = {
|
||||||
year: number;
|
year: number;
|
||||||
month: number;
|
month: number;
|
||||||
|
nationId: number;
|
||||||
generalId: number;
|
generalId: number;
|
||||||
|
gold: number;
|
||||||
|
rice: number;
|
||||||
|
crew: number;
|
||||||
|
train: number;
|
||||||
|
atmos: number;
|
||||||
actionText: string;
|
actionText: string;
|
||||||
actionKey: string;
|
actionKey: string;
|
||||||
requestedAction: string;
|
requestedAction: string;
|
||||||
@@ -269,7 +276,13 @@ describe('NPC 대형 시뮬레이션', () => {
|
|||||||
const trace: TurnTrace = {
|
const trace: TurnTrace = {
|
||||||
year: ctx.world.currentYear,
|
year: ctx.world.currentYear,
|
||||||
month: ctx.world.currentMonth,
|
month: ctx.world.currentMonth,
|
||||||
|
nationId: ctx.general.nationId,
|
||||||
generalId: ctx.general.id,
|
generalId: ctx.general.id,
|
||||||
|
gold: ctx.general.gold,
|
||||||
|
rice: ctx.general.rice,
|
||||||
|
crew: ctx.general.crew,
|
||||||
|
train: ctx.general.train,
|
||||||
|
atmos: ctx.general.atmos,
|
||||||
actionKey: 'unknown',
|
actionKey: 'unknown',
|
||||||
requestedAction: 'unknown',
|
requestedAction: 'unknown',
|
||||||
usedFallback: false,
|
usedFallback: false,
|
||||||
@@ -282,6 +295,9 @@ describe('NPC 대형 시뮬레이션', () => {
|
|||||||
const actionLog = result.logs?.find((log) => log.category === LogCategory.ACTION);
|
const actionLog = result.logs?.find((log) => log.category === LogCategory.ACTION);
|
||||||
trace.actionText = actionLog?.text ?? 'unknown';
|
trace.actionText = actionLog?.text ?? 'unknown';
|
||||||
trace.logs = result.logs ?? [];
|
trace.logs = result.logs ?? [];
|
||||||
|
if (ctx.general.nationId === 0) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
turnTraces.push(trace);
|
turnTraces.push(trace);
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
@@ -333,8 +349,8 @@ describe('NPC 대형 시뮬레이션', () => {
|
|||||||
? ` fallback(${trace.requestedAction} -> ${trace.actionKey}) ${trace.blockedReason ?? ''}`
|
? ` fallback(${trace.requestedAction} -> ${trace.actionKey}) ${trace.blockedReason ?? ''}`
|
||||||
: ` ${trace.requestedAction} -> ${trace.actionKey}`;
|
: ` ${trace.requestedAction} -> ${trace.actionKey}`;
|
||||||
console.log(
|
console.log(
|
||||||
`- ${trace.year}-${String(trace.month).padStart(2, '0')} G${trace.generalId} ` +
|
`- ${trace.year}-${String(trace.month).padStart(2, '0')} N${trace.nationId} G${trace.generalId} g${round(trace.gold)}/r${round(trace.rice)} c${trace.crew}/t${trace.train}/a${trace.atmos} ` +
|
||||||
`${trace.ok ? 'OK' : 'FAIL'} ${action}${extra}`
|
`${trace.ok ? 'OK' : 'FAIL'} ${action}${extra}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -416,7 +432,7 @@ describe('NPC 대형 시뮬레이션', () => {
|
|||||||
expect(maxAtmos).toBeGreaterThan(0);
|
expect(maxAtmos).toBeGreaterThan(0);
|
||||||
expect(ready.length).toBeGreaterThanOrEqual(minReadyCount);
|
expect(ready.length).toBeGreaterThanOrEqual(minReadyCount);
|
||||||
};
|
};
|
||||||
|
|
||||||
const assertDispatchRecorded = (year: number, month: number, minCount = 1) => {
|
const assertDispatchRecorded = (year: number, month: number, minCount = 1) => {
|
||||||
const matches = turnTraces.filter(
|
const matches = turnTraces.filter(
|
||||||
(trace) => trace.year === year && trace.month === month && trace.actionKey === 'che_출병'
|
(trace) => trace.year === year && trace.month === month && trace.actionKey === 'che_출병'
|
||||||
@@ -520,9 +536,9 @@ describe('NPC 대형 시뮬레이션', () => {
|
|||||||
['181-01', () => assertNationGeneralCount(10)],
|
['181-01', () => assertNationGeneralCount(10)],
|
||||||
['182-01', () => assertDomesticGrowthBy(182, 1)],
|
['182-01', () => assertDomesticGrowthBy(182, 1)],
|
||||||
['182-10', () => assertNationRecruitCount(5)],
|
['182-10', () => assertNationRecruitCount(5)],
|
||||||
['182-12', () => assertWarReadiness(10, 70, 70)],
|
['183-01', () => assertWarReadiness(10, 70, 70)],
|
||||||
//['183-01', () => assertDispatchRecorded(183, 1, 1)],
|
['183-02', () => assertDispatchRecorded(183, 1, 1)],
|
||||||
//['183-07', () => assertNoNeutralCities()],
|
['183-07', () => assertNoNeutralCities()],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const toKey = (year: number, month: number) => `${year}-${String(month).padStart(2, '0')}`;
|
const toKey = (year: number, month: number) => `${year}-${String(month).padStart(2, '0')}`;
|
||||||
|
|||||||
Reference in New Issue
Block a user