73
edits
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 Shop = require('Module:Shop') | |||
local GameData = require('Module:GameData') | local GameData = require('Module:GameData') | ||
local SkillData = GameData.skillData | local SkillData = GameData.skillData | ||
Line 20: | Line 21: | ||
['Hitpoints'] = {}, | ['Hitpoints'] = {}, | ||
['Ranged'] = {}, | ['Ranged'] = {}, | ||
['Magic'] = {'spells'}, | ['Magic'] = {'spells', 'altmagic'}, | ||
['Prayer'] = {'prayers'}, | ['Prayer'] = {'prayers'}, | ||
['Slayer'] = {'areas'}, | ['Slayer'] = {'areas'}, | ||
Line 39: | Line 40: | ||
['Summoning'] = {}, | ['Summoning'] = {}, | ||
['Astrology'] = {}, | ['Astrology'] = {}, | ||
['Alt. Magic'] = {}, | ['Alt. Magic'] = {'altmagic'}, | ||
} | } | ||
local TYPE_SORT_ORDER = { | local TYPE_SORT_ORDER = { | ||
Line 74: | Line 75: | ||
['archaic'] = 'Cast', | ['archaic'] = 'Cast', | ||
['prayer'] = 'Cast', | ['prayer'] = 'Cast', | ||
['altMagic'] = 'Cast', | |||
['tree'] = 'Cut', | ['tree'] = 'Cut', | ||
['fish'] = 'Catch', | ['fish'] = 'Catch', | ||
Line 789: | Line 791: | ||
end | end | ||
return entityType | return entityType | ||
end | |||
function p._getOtherSkillReqs(reqList, skillName) | |||
-- Remove the current skill's requirement, leaving us with all others | |||
local otherReqs = {} | |||
for i, req in ipairs(reqList) do | |||
if req.type ~= 'SkillLevel' or req.skillID ~= Constants.getSkillID(skillName) then | |||
table.insert(otherReqs, req) | |||
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 | |||
end | |||
function p._getSpellReqs(spell) | |||
-- Get spell requirements that aren't SkillLevel (ex. equipped item) | |||
local reqs = {} | |||
if spell.requiredItemID ~= nil then | |||
local item = Items.getItemByID(spell.requiredItemID) | |||
if item ~= nil then | |||
table.insert(reqs, {['type'] = 'item', ['item'] = item}) | |||
end | |||
end | |||
if spell.requirements ~= nil then | |||
for i, req in ipairs(spell.requirements) do | |||
table.insert(reqs, req) | |||
end | |||
end | |||
return reqs | |||
end | |||
function p._getGatherableReqs(node, skillName) | |||
-- Get gatherable requirements that aren't SkillLevel (ex. shop item) | |||
local reqs = {} | |||
if node.shopItemPurchased ~= nil then | |||
local purchase = GameData.getEntityByID('shopPurchases', node.shopItemPurchased) | |||
if purchase ~= nil then | |||
table.insert(reqs, {['type'] = 'shop', ['purchase'] = purchase}) | |||
end | |||
end | |||
if node.totalMasteryRequired ~= nil then | |||
table.insert(reqs, {['type'] = 'totalMastery', ['mastery'] = node.totalMasteryRequired, ['skill'] = skillName}) | |||
end | |||
return reqs | |||
end | end | ||
Line 810: | Line 873: | ||
processed.subType = p._getEntityTrueSubtype(item.type, item.name) | processed.subType = p._getEntityTrueSubtype(item.type, item.name) | ||
processed.skillLevel = Items._getItemStat(item, skillReqLabel) | processed.skillLevel = Items._getItemStat(item, skillReqLabel) | ||
processed.otherReqs = p._getOtherSkillReqs(item.equipRequirements, skillName) | |||
table.insert(entityList, processed) | table.insert(entityList, processed) | ||
end | end | ||
Line 839: | Line 903: | ||
end | end | ||
end | end | ||
processed.otherReqs = p._getOtherSkillReqs(area.entryRequirements, skillName) | |||
table.insert(entityList, processed) | table.insert(entityList, processed) | ||
end | end | ||
Line 846: | Line 911: | ||
function p._addSpellsWithSkillRequirement(entityList, skillName) | function p._addSpellsWithSkillRequirement(entityList, skillName) | ||
-- Alt. Magic is in a separate function | |||
local SPELL_TYPES = {'standardSpells', 'auroraSpells', 'curseSpells', 'ancientSpells', 'archaicSpells'} | local SPELL_TYPES = {'standardSpells', 'auroraSpells', 'curseSpells', 'ancientSpells', 'archaicSpells'} | ||
Line 857: | Line 923: | ||
processed.subType = spell.spellBook | processed.subType = spell.spellBook | ||
processed.skillLevel = spell.level | processed.skillLevel = spell.level | ||
processed.otherReqs = p._getSpellReqs(spell) | |||
table.insert(entityList, processed) | table.insert(entityList, processed) | ||
end | end | ||
end | |||
return entityList | |||
end | |||
function p._addAltMagicWithSkillRequirement(entityList, skillName) | |||
for i, spell in ipairs(GameData.getSkillData('melvorD:Magic')['altSpells']) do | |||
local processed = {} | |||
processed.entity = spell | |||
processed.entityName = spell.name | |||
processed.entityType = 'spell' | |||
processed.subType = spell.spellBook | |||
processed.skillLevel = spell.level | |||
processed.otherReqs = p._getSpellReqs(spell) | |||
table.insert(entityList, processed) | |||
end | end | ||
Line 872: | Line 954: | ||
processed.subType = 'prayer' | processed.subType = 'prayer' | ||
processed.skillLevel = prayer.level | processed.skillLevel = prayer.level | ||
processed.otherReqs = {} | |||
table.insert(entityList, processed) | table.insert(entityList, processed) | ||
end | end | ||
Line 920: | Line 1,003: | ||
end | end | ||
processed.skillLevel = entity.level | processed.skillLevel = entity.level | ||
processed.otherReqs = p._getGatherableReqs(entity.node, skillName) | |||
table.insert(entityList, processed) | table.insert(entityList, processed) | ||
end | end | ||
Line 929: | Line 1,013: | ||
['areas'] = p._addAreasWithSkillRequirement, | ['areas'] = p._addAreasWithSkillRequirement, | ||
['spells'] = p._addSpellsWithSkillRequirement, | ['spells'] = p._addSpellsWithSkillRequirement, | ||
['altmagic'] = p._addAltMagicWithSkillRequirement, | |||
['prayers'] = p._addPrayersWithSkillRequirement, | ['prayers'] = p._addPrayersWithSkillRequirement, | ||
['gathering'] = p._addGatherablesWithSkillRequirement | ['gathering'] = p._addGatherablesWithSkillRequirement | ||
} | } | ||
function p._prepareOtherReqs(entity) | |||
local extraReqs = {} | |||
if entity.otherReqs ~= nil and entity.otherReqs ~= {} then | |||
-- Don't list a bazillion skills for the max skillcapes | |||
if entity.entityName == 'Maximum Skillcape' then | |||
return ' (requires level 99 in all skills)' | |||
elseif entity.entityName == 'Superior Max Skillcape' then | |||
return ' (requires level 120 in all skills)' | |||
else | |||
for i, req in ipairs(entity.otherReqs) do | |||
-- TODO: "Completion" requirement | |||
if req.type == 'SkillLevel' then | |||
local skillInfo = Icons.Icon({Constants.getSkillName(req.skillID), type='skill', qty=req.level, notext='true'}) | |||
table.insert(extraReqs, skillInfo) | |||
elseif req.type == 'DungeonCompletion' then | |||
local dungeonName = GameData.getEntityByID('dungeons', req.dungeonID).name | |||
-- If you only need to clear it once (Impending Darkness), | |||
-- don't bother listing the count | |||
local appendCount = '' | |||
if req.count > 1 then | |||
appendCount = ' ' .. req.count .. ' clears' | |||
end | |||
local dungeonInfo = Icons.Icon({dungeonName, type='dungeon', notext=true}) .. appendCount | |||
table.insert(extraReqs, dungeonInfo) | |||
elseif req.type == 'MonsterKilled' then | |||
local monsterName = GameData.getEntityByID('monsters', req.monsterID).name | |||
local monsterInfo = Icons.Icon({monsterName, type='monster', qty=req.count}) .. ' kills' | |||
table.insert(extraReqs, monsterInfo) | |||
elseif req.type == 'item' then | |||
local itemInfo = Icons.Icon({req.item.name, type='item'}) | |||
table.insert(extraReqs, itemInfo) | |||
elseif req.type == 'shop' then | |||
table.insert(extraReqs, Shop._getPurchaseIcon({req.purchase})) | |||
elseif req.type == 'totalMastery' then | |||
table.insert(extraReqs, Shared.formatnum(req.mastery) .. ' ' .. Icons.Icon({req.skill, type='skill', notext=true}) .. ' ' .. Icons.Icon({'Mastery'})) | |||
end | |||
end | |||
end | |||
end | |||
if not next(extraReqs) then | |||
return '' | |||
else | |||
return ' (requires ' .. table.concat(extraReqs, ', ') .. ')' | |||
end | |||
end | |||
function p._prepareSingleEntity(entity) | function p._prepareSingleEntity(entity) | ||
Line 942: | Line 1,075: | ||
-- Icon overrides | -- Icon overrides | ||
local iconType = entity.entityType | local iconType = entity.entityType | ||
local | local iconName = entity.entityName | ||
if entity.entityType == 'slayerArea' then | if entity.entityType == 'slayerArea' then | ||
iconType = 'combatArea' | iconType = 'combatArea' | ||
Line 957: | Line 1,090: | ||
iconType = entity.subType | iconType = entity.subType | ||
end | end | ||
iconName = entity.item.name | |||
end | end | ||
return verb .. Icons.Icon({ | -- Any other requirements? | ||
local extraReqs = p._prepareOtherReqs(entity) | |||
return verb .. Icons.Icon({iconName, entity.entityName, img=entity.entityName, type=iconType}) .. extraReqs | |||
end | end | ||
Line 1,067: | Line 1,203: | ||
function p.test() | function p.test() | ||
local | local purchase = Shop.getPurchaseByID('melvorTotH:Corundum_Axe') | ||
mw.log(Shop._getPurchaseIcon({purchase, notext='true'})) | |||
end | end | ||
return p | return p |
edits