fix: align legacy speciality selection

This commit is contained in:
2026-07-25 20:55:27 +00:00
parent 4fa91439d5
commit 80d7f264af
13 changed files with 306 additions and 30 deletions
@@ -427,6 +427,7 @@ export const seedScenarioToDatabase = async (options: ScenarioSeedOptions): Prom
itemCode: general.item ?? 'None',
turnTime: now,
age: resolveGeneralAge(scenario.startYear ?? null, general.birthYear),
startAge: resolveGeneralAge(scenario.startYear ?? null, general.birthYear),
personalCode: general.personality ?? 'None',
specialCode: general.special ?? 'None',
special2Code: general.specialWar ?? 'None',
+1
View File
@@ -22,6 +22,7 @@ export interface TurnWorldState {
export interface TurnGeneral extends General {
userId?: string | null;
startAge?: number;
bornYear?: number;
deadYear?: number;
affinity?: number | null;
+1
View File
@@ -200,6 +200,7 @@ const mapGeneralRow = (row: TurnEngineGeneralRow): TurnGeneral => {
train: row.train,
atmos: row.atmos,
age: row.age,
startAge: row.startAge,
npcState: row.npcState,
bornYear: row.bornYear,
deadYear: row.deadYear,
@@ -28,6 +28,7 @@ type ScenarioSeederPrismaClient = {
};
general: {
count(): Promise<number>;
findFirst(): Promise<{ age: number; startAge: number; meta: unknown } | null>;
};
diplomacy: {
count(): Promise<number>;
@@ -116,6 +117,14 @@ describeDb('scenario database seed', () => {
expect(diplomacyCount).toBe(seed.nations.length * Math.max(0, seed.nations.length - 1));
expect(eventCount).toBe(seed.events.length);
expect(generalCount).toBeGreaterThan(0);
const seededGeneral = await prisma.general.findFirst();
expect(seededGeneral?.startAge).toBe(seededGeneral?.age);
expect(seededGeneral?.meta).toEqual(
expect.objectContaining({
specage: expect.any(Number),
specage2: expect.any(Number),
})
);
const freeCity = seed.cities.find((city) => city.nationId === 0);
const occupiedCity = seed.cities.find((city) => city.nationId !== 0);