Files
core2026/app/game-engine/test/inMemoryTurnProcessorInvader.test.ts
T
Hide_D 81279e76b5 feat: 응답 가능한 서신과 턴 시간 호환 이관
등용장과 이민족 선택 응답을 turn daemon transaction으로 연결하고 Ref의 통일 이후 상태 전이와 수신자별 메시지 저장 규칙을 보존한다.\n\n유산 턴 시간 변경을 nextTurnTimeBase 기반 결정적 계산으로 바로잡고 API, 엔진, Chromium 회귀를 추가한다.
2026-08-19 18:03:56 +00:00

63 lines
2.2 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { InMemoryTurnProcessor } from '../src/turn/inMemoryTurnProcessor.js';
import { InMemoryTurnWorld } from '../src/turn/inMemoryWorld.js';
import type { TurnWorldSnapshot, TurnWorldState } from '../src/turn/types.js';
const buildWorld = (isunited: number): InMemoryTurnWorld => {
const state: TurnWorldState = {
id: 1,
currentYear: 200,
currentMonth: 1,
tickSeconds: 600,
lastTurnTime: new Date('0200-01-01T00:00:00.000Z'),
meta: { isunited },
};
const snapshot: TurnWorldSnapshot = {
generals: [],
cities: [],
nations: [],
troops: [],
diplomacy: [],
events: [],
initialEvents: [],
scenarioConfig: {
stat: { total: 300, min: 10, max: 100, npcTotal: 150, npcMax: 50, npcMin: 10, chiefMin: 70 },
iconPath: '',
map: {},
const: {},
environment: { mapName: 'test', unitSet: 'default' },
},
map: { id: 'test', name: 'test', cities: [] },
};
return new InMemoryTurnWorld(state, snapshot, {
schedule: { entries: [{ startMinute: 0, tickMinutes: 10 }] },
});
};
describe('invader event-game month progression', () => {
it('continues monthly processing while the invader game is active', async () => {
const world = buildWorld(1);
const result = await new InMemoryTurnProcessor(world).run(new Date('0200-01-01T00:10:00.000Z'), {
budgetMs: 1_000,
maxGenerals: 10,
catchUpCap: 1,
});
expect(result.processedTurns).toBe(1);
expect(world.getState()).toMatchObject({ currentYear: 200, currentMonth: 2 });
});
it.each([2, 3])('stops monthly processing at terminal united state %s', async (isunited) => {
const world = buildWorld(isunited);
const result = await new InMemoryTurnProcessor(world).run(new Date('0200-01-01T00:10:00.000Z'), {
budgetMs: 1_000,
maxGenerals: 10,
catchUpCap: 1,
});
expect(result.processedTurns).toBe(0);
expect(world.getState()).toMatchObject({ currentYear: 200, currentMonth: 1 });
});
});