Module:Shop: Difference between revisions

_getShopSkillcapeTable: Fix sorting function & extend to include superior skillcapes
(_getShopTable: Use game defined order when no custom sort defined)
(_getShopSkillcapeTable: Fix sorting function & extend to include superior skillcapes)
Line 615: Line 615:
end
end


function p.getShopSkillcapeTable()
function p._getShopSkillcapeTable(showSuperior)
local capeList = p.getPurchases(function(purch) return purch.category == 'melvorD:Skillcapes' end)
local categoryID = (showSuperior and 'melvorTotH:SuperiorSkillcapes') or 'melvorD:Skillcapes'
local sortOrderFunc = function(a, b)
local capeList = p.getPurchases(function(purch) return purch.category == categoryID end)
if a.cost.gp == b.cost.gp then
local sortOrderFunc =
return p._getPurchaseName(a) < p._getPurchaseName(b)
function(a, b)
else
local costA, costB = p._getPurchaseSortValue(a), p._getPurchaseSortValue(b)
return a.cost.gp < b.cost.gp
if costA == costB then
end
return p._getPurchaseName(a) < p._getPurchaseName(b)
end
else
return costA < costB
end
end
return p._getShopTable(capeList, {
return p._getShopTable(capeList, {
columns = { 'Purchase', 'Description', 'Cost' },
columns = { 'Purchase', 'Description', 'Cost' },
Line 630: Line 633:
headerProps = {["Purchase"] = 'colspan="2" style="width:200px;"', ["Cost"] = 'style=width:120px;'}
headerProps = {["Purchase"] = 'colspan="2" style="width:200px;"', ["Cost"] = 'style=width:120px;'}
})
})
end
function p.getShopSkillcapeTable(frame)
local capeCategory = frame.args ~= nil and frame.args[1] or frame
local showSuperior = string.lower(capeCategory) == 'superior'
return p._getShopSkillcapeTable(showSuperior)
end
end