Anonymous

Module:SkillUnlocks: Difference between revisions

From Melvor Idle
no edit summary
No edit summary
No edit summary
Line 24: Line 24:
['Prayer'] = {'prayers'},
['Prayer'] = {'prayers'},
['Slayer'] = {'areas'},
['Slayer'] = {'areas'},
['Farming'] = {'gathering'},
['Farming'] = {'gatheringitems'},
['Township'] = {},
['Township'] = {},
['Woodcutting'] = {'gathering'},
['Woodcutting'] = {'gatheringitems'},
['Fishing'] = {'gathering'},
['Fishing'] = {'gatheringitems'},
['Firemaking'] = {'firemaking'},
['Firemaking'] = {'firemaking'},
['Cooking'] = {'artisan'},
['Cooking'] = {'artisanitems'},
['Mining'] = {'gathering'},
['Mining'] = {'gatheringitems'},
['Smithing'] = {'artisan'},
['Smithing'] = {'artisanitems'},
['Thieving'] = {'artisan'},
['Thieving'] = {'thieving'},
['Fletching'] = {'artisan'},
['Fletching'] = {'artisanitems'},
['Crafting'] = {'artisan'},
['Crafting'] = {'artisanitems'},
['Runecrafting'] = {'artisan'},
['Runecrafting'] = {'artisanitems'},
['Herblore'] = {'artisan'},
['Herblore'] = {'artisanitems'},
['Agility'] = {},
['Agility'] = {},
['Summoning'] = {'artisan'},
['Summoning'] = {'artisanitems'},
['Astrology'] = {},
['Astrology'] = {'constellations'},
['Alt. Magic'] = {'altmagic'},
['Alt. Magic'] = {'altmagic'},
}
}
local TYPE_SORT_ORDER = {
local TYPE_SORT_ORDER = {
['spell'] = 1,
['shop'] = 1,
['prayer'] = 2,
['spell'] = 2,
['gathering'] = 3,
['prayer'] = 3,
['artisan'] = 4,
['gathering'] = 4,
['item'] = 5,  
['artisan'] = 5,
['combatArea'] = 6,
['item'] = 6,  
['slayerArea'] = 7,
['combatArea'] = 7,
['dungeon'] = 8
['slayerArea'] = 8,
['dungeon'] = 9
}
}
local VERBS_PER_SUBTYPE = {
local VERBS_PER_SUBTYPE = {
Line 89: Line 90:
['melvorF:SkillPotions'] = 'Brew',
['melvorF:SkillPotions'] = 'Brew',
['melvorF:CombatPotions'] = 'Brew',
['melvorF:CombatPotions'] = 'Brew',
['log'] = 'Burn'
['log'] = 'Burn',
['npc'] = 'Pickpocket',
['constellation'] = 'Study',
['shop'] = 'Purchase'
}
}
local SUBTYPE_OVERRIDES = {
local SUBTYPE_OVERRIDES = {
Line 108: Line 112:
}
}
local SUBTYPE_SORT_OVERRIDES = {
local SUBTYPE_SORT_OVERRIDES = {
['melvorD:Bars'] = '1',
['melvorF:StandardRunes'] = '1',
['melvorF:StandardRunes'] = '1',
['log'] = '1'
['log'] = '1'
Line 865: Line 870:
return reqs
return reqs
end
function p._addEntities(frame)
local args = frame.args ~= nil and frame.args or frame
local entityList = args[1]
local data = args[2]
local entityType = args.type
local typeParam = args.typeParam
--local passedType = typeParam ~= nil and entity[typeParam] or entityType
local subType = args.subType
local subTypeParam = args.subTypeParam
local otherReqsFunc = args.otherReqsFunc
for i, entity in ipairs(data) do
local processed = {}
processed.entityName = entity.name
processed.entityType = p._getEntityTrueSubtype(typeParam ~= nil and entity[typeParam] or entityType)
processed.subType = subTypeParam ~= nil and entity[subTypeParam] or subType
processed.skillLevel = entity.level
processed.otherReqs = otherReqsFunc ~= nil and otherReqsFunc(entity) or {}
table.insert(entityList, processed)
end
return entityList
end
end


Line 878: Line 907:
end)
end)
-- TODO: This can probably be made into a generic function for each entity
-- TODO: Squeeze this into _addEntities
for i, item in ipairs(itemList) do
for i, item in ipairs(itemList) do
local processed = {}
local processed = {}
Line 905: Line 934:
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 = {}
processed.entity = area
processed.entityName = area.name
processed.entityName = area.name
processed.entityType = area.type
processed.entityType = area.type
Line 923: Line 952:
end
end


function p._addSpellsWithSkillRequirement(entityList, skillName)
function p._addShopPurchasesWithSkillRequirements(entityList, skillName)
-- Alt. Magic is in a separate function
local purchaseList = Shop.getPurchases(function(purchase)
local SPELL_TYPES = {'standardSpells', 'auroraSpells', 'curseSpells', 'ancientSpells', 'archaicSpells'}
local hasSkillReq = false
for i, req in ipairs(purchase.purchaseRequirements) do
if req.type == 'SkillLevel' and req.skillID == Constants.getSkillID(skillName) then
hasSkillReq = true
end
end
return hasSkillReq
end)
-- Iterate through each spell type and each spell within that type
for i, purchase in ipairs(purchaseList) do
for i, spellType in ipairs(SPELL_TYPES) do
-- Skip skillcapes here, as we handle them with items
for j, spell in ipairs(GameData.rawData[spellType]) do
if purchase.category ~= 'melvorD:Skillcapes' and purchase.category ~= 'melvorTotH:SuperiorSkillcapes' then
local processed = {}
local processed = {}
processed.entity = spell
processed.entityName = Shop._getPurchaseName(purchase)
processed.entityName = spell.name
processed.entityType = 'shop'
processed.entityType = 'spell'
processed.subType = purchase.category
processed.subType = spell.spellBook
for a, req in ipairs(purchase.purchaseRequirements) do
processed.skillLevel = spell.level
if req.type == 'SkillLevel' and req.skillID == Constants.getSkillID(skillName) then
processed.otherReqs = p._getSpellReqs(spell)
processed.skillLevel = req.level
end
end
processed.otherReqs = p._getOtherSkillReqs(purchase.purchaseRequirements, skillName)
table.insert(entityList, processed)
table.insert(entityList, processed)
end
end
Line 944: Line 983:
end
end


