Anonymous

Module:Skills/Artisan: Difference between revisions

From Melvor Idle
Undo revision 60646 by Auron956 (talk) - Reinstate changes
(Revert recent changes)
Tags: Manual revert Reverted
(Undo revision 60646 by Auron956 (talk) - Reinstate changes)
Tag: Undo
Line 211: Line 211:
end
end
return p._getRecipeTable('Crafting', category, columns)
return p._getRecipeTable('Crafting', category, columns)
end
function p.getSmithingTable(frame)
local category = frame.args ~= nil and frame.args[1] or frame
local columns = {'Item', 'SkillLevel', 'SkillXP', 'GP', 'Ingredients'}
if category ~= 'Bars' then
table.insert(columns, 'GPBar')
end
return p._getRecipeTable('Smithing', category, columns)
end
end


Line 229: Line 238:


local supportedSkills = {
local supportedSkills = {
'Smithing',
'Crafting',
'Crafting',
'Fletching',
'Fletching',
Line 260: Line 270:
["Item"] = {["header"] = 'Item\r\n!Name', ["altRepeat"] = true},
["Item"] = {["header"] = 'Item\r\n!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},
["GP"] = {["header"] = 'Value', ["altRepeat"] = true},
["GP"] = {["header"] = 'Value', ["altRepeat"] = true},
["Ingredients"] = {["header"] = 'Ingredients', ["altRepeat"] = true},
["Ingredients"] = {["header"] = 'Ingredients', ["altRepeat"] = true},
["SkillXPSec"] = {["header"] = 'XP/s', ["altRepeat"] = false},
["SkillXPSec"] = {["header"] = 'XP/s', ["altRepeat"] = false},
["GPSec"] = {["header"] = 'GP/s', ["altRepeat"] = true},
["GPSec"] = {["header"] = 'GP/s', ["altRepeat"] = true},
["GPBar"] = {["header"] = 'Value/Bar', ["altRepeat"] = true },
["Description"] = {["header"] = "Description", ["altRepeat"] = true}
["Description"] = {["header"] = "Description", ["altRepeat"] = true}
}
}
-- Build the table header while we're here
-- Build the table header while we're here
local resultPart = {}
local resultPart, barIDList = {}, {}
table.insert(resultPart, '{| class="wikitable sortable stickyHeader"\r\n|- class="headerRow-0"')
table.insert(resultPart, '{| class="wikitable sortable stickyHeader"\r\n|- class="headerRow-0"')
for i, colID in ipairs(columnList) do
for i, colID in ipairs(columnList) do
Line 275: Line 286:
else
else
table.insert(resultPart, '\r\n! ' .. columnDef[colID].header)
table.insert(resultPart, '\r\n! ' .. columnDef[colID].header)
if colID == 'GPBar' then
-- For Smithing, a GP value per bar column is included. If this
-- is requested, then obtain a list of bar item IDs
barIDList = p.getBarItemIDs()
end
end
end
end
end
Line 346: Line 362:
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, '\r\n|' .. spanStr .. 'data-sort-value="' .. val .. '"| ' .. Icons.GP(string.format('%.2f', val)))
elseif colID == 'GPBar' then
local barQty = 0
for k, mat in ipairs(costDef.itemCosts) do
if Shared.contains(barIDList, mat.id) then
barQty = barQty + mat.quantity
end
end
if barQty > 0 then
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))
else
table.insert(resultPart, '\r\n|' .. spanStr .. 'data-sort-value="0" class="table-na"| N/A')
end
elseif colID == 'Description' then
elseif colID == 'Description' then
local descrip = Items._getItemStat(item, 'description')
local descrip = Items._getItemStat(item, 'description')
Line 362: Line 391:
table.insert(resultPart, '\r\n|}')
table.insert(resultPart, '\r\n|}')
return table.concat(resultPart)
return table.concat(resultPart)
end
function p.getBarItemIDs()
local barIDList = {}
for i, recipe in ipairs(SkillData.Smithing.recipes) do
if recipe.categoryID == 'melvorD:Bars' then
table.insert(barIDList, recipe.productID)
end
end
return barIDList
end
end


return p
return p