2,875
edits
(Update to reflect changes from Agility api) |
No edit summary |
||
Line 57: | Line 57: | ||
end | end | ||
function | local function getObstacles(obstacleNames, checkDoubleSlots, costReduction) | ||
-- Collect all obstacles and filter out nill values. | -- Collect all obstacles and filter out nill values. | ||
local courseObstacles = {} | local courseObstacles = {} | ||
Line 74: | Line 74: | ||
end | end | ||
return courseObstacles | |||
end | |||
function p.calculateCourse(obstacleNames, checkDoubleSlots, costReduction) | |||
local funcPoolCosts = function(tbl, item, amount) | |||
Shared.addOrUpdate(tbl, item, function(x) x = x or 0 return x + amount end) | |||
end | |||
local courseObstacles = getObstacles(obstacleNames, checkDoubleSlots, costReduction) | |||
-- Calculate the highest level requirements and the total amount of items | -- Calculate the highest level requirements and the total amount of items | ||
-- required to build this agility course. | -- required to build this agility course. | ||
Line 90: | Line 100: | ||
-- Pool together total item costs to build the entire course course. | -- Pool together total item costs to build the entire course course. | ||
local courseCosts = course.ItemCosts | local courseCosts = course.ItemCosts | ||
funcPoolCosts(courseItemCosts, 'GP', courseCosts['GP']) | |||
funcPoolCosts(courseItemCosts, 'SC', courseCosts['SC']) | |||
for item, amount in pairs(courseCosts['Items']) do | for item, amount in pairs(courseCosts['Items']) do | ||
funcPoolCosts(courseItemCosts, item, amount) | |||
end | end | ||
end | end |
edits