feat: crewTypeId 및 defaultCrewTypeId 추가로 시나리오 부트스트랩 개선

This commit is contained in:
2025-12-28 16:40:28 +00:00
parent f7d9d423fa
commit 45c238ab38
4 changed files with 18 additions and 0 deletions
+1
View File
@@ -36,6 +36,7 @@ export interface General<TriggerState extends GeneralTriggerState = GeneralTrigg
gold: number;
rice: number;
crew: number;
crewTypeId: number;
train: number;
age: number;
npcState: number;
+13
View File
@@ -28,6 +28,7 @@ export interface ScenarioBootstrapOptions {
neutralNationColor?: string;
defaultGeneralGold?: number;
defaultGeneralRice?: number;
defaultCrewTypeId?: number;
nationTypePrefix?: string;
mapDefaults?: Partial<MapDefaults>;
}
@@ -63,6 +64,7 @@ const DEFAULT_NEUTRAL_NATION_NAME = '재야';
const DEFAULT_NEUTRAL_NATION_COLOR = '#000000';
const DEFAULT_GENERAL_GOLD = 1000;
const DEFAULT_GENERAL_RICE = 1000;
const DEFAULT_CREWTYPE_ID = 1100;
const DEFAULT_CITY_TRUST = 50;
const DEFAULT_CITY_TRADE = 100;
const DEFAULT_CITY_SUPPLY_STATE = 1;
@@ -233,6 +235,7 @@ const buildGeneralSeeds = (
cityByName: Map<string, { id: number }>,
nationNameToId: Map<string, number>,
warnings: ScenarioBootstrapWarning[],
defaultCrewTypeId: number,
options?: ScenarioBootstrapOptions
): {
seeds: GeneralSeed[];
@@ -310,12 +313,14 @@ const buildGeneralSeeds = (
picture: row.picture,
npcType,
text: row.text,
crewTypeId: defaultCrewTypeId,
meta: seedMeta,
};
seeds.push(seed);
const generalMeta: Record<string, TriggerValue> = {
npcType,
crewTypeId: defaultCrewTypeId,
};
addTriggerMeta(generalMeta, 'affinity', row.affinity);
addTriggerMeta(generalMeta, 'personality', row.personality ?? undefined);
@@ -339,6 +344,7 @@ const buildGeneralSeeds = (
gold: defaultGold,
rice: defaultRice,
crew: 0,
crewTypeId: defaultCrewTypeId,
train: 0,
age,
npcState: npcType,
@@ -503,6 +509,10 @@ export const buildScenarioBootstrap = (
}
const mapDefaults = resolveMapDefaults(map, options);
const defaultCrewTypeId =
unitSet?.defaultCrewTypeId ??
options?.defaultCrewTypeId ??
DEFAULT_CREWTYPE_ID;
const seedCities: CitySeed[] = [];
const domainCities: City[] = [];
@@ -580,6 +590,7 @@ export const buildScenarioBootstrap = (
cityByName,
nationNameToId,
warnings,
defaultCrewTypeId,
options
);
allGeneralSeeds.push(...generalResult.seeds);
@@ -595,6 +606,7 @@ export const buildScenarioBootstrap = (
cityByName,
nationNameToId,
warnings,
defaultCrewTypeId,
options
);
allGeneralSeeds.push(...generalExResult.seeds);
@@ -610,6 +622,7 @@ export const buildScenarioBootstrap = (
cityByName,
nationNameToId,
warnings,
defaultCrewTypeId,
options
);
allGeneralSeeds.push(...generalNeutralResult.seeds);
+2
View File
@@ -55,6 +55,7 @@ export interface MapDefinition {
export interface UnitSetDefinition {
id: string;
name: string;
defaultCrewTypeId?: number;
meta?: Record<string, unknown>;
}
@@ -118,6 +119,7 @@ export interface GeneralSeed {
picture: number | string | null;
npcType: number;
text: string | null;
crewTypeId: number;
meta: Record<string, unknown>;
}
@@ -105,6 +105,7 @@ describe('scenario bootstrap', () => {
const unitSet: UnitSetDefinition = {
id: 'test-unit',
name: 'test-unit',
defaultCrewTypeId: 1200,
};
const result = buildScenarioBootstrap({ scenario, map, unitSet });
@@ -115,6 +116,7 @@ describe('scenario bootstrap', () => {
expect(result.snapshot.cities[0]?.nationId).toBe(1);
expect(result.seed.cities[0]?.nationId).toBe(1);
expect(result.snapshot.generals[0]?.cityId).toBe(1);
expect(result.snapshot.generals[0]?.crewTypeId).toBe(1200);
expect(result.seed.generals[0]?.npcType).toBe(2);
expect(result.snapshot.scenarioMeta?.title).toBe('Test Scenario');
});