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