2,875
edits
(Make costReduction parsing more robust) |
No edit summary |
||
Line 7: | Line 7: | ||
local Shared = require('Module:Shared') | local Shared = require('Module:Shared') | ||
local Icons = require('Module:Icons') | local Icons = require('Module:Icons') | ||
local function getItemIcon(itemName, amount) | local function getItemIcon(itemName, amount) | ||
Line 288: | Line 287: | ||
--== Parse optional parameters==-- | --== Parse optional parameters==-- | ||
local showTotals = yesno(args['showtotals'], true) | local showTotals = yesno(args['showtotals'], false) | ||
local showbonus = yesno(args['obstacleMastery'], true) | |||
local showrequirements = yesno(args['obstacleMastery'], true) | |||
local showcosts = yesno(args['obstacleMastery'], true) | |||
local obstacleMastery = yesno(args['obstacleMastery'], false) | local obstacleMastery = yesno(args['obstacleMastery'], false) | ||
local costReduction = { | local costReduction = { | ||
['GP'] = Num.toNumberOrDefault(args['gpCostReduction'], 0), | ['GP'] = Num.toNumberOrDefault(args['gpCostReduction'], 0), | ||
Line 302: | Line 304: | ||
--== Start of table formatting ==-- | --== Start of table formatting ==-- | ||
local tbl = mw.html.create("table") | local tbl = mw.html.create("table") | ||
:addClass("wikitable | :addClass("wikitable stickyheader") | ||
tbl :tag('tr') | tbl :tag('tr') | ||
:tag('th'):wikitext('Slot') | :tag('th'):wikitext('Slot') | ||
:tag('th'):wikitext('Obstacle') | :tag('th'):wikitext('Obstacle') | ||
if showbonus then | |||
tbl:tag('th'):wikitext('Bonuses') | |||
end | |||
if showrequirements then | |||
tbl:tag('th'):wikitext('Requirements') | |||
end | |||
if showcosts then | |||
tbl:tag('th'):wikitext('Costs') | |||
end | |||
for _, obstacle in pairs(courseRequirements.Obstacles) do | for _, obstacle in pairs(courseRequirements.Obstacles) do | ||
tbl :tag('tr') | local tr = tbl:tag('tr') | ||
tr :tag('td') | |||
:css('text-align', 'right') | |||
:wikitext(obstacle.Slot) | |||
:tag('td'):wikitext(Icons.Icon({obstacle.Name, type='agility'})) | |||
if showbonus then | |||
tr:tag('td'):wikitext(getBonusses(obstacle.Obstacle)) | |||
end | |||
if showrequirements then | |||
tr:tag('td'):wikitext(getRequirements(obstacle.LevelRequirements)) | |||
end | |||
if showcosts then | |||
tr:tag('td'):wikitext(getCosts(obstacle.ItemCosts)) | |||
end | |||
end | end | ||
if showTotals == true then | if showTotals == true then | ||
tbl :tag('tr') | local tr = tbl:tag('tr') | ||
tr :tag('th') | |||
:attr('colspan', 2) | |||
:wikitext('Totals') | |||
if showbonus then | |||
tr:wikitext(getTotalBonuses(courseRequirements.Obstacles)) | |||
end | |||
if showrequirements then | |||
tr:wikitext(getRequirements(courseRequirements.CourseLevelRequirements)) | |||
end | |||
if showcosts then | |||
tr:wikitext(getCosts(courseRequirements.CourseItemCosts)) | |||
end | |||
end | end | ||
Line 341: | Line 360: | ||
local obstacles = {"Rope Climb","Monkey Bars"," Balance Seesaw","Elite Pillar of Conflict"} | local obstacles = {"Rope Climb","Monkey Bars"," Balance Seesaw","Elite Pillar of Conflict"} | ||
local obs = p.calculateCourse(obstacles) | local obs = p.calculateCourse(obstacles) | ||
end | end | ||
return p | return p |
edits