Module:SkillUnlocks: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 12: Line 12:
local CombatAreas = require('Module:CombatAreas')
local CombatAreas = require('Module:CombatAreas')
local GameData = require('Module:GameData')
local GameData = require('Module:GameData')
local SkillData = GameData.skillData


local SKILL_CHECK_MAP = {
local SKILL_CHECK_MAP = {
Line 20: Line 21:
['Ranged'] = {},
['Ranged'] = {},
['Magic'] = {'spells'},
['Magic'] = {'spells'},
['Prayer'] = {},
['Prayer'] = {'prayers'},
['Slayer'] = {'areas'},
['Slayer'] = {'areas'},
['Farming'] = {},
['Farming'] = {},
['Township'] = {},
['Township'] = {},
['Woodcutting'] = {},
['Woodcutting'] = {'gathering'},
['Fishing'] = {},
['Fishing'] = {'gathering'},
['Firemaking'] = {},
['Firemaking'] = {},
['Cooking'] = {},
['Cooking'] = {},
['Mining'] = {},
['Mining'] = {'gathering'},
['Smithing'] = {},
['Smithing'] = {},
['Thieving'] = {},
['Thieving'] = {},
Line 42: Line 43:
local TYPE_SORT_ORDER = {
local TYPE_SORT_ORDER = {
['spell'] = 1,
['spell'] = 1,
['item'] = 2,  
['prayer'] = 2,
['combatArea'] = 3,
['gathering'] = 3,
['slayerArea'] = 4,
['item'] = 4,  
['dungeon'] = 5
['combatArea'] = 5,
['slayerArea'] = 6,
['dungeon'] = 7
}
}
local VERBS_PER_SUBTYPE = {
local VERBS_PER_SUBTYPE = {
Line 69: Line 72:
['curse'] = 'Cast',
['curse'] = 'Cast',
['ancient'] = 'Cast',
['ancient'] = 'Cast',
['archaic'] = 'Cast'
['archaic'] = 'Cast',
['prayer'] = 'Cast',
['tree'] = 'Cut',
['fish'] = 'Catch',
['Essence'] = 'Mine',
['Ore'] = 'Mine',
['Gem'] = 'Mine'
}
}
local SUBTYPE_OVERRIDES = {
local SUBTYPE_OVERRIDES = {
Line 854: Line 863:
return entityList
return entityList
end
end
function p._addPrayersWithSkillRequirement(entityList, skillName)
for i, prayer in ipairs(GameData.rawData.prayers) do
local processed = {}
processed.entity = prayer
processed.entityName = prayer.name
processed.entityType = 'prayer'
processed.subType = 'prayer'
processed.skillLevel = prayer.level
table.insert(entityList, processed)
end
return entityList
end
function p._addGatherablesWithSkillRequirement(entityList, skillName)
-- Figure out what to look up based on the skill
local sourceData = {}
local processedData = {}
local subType = ''
if skillName == 'Woodcutting' then
sourceData = SkillData.Woodcutting.trees
subType = 'tree'
elseif skillName == 'Fishing' then
sourceData = SkillData.Fishing.fish
subType = 'fish'
elseif skillName == 'Mining' then
sourceData = SkillData.Mining.rockData
end
for i, node in ipairs(sourceData) do
local gatherable = Items.getItemByID(node.productId)
local processedItem = {
['level'] = node.level,
['item'] = gatherable
}
if skillName == 'Fishing' then
processedItem['name'] = gatherable.name
else
processedItem['name'] = node.name
end
table.insert(processedData, processedItem)
end
for i, entity in ipairs(processedData) do
local processed = {}
processed.entity = entity
processed.item = entity.item
processed.entityName = entity.name
processed.entityType = 'gathering'
if skillName == 'Mining' then
processed.subType = entity.type
else
processed.subType = subType
end
processed.skillLevel = entity.level
table.insert(entityList, processed)
end
return entityList
end
local SOURCE_FUNCS = {
['areas'] = p._addAreasWithSkillRequirement,
['spells'] = p._addSpellsWithSkillRequirement,
['prayers'] = p._addPrayersWithSkillRequirement,
['gathering'] = p._addGatherablesWithSkillRequirement
}


function p._prepareSingleEntity(entity)
function p._prepareSingleEntity(entity)
Line 864: Line 941:
-- Icon overrides
-- Icon overrides
local iconType = entity.entityType
local iconType = entity.entityType
local name = entity.entityName
if entity.entityType == 'slayerArea' then
if entity.entityType == 'slayerArea' then
iconType = 'combatArea'
iconType = 'combatArea'
Line 870: Line 948:
iconType = entity.subType
iconType = entity.subType
end
end
if entity.entityType == 'gathering' then
return verb .. Icons.Icon({entity.entityName, type=iconType})
if entity.subType == 'fish' then
iconType = 'item'
else
iconType = entity.subType
end
name = entity.item.name
end
return verb .. Icons.Icon({name, entity.entityName, img=entity.entityName, type=iconType})
end
end


Line 885: Line 971:
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)
73

edits