Module:Items/ComparisonTables/Sandbox: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 127: Line 127:
cell:wikitext(dr .. '%')
cell:wikitext(dr .. '%')
return cell
return cell
end
local function getRequirements(item)
if item.equipRequirements == nil then
return nil
end
local function getSkillName(skillID)
local _, localSkillID = GameData.getLocalID(skillID)
return localSkillID
end
local iconFuncs = {
['AbyssalLevel'] = function(x)
return Icons._SkillRealmIcon(getSkillName(x.skillID), 'melvorItA:Abyssal') .. ' ' .. x.level
end,
['SkillLevel'] = function(x)
return Icons._SkillRealmIcon(getSkillName(x.skillID)) .. ' ' .. x.level
end,
}
local reqs = {}
local abyssalSkills = {}
local highestLvReq = 0
-- Filter out all Abyssal Levels
    for _, req in ipairs(item.equipRequirements) do
        if req.type == 'AbyssalLevel' then abyssalSkills[req.skillID] = true end
    end
-- If the req is a SkillLevel, but the skillID is already an AbyssalLevel, skip the entry
-- These are likely 99 Level requirements in addition to the AbyssalLevel requirement.
    for _, req in ipairs(item.equipRequirements) do
if not (req.type == 'SkillLevel' and abyssalSkills[req.skillID] == true) then
-- Add requirement via factory function.
local func = iconFuncs[req.type]
if func then table.insert(reqs, func(req)) end
-- Track highest level for data sorting.
local lv = req.level or 0
if lv > highestLvReq then highestLvReq = lv end
end
    end
   
    if Shared.tableIsEmpty(abyssalSkills) == false then
    highestLvReq = highestLvReq + 99
    end
return {
['datasortvalue'] = highestLvReq,
['requirements'] = table.concat(reqs, '<br>')
}
end
end


Line 231: Line 283:
-- TODO: Format requirements
-- TODO: Format requirements
row:tag('td'):wikitext('None')
local reqs = getRequirements(item)
--'attackLevelRequired', 'strengthLevelRequired',  
if reqs == nil then
--'defenceLevelRequired', 'rangedLevelRequired', 'magicLevelRequired',
row:tag('td'):wikitext('None')
--'attackAbyssalLevel', 'strengthAbyssalLevel','defenceAbyssalLevel',
:attr('data-sort-value', 0)
--'rangedAbyssalLevel', 'magicAbyssalLevel'
else
row:tag('td'):wikitext(reqs.requirements)
:attr('data-sort-value', reqs.datasortvalue)
end
end
end


Line 242: Line 297:


-- TODO:
-- TODO:
--- Split Melvor / Abyss items (based on realm?)
--- Split 1h and 2h weapons
--- Split 1h and 2h weapons
--- When the category is 'Weapon', include every wieldable items (incl knives, javs, etc)
--- When the category is 'Weapon', include every wieldable items (incl knives, javs, etc)
2,875

edits