2,875
edits
No edit summary |
No edit summary |
||
Line 180: | Line 180: | ||
' Cargo Net ',' Balance Beam','Pipe Climb' | ' Cargo Net ',' Balance Beam','Pipe Climb' | ||
})) | })) | ||
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 |
edits