Anonymous

Template:Disambiguation/doc: Difference between revisions

From Melvor Idle
m
Updated to fix headers sometimes not being present
(Fixed incorrect search array for Thieving npcs, sorted equipment by Weapons, Armors, Arrows)
m (Updated to fix headers sometimes not being present)
Line 20: Line 20:
}
}
const pushResults = (obj) => {
const pushResults = (obj) => {
if (obj.arr.length > 0 && !returnEquipmentTemplate && obj.header !== '')
if (obj.arr.length > 0 && !returnEquipmentTemplate && !results.includes(obj.header))
results.push(obj.header);
results.push(obj.header);
obj.arr.forEach(item => {
obj.arr.forEach(item => {
Line 31: Line 31:
if (!returnEquipmentTemplate) results.push(`{{Disam}}{{V|${gameVersion.substr(1)}}}\n`, `'''${searchTerm}''' may refer to:`);
if (!returnEquipmentTemplate) results.push(`{{Disam}}{{V|${gameVersion.substr(1)}}}\n`, `'''${searchTerm}''' may refer to:`);
pushResults({arr: game.items.weapons.filter(x => search(x)), header: '===Equipment===', iconType: 'ItemIcon'});
pushResults({arr: game.items.weapons.filter(x => search(x)), header: '===Equipment===', iconType: 'ItemIcon'});
pushResults({arr: game.items.equipment.filter(x => search(x) && !(x instanceof WeaponItem) && !x.validSlots.includes('Quiver')), header: '', iconType: 'ItemIcon'});
pushResults({arr: game.items.equipment.filter(x => search(x) && !(x instanceof WeaponItem) && !x.validSlots.includes('Quiver')), header: '===Equipment===', iconType: 'ItemIcon'});
pushResults({arr: game.items.equipment.filter(x => search(x) && x.validSlots.includes('Quiver')), header: '', iconType: 'ItemIcon'});
pushResults({arr: game.items.equipment.filter(x => search(x) && x.validSlots.includes('Quiver')), header: '===Equipment===', iconType: 'ItemIcon'});
pushResults({arr: game.items.filter(x => x.validSlots === undefined && !(x instanceof OpenableItem) && !(x instanceof BoneItem) && !(x instanceof FoodItem) && search(x)), header: '===Items===', iconType: 'ItemIcon'});
pushResults({arr: game.items.filter(x => x.validSlots === undefined && !(x instanceof OpenableItem) && !(x instanceof BoneItem) && !(x instanceof FoodItem) && search(x)), header: '===Items===', iconType: 'ItemIcon'});
pushResults({arr: game.items.openables.filter(x => search(x)), header: '===Openables===', iconType: 'ItemIcon'});
pushResults({arr: game.items.openables.filter(x => search(x)), header: '===Openables===', iconType: 'ItemIcon'});
Line 45: Line 45:
pushResults({arr: [...game.township.buildings.allObjects, ...game.township.seasons.allObjects, ...game.township.biomes.allObjects, ...game.township.resources.allObjects].filter(x => search(x)), header: '===Township===', iconType: 'TownshipIcon'});
pushResults({arr: [...game.township.buildings.allObjects, ...game.township.seasons.allObjects, ...game.township.biomes.allObjects, ...game.township.resources.allObjects].filter(x => search(x)), header: '===Township===', iconType: 'TownshipIcon'});
pushResults({arr: game.skills.filter(x => search(x)), header: '===Others===', iconType: 'Skill'});
pushResults({arr: game.skills.filter(x => search(x)), header: '===Others===', iconType: 'Skill'});
pushResults({arr: game.pets.filter(x => search(x)), header: '', iconType: 'PetIcon'});
pushResults({arr: game.pets.filter(x => search(x)), header: '===Others===', iconType: 'PetIcon'});
pushResults({arr: game.astrology.actions.filter(x => search(x)), header: '', iconType: 'ConstellationIcon'});
pushResults({arr: game.astrology.actions.filter(x => search(x)), header: '===Others===', iconType: 'ConstellationIcon'});
pushResults({arr: game.agility.actions.filter(x => search(x)), header: '', iconType: 'AgilityIcon'});
pushResults({arr: game.agility.actions.filter(x => search(x)), header: '===Others===', iconType: 'AgilityIcon'});
pushResults({arr: game.thieving.actions.filter(x => search(x)), header: '', iconType: 'Icon', extras: '|type=thieving'});
pushResults({arr: game.thieving.actions.filter(x => search(x)), header: '===Others===', iconType: 'Icon', extras: '|type=thieving'});
if (cloudManager.hasAoDEntitlementAndIsEnabled)
if (cloudManager.hasAoDEntitlementAndIsEnabled)
pushResults({arr: game.cartography.worldMaps.getObjectByID('melvorAoD:Melvor').pointsOfInterest.filter(x => search(x)), header: '', iconType: 'POIIcon'});
pushResults({arr: game.cartography.worldMaps.getObjectByID('melvorAoD:Melvor').pointsOfInterest.filter(x => search(x)), header: '===Others===', iconType: 'POIIcon'});
let outputString = ``;
let outputString = ``;
results.forEach((str, i) => { outputString += (returnEquipmentTemplate ? i > 0 ? `\n|${str}` : `${str}` : `${str}\n`) });
results.forEach((str, i) => { outputString += (returnEquipmentTemplate ? i > 0 ? `\n|${str}` : `${str}` : `${str}\n`) });