Anonymous

Module:Skills/Agility: Difference between revisions

From Melvor Idle
no edit summary
No edit summary
No edit summary
Line 68: Line 68:
return levelRequirements
return levelRequirements
end
local function formatObstacleRequirements(obstacle)
local resultPart = {}
local requirements = p.getObstacleRequirements(obstacle)
for skill, level in pairs(requirements) do
table.insert(resultPart, Icons._SkillReq(skill, level))
end
return table.concat(resultPart, '<br/>')
end
end


Line 98: Line 87:
return costs
return costs
end
local function formatObstacleRequirements(obstacle)
local resultPart = {}
local requirements = p.getObstacleRequirements(obstacle)
for skill, level in pairs(requirements) do
table.insert(resultPart, Icons._SkillReq(skill, level))
end
return table.concat(resultPart, '<br/>')
end
end


Line 121: Line 121:
result = '{| class="wikitable sortable stickyHeader"'
result = '{| class="wikitable sortable stickyHeader"'
result = result..'\r\n|- class="headerRow-0"'
result = result..'\r\n|- class="headerRow-0"'
result = result..'\r\n!Slot!!Name!!XP!!GP!!Time!!XP/s!!GP/s'--!!XP/s!!GP/s (left comment here for posterity)
result = result..'\r\n!Slot!!Name!!XP!!GP!!Time!!XP/s!!GP/s!!Bonuses!!Requirements!!Cost'
result = result..'!!Bonuses!!Requirements!!Cost'


local catLog = {}
local catLog = {}
Line 232: Line 231:


return result
return result
end
function p._getCourseTable(obstacleNames)
local result = ''
local obstacles = {}
for i, name in ipairs(obstacleNames) do
local obst = p.getObstacle(Shared.trim(name))
if obst == nil then
result = result .. Shared.printError('Invalid Obstacle Name "' .. name .. '"') .. '<br/>'
else
table.insert(obstacles, obst)
end
end
result = result..'{| class="wikitable sortable stickyHeader"'
result = result..'\r\n|- class="headerRow-0"'
result = result..'\r\n!Slot!!Name!!Bonuses!!Requirements!!Cost'
local catLog = {}
table.sort(obstacles, function(a, b) return a.category < b.category end)
local catCounts = {}
for i, obst in ipairs(obstacles) do
if catCounts[obst.category] == nil then
catCounts[obst.category] = 1
else
catCounts[obst.category] = catCounts[obst.category] + 1
end
end
for i, obst in ipairs(obstacles) do
result = result..'\r\n|-'
result = result..'\r\n|'
if catLog[obst.category] == nil then
local rowspan = catCounts[obst.category]
result = result..'rowspan="'..rowspan..'" style="border:1px solid black"|'..(obst.category + 1)..'||'
catLog[obst.category] = true
end
result = result..obst.name
local bonuses = {}
--After that, adding the bonuses
for bonusName, bonusValue in pairs(obst.modifiers) do
table.insert(bonuses, Constants._getModifierText(bonusName, bonusValue))
end
if Shared.tableIsEmpty(bonuses) then
table.insert(bonuses, '<span style="color:red">None :(</span>')
end
result = result..'||'..table.concat(bonuses, '<br/>')
--Grabbing requirements to create
result = result..'|| ' .. formatObstacleRequirements(obst)
--Finally, the cost
result = result..'|| data-sort-value="'..obst.gpCost..'"|'.. formatObstacleCosts(obst)
end
result = result..'\r\n|}'
return result
end
function p.getCourseTable(frame)
local obstNameStr = frame.args ~= nil and frame.args[1] or frame
local obstacleNames = Shared.splitString(obstNameStr, ',')
return p._getCourseTable(obstacleNames)
end
end


return p
return p
2,875

edits