Module:Skills/Artisan: Difference between revisions

_getRecipeTable: Prevent repeating of item image for recipes with multiple costs
(Undo revision 60646 by Auron956 (talk) - Reinstate changes)
Tag: Undo
(_getRecipeTable: Prevent repeating of item image for recipes with multiple costs)
Line 196: Line 196:
function p.getRunecraftingTable(frame)
function p.getRunecraftingTable(frame)
local category = frame.args ~= nil and frame.args[1] or frame
local category = frame.args ~= nil and frame.args[1] or frame
return p._getRecipeTable('Runecrafting', category, {'Item', 'SkillLevel', 'SkillXP', 'GP', 'Ingredients', 'SkillXPSec', 'GPSec'})
return p._getRecipeTable('Runecrafting', category, {'ItemImage', 'ItemName', 'SkillLevel', 'SkillXP', 'GP', 'Ingredients', 'SkillXPSec', 'GPSec'})
end
end


function p.getFletchingTable(frame)
function p.getFletchingTable(frame)
local category = frame.args ~= nil and frame.args[1] or frame
local category = frame.args ~= nil and frame.args[1] or frame
return p._getRecipeTable('Fletching', category, {'Item', 'SkillLevel', 'SkillXP', 'GP', 'Ingredients'})
return p._getRecipeTable('Fletching', category, {'ItemImage', 'ItemName', 'SkillLevel', 'SkillXP', 'GP', 'Ingredients'})
end
end


