17,101
edits
(Reference the Melvor world map by ID rather than by a numerical index - the order of maps within SkillData.Cartography.worldMaps cannot be guaranteed) |
(Allow MelvorMap to be referenced by other modules) |
||
Line 9: | Line 9: | ||
local Icons = require('Module:Icons') | local Icons = require('Module:Icons') | ||
p.MelvorMap = GameData.getEntityByID(SkillData.Cartography.worldMaps, 'melvorAoD:Melvor') | |||
function p.getPointOfInterestByID(id) | function p.getPointOfInterestByID(id) | ||
for i, POI in pairs(MelvorMap.pointsOfInterest) do | for i, POI in pairs(p.MelvorMap.pointsOfInterest) do | ||
if POI.id == id then | if POI.id == id then | ||
return POI | return POI | ||
Line 26: | Line 26: | ||
return nil | return nil | ||
end | end | ||
for i, POI in pairs(MelvorMap.pointsOfInterest) do | for i, POI in pairs(p.MelvorMap.pointsOfInterest) do | ||
if (POI.coords.q == hex.coordinates.q and | if (POI.coords.q == hex.coordinates.q and | ||
POI.coords.r == hex.coordinates.r) then | POI.coords.r == hex.coordinates.r) then | ||
Line 36: | Line 36: | ||
function p.getPointOfInterestForDigSite(digSiteID) | function p.getPointOfInterestForDigSite(digSiteID) | ||
for i, POI in pairs(MelvorMap.pointsOfInterest) do | for i, POI in pairs(p.MelvorMap.pointsOfInterest) do | ||
if POI.digSiteID ~= nil and POI.digSiteID == digSiteID then | if POI.digSiteID ~= nil and POI.digSiteID == digSiteID then | ||
return POI | return POI | ||
Line 47: | Line 47: | ||
name = string.gsub(name, "%%27", "'") | name = string.gsub(name, "%%27", "'") | ||
name = string.gsub(name, "'", "'") | name = string.gsub(name, "'", "'") | ||
for i, POI in pairs(MelvorMap.pointsOfInterest) do | for i, POI in pairs(p.MelvorMap.pointsOfInterest) do | ||
if POI.name == name then | if POI.name == name then | ||
return POI | return POI | ||
Line 57: | Line 57: | ||
function p.getPointsOfInterest(checkFunc) | function p.getPointsOfInterest(checkFunc) | ||
local result = {} | local result = {} | ||
for i, POI in pairs(MelvorMap.pointsOfInterest) do | for i, POI in pairs(p.MelvorMap.pointsOfInterest) do | ||
if checkFunc(POI) then | if checkFunc(POI) then | ||
table.insert(result, POI) | table.insert(result, POI) | ||
Line 72: | Line 72: | ||
end | end | ||
for i, hex in pairs(MelvorMap.hexes) do | for i, hex in pairs(p.MelvorMap.hexes) do | ||
local coords = hex.coordinates | local coords = hex.coordinates | ||
if coords.q == Q and coords.r == R then | if coords.q == Q and coords.r == R then | ||
Line 165: | Line 165: | ||
:tag('th'):wikitext('Rewards') | :tag('th'):wikitext('Rewards') | ||
local masteryBonuses = Shared.shallowClone(MelvorMap.masteryBonuses) | local masteryBonuses = Shared.shallowClone(p.MelvorMap.masteryBonuses) | ||
table.sort(masteryBonuses, function(a, b) return a.masteredHexes < b.masteredHexes end) | table.sort(masteryBonuses, function(a, b) return a.masteredHexes < b.masteredHexes end) | ||
for i, bonus in ipairs(masteryBonuses) do | for i, bonus in ipairs(masteryBonuses) do | ||
Line 220: | Line 220: | ||
table.insert(tableStr, '\r\n|-\r\n!colspan="2"|Name!!Type!!X!!Y!!Requirements!!Discovery Rewards!!Discovery Modifiers!!Active Effect') | table.insert(tableStr, '\r\n|-\r\n!colspan="2"|Name!!Type!!X!!Y!!Requirements!!Discovery Rewards!!Discovery Modifiers!!Active Effect') | ||
for i, POI in pairs(MelvorMap.pointsOfInterest) do | for i, POI in pairs(p.MelvorMap.pointsOfInterest) do | ||
table.insert(POIs, POI) | table.insert(POIs, POI) | ||
end | end | ||
Line 282: | Line 282: | ||
function p._getDiscoveryRewardsTable(items) | function p._getDiscoveryRewardsTable(items) | ||
local POIs = {} | local POIs = {} | ||
for i, POI in ipairs(MelvorMap.pointsOfInterest) do | for i, POI in ipairs(p.MelvorMap.pointsOfInterest) do | ||
if POI.discoveryRewards ~= nil and POI.discoveryRewards.items ~= nil then | if POI.discoveryRewards ~= nil and POI.discoveryRewards.items ~= nil then | ||
for i, reward in ipairs(POI.discoveryRewards.items) do | for i, reward in ipairs(POI.discoveryRewards.items) do | ||
Line 372: | Line 372: | ||
function p.testDiscoveryRewards() | function p.testDiscoveryRewards() | ||
local testTable = {} | local testTable = {} | ||
for i, POI in pairs(MelvorMap.pointsOfInterest) do | for i, POI in pairs(p.MelvorMap.pointsOfInterest) do | ||
if POI.discoveryRewards ~= nil and POI.discoveryRewards.items ~= nil then | if POI.discoveryRewards ~= nil and POI.discoveryRewards.items ~= nil then | ||
local item = Items.getItemByID(POI.discoveryRewards.items[1].id) | local item = Items.getItemByID(POI.discoveryRewards.items[1].id) |