Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions api/src/jsons/npcs.json
Original file line number Diff line number Diff line change
@@ -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": []
}
}
6 changes: 6 additions & 0 deletions api/src/lib/gameData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) }))
Expand Down
Loading