Module:Skills/Cartography: Difference between revisions

Reference the Melvor world map by ID rather than by a numerical index - the order of maps within SkillData.Cartography.worldMaps cannot be guaranteed
No edit summary
(Reference the Melvor world map by ID rather than by a numerical index - the order of maps within SkillData.Cartography.worldMaps cannot be guaranteed)
Line 8: Line 8:
local Common = require('Module:Common')
local Common = require('Module:Common')
local Icons = require('Module:Icons')
local Icons = require('Module:Icons')
local MelvorMap = GameData.getEntityByID(SkillData.Cartography.worldMaps, 'melvorAoD:Melvor')


function p.getPointOfInterestByID(id)
function p.getPointOfInterestByID(id)
for i, POI in pairs(SkillData.Cartography.worldMaps[1].pointsOfInterest) do
for i, POI in pairs(MelvorMap.pointsOfInterest) do
if POI.id == id then
if POI.id == id then
return POI
return POI
Line 23: Line 26:
return nil
return nil
end
end
for i, POI in pairs(SkillData.Cartography.worldMaps[1].pointsOfInterest) do
for i, POI in pairs(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 33: Line 36:


function p.getPointOfInterestForDigSite(digSiteID)
function p.getPointOfInterestForDigSite(digSiteID)
for i, POI in pairs(SkillData.Cartography.worldMaps[1].pointsOfInterest) do
for i, POI in pairs(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 44: 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(SkillData.Cartography.worldMaps[1].pointsOfInterest) do
for i, POI in pairs(MelvorMap.pointsOfInterest) do
if POI.name == name then
if POI.name == name then
return POI
return POI
Line 54: Line 57:
function p.getPointsOfInterest(checkFunc)
function p.getPointsOfInterest(checkFunc)
local result = {}
local result = {}
for i, POI in pairs(SkillData.Cartography.worldMaps[1].pointsOfInterest) do
for i, POI in pairs(MelvorMap.pointsOfInterest) do
if checkFunc(POI) then
if checkFunc(POI) then
table.insert(result, POI)
table.insert(result, POI)
Line 69: Line 72:
end
end
for i, hex in pairs(SkillData.Cartography.worldMaps[1].hexes) do
for i, hex in pairs(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 162: Line 165:
:tag('th'):wikitext('Rewards')
:tag('th'):wikitext('Rewards')
local masteryBonuses = Shared.shallowClone(SkillData.Cartography.worldMaps[1].masteryBonuses)
local masteryBonuses = Shared.shallowClone(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 217: 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(SkillData.Cartography.worldMaps[1].pointsOfInterest) do
for i, POI in pairs(MelvorMap.pointsOfInterest) do
table.insert(POIs, POI)
table.insert(POIs, POI)
end
end
Line 279: Line 282:
function p._getDiscoveryRewardsTable(items)
function p._getDiscoveryRewardsTable(items)
local POIs = {}
local POIs = {}
for i, POI in ipairs(SkillData.Cartography.worldMaps[1].pointsOfInterest) do
for i, POI in ipairs(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 292: Line 295:
end
end


if POIs[1] == nil then
if Shared.tableIsEmpty(POIs) then
return ''
return ''
end
end
Line 369: Line 372:
function p.testDiscoveryRewards()
function p.testDiscoveryRewards()
local testTable = {}
local testTable = {}
for i, POI in pairs(SkillData.Cartography.worldMaps[1].pointsOfInterest) do
for i, POI in pairs(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)