Anonymous

Template:Disambiguation/doc: Difference between revisions

From Melvor Idle
Updated to include Thieving NPCs
m (Swapped version and disam templates)
(Updated to include Thieving NPCs)
Line 9: Line 9:
let searchTerm = 'Siren';
let searchTerm = 'Siren';
let lcSearchTerm = searchTerm.toLowerCase();
let lcSearchTerm = searchTerm.toLowerCase();
const search = (obj) => obj.name.toLowerCase().includes(lcSearchTerm);
const search = (obj) => obj.name?.toLowerCase().includes(lcSearchTerm);
const wikiIcon = (obj, icon) => `*${obj.namespace?.includes('TotH') ? '{{TotH}}' : obj.namespace?.includes('AoD') ? '{{AoD}}' : ''}{{${icon}|${obj.name}}}`
const wikiIcon = (obj, icon, extras='') => `*${obj.namespace?.includes('TotH') ? '{{TotH}}' : obj.namespace?.includes('AoD') ? '{{AoD}}' : ''}{{${icon}|${obj.name}${extras}}}`
let results = [`{{Disam}}{{V|${gameVersion.substr(1)}}}`, '', `'''${searchTerm}''' may refer to:`, '===Equipment==='];
let results = [`{{Disam}}{{V|${gameVersion.substr(1)}}}`, '', `'''${searchTerm}''' may refer to:`, '===Equipment==='];
game.items.equipment.filter(x => search(x)).forEach(item => results.push(wikiIcon(item, 'ItemIcon')));
game.items.equipment.filter(x => search(x)).forEach(item => results.push(wikiIcon(item, 'ItemIcon')));
Line 46: Line 46:
game.astrology.actions.filter(x => search(x)).forEach(constellation => results.push(wikiIcon(constellation, 'ConstellationIcon')));
game.astrology.actions.filter(x => search(x)).forEach(constellation => results.push(wikiIcon(constellation, 'ConstellationIcon')));
game.agility.actions.filter(x => search(x)).forEach(obstacle => results.push(wikiIcon(obstacle, 'AgilityIcon')));
game.agility.actions.filter(x => search(x)).forEach(obstacle => results.push(wikiIcon(obstacle, 'AgilityIcon')));
game.thieving.actions.filter(x => search(x)).forEach(npc => results.push(wikiIcon(npc, 'Icon', '|type=thieving')));
if (cloudManager.hasAoDEntitlementAndIsEnabled)
if (cloudManager.hasAoDEntitlementAndIsEnabled)
game.cartography.worldMaps.getObjectByID('melvorAoD:Melvor').pointsOfInterest.filter(x => search(x)).forEach(poi => results.push(wikiIcon(poi, 'POIIcon')));
game.cartography.worldMaps.getObjectByID('melvorAoD:Melvor').pointsOfInterest.filter(x => search(x)).forEach(poi => results.push(wikiIcon(poi, 'POIIcon')));