

var ObjectEditor = {
    Data: {
        Units: require('../WEdata/data/Units.json')
    },
    Fields: {
        Units: require('../WEdata/fields/UnitMetaData.json')
    },

    Find: {
        UnitFieldIdByLongName: function(longName) {
            // e.g. bountydice -> ubdi
            // TODO: time this function -- it may take too long for lookups

            for(var fieldKey in ObjectEditor.Fields.Units) {
                if( ObjectEditor.Fields.Units[fieldKey] &&
                    ObjectEditor.Fields.Units[fieldKey].field.toLowerCase() === longName.toLowerCase()) {
                    return fieldKey;
                }
            }

            // console.error('Unable to lookup unit field by long name:', longName);
            return null; // Unable to find by long name
        },
        UnitFieldLongNameById: function(id) {
            // e.g. ubdi -> bountydice
            return ObjectEditor.Fields.Units[id].field;
        }
    }
}

module.exports = ObjectEditor;

@@ -75,24 +75,77 @@
 Units.json')
+,%0A        Items: require('../WEdata/data/Items.json')
 %0A    %7D,%0A    
@@ -210,24 +210,86 @@
 aData.json')
+,%0A        Items: require('../WEdata/fields/ItemMetaData.json')
 %0A    %7D,%0A%0A   

Load item data and meta data in ObjectEditor class