4,951
edits
Falterfire (talk | contribs) (areaName => name) |
Falterfire (talk | contribs) (Added requirements code and made it work with slayer stuff) |
||
Line 94: | Line 94: | ||
end | end | ||
function p. | function p._getAreaRequirements(area) | ||
local result = '' | |||
local resultArray = {} | |||
local addReqsToArray = function(reqArray, requirements) | |||
for i, reqDetails in Shared.skpairs(requirements) do | |||
mw.log(reqDetails.type) | |||
if reqDetails.type == 'Level' then | |||
for j, lvlDetails in Shared.skpairs(reqDetails.levels) do | |||
local skill = Constants.getSkillName(lvlDetails.skill) | |||
table.insert(reqArray, Icons._SkillReq(skill, lvlDetails.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 == 'Dungeon' then | |||
for j, dungDetails in Shared.skpairs(reqDetails.dungeons) do | |||
local dung = p.getAreaByID('dungeon', dungDetails.dungeonID) | |||
if dungDetails.count > 1 then | |||
table.insert(reqArray, dungDetails.count..'x '..Icons.Icon({dung.name, type='dungeon'})..' Completions') | |||
else | |||
table.insert(reqArray, Icons.Icon({dung.name, type='dungeon'})..' Completed') | |||
end | |||
end | |||
end | |||
end | end | ||
end | end | ||
if area.entryRequirements ~= nil then | |||
addReqsToArray(resultArray, area.entryRequirements) | |||
end | |||
if area.unlockRequirement ~= nil then | |||
addReqsToArray(resultArray, { area.unlockRequirement }) | |||
end | |||
result = table.concat(resultArray, '<br/>') | |||
return result | |||
end | |||
function p._getAreaStat(area, statName) | |||
if statName == 'requirements' then | |||
return p._getAreaRequirements(area) | |||
elseif statName == 'areaEffectDesc' then | elseif statName == 'areaEffectDesc' then | ||
if area.areaEffect ~= nil and area.areaEffect then | if area.areaEffect ~= nil and area.areaEffect then | ||
Line 177: | Line 197: | ||
end | end | ||
local result = p._getAreaStat(area, ' | local result = p._getAreaStat(area, 'requirements') | ||
if result ~= '' then | if result ~= '' then | ||
result = "\r\n|-\r\n|'''Requirements:'''<br/>"..result | result = "\r\n|-\r\n|'''Requirements:'''<br/>"..result |