Module:Skills/Cartography

< Module:Skills
Revision as of 19:46, 12 September 2023 by Falterfire (talk | contribs) (adding another linebreak for readablity)

Documentation for this module may be created at Module:Skills/Cartography/doc

local p = {}

local Shared = require('Module:Shared')
local Constants = require('Module:Constants')
local GameData = require('Module:GameData')
local SkillData = GameData.skillData
local Items = require('Module:Items')
local Icons = require('Module:Icons')

function p.convertAxialToXY(HexCoords)
	local Y = HexCoords.r + (HexCoords.q - (HexCoords.q % 2)) / 2
	local X = HexCoords.q
	return X, Y
end

function p.test()
	local POIs = {}
	local POI_Strings = {}
	
	
	for i, POI in pairs(SkillData.Cartography.worldMaps[1].pointsOfInterest) do
		table.insert(POIs, POI)
	end
	
	table.sort(POIs, function(a, b)
						local aX, aY = p.convertAxialToXY(a.coords)
						local bX, bY = p.convertAxialToXY(b.coords)
						if aX ~= bX then
							return aX < bX
						else
							return aY < bY
						end
					 end)
	
	for i, POI in pairs(POIs) do
		local X, Y = p.convertAxialToXY(POI.coords)
		table.insert(POI_Strings, POI.name..' ('..X..', '..Y..')')
	end
	
	local keyset={}
	local n=0
	
	for k,v in pairs(SkillData.Cartography.worldMaps[1]) do
	  n=n+1
	  keyset[n]=k
	end
	mw.logObject(POIs[1])
	return table.concat(POI_Strings, '<br/>\n')
end

return p