2,869
edits
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
local Constants = require('Module:Constants') | local Constants = require('Module:Constants') | ||
local Agility = require('Module:Skills/Agility') | local Agility = require('Module:Skills/Agility') | ||
local Shared = require('Module:Shared') | local Shared = require('Module:Shared') | ||
local Icons = require('Module:Icons') | local Icons = require('Module:Icons') | ||
local Debug = require('Module:Debug') -- Comment out when Module is finalised. | local Debug = require('Module:Debug') -- Comment out when Module is finalised. | ||
Line 140: | Line 137: | ||
div:tag('b'):wikitext('Obstacles') | div:tag('b'):wikitext('Obstacles') | ||
local tbl = mw.html.create("table") | local tbl = mw.html.create("table") | ||
:addClass("wikitable | :addClass("wikitable stickyHeader text-align-left") | ||
tbl :tag("tr") | tbl :tag("tr") | ||
Line 195: | Line 192: | ||
end | end | ||
function p. | function p.getCourseTable(frame) | ||
local | local args = frame:getParent().args | ||
return p._getCourseList(args) | |||
end | |||
function p._getCourseTable(args) | |||
--== Local Functions for formatting Obstacle MetaData ==-- | |||
local function getBonusses(obstacle) | |||
local bonuses = {} | local bonuses = {} | ||
for bonusName, bonusValue in pairs(obstacle.modifiers) do | |||
for bonusName, bonusValue in pairs( | |||
table.insert(bonuses, Constants._getModifierText(bonusName, bonusValue)) | table.insert(bonuses, Constants._getModifierText(bonusName, bonusValue)) | ||
end | end | ||
Line 242: | Line 207: | ||
table.insert(bonuses, '<span style="color:red">None :(</span>') | table.insert(bonuses, '<span style="color:red">None :(</span>') | ||
end | end | ||
return table.concat(bonuses, '<br/>') | |||
end | |||
-- | |||
local function getRequirements(requirementsTable) | |||
local skillList = Shared.sortDictionary(requirementsTable, | |||
function(a, b) return a.skill < b.skill end, | |||
function(a, b) return {skill = a, level = b} end) | |||
local res = {} | |||
for _, v in pairs(skillList) do | |||
Icons._SkillReq(v.skill, v.level) | |||
end | |||
return table.concat(bonuses, '<br/>') | |||
end | |||
local function getCosts(costsTable) | |||
-- Order table with GP, SC first, then the other items. | |||
local sortedCosts = {} | |||
if costsTable['GP'] then table.insert(sortedCosts, {item = 'GP', amount = costsTable['GP']}) end | |||
if costsTable['SC'] then table.insert(sortedCosts, {item = 'SC', amount = costsTable['SC']}) end | |||
for k, v in pairs(costsTable) do | |||
if k ~= 'GP' and k ~= 'SC' then | |||
table.insert(sortedCosts, {item = k, amount = v}) | |||
end | |||
end | |||
local res = {} | |||
for _, v in pairs(sortedCosts) do | |||
table.insert(res, getItemIcon(v.item, v.amount)) | |||
end | |||
return table.concat(res, '<br/>') | |||
end | end | ||
--== Start of table formatting ==-- | |||
local obstacleNames = parseObstacleArgs(args) | |||
local courseRequirements = p.calculateCourse(obstacleNames, true) | |||
local showTotals = args['showtotals'] or true | |||
local tbl = mw.html.create("table") | |||
:addClass("wikitable stickyHeader") | |||
tbl :tag('tr') | |||
:tag('th'):wikitext('Slot') | |||
:tag('th'):wikitext('Obstacle') | |||
:tag('th'):wikitext('Bonuses') | |||
:tag('th'):wikitext('Requirements') | |||
:tag('th'):wikitext('Costs') | |||
for _, obstacle in pairs(courseRequirements.Obstacles) do | |||
tbl :tag('tr') | |||
:tag('td'):wikitext(obstacle.Slot) | |||
:tag('td'):wikitext(Icons.Icon({obstacle.Name, type='agility'})) | |||
:tag('td'):wikitext(getBonusses(obstacle.Obstacle)) | |||
:tag('td'):wikitext(getRequirements(obstacle.LevelRequirements)) | |||
:tag('td'):wikitext(getCosts(obstacle.ItemCosts)) | |||
end | |||
return | --local obstacleInfo = { | ||
--Name = obstacle.name, | |||
--Slot = slot, | |||
--Obstacle = obstacle, | |||
--LevelRequirements = Agility.getObstacleRequirements(obstacle), | |||
--ItemCosts = Agility.getObstacleCosts(obstacle), | |||
--} | |||
return tostring(tbl) | |||
end | end | ||
return p | return p |
edits