diff --git a/api/src/jsons/npcs.json b/api/src/jsons/npcs.json new file mode 100644 index 00000000..4a58401f --- /dev/null +++ b/api/src/jsons/npcs.json @@ -0,0 +1,23 @@ +{ + "1": { + "name": "Comerciante de Armas", + "npcType": 10, + "idHead": 1, + "idBody": 1, + "movement": 0, + "objs": [ + { "item": 1, "cant": 50 }, + { "item": 2, "cant": 50 } + ], + "drop": [] + }, + "2": { + "name": "Sacerdote", + "npcType": 2, + "idHead": 2, + "idBody": 2, + "movement": 0, + "objs": [], + "drop": [] + } +} diff --git a/api/src/lib/gameData.ts b/api/src/lib/gameData.ts index d1f123c9..02ef995b 100644 --- a/api/src/lib/gameData.ts +++ b/api/src/lib/gameData.ts @@ -250,12 +250,18 @@ export function loadSeedNpcsJson(): Array<{ data: GameNpcRecordData; }> { const filePath = resolveSeedJsonPath("npcs.json", "npcs.compact.json"); + if (!fs.existsSync(filePath)) { + return []; + } return loadNpcsJsonFromFile(filePath); } export function loadNpcsJsonFromFile( filePath: string, ): Array<{ id: number; data: GameNpcRecordData }> { + if (!fs.existsSync(filePath)) { + return []; + } const raw = JSON.parse(fs.readFileSync(filePath, "utf8")) as NpcsById; return Object.entries(raw) .map(([id, data]) => ({ id: Number(id), data: normalizeNpcData(data) }))