Module:Skills/Gathering: Difference between revisions

getFarmingPlotTable: Fix missing item costs & plot order
(Replace unorthodox use of GameData.getEntities() with Shared.shallowClone(); getFishTable: Amend layout of catch time columns)
(getFarmingPlotTable: Fix missing item costs & plot order)
Line 6: Line 6:
local GameData = require('Module:GameData')
local GameData = require('Module:GameData')
local SkillData = GameData.skillData
local SkillData = GameData.skillData
local Common = require('Module:Common')
local Items = require('Module:Items')
local Items = require('Module:Items')
local Icons = require('Module:Icons')
local Icons = require('Module:Icons')
Line 626: Line 627:
function(plot)
function(plot)
return plot.categoryID == category.id
return plot.categoryID == category.id
end)
table.sort(patches,
function(a, b)
if a.level == b.level then
return a.id < b.id
else
return a.level < b.level
end
end)
end)
if Shared.tableIsEmpty(patches) then
if Shared.tableIsEmpty(patches) then
Line 634: Line 643:
result = result..'\r\n!Plot!!'..Icons.Icon({'Farming', type='skill', notext=true})..' Level!!Cost'
result = result..'\r\n!Plot!!'..Icons.Icon({'Farming', type='skill', notext=true})..' Level!!Cost'


for i, patch in Shared.skpairs(patches) do
for i, patch in ipairs(patches) do
result = result..'\r\n|-\r\n|'..i
result = result..'\r\n|-\r\n|'..i
result = result..'||style="text-align:right;" data-sort-value="' .. patch.level .. '"|'..patch.level
result = result..'||style="text-align:right;" data-sort-value="' .. patch.level .. '"|'..patch.level
local costText = (patch.gpCost > 0 and Icons.GP(patch.gpCost)) or 'Free'
local costText = Common.getCostString({ items = patch.itemCosts, gp = patch.gpCost }, 'Free')
result = result..'||style="text-align:right;" data-sort-value="'..patch.gpCost..'"|'..costText
result = result..'||style="text-align:right;" data-sort-value="'..patch.gpCost..'"|'..costText
end
end