2,875
edits
No edit summary |
No edit summary |
||
Line 1,060: | Line 1,060: | ||
function p.getFarmingPlotTable(frame) | function p.getFarmingPlotTable(frame) | ||
local skillID = 'Farming' | |||
local areaName = frame.args ~= nil and frame.args[1] or frame | |||
local category = GameData.getEntityByName(SkillData.Farming.categories, areaName) | |||
if category == nil then | |||
return Shared.printError('Invalid farming category. Please choose Allotments, Herbs, Trees or Special') | |||
end | |||
local patches = GameData.getEntities(SkillData.Farming.plots, | |||
function(plot) | |||
return plot.categoryID == category.id | |||
end | |||
) | |||
table.sort(patches, | |||
function(a, b) | |||
local abyssA, abyssB = a.abyssalLevel or 0, b.abyssalLevel or 0 | |||
if abyssA == abyssB then | |||
if a.level == b.level then | |||
return a.id < b.id | |||
else | |||
return a.level < b.level | |||
end | |||
else | |||
return abyssA < abyssB | |||
end | |||
end | |||
) | |||
if Shared.tableIsEmpty(patches) then | |||
return '' | |||
end | |||
local root = mw.html.create('table') | |||
:addClass('wikitable sortable stickyHeader') | |||
-- Header row | |||
local headerRow = root:tag('tr') | |||
headerRow:tag('th'):wikitext('Plot') | |||
headerRow:tag('th'):wikitext('Requirements') | |||
headerRow:tag('th'):wikitext('Cost') | |||
for i, patch in ipairs(patches) do | |||
local level = Skills.getRecipeLevel(skillID, patch) | |||
local reqText = Skills.getRecipeRequirementText(skillID, patch) | |||
local costText = Common.getCostString({ items = patch.itemCosts, currencies = patch.currencyCosts }, 'Free') | |||
local costVal = (patch.currencyCosts and patch.currencyCosts[1] and patch.currencyCosts[1].quantity) or 0 | |||
local row = root:tag('tr') | |||
row:tag('td'):wikitext(i) | |||
row:tag('td'):css('text-align', 'right') | |||
:attr('data-sort-value', level) | |||
:wikitext(reqText) | |||
row:tag('td'):css('text-align', 'right') | |||
:attr('data-sort-value', costVal) | |||
:wikitext(costText) | |||
end | |||
return tostring(root) | |||
end | |||
function p._buildAstrologyConstellationTable(realmID) | function p._buildAstrologyConstellationTable(realmID) |
edits