Module:SkillUnlocks: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 11: Line 11:
local Items = require('Module:Items')
local Items = require('Module:Items')
local CombatAreas = require('Module:CombatAreas')
local CombatAreas = require('Module:CombatAreas')
local GameData = require('Module:GameData')


local CHECK_ITEMS = {'Attack', 'Strength', 'Defence', 'Ranged', 'Magic',  
local SKILL_CHECK_MAP = {
'Slayer'}
['Attack'] = {},
local CHECK_AREAS = {'Slayer'}
['Strength'] = {},
['Defence'] = {},
['Hitpoints'] = {},
['Ranged'] = {},
['Magic'] = {'spells'},
['Prayer'] = {},
['Slayer'] = {'areas'},
['Farming'] = {},
['Township'] = {},
['Woodcutting'] = {},
['Fishing'] = {},
['Firemaking'] = {},
['Cooking'] = {},
['Mining'] = {},
['Smithing'] = {},
['Thieving'] = {},
['Fletching'] = {},
['Crafting'] = {},
['Runecrafting'] = {},
['Herblore'] = {},
['Agility'] = {},
['Summoning'] = {},
['Astrology'] = {},
['Alt. Magic'] = {},
}
local TYPE_SORT_ORDER = {
local TYPE_SORT_ORDER = {
['item'] = 1,  
['spell'] = 1,
['combatArea'] = 2,
['item'] = 2,  
['slayerArea'] = 3,
['combatArea'] = 3,
['dungeon'] = 4
['slayerArea'] = 4,
['dungeon'] = 5
}
}
local VERBS_PER_SUBTYPE = {
local VERBS_PER_SUBTYPE = {
Line 38: Line 64:
['combatArea'] = 'Access',
['combatArea'] = 'Access',
['slayerArea'] = 'Access',
['slayerArea'] = 'Access',
['dungeon'] = 'Access'
['dungeon'] = 'Access',
['standard'] = 'Cast',
['aurora'] = 'Cast',
['curse'] = 'Cast',
['ancient'] = 'Cast',
['archaic'] = 'Cast'
}
}
local SUBTYPE_OVERRIDES = {
local SUBTYPE_OVERRIDES = {
Line 800: Line 831:
end
end
table.insert(entityList, processed)
table.insert(entityList, processed)
end
return entityList
end
function p._addSpellsWithSkillRequirement(entityList, skillName)
local SPELL_TYPES = {'standardSpells', 'auroraSpells', 'curseSpells', 'ancientSpells', 'archaicSpells'}
-- Iterate through each spell type and each spell within that type
for i, spellType in ipairs(SPELL_TYPES) do
for j, spell in ipairs(GameData.rawData[spellType]) do
local processed = {}
processed.entity = spell
processed.entityName = spell.name
processed.entityType = 'spell'
processed.subType = spell.spellBook
processed.skillLevel = spell.level
table.insert(entityList, processed)
end
end
end
Line 816: Line 866:
if entity.entityType == 'slayerArea' then
if entity.entityType == 'slayerArea' then
iconType = 'combatArea'
iconType = 'combatArea'
end
if entity.entityType == 'spell' and (entity.subType == 'aurora' or entity.subType == 'curse') then
iconType = entity.subType
end
end
Line 832: Line 885:
return gearSet.verb .. ' ' .. icons .. ' ' .. gearSet.name
return gearSet.verb .. ' ' .. icons .. ' ' .. gearSet.name
end
end
local SOURCE_FUNCS = {
['areas'] = p._addAreasWithSkillRequirement,
['spells'] = p._addSpellsWithSkillRequirement
}


function p._getSkillUnlockTable(skillName)
function p._getSkillUnlockTable(skillName)
-- local skillReqLabel = skillName:lower() .. 'LevelRequired'
-- What do we need to check for this skill? Avoid checking everything for
-- every skill to save time...except for items, because every skill at least
-- What do we need to check for this skill? (avoid checking everything for
-- has skillcapes with a level requirement
-- every skill to save time)
local entityList = {}
local entityList = {}
if Shared.contains(CHECK_ITEMS, skillName) then
entityList = p._addItemsWithSkillRequirement(entityList, skillName)
entityList = p._addItemsWithSkillRequirement(entityList, skillName)
for i, dataSource in ipairs(SKILL_CHECK_MAP[skillName]) do
end
entityList = SOURCE_FUNCS[dataSource](entityList, skillName)
if Shared.contains(CHECK_AREAS, skillName) then
entityList = p._addAreasWithSkillRequirement(entityList, skillName)
end
end
Line 880: Line 935:
-- Skip this one if it's in a gear set we've already listed
-- Skip this one if it's in a gear set we've already listed
local entityGearSet = nil
local entityGearSet = nil
for i, gearSet in ipairs(GEAR_SETS) do
if entity.entityType == 'item' then
if Shared.contains(gearSet.entities, entity.entityName) then
for i, gearSet in ipairs(GEAR_SETS) do
entityGearSet = gearSet
if Shared.contains(gearSet.entities, entity.entityName) then
break
entityGearSet = gearSet
break
end
end
end
end
end
Line 927: Line 984:
function p.test()
function p.test()
local ret = {}
local ret = {}
for i, gearSet in ipairs(GEAR_SETS) do
for i, spell in ipairs(GameData.rawData.standardSpells) do
mw.logObject(gearSet)
mw.logObject(spell)
break
--[[
if Shared.contains(gearSet.entities, 'Bronze Boots') then
ret = gearSet
break
end
--]]
end
end
73

edits