Module:Calculator/AgilityObstacle: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 237: Line 237:
local function getTotalBonuses(obstacles)
local function getTotalBonuses(obstacles)
-- Add all bonuses together from all obstacles
local bonuses = {}
local bonuses = {}
for _, obstacle in pairs(obstacles) do
for _, obstacle in pairs(obstacles) do
for bonusName, bonusValue in pairs(obstacle.Obstacle.modifiers) do
for bonusName, bonusValue in pairs(obstacle.Obstacle.modifiers) do
Shared.addOrUpdate(bonuses, bonusName,  
table.insert(bonuses, {name = bonusName, value = bonusValue})
function(x)
x = x or 0 return x + bonusValue
end)
end
end
end
end
table.sort(bonuses, function(a, b) return a.name < b.name end)
local ret = {}
local ret = {}
Line 305: Line 303:


function p.test()
function p.test()
local obs = getObstacle('pipe crawl')
local obstacles = {"Rope Climb","Monkey Bars"," Balance Seesaw","Elite Pillar of Conflict"}
local obs = p._getCourseTable(obstacles)
for bonusName, bonusValue in pairs(obs.Obstacle.modifiers) do
 
Debug.log(bonusName)
 
end
Debug.log(obs)
--Debug.log(obs)
end
end
return p
return p
2,875

edits