Module:Skills: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 514: Line 514:


function p.getFiremakingTable(frame)
function p.getFiremakingTable(frame)
local args = frame.args ~= nil and frame.args or frame
    local args = frame.args ~= nil and frame.args or frame
local realmName = args.realm
    local realmName = args.realm
local realm = p.getRealmFromName(realmName)
    local realm = p.getRealmFromName(realmName)
if realm == nil then
    if realm == nil then
return Shared.printError('Failed to find a realm with name ' .. (realmName or 'nil'))
        return Shared.printError('Failed to find a realm with name ' .. (realmName or 'nil'))
end
    end
local skillID = 'Firemaking'
    local skillID = 'Firemaking'


local resultPart = {}
    local tableHtml = mw.html.create('table')
table.insert(resultPart, '{| class="wikitable sortable stickyHeader"')
        :addClass('wikitable sortable stickyHeader')
table.insert(resultPart, '\r\n|-class="headerRow-0"')
   
table.insert(resultPart, '\r\n!colspan="2" rowspan="2"|Logs!!rowspan="2"|Requirements')
    local headerRow0 = tableHtml:tag('tr'):addClass('headerRow-0')
table.insert(resultPart, '!!rowspan="2"|Burn Time!!colspan="2"|Without Bonfire!!colspan="2"|With Bonfire!!rowspan="2"|Bonfire Bonus!!rowspan="2"|Bonfire Time')
    headerRow0:tag('th'):attr('colspan', '2')
table.insert(resultPart, '\r\n|-class="headerRow-1"')
                        :attr('rowspan', '2')
table.insert(resultPart, '\r\n!XP!!XP/s!!XP!!XP/s')
                        :wikitext('Logs')
    headerRow0:tag('th'):attr('rowspan', '2')
                        :wikitext('Requirements')
    headerRow0:tag('th'):attr('rowspan', '2')
                        :wikitext('Burn Time')
    headerRow0:tag('th'):attr('colspan', '2')
                        :wikitext('Without Bonfire')
    headerRow0:tag('th'):attr('colspan', '2')
                        :wikitext('With Bonfire')
    headerRow0:tag('th'):attr('rowspan', '2')
                        :wikitext('Bonfire Bonus')
    headerRow0:tag('th'):attr('rowspan', '2')
                        :wikitext('Bonfire Time')


local logsData = GameData.getEntities(SkillData.Firemaking.logs,
    local headerRow1 = tableHtml:tag('tr'):addClass('headerRow-1')
function(obj)
    headerRow1:tag('th'):wikitext('XP')
return p.getRecipeRealm(obj) == realm.id
    headerRow1:tag('th'):wikitext('XP/s')
end
    headerRow1:tag('th'):wikitext('XP')
)
    headerRow1:tag('th'):wikitext('XP/s')
table.sort(logsData, function(a, b) return p.standardRecipeSort(skillID, a, b) end)
for i, logData in ipairs(logsData) do
local logs = Items.getItemByID(logData.logID)
local name = logs.name
local level = p.getRecipeLevel(skillID, logData)
local baseXP = logData.baseAbyssalExperience or logData.baseExperience
local reqText = p.getRecipeRequirementText(SkillData.Firemaking.name, logData)
local bonfireBonus = logData.bonfireAXPBonus or logData.bonfireXPBonus
local burnTime = logData.baseInterval / 1000
local bonfireTime = logData.baseBonfireInterval / 1000
local XPS = baseXP / burnTime
local XP_BF = baseXP * (1 + bonfireBonus / 100)
local XPS_BF = Num.round(XP_BF / burnTime, 2, 2)
XP_BF = Num.round(XP_BF, 2, 0)


table.insert(resultPart, '\r\n|-')
    local logsData = GameData.getEntities(SkillData.Firemaking.logs, function(obj)
table.insert(resultPart, '\r\n|data-sort-value="'..name..'"|'..Icons.Icon({name, type='item', size='50', notext=true}))
        return p.getRecipeRealm(obj) == realm.id
table.insert(resultPart, '||'..Icons.getExpansionIcon(logs.id)..Icons.Icon({name, type='item', noicon=true}))
    end)
