2,875
edits
No edit summary |
No edit summary |
||
Line 8: | Line 8: | ||
local Items = require('Module:Items') | local Items = require('Module:Items') | ||
local Icons = require('Module:Icons') | local Icons = require('Module:Icons') | ||
local Debug = require('Module:Debug') -- Comment out when Module is finalised. | |||
-- Adds the the highest level to the dictionary, or the level, if the key isn't present. | -- Adds the the highest level to the dictionary, or the level, if the key isn't present. | ||
Line 54: | Line 55: | ||
local function getItemRequirements(obstacle) | local function getItemRequirements(obstacle) | ||
local itemRequirements = {} | local itemRequirements = {} | ||
if obstacle.gpCost > 0 then | |||
concatItemRequirements(itemRequirements, 'GP', obstacle.gpCost) | |||
end | |||
if obstacle.scCost > 0 then | |||
concatItemRequirements(itemRequirements, 'GP', obstacle.scCost) | |||
end | |||
for j, itemCost in ipairs(obstacle.itemCosts) do | |||
local item = Items.getItemByID(itemCost.id) | |||
concatItemRequirements(itemRequirements, item.name, itemCost.quantity) | |||
end | |||
return itemRequirements | |||
end | end | ||
local function getObstacle(name) | local function getObstacle(name) | ||
name = Shared. | name = Shared.specialTitleCase(name) | ||
local obstacle = Agility.getObstacle(name) | local obstacle = Agility.getObstacle(name) | ||
if obstacle == nil then | if obstacle == nil then | ||
return nil | return nil | ||
end | end | ||
-- TODO: Handle pillars and return the same format/table. | |||
-- if obstacle == pillar..... | |||
local obstacleInfo = { | local obstacleInfo = { | ||
Name, | Name = obstacle.name, | ||
LevelRequirements = | Slot = obstacle.category + 1, | ||
ItemCosts = | LevelRequirements = getLevelRequirements(obstacle), | ||
ItemCosts = getItemRequirements(obstacle), | |||
} | } | ||
return obstacleInfo | |||
end | end | ||
Line 85: | Line 98: | ||
function p._main(args) | function p._main(args) | ||
return Debug.toString(args) | |||
end | end | ||
function p.test() | function p.test() | ||
Debug.log(getObstacle("a lovely jog")) | |||
end | end | ||
return p | return p |
edits