Module:SkillUnlocks: Difference between revisions

no edit summary
No edit summary
No edit summary
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
local p = {}
local p = {}


--This module polls various game data sources to produce a full list of skill
-- This module polls various game data sources to produce a full list of skill
--level unlocks for each skill. The game has a hard-coded set of "milestones"
-- level unlocks for each skill. The game has a hard-coded set of "milestones"
--for each skill that does the same thing, but it is not exhaustive and not
-- for each skill that does the same thing, but it is not exhaustive and not
--permanently visible for most combat skills.
-- permanently visible for most combat skills.
 
-- TODO: Args to filter by level range and unlock type


local Shared = require('Module:Shared')
local Shared = require('Module:Shared')
Line 15: Line 17:
local GameData = require('Module:GameData')
local GameData = require('Module:GameData')
local SkillData = GameData.skillData
local SkillData = GameData.skillData
local Num = require('Module:Number')


-- This excludes certain checks pertinent to all skills, like equipment
-- This excludes certain checks pertinent to all skills, like equipment
Line 50: Line 53:
['plot'] = 4,
['plot'] = 4,
['obstacleslot'] = 5,
['obstacleslot'] = 5,
['spell'] = 6,
['pillar'] = 6,
['prayer'] = 7,
['spell'] = 7,
['thieving'] = 8,
['prayer'] = 8,
['constellation'] = 9,
['thieving'] = 9,
['gathering'] = 10,
['constellation'] = 10,
['artisan'] = 11,
['gathering'] = 11,
['item'] = 12,  
['artisan'] = 12,
['combatArea'] = 13,
['item'] = 13,  
['slayerArea'] = 14,
['combatArea'] = 14,
['dungeon'] = 15,
['slayerArea'] = 15,
['shop'] = 16,
['dungeon'] = 16,
['trader'] = 17,
['shop'] = 17,
['obstacle'] = 18
['trader'] = 18,
['obstacle'] = 19
}
}
local VERBS_PER_SUBTYPE = {
local VERBS_PER_SUBTYPE = {
Line 87: Line 91:
['ancient'] = 'Cast',
['ancient'] = 'Cast',
['archaic'] = 'Cast',
['archaic'] = 'Cast',
['prayer'] = 'Cast',
['prayer'] = 'Use',
['altMagic'] = 'Cast',
['altMagic'] = 'Cast',
['tree'] = 'Cut',
['tree'] = 'Cut',
Line 867: Line 871:
end
end
end
end
-- Sort it so the results are rendered consistently
--[[
table.sort(entityList, function(a, b)
if a.type ~= b.type then
return a.type < b.type
else
end
end)
--]]
return otherReqs
return otherReqs
Line 926: Line 919:
local entityType = args.type
local entityType = args.type
local typeParam = args.typeParam
local typeParam = args.typeParam
--local passedType = typeParam ~= nil and entity[typeParam] or entityType
local subType = args.subType
local subType = args.subType
local subTypeParam = args.subTypeParam
local subTypeParam = args.subTypeParam
Line 955: Line 947:
end)
end)
-- TODO: Squeeze this into _addEntities?
for i, item in ipairs(itemList) do
for i, item in ipairs(itemList) do
local processed = {}
local processed = {}
Line 982: Line 973:
end)
end)
-- TODO: Squeeze this into _addEntities
for i, area in ipairs(areaList) do
for i, area in ipairs(areaList) do
local processed = {}
local processed = {}
Line 1,213: Line 1,203:
-- Manually add pillars
-- Manually add pillars
table.insert(entityList, {['entityName'] = 'Passive Pillars', ['entityType'] = 'obstacleslot', ['subType'] = 'pillar', ['skillLevel'] = 99, ['otherReqs'] = {}})
table.insert(entityList, {['entityName'] = 'Passive Pillars', ['entityType'] = 'pillar', ['subType'] = 'pillar', ['skillLevel'] = 99, ['otherReqs'] = {}})
table.insert(entityList, {['entityName'] = 'Elite Passive Pillars', ['entityType'] = 'obstacleslot', ['subType'] = 'pillar', ['skillLevel'] = 120, ['otherReqs'] = {}})
table.insert(entityList, {['entityName'] = 'Elite Passive Pillars', ['entityType'] = 'pillar', ['subType'] = 'pillar', ['skillLevel'] = 120, ['otherReqs'] = {}})
return entityList
return entityList
Line 1,249: Line 1,239:
processed['entityName'] = gatherable.name
processed['entityName'] = gatherable.name
elseif skillName == 'Mining' then
elseif skillName == 'Mining' then
processed['subType'] = node.type
processed['subType'] = node.category
elseif skillName == 'Farming' then
elseif skillName == 'Farming' then
processed['entityName'] = gatherable.name
processed['entityName'] = gatherable.name
Line 1,325: Line 1,315:
else
else
for i, req in ipairs(entity.otherReqs) do
for i, req in ipairs(entity.otherReqs) do
-- TODO: "Completion" requirement
-- TODO: "Completion" requirement? Might not be needed
-- TODO: Township buildings requirement
if req.type == 'SkillLevel' then
if req.type == 'SkillLevel' then
local skillInfo = Icons.Icon({Constants.getSkillName(req.skillID), type='skill', notext='true'}) .. ' ' .. req.level
local skillInfo = Icons.Icon({Constants.getSkillName(req.skillID), type='skill', notext='true'}) .. ' ' .. req.level
Line 1,349: Line 1,338:
table.insert(extraReqs, Shop._getPurchaseIcon({req.purchase}))
table.insert(extraReqs, Shop._getPurchaseIcon({req.purchase}))
elseif req.type == 'totalMastery' then
elseif req.type == 'totalMastery' then
table.insert(extraReqs, Shared.formatnum(req.mastery) .. ' ' .. Icons.Icon({req.skill, type='skill', notext=true}) .. ' ' .. Icons.Icon({'Mastery'}))
table.insert(extraReqs, Num.formatnum(req.mastery) .. ' ' .. Icons.Icon({req.skill, type='skill', notext=true}) .. ' ' .. Icons.Icon({'Mastery'}))
elseif req.type == 'TownshipBuilding' then
local building = Township._getBuildingByID(req.buildingID)
table.insert(extraReqs, Icons.Icon({building.name, type='building', qty=req.count}))
end
end
end
end
Line 1,400: Line 1,392:
if entity.subType == 'fish' then
if entity.subType == 'fish' then
iconType = 'item'
iconType = 'item'
elseif entity.subType == 'Essence' or entity.subType == 'Ore' or entity.subType == 'Gem' then
elseif Shared.contains({
'melvorD:Ore',
'melvorD:Essence',
'melvorD:Gem',
'melvorItA:AbyssalOre',
'melvorItA:AbyssalGem',
'melvorItA:Outcrop',
'melvorItA:AbyssalEssence'
}, entity.subType) then
iconType = 'rock'
iconType = 'rock'
else
else
Line 1,420: Line 1,420:
end
end
if entity.entityType == 'obstacle' then
if entity.entityType == 'obstacle' then
iconType = 'agility'
end
if entity.entityType == 'obstacleslot' then
iconType = 'agility'
iconType = 'agility'
iconLink = 'Obstacles'
iconLink = 'Obstacles'
end
end
if entity.entityType == 'obstacleslot' then
if entity.entityType == 'pillar' then
iconType = 'agility'
iconType = 'agility'
iconLink = 'Passive_Pillars'
iconLink = 'Passive_Pillars'
Line 1,455: Line 1,458:
end
end


