12,787
edits
(_getAreaRequirements: Support requirement types ItemFound, CartographyPOIDiscovery) |
(_getAreaRequirements: Resolve cases where requirement text returned could contain empty lines) |
||
(2 intermediate revisions by 2 users not shown) | |||
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 areaMap = { | local areaMap = { | ||
Line 72: | Line 71: | ||
function p._getAreaRequirements(area) | function p._getAreaRequirements(area) | ||
local resultArray = {} | local resultArray = {} | ||
if area.entryRequirements ~= nil then | |||
local reqText = Common.getRequirementString(area.entryRequirements) | |||
if reqText ~= nil then | |||
table.insert(resultArray, reqText) | |||
end | end | ||
end | end | ||
Line 127: | Line 81: | ||
-- 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 | ||
local reqText = Common.getRequirementString(area.unlockRequirement) | |||
if reqText ~= nil then | |||
table.insert(resultArray, reqText) | |||
end | |||
end | end | ||
end | end | ||
return table.concat(resultArray, '<br/>') | return table.concat(resultArray, '<br/>') | ||
end | |||
function p.getAreaRequirementsForBox(frame) | |||
--Returns infobox formatting for requirements, or returns nothing if there are none. | |||
local areaName = frame.args ~= nil and frame.args[1] or frame | |||
local area = p.getArea(areaName) | |||
if area == nil then | |||
return Shared.printError('No area named "' .. areaName .. '" exists in the data module') | |||
end | |||
local reqs = p._getAreaRequirements(area) | |||
if reqs ~= '' then | |||
reqs = "|-\r\n|'''Requirements:'''\r\n"..reqs | |||
end | |||
return reqs | |||
end | end | ||