fix(game): complete clock after invader ending

This commit is contained in:
2026-09-03 20:16:28 +00:00
parent 156f4e68b8
commit 51f8be492f
6 changed files with 54 additions and 2 deletions
@@ -549,6 +549,7 @@ export const createInvaderEndingHandler = (options: {
isUnited: 3,
refreshLimit: readNumber(meta.refreshLimit) * 100,
});
world.completeGameClock();
world.removeEvent(environment.currentEventID);
};
};
@@ -126,6 +126,7 @@ const buildHarness = (options?: {
currentMonth: 1,
tickSeconds: 600,
lastTurnTime: new Date('0200-01-01T00:00:00.000Z'),
clockPhase: 'RUNNING',
meta: {
hiddenSeed: 'raise-invader-fixture',
serverId: 'fixture-server',
@@ -410,6 +411,7 @@ describe('invader monthly actions', () => {
await world.advanceMonth(new Date('0200-01-01T00:00:00.000Z'));
expect(world.getState().meta).toMatchObject({ isunited: 3, isUnited: 3, refreshLimit: 300 });
expect(world.getState().clockPhase).toBe('COMPLETED');
expect(world.listEvents()).toHaveLength(0);
expect(world.peekDirtyState().logs.map((log) => log.text)).toEqual([
'<L><b>【이벤트】</b></>이민족을 모두 소탕했습니다!',
@@ -449,6 +451,7 @@ describe('invader monthly actions', () => {
await world.advanceMonth(new Date('0200-01-01T00:00:00.000Z'));
expect(world.getState().meta).toMatchObject({ isunited: 3, isUnited: 3, refreshLimit: 300 });
expect(world.getState().clockPhase).toBe('COMPLETED');
expect(world.listEvents()).toHaveLength(0);
expect(world.peekDirtyState().logs.map((log) => log.text)).toEqual([
'<L><b>【이벤트】</b></>중원은 이민족에 의해 혼란에 빠졌습니다.',
@@ -338,6 +338,12 @@ integration('RaiseInvader database persistence', () => {
currentYear: 199,
currentMonth: 12,
tickSeconds: 600,
clockBaseTime: new Date('0200-01-01T00:00:00.000Z'),
clockTick: 0n,
clockMode: 'realtime',
clockWallAnchor: new Date('0200-01-01T00:00:00.000Z'),
lastTurnTick: 0n,
clockPhase: 'RUNNING',
config: {},
meta: {
hiddenSeed: serverId,
@@ -354,6 +360,14 @@ integration('RaiseInvader database persistence', () => {
currentMonth: 12,
tickSeconds: 600,
lastTurnTime: new Date('0200-01-01T00:00:00.000Z'),
clockBaseTime: new Date('0200-01-01T00:00:00.000Z'),
clockTick: 0,
clockMode: 'realtime',
clockWallAnchor: new Date('0200-01-01T00:00:00.000Z'),
lastTurnTick: 0,
clockPhase: 'RUNNING',
clockRevision: 1,
deadlineGeneration: 1,
meta: {
hiddenSeed: serverId,
lastGeneralId: firstCreatedGeneralId - 1,
@@ -610,6 +624,7 @@ integration('RaiseInvader database persistence', () => {
leasedNationKeys: [],
});
expect(await db.worldState.findUniqueOrThrow({ where: { id: stateRow.id } })).toMatchObject({
clockPhase: 'COMPLETED',
meta: expect.objectContaining({ isunited: 3, isUnited: 3, refreshLimit: 300 }),
});
expect(