table.insert(resultPart, '||style ="text-align: right;" data-sort-value="' .. level .. '"|'..reqText)
    table.sort(logsData, function(a, b) return p.standardRecipeSort(skillID, a, b) end)
table.insert(resultPart, '||style ="text-align: right;" data-sort-value="'..burnTime..'"|'..Shared.timeString(burnTime, true))
   
table.insert(resultPart, '||style ="text-align: right;" data-sort-value="' .. baseXP .. '"| ' .. Num.formatnum(baseXP))
    for i, logData in ipairs(logsData) do
table.insert(resultPart, '||style ="text-align: right;" data-sort-value="'..XPS..'"|'..Num.formatnum(Num.round(XPS, 2, 2)))
        local logs = Items.getItemByID(logData.logID)
if bonfireBonus == 0 then
        local name = logs.name
table.insert(resultPart, '||colspan="4" class="table-na"| N/A ')
        local level = p.getRecipeLevel(skillID, logData)
else
        local baseXP = logData.baseAbyssalExperience or logData.baseExperience
table.insert(resultPart, '||style ="text-align: right;" data-sort-value="' .. XP_BF .. '"| ' .. Num.formatnum(XP_BF))
        local reqText = p.getRecipeRequirementText(SkillData.Firemaking.name, logData)
table.insert(resultPart, '||style ="text-align: right;" data-sort-value="'..XPS_BF..'"|'..Num.formatnum(XPS_BF, 2, 2))
        local bonfireBonus = logData.bonfireAXPBonus or logData.bonfireXPBonus
table.insert(resultPart, '||style ="text-align: right;" data-sort-value="'..bonfireBonus..'"|'..bonfireBonus..'%')
        local burnTime = logData.baseInterval / 1000
table.insert(resultPart, '||style ="text-align: right;" data-sort-value="'..bonfireTime..'"|'..Shared.timeString(bonfireTime, true))
        local bonfireTime = logData.baseBonfireInterval / 1000
end
        local XPS = baseXP / burnTime
end
        local XP_BF = baseXP * (1 + bonfireBonus / 100)
        local XPS_BF = Num.round(XP_BF / burnTime, 2, 2)
        XP_BF = Num.round(XP_BF, 2, 0)


table.insert(resultPart, '\r\n|}')
        local row = tableHtml:tag('tr')
return table.concat(resultPart)
        row:tag('td'):attr('data-sort-value', name)
                    :wikitext('[[File:' .. name .. '_(skill).svg|25x25px|link=' .. name .. ']]')
        row:tag('td'):wikitext(Icons.getExpansionIcon(logs.id) .. '[[File:' .. name .. '_(skill).svg|25x25px|link=' .. name .. ']]')
        row:tag('td'):attr('style', 'text-align: right;')
                    :attr('data-sort-value', level)
                    :wikitext(reqText)
        row:tag('td'):attr('style', 'text-align: right;')
                    :attr('data-sort-value', burnTime)
                    :wikitext(Shared.timeString(burnTime, true))
        row:tag('td'):attr('style', 'text-align: right;')
                    :attr('data-sort-value', baseXP)
                    :wikitext(Num.formatnum(baseXP))
        row:tag('td'):attr('style', 'text-align: right;')
                    :attr('data-sort-value', XPS)
                    :wikitext(Num.formatnum(Num.round(XPS, 2, 2)))
       
        if bonfireBonus == 0 then
            row:tag('td'):attr('colspan', '4')
                        :addClass('table-na')
                        :wikitext('N/A')
        else
            row:tag('td'):attr('style', 'text-align: right;')
                        :attr('data-sort-value', XP_BF)
                        :wikitext(Num.formatnum(XP_BF))
            row:tag('td'):attr('style', 'text-align: right;')
                        :attr('data-sort-value', XPS_BF)
                        :wikitext(Num.formatnum(XPS_BF, 2, 2))
            row:tag('td'):attr('style', 'text-align: right;')
                        :attr('data-sort-value', bonfireBonus)
                        :wikitext(bonfireBonus .. '%')
            row:tag('td'):attr('style', 'text-align: right;')
                        :attr('data-sort-value', bonfireTime)
                        :wikitext(Shared.timeString(bonfireTime, true))
        end
    end
 
    return tostring(tableHtml)
end
end


2,875

edits