Module:Skills: Difference between revisions

getFiremakingTable: Add XP with bonfire stats & refactor to avoid repetitive string concatenation
(moved getPotionNavbox to Module:Navboxes)
(getFiremakingTable: Add XP with bonfire stats & refactor to avoid repetitive string concatenation)
Line 472: Line 472:


function p.getFiremakingTable(frame)
function p.getFiremakingTable(frame)
   local result = '{| class="wikitable sortable stickyHeader"'
   local resultPart = {}
   result = result..'\r\n|-class="headerRow-0"'
  table.insert(resultPart, '{| class="wikitable sortable stickyHeader"')
   result = result..'\r\n!colspan="2"|Logs!!'..Icons.Icon({'Firemaking', type='skill', notext=true})..' Level'
   table.insert(resultPart, '\r\n|-class="headerRow-0"')
   result = result..'!!XP!!Burn Time!!XP/s!!Bonfire Bonus!!Bonfire Time'
   table.insert(resultPart, '\r\n!colspan="2" rowspan="2"|Logs!!rowspan="2"|'..Icons.Icon({'Firemaking', type='skill', notext=true})..' Level')
   table.insert(resultPart, '!!rowspan="2"|Burn Time!!colspan="2"|Without Bonfire!!colspan="2"|With Bonfire!!rowspan="2"|Bonfire Bonus!!rowspan="2"|Bonfire Time')
  table.insert(resultPart, '\r\n|-class="headerRow-1"')
  table.insert(resultPart, '\r\n!XP!!XP/s!!XP!!XP/s')


   for i, logData in Shared.skpairs(SkillData.Firemaking) do
   for i, logData in Shared.skpairs(SkillData.Firemaking) do
    result = result..'\r\n|-'
     local name = Shared.titleCase(logData.type..' Logs')
     local name = Shared.titleCase(logData.type..' Logs')
    result = result..'\r\n|data-sort-value="'..name..'"|'..Icons.Icon({name, type='item', size='50', notext=true})
    result = result..'||[['..name..']]'
    result = result..'||style ="text-align: right;"|'..logData.level
    result = result..'||style ="text-align: right;"|'..logData.xp
     local burnTime = logData.interval / 1000
     local burnTime = logData.interval / 1000
     local XPS = logData.xp / burnTime
     local XPS = logData.xp / burnTime
     result = result..'||style ="text-align: right;" data-sort-value="'..burnTime..'"|'..Shared.timeString(burnTime, true)
     local XP_BF = logData.xp * (1 + logData.bonfireBonus / 100)
     result = result..'||style ="text-align: right;" data-sort-value="'..XPS..'"|'..Shared.round(XPS, 2, 2)
    local XPS_BF = XP_BF / burnTime
     result = result..'||style ="text-align: right;" data-sort-value="'..logData.bonfireBonus..'"|'..logData.bonfireBonus..'%'
 
     result = result..'||style ="text-align: right;" data-sort-value="'..logData.bonfireInterval..'"|'..Shared.timeString(logData.bonfireInterval / 1000, true)
    table.insert(resultPart, '\r\n|-')
    table.insert(resultPart, '\r\n|data-sort-value="'..name..'"|'..Icons.Icon({name, type='item', size='50', notext=true}))
    table.insert(resultPart, '||[['..name..']]')
    table.insert(resultPart, '||style ="text-align: right;"|'..logData.level)
    table.insert(resultPart, '||style ="text-align: right;" data-sort-value="'..burnTime..'"|'..Shared.timeString(burnTime, true))
     table.insert(resultPart, '||style ="text-align: right;"|'..logData.xp)
    table.insert(resultPart, '||style ="text-align: right;" data-sort-value="'..XPS..'"|'..Shared.round(XPS, 2, 2))
     table.insert(resultPart, '||style ="text-align: right;"|'..Shared.round(XP_BF, 2, 0))
    table.insert(resultPart, '||style ="text-align: right;" data-sort-value="'..XPS_BF..'"|'..Shared.round(XPS_BF, 2, 2))
    table.insert(resultPart, '||style ="text-align: right;" data-sort-value="'..logData.bonfireBonus..'"|'..logData.bonfireBonus..'%')
     table.insert(resultPart, '||style ="text-align: right;" data-sort-value="'..logData.bonfireInterval..'"|'..Shared.timeString(logData.bonfireInterval / 1000, true))
   end
   end


   result = result..'\r\n|}'
   table.insert(resultPart, '\r\n|}')
   return result
   return table.concat(resultPart)
end
end


return p
return p