Module:Skills/Gathering: Difference between revisions

From Melvor Idle
(Update for v1.3)
No edit summary
Line 35: Line 35:
local skillID = 'Woodcutting'
local skillID = 'Woodcutting'


local resultPart = {}
local html = mw.html.create('table')
table.insert(resultPart, '{| class="wikitable sortable stickyHeader"')
:addClass('wikitable sortable stickyHeader')
table.insert(resultPart, '\n|- class="headerRow-0"')
table.insert(resultPart, '\n!colspan="2"|Tree!!colspan="2"|Logs!!Requirements')
html:tag('tr')
table.insert(resultPart, '!!XP!!Cut Time!!XP/s!!Price/s')
:addClass("headerRow-0")
:tag('th'):attr('colspan', 2)
  :wikitext('Tree')
:tag('th'):attr('colspan', 2)
  :wikitext('Logs')
:tag('th'):wikitext('Requirements')
:tag('th'):wikitext('[[DLC]]')
:tag('th'):wikitext('XP')
:tag('th'):wikitext('Cut Time')
:tag('th'):wikitext('XP/s')
:tag('th'):wikitext('Price/s')


local trees = GameData.getEntities(SkillData.Woodcutting.trees,
local trees = GameData.getEntities(SkillData.Woodcutting.trees,
Line 46: Line 56:
end
end
)
)
table.sort(trees, function(a, b) return Skills.standardRecipeSort(skillID, a, b) end)
table.sort(trees, function(a, b) return Skills.standardRecipeSort(skillID, a, b) end)
for i, tree in ipairs(trees) do
for i, tree in ipairs(trees) do
Line 57: Line 68:
local currSec = Shared.round(log.sellsFor / (baseInt / 1000), 2, 2)
local currSec = Shared.round(log.sellsFor / (baseInt / 1000), 2, 2)


table.insert(resultPart, '\n|-')
html:tag('tr')
table.insert(resultPart, '\n|class="table-img" data-sort-value="'..tree.name..'"| '..Icons.Icon({log.name, img=tree.name, type='tree', notext=true, size=50}))
:tag('td'):wikitext(Icons.Icon({log.name, img=tree.name, type='tree', notext=true}))
table.insert(resultPart, '\n|data-sort-value="'..tree.name..'"|'..Icons.getExpansionIcon(tree.id)..tree.name)
          :addClass('table-img')
table.insert(resultPart, '\n|class="table-img" data-sort-value="'..log.name..'"| '..Icons.Icon({log.name, type='item', notext=true, size=50}))
          :attr('data-sort-value', tree.name)
table.insert(resultPart, '\n| '..Icons.Icon({log.name, type='item', noicon=true}))
:tag('td'):wikitext(tree.name)
table.insert(resultPart, '\n|data-sort-value="' .. level .. '"| ' .. reqText)
:tag('td'):wikitext(Icons.Icon({log.name, type='item', notext=true}))
table.insert(resultPart, '\n|style="text-align:right"| ' .. Shared.formatnum(baseXP))
  :addClass('table-img')
table.insert(resultPart, '\n|style="text-align:right" data-sort-value="'..baseInt..'"| '..Shared.timeString(baseInt / 1000, true))
          :attr('data-sort-value', log.name)
table.insert(resultPart, '\n|style="text-align:right"| '..Shared.round(XPSec, 2, 2))
:tag('td'):wikitext('[[' .. log.name .. ']]')
table.insert(resultPart, '\n|style="text-align:right" data-sort-value="'..currSec..'"| '..Icons._Currency(sellCurrency, currSec))
:tag('td'):wikitext(reqText)
          :attr('data-sort-value', level)
:tag('td'):wikitext(Icons.getExpansionIcon(tree.id))
  :css('text-align', 'center')
:tag('td'):wikitext(Shared.formatnum(baseXP))
  :css('text-align', 'right')
:tag('td'):wikitext(Shared.timeString(baseInt / 1000, true))
  :attr('data-sort-value', baseInt)
  :css('text-align', 'right')
:tag('td'):wikitext(Shared.round(XPSec, 2, 2))
  :css('text-align', 'right')
:tag('td'):wikitext(Icons._Currency(sellCurrency, currSec))
  :attr('data-sort-value', currSec)
  :css('text-align', 'right')
end
end
 
table.insert(resultPart, '\n|}')
return tostring(html)
return table.concat(resultPart)
end
end