Module:Skills/Cartography: Difference between revisions

Swapped POI reqs to a separate function so I can more easily call it from Skills/Archaeology
(Added the option to get Point of Interest by ID)
(Swapped POI reqs to a separate function so I can more easily call it from Skills/Archaeology)
Line 70: Line 70:
local X = Q
local X = Q
return X, Y
return X, Y
end
function p._getPOIRequirements(POI)
local Hex = p.getHexByAxial(POI.coords)
local reqTable = {}
local HexReqs = Common.getRequirementString(Hex.requirements, '')
if HexReqs ~= '' then
table.insert(reqTable, HexReqs)
end
if POI.hidden ~= nil then
local POIReqs = Common.getRequirementString(POI.hidden.requirements, '')
if POIReqs ~= '' then
table.insert(reqTable, POIReqs)
end
end
return reqTable
end
end


Line 95: Line 111:
for i, POI in pairs(POIs) do
for i, POI in pairs(POIs) do
local X, Y = p.convertAxialToXY(POI.coords)
local X, Y = p.convertAxialToXY(POI.coords)
local Hex = p.getHexByAxial(POI.coords)
table.insert(POI_Strings, POI.name..' ('..X..', '..Y..')')
table.insert(POI_Strings, POI.name..' ('..X..', '..Y..')')
Line 117: Line 132:
--Add Requirements
--Add Requirements
table.insert(tableStr, '\r\n|')
table.insert(tableStr, '\r\n|')
local reqTable = {}
local reqTable= p._getPOIRequirements(POI)
local HexReqs = Common.getRequirementString(Hex.requirements, '')
if HexReqs ~= '' then
table.insert(reqTable, HexReqs)
end
if POI.hidden ~= nil then
local POIReqs = Common.getRequirementString(POI.hidden.requirements, '')
if POIReqs ~= '' then
table.insert(reqTable, POIReqs)
end
end
table.insert(tableStr, table.concat(reqTable, '<br/>'))
table.insert(tableStr, table.concat(reqTable, '<br/>'))