Merge pull request #142 from downthecrop/undefined-item-data

Resolve error with out of sync item definitions
This commit is contained in:
Ceikry 2022-04-03 10:45:56 -05:00 committed by GitHub
commit 4085421b85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,6 +11,12 @@ class npcObject {
} }
} }
// our json data is out of sync.
function itemErrorMessage(npc,item){
console.log("Error with npc",npc," drop id: ",item)
console.log("update this tools json/item_config.json")
}
function newDisplayItem(name, id, min, max, weight, totalWeight) { function newDisplayItem(name, id, min, max, weight, totalWeight) {
let row = $("<tr>") let row = $("<tr>")
let icon = $("<img>").attr('src', iconURL(id)) let icon = $("<img>").attr('src', iconURL(id))
@ -46,6 +52,12 @@ function mapNPCItem(drops) {
// Add default drops // Add default drops
npc['default'].forEach(drop => { npc['default'].forEach(drop => {
if(getItemName(drop.id) == undefined){
itemErrorMessage(npc,drop.id)
return
}
let name = spaceToUnder(getItemName(drop.id)) let name = spaceToUnder(getItemName(drop.id))
if (items[name]) if (items[name])
items[name] += ("," + npc['ids']) items[name] += ("," + npc['ids'])
@ -59,6 +71,12 @@ function mapNPCItem(drops) {
// Normal drops // Normal drops
npc['main'].forEach(drop => { npc['main'].forEach(drop => {
if(getItemName(drop.id) == undefined){
itemErrorMessage(npc,drop.id)
return
}
let name = spaceToUnder(getItemName(drop.id)) let name = spaceToUnder(getItemName(drop.id))
npcObj.totalWeight += parseFloat(drop.weight) npcObj.totalWeight += parseFloat(drop.weight)
if (items[name]) if (items[name])