function p.getCraftingTable(frame)
function p.getCraftingTable(frame)
local category = frame.args ~= nil and frame.args[1] or frame
local category = frame.args ~= nil and frame.args[1] or frame
local columns = {'Item', 'SkillLevel', 'SkillXP', 'GP', 'Ingredients'}
local columns = {'ItemImage', 'ItemName', 'SkillLevel', 'SkillXP', 'GP', 'Ingredients'}
if category == 'Rings' or category == 'Necklaces' then
if category == 'Rings' or category == 'Necklaces' then
table.insert(columns, "Description")
table.insert(columns, "Description")
Line 215: Line 215:
function p.getSmithingTable(frame)
function p.getSmithingTable(frame)
local category = frame.args ~= nil and frame.args[1] or frame
local category = frame.args ~= nil and frame.args[1] or frame
local columns = {'Item', 'SkillLevel', 'SkillXP', 'GP', 'Ingredients'}
local columns = {'ItemImage', 'ItemName', 'SkillLevel', 'SkillXP', 'GP', 'Ingredients'}
if category ~= 'Bars' then
if category ~= 'Bars' then
table.insert(columns, 'GPBar')
table.insert(columns, 'GPBar')
Line 268: Line 268:
-- Validation: Column list
-- Validation: Column list
local columnDef = {
local columnDef = {
["Item"] = {["header"] = 'Item\r\n!Name', ["altRepeat"] = true},
["ItemImage"] = {["header"] = 'Item', ["altRepeat"] = false},
["ItemName"] = {["header"] = 'Name', ["altRepeat"] = true},
["SkillLevel"] = {["header"] = Icons.Icon({skillName, type='skill', notext=true}) .. ' Level', ["altRepeat"] = false},
["SkillLevel"] = {["header"] = Icons.Icon({skillName, type='skill', notext=true}) .. ' Level', ["altRepeat"] = false},
["SkillXP"] = {["header"] = 'XP', ["altRepeat"] = false},
["SkillXP"] = {["header"] = 'XP', ["altRepeat"] = false},
Line 321: Line 322:
local rowspanStr = (recipeRow == 1 and costCount > 1 and 'rowspan="' .. costCount .. '" ') or ''
local rowspanStr = (recipeRow == 1 and costCount > 1 and 'rowspan="' .. costCount .. '" ') or ''
local qty = (costDef.quantityMultiplier or 1) * (recipe.baseQuantity or 1)
local qty = (costDef.quantityMultiplier or 1) * (recipe.baseQuantity or 1)
table.insert(resultPart, '\r\n|-')
table.insert(resultPart, '\n|-')
for j, colID in ipairs(columnList) do
for j, colID in ipairs(columnList) do
local altRepeat = columnDef[colID].altRepeat
local altRepeat = columnDef[colID].altRepeat
Line 328: Line 329:
if recipeRow == 1 or altRepeat then
if recipeRow == 1 or altRepeat then
local spanStr = (not altRepeat and rowspanStr) or ''
local spanStr = (not altRepeat and rowspanStr) or ''
if colID == 'Item' then
if colID == 'ItemImage' then
table.insert(resultPart, '\n|' .. spanStr .. 'class="table-img"| ' .. Icons.Icon({item.name, type='item', size='50', notext=true}))
elseif colID == "ItemName" then
local namePrefix = spanStr
local namePrefix = spanStr
if qty > 1 then
if qty > 1 then
namePrefix = namePrefix .. 'data-sort-value="' .. item.name .. '"'
namePrefix = namePrefix .. 'data-sort-value="' .. item.name .. '"'
end
end
table.insert(resultPart, '\r\n|' .. spanStr .. 'style="text-align:center;min-width:25px"| ' .. Icons.Icon({item.name, type='item', size='50', notext=true}))
table.insert(resultPart, '\n|'.. (namePrefix ~= '' and namePrefix .. '| ' or ' ') .. Icons.getExpansionIcon(item.id) .. (qty > 1 and '<b>' .. qty .. 'x</b> ' or '') .. Icons.Icon({item.name, type='item', noicon=true}))
table.insert(resultPart, '\r\n|'.. (namePrefix ~= '' and namePrefix .. '| ' or ' ') .. Icons.getExpansionIcon(item.id) .. (qty > 1 and '<b>' .. qty .. 'x</b> ' or '') .. Icons.Icon({item.name, type='item', noicon=true}))
elseif colID == 'SkillLevel' then
elseif colID == 'SkillLevel' then
table.insert(resultPart, '\r\n|' .. spanStr .. 'style="text-align:right"| ' .. recipe.level)
table.insert(resultPart, '\n|' .. spanStr .. 'style="text-align:right"| ' .. recipe.level)
elseif colID == 'SkillXP' then
elseif colID == 'SkillXP' then
table.insert(resultPart, '\r\n|' .. spanStr .. 'data-sort-value="' .. recipe.baseExperience ..'" style="text-align:right"| ' .. Shared.formatnum(recipe.baseExperience))
table.insert(resultPart, '\n|' .. spanStr .. 'data-sort-value="' .. recipe.baseExperience ..'" style="text-align:right"| ' .. Shared.formatnum(recipe.baseExperience))
elseif colID == 'GP' then
elseif colID == 'GP' then
local val = math.floor(item.sellsFor)
local val = math.floor(item.sellsFor)
table.insert(resultPart, '\r\n|' .. spanStr .. 'data-sort-value="' .. (val * qty) .. '"| ' .. Icons.GP(val) .. (qty > 1 and ' (x' .. qty .. ')' or ''))
table.insert(resultPart, '\n|' .. spanStr .. 'data-sort-value="' .. (val * qty) .. '"| ' .. Icons.GP(val) .. (qty > 1 and ' (x' .. qty .. ')' or ''))
elseif colID == 'Ingredients' then
elseif colID == 'Ingredients' then
local matArray = {}
local matArray = {}
Line 356: Line 358:
table.insert(matArray, Icons.SC(recipe.scCost))
table.insert(matArray, Icons.SC(recipe.scCost))
end
end
table.insert(resultPart, '\r\n|' .. (spanStr ~= '' and spanStr .. '| ' or ' ') .. table.concat(matArray, ', '))
table.insert(resultPart, '\n|' .. (spanStr ~= '' and spanStr .. '| ' or ' ') .. table.concat(matArray, ', '))
elseif colID == 'SkillXPSec' then
elseif colID == 'SkillXPSec' then
table.insert(resultPart, '\r\n|' .. spanStr .. 'style="text-align:right"| ' .. string.format('%.2f', recipe.baseExperience / actionInterval))
table.insert(resultPart, '\n|' .. spanStr .. 'style="text-align:right"| ' .. string.format('%.2f', recipe.baseExperience / actionInterval))
elseif colID == 'GPSec' then
elseif colID == 'GPSec' then
local val = math.floor(item.sellsFor) * qty / actionInterval
local val = math.floor(item.sellsFor) * qty / actionInterval
table.insert(resultPart, '\r\n|' .. spanStr .. 'data-sort-value="' .. val .. '"| ' .. Icons.GP(string.format('%.2f', val)))
table.insert(resultPart, '\n|' .. spanStr .. 'data-sort-value="' .. val .. '"| ' .. Icons.GP(string.format('%.2f', val)))
elseif colID == 'GPBar' then
elseif colID == 'GPBar' then
local barQty = 0
local barQty = 0
Line 371: Line 373:
if barQty > 0 then
if barQty > 0 then
local barVal = Shared.round(math.floor(item.sellsFor) * qty / barQty, 1, 1)
local barVal = Shared.round(math.floor(item.sellsFor) * qty / barQty, 1, 1)
table.insert(resultPart, '\r\n|' .. spanStr .. 'data-sort-value="' .. barVal .. '"| ' .. Icons.GP(barVal))
table.insert(resultPart, '\n|' .. spanStr .. 'data-sort-value="' .. barVal .. '"| ' .. Icons.GP(barVal))
else
else
table.insert(resultPart, '\r\n|' .. spanStr .. 'data-sort-value="0" class="table-na"| N/A')
table.insert(resultPart, '\n|' .. spanStr .. 'data-sort-value="0" class="table-na"| N/A')
end
end
elseif colID == 'Description' then
elseif colID == 'Description' then
Line 380: Line 382:
descrip = Constants.getModifiersText(item.modifiers, false)
descrip = Constants.getModifiersText(item.modifiers, false)
end
end
table.insert(resultPart, '\r\n| '..spanStr..'|'..descrip)
table.insert(resultPart, '\n| '..spanStr..'|'..descrip)
else
else
table.insert(resultPart, '\r\n| ')
table.insert(resultPart, '\n| ')
end
end
end
end
Line 389: Line 391:
end
end
end
end
table.insert(resultPart, '\r\n|}')
table.insert(resultPart, '\n|}')
return table.concat(resultPart)
return table.concat(resultPart)
end
end