Anonymous

Module:Sandbox/Skills/Cartography: Difference between revisions

From Melvor Idle
Cleanup
(Fixed testDiscoveryRewards)
(Cleanup)
Line 125: Line 125:
end
end
return rewardTable
return rewardTable
end
function p.sortPOIByCoords(array)
table.sort(array, 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)
return array
end
end


Line 137: Line 150:
table.insert(POIs, POI)
table.insert(POIs, POI)
end
end
 
table.sort(POIs, function(a, b)
POIs = p.sortPOIByCoords(POIs)
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
for i, POI in pairs(POIs) do
Line 215: Line 220:
end
end


table.sort(POIs, function(a, b)
POIs = p.sortPOIByCoords(POIs)
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)


-- Build the table
-- Build the table
local resultTable = mw.html.create('table')
local resultTable = mw.html.create('table')
resultTable:addClass('wikitable'):addClass('sortable')
resultTable:addClass('wikitable sortable')
resultTable:tag('tr'):addClass('headerRow-0')
resultTable:tag('tr'):addClass('headerRow-0')
:tag('th'):wikitext('Point of Interest'):done()
:tag('th'):wikitext('Point of Interest')
:tag('th'):wikitext('X'):done()
:tag('th'):wikitext('X')
:tag('th'):wikitext('Y'):done()
:tag('th'):wikitext('Y')
:tag('th'):wikitext('Requirements'):done()
:tag('th'):wikitext('Requirements')
:tag('th'):wikitext('Discovery Rewards'):done()
:tag('th'):wikitext('Discovery Rewards')


for _, POI in ipairs(POIs) do
for _, POI in ipairs(POIs) do