function p._getSkillUnlockTable(skillName)
function p._getSkillUnlockTable(skillName, args)
local itemsOnly = args.itemsOnly ~= nil and args.itemsOnly or false
-- TODO: Pass these min/max level params along to filter by them
local minLevel = args.minLevel ~= nil and args.minLevel or 0
local maxLevel = args.maxLevel ~= nil and args.maxLevel or 999
-- What do we need to check for this skill? Avoid checking everything for
-- What do we need to check for this skill? Avoid checking everything for
-- every skill to save time, except for a few broad things
-- every skill to save time, except for a few broad things
local entityList = {}
local entityList = {}
entityList = p._addItemsWithSkillRequirement(entityList, skillName)
entityList = p._addItemsWithSkillRequirement(entityList, skillName)
entityList = p._addShopPurchasesWithSkillRequirements(entityList, skillName)
entityList = p._addTraderItemsWithSkillRequirements(entityList, skillName)
entityList = p._addAgilityObstaclesWithSkillRequirements(entityList, skillName)
-- Now loop through the stuff relevant to this skill
if not itemsOnly then
for i, dataSource in ipairs(SKILL_CHECK_MAP[skillName]) do
entityList = p._addShopPurchasesWithSkillRequirements(entityList, skillName)
entityList = SOURCE_FUNCS[dataSource](entityList, skillName)
entityList = p._addTraderItemsWithSkillRequirements(entityList, skillName)
entityList = p._addAgilityObstaclesWithSkillRequirements(entityList, skillName)
-- Now loop through the stuff relevant to this skill
for i, dataSource in ipairs(SKILL_CHECK_MAP[skillName]) do
entityList = SOURCE_FUNCS[dataSource](entityList, skillName)
end
end
end
Line 1,554: Line 1,565:


function p.getSkillUnlockTable(frame)
function p.getSkillUnlockTable(frame)
local skillName = frame.args ~= nil and frame.args[1]
local args = frame.args ~= nil and frame.args or frame
return p._getSkillUnlockTable(skillName)
local skillName = args[1]
end
return p._getSkillUnlockTable(skillName, args)
 
function p.test()
local purchase = Shop.getPurchaseByID('melvorTotH:Corundum_Axe')
mw.log(Shop._getPurchaseIcon({purchase, notext='true'}))
end
end


return p
return p
2,875

edits