Anonymous

Module:Calculator/AgilityObstacle: Difference between revisions

From Melvor Idle
Add total bonusses
No edit summary
(Add total bonusses)
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(obstables) do
for _, obstacle in pairs(obstables) do
for bonusName, bonusValue in pairs(obstacle.modifiers) do
for bonusName, bonusValue in pairs(obstacle.modifiers) do
bonuses[bonusName] = bonusValue
Shared.addOrUpdate(bonuses, bonusName,
function(x)
x = x or 0 return x + bonusValue
end)
end
end
end
end
local ret = {}
for bonusName, bonusValue in pairs(bonuses) do
table.insert(ret, Constants._getModifierText(bonusName, bonusValue))
end
if Shared.tableIsEmpty(ret) then
table.insert(ret, '<span style="color:red">None :(</span>')
end
return table.concat(ret, '<br/>')
end
end
 
--== Start of table formatting ==--
--== Start of table formatting ==--
local obstacleNames = parseObstacleArgs(args)
local obstacleNames = parseObstacleArgs(args)
Line 282: Line 294:
:wikitext('Totals')
:wikitext('Totals')
:tag('td')
:tag('td')
:wikitext('total bonusses...')
:wikitext(getTotalBonuses(courseRequirements.Obstacles))
:tag('td')
:tag('td')
:wikitext(getRequirements(courseRequirements.CourseLevelRequirements))
:wikitext(getRequirements(courseRequirements.CourseLevelRequirements))
Line 288: Line 300:
:wikitext(getCosts(courseRequirements.CourseItemCosts))
:wikitext(getCosts(courseRequirements.CourseItemCosts))
end
end
--local obstacleInfo = {
--Name = obstacle.name,
--Slot = slot,
--Obstacle = obstacle,
--LevelRequirements = Agility.getObstacleRequirements(obstacle),
--ItemCosts = Agility.getObstacleCosts(obstacle),
--}


return tostring(tbl)
return tostring(tbl)
2,875

edits