Anonymous

Module:Skills/Artisan: Difference between revisions

From Melvor Idle
_getRecipeTable: Determine DLC correctly for recipes with alt costs
(_getRecipeTable: Amend XP rate number formatting)
(_getRecipeTable: Determine DLC correctly for recipes with alt costs)
Line 518: Line 518:
["ItemName"] = {["header"] = 'Name', ["altRepeat"] = true},
["ItemName"] = {["header"] = 'Name', ["altRepeat"] = true},
["SkillLevel"] = {["header"] = Icons._SkillRealmIcon(skillName, categoryRealm) .. ' Level', ["altRepeat"] = false},
["SkillLevel"] = {["header"] = Icons._SkillRealmIcon(skillName, categoryRealm) .. ' Level', ["altRepeat"] = false},
["DLC"] = {["header"] = '[[DLC]]', ["altRepeat"] = false},
["DLC"] = {["header"] = '[[DLC]]', ["altRepeat"] = true},
["SkillXP"] = {["header"] = 'XP', ["altRepeat"] = false},
["SkillXP"] = {["header"] = 'XP', ["altRepeat"] = false},
["Currency"] = {["header"] = 'Value', ["altRepeat"] = true},
["Currency"] = {["header"] = 'Value', ["altRepeat"] = true},
Line 566: Line 566:
if item ~= nil then
if item ~= nil then
-- Some recipes have alternative costs, so the recipe may require multiple rows
-- Some recipes have alternative costs, so the recipe may require multiple rows
local costList = nil
local hasAltCosts = recipe.alternativeCosts ~= nil and not Shared.tableIsEmpty(recipe.alternativeCosts)
if recipe.alternativeCosts ~= nil and not Shared.tableIsEmpty(recipe.alternativeCosts) then
local costList = (hasAltCosts and recipe.alternativeCosts) or {{["itemCosts"] = recipe.itemCosts}}
costList = recipe.alternativeCosts
else
costList = {{["itemCosts"] = recipe.itemCosts}}
end
local costCount = Shared.tableCount(costList)
local costCount = Shared.tableCount(costList)
-- Build one row per element within costList
-- Build one row per element within costList
Line 604: Line 600:
:css('text-align', 'right')
:css('text-align', 'right')
elseif colID == 'DLC' then
elseif colID == 'DLC' then
cell:wikitext(Icons.getDLCColumnIcon(recipe.id))
local dlcID = recipe.id
:attr('data-sort-value', Icons.getExpansionID(recipe.id))
if hasAltCosts then
-- For alt costs, look at the namespace of the required materials,
-- as the recipe could be from base game but using expansion materials
local recNS, recLocalID = Shared.getLocalID(recipe.id)
if Shared.contains({'melvorD', 'melvorF'}, recNS) then
for k, mat in ipairs(costDef.itemCosts) do
local matNS, matLocalID = Shared.getLocalID(mat.id)
if matNS ~= recNS then
dlcID = mat.id
break
end
end
end
end
cell:wikitext(Icons.getDLCColumnIcon(dlcID))
:attr('data-sort-value', Icons.getExpansionID(dlcID))
:css('text-align', 'center')
:css('text-align', 'center')
elseif colID == 'SkillXP' then
elseif colID == 'SkillXP' then