Module:Skills/Artisan: Difference between revisions

no edit summary
(Re-introduce supported column definitions)
No edit summary
Line 45: Line 45:
table.sort(recipeArray, function(a, b) return Skills.standardRecipeSort(skillID, a, b) end)
table.sort(recipeArray, function(a, b) return Skills.standardRecipeSort(skillID, a, b) end)


-- Logic for generating some cells of the table which are consistent for normal & perfect items
local cookIcon = Icons._SkillRealmIcon('Cooking', realm.id)
local getHealingCell = function(item, qty)
local perfectIcon = Icons.Icon({'Perfect', type='bonus', ext='png', notext=true, nolink=true})
if item ~= nil then
local healIcon = Icons.Icon({"Hitpoints", type="skill", notext=true, nolink=true})
return 'data-sort-value="'..(math.floor(item.healsFor) * qty)..'"|'..Icons.Icon({"Hitpoints", type="skill", notext=true})..' '..Num.formatnum(math.floor(item.healsFor * 10))..(qty > 1 and ' (x'..qty..')' or '')
else
local html = mw.html.create('table')
return ' '
:addClass('sortable stickyHeader')
end
end
html:tag('tr'):addClass("headerRow-0")
local getSaleValueCell = function(item, qty)
:tag('th'):wikitext('Cooked Item')
if item ~= nil then
  :attr('colspan', 3)
return 'data-sort-value="'..math.floor(item.sellsFor * qty)..'"|'..Items.getValueText(item)..(qty > 1 and ' (x'..qty..')' or '')
  :attr('rowspan', 2)
else
:tag('th'):wikitext(cookIcon .. '<br>Level')
return ' '
      :attr('rowspan', 2)
end
:tag('th'):wikitext('[[DLC]]')
end
  :attr('rowspan', 2)
 
:tag('th'):wikitext('Cook<br>Time (s)')
local resultPart = {}
  :attr('rowspan', 2)
table.insert(resultPart, '{| class="wikitable sortable stickyHeader"')
:tag('th'):wikitext(cookIcon .. '<br>XP')
table.insert(resultPart, '\r\n|- class="headerRow-0"')
  :attr('rowspan', 2)
table.insert(resultPart, '\r\n!colspan="3" rowspan="2"|Cooked Item!!rowspan="2"|Requirements')
:tag('th'):wikitext('XP/s')
table.insert(resultPart, '!!rowspan="2"|Cook Time (s)!!rowspan="2"|XP!!rowspan="2"|XP/s!!colspan="2"|Healing!!colspan="2"|Value!!rowspan="2"|Ingredients')
  :attr('rowspan', 2)
table.insert(resultPart, '\r\n|- class="headerRow-1"')
:tag('th'):wikitext('Total Healing')
table.insert(resultPart, '\r\n!Normal!!' .. Icons.Icon({'Perfect', type='bonus', ext='png', notext=true, nolink=true}))
  :attr('colspan', 2)
table.insert(resultPart, '!!Normal!!' .. Icons.Icon({'Perfect', type='bonus', ext='png', notext=true, nolink=true}))
:tag('th'):wikitext('Ingredients')
  :attr('rowspan', 2)
 
html:tag('tr'):addClass("headerRow-1")
:tag('th'):wikitext('Normal')
:tag('th'):wikitext(perfectIcon)


for i, recipe in ipairs(recipeArray) do
for i, recipe in ipairs(recipeArray) do
Line 74: Line 79:
local baseXP = recipe.baseAbyssalExperience or recipe.baseExperience
local baseXP = recipe.baseAbyssalExperience or recipe.baseExperience
local baseInt = recipe.baseInterval / 1000
local baseInt = recipe.baseInterval / 1000
local reqText = Skills.getRecipeRequirementText(SkillData.Cooking.name, recipe)
local xpRate = baseXP / baseInt
local xpRate = baseXP / baseInt
local item = Items.getItemByID(recipe.productID)
local item = Items.getItemByID(recipe.productID)
Line 82: Line 86:
end
end
local qty = recipe.baseQuantity or 1
local qty = recipe.baseQuantity or 1
local normalHeal = math.floor(item.healsFor * 10) * qty
local perfectHeal = math.floor(perfectItem.healsFor * 10) * qty
local row = html:tag('tr')
row:tag('td'):wikitext(Icons.Icon({item.name, type='item', notext=true}))
:addClass("table-img")


table.insert(resultPart, '\r\n|-')
table.insert(resultPart, '\r\n|class="table-img"|'..Icons.Icon({item.name, type='item', notext=true, size='50'}))
table.insert(resultPart, '\r\n|class="table-img"| ')
if perfectItem ~= nil then
if perfectItem ~= nil then
table.insert(resultPart, Icons.Icon({perfectItem.name, type='item', notext=true, size='50'}))
row:tag('td'):wikitext(Icons.Icon({perfectItem.name, type='item', notext=true}))
:addClass("table-img")
end
end
table.insert(resultPart, '||')
local nameCell = row:tag('td')
if qty > 1 then
if qty > 1 then
table.insert(resultPart, qty..'x ')
nameCell:wikitext(qty .. 'x ')
end
end
table.insert(resultPart, Icons.getExpansionIcon(item.id))
nameCell:wikitext('[[' .. item.name .. ']]')
table.insert(resultPart, Icons.Icon({item.name, type='item', noicon = true}))
row:tag('td'):wikitext(level)
table.insert(resultPart, '||style="text-align:right" data-sort-value="' .. level .. '"|' .. reqText)
:css('text-align', 'center')
table.insert(resultPart, '||style="text-align:right" data-sort-value="' .. baseInt .. '"|' .. Num.round(baseInt, 2, 0))
row:tag('td'):wikitext(Icons.getDLCColumnIcon(item.id))
table.insert(resultPart, '||style="text-align:right" data-sort-value="' .. baseXP .. '"|' .. Num.formatnum(baseXP))
:css('text-align', 'center')
table.insert(resultPart, '||style="text-align:right" data-sort-value="' .. xpRate .. '"|' .. Num.formatnum(Num.round(xpRate, 2, 0)))
:attr('data-sort-value', Icons.getExpansionID(item.id))
table.insert(resultPart, '||'..getHealingCell(item, qty)..'||'..getHealingCell(perfectItem, qty))
row:tag('td'):wikitext(Num.round(baseInt, 2, 0))
table.insert(resultPart, '||'..getSaleValueCell(item, qty)..'||'..getSaleValueCell(perfectItem, qty))
:css('text-align', 'right')
:attr('data-sort-value', baseInt)
row:tag('td'):wikitext(Num.formatnum(baseXP))
:css('text-align', 'right')
:attr('data-sort-value', baseXP)
row:tag('td'):wikitext(Num.formatnum(Num.round(xpRate, 2, 0)))
:css('text-align', 'right')
:attr('data-sort-value', xpRate)
row:tag('td'):wikitext(healIcon)
:wikitext(Num.formatnum(normalHeal))
:attr('data-sort-value', normalHeal)
row:tag('td'):wikitext(perfectIcon)
:wikitext(Num.formatnum(perfectHeal))
:attr('data-sort-value', perfectHeal)
 
local matArray = {}
local matArray = {}
for j, mat in ipairs(recipe.itemCosts) do
for j, mat in ipairs(recipe.itemCosts) do
Line 108: Line 131:
end
end
end
end
table.insert(resultPart, '\r\n|'..table.concat(matArray, ' '))
row:tag('td'):wikitext(table.concat(matArray, ' '))
end
end


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


2,869

edits