function p._addAltMagicWithSkillRequirement(entityList, skillName)
function p._addSpells(entityList, skillName)
for i, spell in ipairs(GameData.getSkillData('melvorD:Magic')['altSpells']) do
-- Alt. Magic is in a separate function
local processed = {}
local SPELL_TYPES = {'standardSpells', 'auroraSpells', 'curseSpells', 'ancientSpells', 'archaicSpells'}
processed.entity = spell
processed.entityName = spell.name
-- Iterate through each spell type and each spell within that type
processed.entityType = 'spell'
for i, spellType in ipairs(SPELL_TYPES) do
processed.subType = spell.spellBook
entityList = p._addEntities({entityList, GameData.rawData[spellType], type='spell', subTypeParam='spellBook', otherReqsFunc=p._getSpellReqs})
processed.skillLevel = spell.level
processed.otherReqs = p._getSpellReqs(spell)
table.insert(entityList, processed)
end
end
Line 959: Line 995:
end
end


function p._addPrayersWithSkillRequirement(entityList, skillName)
function p._addAltMagic(entityList, skillName)
for i, prayer in ipairs(GameData.rawData.prayers) do
entityList = p._addEntities({entityList, GameData.getSkillData('melvorD:Magic')['altSpells'], type='spell', subType='altMagic', otherReqsFunc=p._getSpellReqs})
local processed = {}
return entityList
processed.entity = prayer
end
processed.entityName = prayer.name
 
processed.entityType = 'prayer'
function p._addPrayers(entityList, skillName)
processed.subType = 'prayer'
entityList = p._addEntities({entityList, GameData.rawData.prayers, type='prayer', subType='prayer'})
processed.skillLevel = prayer.level
processed.otherReqs = {}
table.insert(entityList, processed)
end
return entityList
return entityList
end
end


function p._addFiremakingActionsWithSkillRequirement(entityList, skillName)
function p._addFiremakingActions(entityList, skillName)
for i, fireLog in ipairs(SkillData.Firemaking.logs) do
for i, fireLog in ipairs(SkillData.Firemaking.logs) do
local processed = {}
local processed = {}
Line 989: Line 1,020:
end
end


function p._addGatherablesWithSkillRequirement(entityList, skillName)
function p._addThievingTargets(entityList, skillName)
entityList = p._addEntities({entityList, SkillData.Thieving.npcs, type='thieving', subType='npc'})
return entityList
end
 
function p._addConstellations(entityList, skillName)
entityList = p._addEntities({entityList, SkillData.Astrology.recipes, type='constellation', subType='constellation'})
return entityList
end
 
function p._addGatherables(entityList, skillName)
-- Figure out what to look up based on the skill
-- Figure out what to look up based on the skill
local sourceData = {}
local sourceData = {}
Line 1,034: Line 1,075:
end
end


function p._addRecipesWithSkillRequirement(entityList, skillName)
function p._addRecipes(entityList, skillName)
-- Figure out what to look up based on the skill
-- Figure out what to look up based on the skill
local sourceData = SkillData[skillName].recipes
local sourceData = SkillData[skillName].recipes
Line 1,062: Line 1,103:
local SOURCE_FUNCS = {
local SOURCE_FUNCS = {
['areas'] = p._addAreasWithSkillRequirement,
['areas'] = p._addAreasWithSkillRequirement,
['spells'] = p._addSpellsWithSkillRequirement,
['spells'] = p._addSpells,
['altmagic'] = p._addAltMagicWithSkillRequirement,
['altmagic'] = p._addAltMagic,
['prayers'] = p._addPrayersWithSkillRequirement,
['prayers'] = p._addPrayers,
['gathering'] = p._addGatherablesWithSkillRequirement,
['gatheringitems'] = p._addGatherables,
['artisan'] = p._addRecipesWithSkillRequirement,
['artisanitems'] = p._addRecipes,
['firemaking'] = p._addFiremakingActionsWithSkillRequirement
['firemaking'] = p._addFiremakingActions,
['thieving'] = p._addThievingTargets,
['constellations'] = p._addConstellations,
['shop'] = p._addShopPurchasesWithSkillRequirements
}
}


Line 1,180: Line 1,224:
function p._getSkillUnlockTable(skillName)
function p._getSkillUnlockTable(skillName)
-- 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 items, because every skill at least
-- every skill to save time, except for a few broad things
-- has skillcapes with a level requirement
local entityList = {}
local entityList = {}
entityList = p._addItemsWithSkillRequirement(entityList, skillName)
entityList = p._addItemsWithSkillRequirement(entityList, skillName)
entityList = p._addShopPurchasesWithSkillRequirements(entityList, skillName)
for i, dataSource in ipairs(SKILL_CHECK_MAP[skillName]) do
for i, dataSource in ipairs(SKILL_CHECK_MAP[skillName]) do
entityList = SOURCE_FUNCS[dataSource](entityList, skillName)
entityList = SOURCE_FUNCS[dataSource](entityList, skillName)
73

edits