Anonymous

Module:Skills: Difference between revisions

From Melvor Idle
Adjusted the appearance of the Lesser Relics table
(getThievingSourcesForItem: Include type property in return value to distinguish between various sources)
(Adjusted the appearance of the Lesser Relics table)
 
(6 intermediate revisions by 2 users not shown)
Line 59: Line 59:
if recipe.category ~= nil then
if recipe.category ~= nil then
-- Obstacle
-- Obstacle
if recipe.category == 0 then
return SkillData.Agility.obstacleUnlockLevels[recipe.category+1]
return 1
else
return SkillData.Agility.obstacleUnlockLevels[recipe.category]
end
else
else
-- Pillar
-- Pillar
Line 142: Line 138:
if drop.id == itemID then
if drop.id == itemID then
for k, npcID in ipairs(area.npcIDs) do
for k, npcID in ipairs(area.npcIDs) do
areaNPCs[npcID] = drop.quantity
areaNPCs[npcID] = { qty = drop.quantity, area = area }
end
end
break
break
Line 170: Line 166:
end
end


if areaNPCs[npc.id] ~= nil then
local areaNPC = areaNPCs[npc.id]
table.insert(resultArray, {npc = npc.name, minQty = areaNPCs[npc.id], maxQty = areaNPCs[npc.id], wt = SkillData.Thieving.baseAreaUniqueChance, totalWt = 100, level = npc.level, npcID = npc.id, type = 'areaUnique'})
if areaNPC ~= nil then
table.insert(resultArray, {npc = npc.name, minQty = areaNPC.qty, maxQty = areaNPC.qty, wt = SkillData.Thieving.baseAreaUniqueChance, totalWt = 100, level = npc.level, npcID = npc.id, area = areaNPC.area, type = 'areaUnique'})
end
end
end
end
Line 492: Line 489:
table.insert(resultPart, '\r\n|}')
table.insert(resultPart, '\r\n|}')
return table.concat(resultPart)
return table.concat(resultPart)
end
function p.getAncientRelicsTable(frame)
local skillName = frame.args ~= nil and frame.args[1] or frame
local skillID = nil
if skillName ~= nil and skillName ~= '' then
skillID = Constants.getSkillID(skillName)
if skillID == nil then
return Shared.printError('Failed to find a skill ID for ' .. skillName)
end
end
local resultPart = {}
table.insert(resultPart, '{| class="wikitable sortable stickyHeader lighttable"')
table.insert(resultPart, '\n|-class="headerRow-0"')
table.insert(resultPart, '\n|-\n!colspan="2"|Skill\n!Relic\n!Modifiers')
local relics = GameData.getEntities('ancientRelics',
function(relic)
return skillID == nil or relic.skillID == skillID
end)
table.sort(relics,
function (a, b)
local skillNameA, skillNameB = Constants.getSkillName(a.skillID), Constants.getSkillName(b.skillID)
if skillNameA == skillNameB then
-- Order by numbers at the end of relic IDs
-- Relics have a 'number' property, but this appears to contain duplicates
return string.sub(a.id, string.len(a.id)) < string.sub(b.id, string.len(b.id))
else
return skillNameA < skillNameB
end
end)
local function appendSkillRows(resultTable, rowTable, relicCount, skillID)
local skillName = Constants.getSkillName(skillID)
table.insert(resultTable, '\n|-\n|rowspan="' .. relicCount .. '"| ' .. Icons.Icon({skillName, type='skill', notext=true, size=50}))
table.insert(resultTable, '\n|rowspan="' .. relicCount .. '"| ' .. Icons.Icon({skillName, type='skill', noicon=true}))
table.insert(resultTable, table.concat(rowTable))
end
local skillRelicCount, currentSkillID, tablePart = 0, nil, {}
for i, relic in ipairs(relics) do
if currentSkillID == nil then
currentSkillID = relic.skillID
elseif relic.skillID ~= currentSkillID then
appendSkillRows(resultPart, tablePart, skillRelicCount, currentSkillID)
tablePart = {}
currentSkillID = relic.skillID
skillRelicCount = 0
end
skillRelicCount = skillRelicCount + 1
if skillRelicCount > 1 then
table.insert(tablePart, '\n|-')
end
table.insert(tablePart, '\n| ' .. skillRelicCount .. '\n| ' .. Constants.getModifiersText(relic.modifiers))
end
appendSkillRows(resultPart, tablePart, skillRelicCount, currentSkillID)
table.insert(resultPart, '\n|}')
return table.concat(resultPart)
end
function p.getLesserRelicsTable(frame)
local lesserRelics = {}
-- Iterate over each skill with a global rare drop then check
-- if the skill has a Lesser Relic drop
for skillLocalID, skill in pairs(SkillData) do
if skill.rareDrops ~= nil then
for i, drops in pairs(skill.rareDrops) do
if string.match(drops.itemID, '_Lesser_Relic') then
table.insert(lesserRelics, Items.getItemByID(drops.itemID))
end
end
end
end
table.sort(lesserRelics, function(a, b) return a.name < b.name end)
-- Create the Table
local resultTable = mw.html.create('table')
resultTable:addClass('wikitable sortable')
resultTable:tag('tr'):addClass('headerRow-0')
:tag('th'):wikitext('Icon')
:tag('th'):wikitext('Lesser Relic')
:tag('th'):wikitext('Modifiers')
for _, relic in ipairs(lesserRelics) do
local tr = mw.html.create('tr')
tr:tag('td'):wikitext(Icons.Icon({relic.name, type='item', size='50', notext=true}))
tr:tag('td'):wikitext(Icons.Icon({relic.name, type='item', noicon=true}))
tr:tag('td'):wikitext(Constants.getModifiersText(relic.modifiers))
resultTable:node(tr)
end
return resultTable
end
end


return p
return p
463

edits