17,376
edits
(Update code) |
(Resolve property filters not applying to properties whose values were objects; add more property filters) |
||
Line 40: | Line 40: | ||
ignoreCompletion: function(entityType, entity) { return entity.ignoreCompletion; }, | ignoreCompletion: function(entityType, entity) { return entity.ignoreCompletion; }, | ||
obtainFromItemLog: function(entityType, entity) { return entity.obtainFromItemLog; }, | obtainFromItemLog: function(entityType, entity) { return entity.obtainFromItemLog; }, | ||
occupiesSlots: function(entityType, entity) { return entity.occupiesSlots.length > 0; } | validSlots: function(entityType, entity) { return entity.validSlots.length > 0; }, | ||
occupiesSlots: function(entityType, entity) { return entity.occupiesSlots.length > 0; }, | |||
equipRequirements: function(entityType, entity) { return entity.equipRequirements.length > 0; }, | |||
equipmentStats: function(entityType, entity) { return entity.equipmentStats.length > 0; }, | |||
tier: function(entityType, entity) { | |||
if (entityType === 'items') { | |||
return entity.tier !== 'none'; | |||
} | |||
else { | |||
return true; | |||
} | |||
} | |||
}; | }; | ||
this.dataPropTransforms = { | this.dataPropTransforms = { | ||
Line 176: | Line 187: | ||
// Iterate properties of object, checking if each should be deleted or transformed | // Iterate properties of object, checking if each should be deleted or transformed | ||
Object.keys(dataNode).forEach((key) => { | Object.keys(dataNode).forEach((key) => { | ||
if (typeof dataNode[key] === "object" && dataNode[key] !== null) { | // Check if property is to be deleted or not | ||
const filterFunc = this.dataPropFilters[key]; | |||
if (filterFunc !== undefined && !filterFunc(categoryName, dataNode)) { | |||
delete dataNode[key]; | |||
} | |||
else if (typeof dataNode[key] === "object" && dataNode[key] !== null) { | |||
// If an object (either an array or key/value store) is within the current | // If an object (either an array or key/value store) is within the current | ||
// object then we must traverse this too | // object then we must traverse this too | ||
Line 182: | Line 198: | ||
} | } | ||
else { | else { | ||
// Transform property, if a transformation is defined below | |||
switch(key) { | |||
case 'id': | |||
// Add namespace to ID if it isn't already | |||
dataNode[key] = this.getNamespacedID(ns, dataNode[key]); | |||
break; | |||
} | } | ||
} | } | ||
Line 220: | Line 229: | ||
'passiveRegenInterval' | 'passiveRegenInterval' | ||
]; | ]; | ||
dataNode.baseGemChance = 1; | |||
break; | break; | ||
case 'melvorD:Smithing': | case 'melvorD:Smithing': |