feat: Enhance scenario installation options and UI integration

- Added new installation options to GatewayAdminActionRecord and implemented parsing logic in gatewayOrchestrator.ts.
- Updated resolveResetSeedInfo to accommodate new scenario installation parameters.
- Introduced a new scenario catalog module to manage scenario previews and details.
- Enhanced AdminView.vue to include a comprehensive installation form with various configuration options.
- Implemented scenario listing and selection functionality in the frontend.
- Updated profile repository to support scenario updates.
- Added tests to cover new functionalities and ensure stability.
This commit is contained in:
2026-01-17 12:24:57 +00:00
parent f13f8bc1cf
commit bc76b6e725
12 changed files with 1362 additions and 28 deletions
@@ -1,6 +1,7 @@
import { createGamePostgresConnector } from '@sammo-ts/infra';
import { describe, expect, test } from 'vitest';
import { resolveDatabaseUrl } from '../src/scenario/databaseUrl.js';
import { loadScenarioDefinitionById } from '../src/scenario/scenarioLoader.js';
import { seedScenarioToDatabase } from '../src/scenario/scenarioSeeder.js';
const scenarioId = 1010;
@@ -25,6 +26,15 @@ type ScenarioSeederPrismaClient = {
where: { srcNationId: number; destNationId: number };
}): Promise<{ stateCode: number; term: number } | null>;
};
worldState: {
findFirst(): Promise<{
config: unknown;
meta: unknown;
tickSeconds: number;
currentYear: number;
currentMonth: number;
} | null>;
};
};
const canConnectToDatabase = async (url: string): Promise<boolean> => {
@@ -97,4 +107,57 @@ describeDb('scenario database seed', () => {
await connector.disconnect();
}
});
test('applies install options to world state', async () => {
const scenario = await loadScenarioDefinitionById(scenarioId);
const { seed } = await seedScenarioToDatabase({
scenarioId,
databaseUrl,
now: new Date('2030-01-01T00:00:00Z'),
installOptions: {
turnTermMinutes: 60,
sync: false,
fiction: 1,
extend: false,
blockGeneralCreate: 2,
npcMode: 0,
showImgLevel: 3,
tournamentTrig: true,
joinMode: 'full',
autorunUser: {
limitMinutes: 60,
options: {
develop: true,
},
},
},
});
const expectedGenerals = scenario.generals.length + scenario.generalsNeutral.length;
expect(seed.generals.length).toBe(expectedGenerals);
const connector = createGamePostgresConnector({ url: databaseUrl });
await connector.connect();
try {
const prisma = connector.prisma as unknown as ScenarioSeederPrismaClient;
const worldState = await prisma.worldState.findFirst();
expect(worldState).not.toBeNull();
if (!worldState) {
return;
}
expect(worldState.tickSeconds).toBe(3600);
expect(worldState.currentMonth).toBe(1);
const config = (worldState.config ?? {}) as Record<string, unknown>;
expect(config.extendedGeneral).toBe(false);
expect(config.joinMode).toBe('full');
const meta = (worldState.meta ?? {}) as Record<string, unknown>;
const autorun = (meta.autorun_user ?? {}) as Record<string, unknown>;
const autorunOptions = (autorun.options ?? {}) as Record<string, unknown>;
expect(autorunOptions.develop).toBe(true);
} finally {
await connector.disconnect();
}
});
});