Anonymous

Module:Calculator/AgilityObstacle: Difference between revisions

From Melvor Idle
no edit summary
No edit summary
No edit summary
Line 31: Line 31:
end
end
)
)
end
--- Gets all required levels to build the given obstacle.
local function getLevelRequirements(obstacle)
local levelRequirements = {}
-- Add agility level requirement.
addHighestLevelRequirement(levelRequirements, 'Agility', Skills.getRecipeLevel('Agility', obstacle))
-- Add other level requirements.
if type(obstacle.skillRequirements) == 'table' then
for i, skillReq in ipairs(obstacle.skillRequirements) do
local skillName = Constants.getSkillName(skillReq.skillID)
if skillName ~= nil then
addHighestLevelRequirement(levelRequirements, skillName, skillReq.level)
end
end
end
return levelRequirements
end
local function getItemRequirements(obstacle)
local itemRequirements = {}
if obstacle.gpCost > 0 then
concatItemRequirements(itemRequirements, 'GP', obstacle.gpCost)
end
if obstacle.scCost > 0 then
concatItemRequirements(itemRequirements, 'SC', 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


Line 84: Line 46:
Name = obstacle.name,
Name = obstacle.name,
Slot = obstacle.category + 1,
Slot = obstacle.category + 1,
LevelRequirements = getLevelRequirements(obstacle),
LevelRequirements = Agility.getLevelRequirements(obstacle),
ItemCosts = getItemRequirements(obstacle),
ItemCosts = Agility.getItemRequirements(obstacle),
}
}


Line 186: Line 148:
local obstacles = {}
local obstacles = {}
for i, name in ipairs(obstacleNames) do
for i, name in ipairs(obstacleNames) do
local obst = p.getObstacle(Shared.trim(name))
local obst = Agility.getObstacle(Shared.trim(name))
if obst == nil then
if obst == nil then
result = result .. Shared.printError('Invalid Obstacle Name "' .. name .. '"') .. '<br/>'
result = result .. Shared.printError('Invalid Obstacle Name "' .. name .. '"') .. '<br/>'
2,875

edits