|
|
Line 5: |
Line 5: |
| local Shared = require('Module:Shared') | | local Shared = require('Module:Shared') |
| local GameData = require('Module:GameData') | | local GameData = require('Module:GameData') |
| | local Common = require('Module:Common') |
| local Icons = require('Module:Icons') | | local Icons = require('Module:Icons') |
| local Items = require('Module:Items')
| |
| local Shop = require('Module:Shop')
| |
|
| |
|
| local areaMap = { | | local areaMap = { |
Line 72: |
Line 71: |
| function p._getAreaRequirements(area) | | function p._getAreaRequirements(area) |
| local resultArray = {} | | local resultArray = {} |
| local addReqsToArray = function(reqArray, requirements)
| |
| for i, reqDetails in ipairs(requirements) do
| |
| if reqDetails.type == 'SkillLevel' then
| |
| local skillName = Constants.getSkillName(reqDetails.skillID)
| |
| if skillName ~= nil then
| |
| table.insert(reqArray, Icons._SkillReq(skillName, reqDetails.level))
| |
| end
| |
| elseif reqDetails.type == 'SlayerItem' then
| |
| local item = Items.getItemByID(reqDetails.itemID)
| |
| table.insert(reqArray, Icons.Icon({item.name, type='item'}) .. ' Equipped')
| |
| elseif reqDetails.type == 'DungeonCompletion' then
| |
| local dung = p.getAreaByID(reqDetails.dungeonID, 'dungeon')
| |
| if dung ~= nil then
| |
| if reqDetails.count > 1 then
| |
| table.insert(reqArray, Shared.formatnum(reqDetails.count) .. 'x ' .. Icons.Icon({dung.name, type='dungeon'}) .. ' Completions')
| |
| else
| |
| table.insert(reqArray, Icons.Icon({dung.name, type='dungeon'}) .. ' Completed')
| |
| end
| |
| end
| |
| elseif reqDetails.type == 'ShopPurchase' then
| |
| local shopPurchase = GameData.getEntityByID('shopPurchases', reqDetails.purchaseID)
| |
| if shopPurchase ~= nil then
| |
| table.insert(reqArray, Shop._getPurchaseIcon({ shopPurchase }) .. ' Purchased')
| |
| end
| |
| elseif reqDetails.type == 'ItemFound' then
| |
| local item = Items.getItemByID(reqDetails.itemID)
| |
| table.insert(reqArray, 'Find ' .. Icons.Icon({item.name, type='item'}))
| |
| elseif reqDetails.type == 'CartographyPOIDiscovery' then
| |
| -- TODO Amend when Cartography module with helper functions exists
| |
| local map = GameData.getEntityByID(GameData.skillData.Cartography.worldMaps, reqDetails.worldMapID)
| |
| if map ~= nil then
| |
| local poiPart = {}
| |
| for j, poiID in ipairs(reqDetails.poiIDs) do
| |
| local poi = GameData.getEntityByID(map.pointsOfInterest, poiID)
| |
| if poi ~= nil then
| |
| table.insert(poiPart, Icons.Icon({poi.name, type='poi'}))
| |
| else
| |
| table.insert(poiPart, Shared.printError('Could not find POI with ID ' .. poiID))
| |
| end
| |
| end
| |
| table.insert(reqArray, 'Discover ' .. table.concat(poiPart, ', '))
| |
| end
| |
| else
| |
| table.insert(reqArray, Shared.printError('Unknown requirement type ' .. (reqDetails.type or 'nil')))
| |
| end
| |
| end
| |
| end
| |
|
| |
| if area.entryRequirements ~= nil then | | if area.entryRequirements ~= nil then |
| addReqsToArray(resultArray, area.entryRequirements) | | table.insert(resultArray, Common.getRequirementString(area.entryRequirements, '')) |
| end | | end |
|
| |
|
Line 127: |
Line 78: |
| -- Avoid repeating the same requirements twice, can happen for some dungeons e.g. Impending Darkness | | -- Avoid repeating the same requirements twice, can happen for some dungeons e.g. Impending Darkness |
| if area.entryRequirements == nil or mw.dumpObject(area.unlockRequirement) ~= mw.dumpObject(area.entryRequirements) then | | if area.entryRequirements == nil or mw.dumpObject(area.unlockRequirement) ~= mw.dumpObject(area.entryRequirements) then |
| addReqsToArray(resultArray, area.unlockRequirement) | | table.insert(resultArray, Common.getRequirementString(area.unlockRequirement, '')) |
| end | | end |
| end | | end |