964
edits
No edit summary |
(Add expansion icon to obstacle) |
||
(8 intermediate revisions by the same user not shown) | |||
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 19: | Line 18: | ||
return Icons.Icon({itemName, type='item', qty = amount, notext=true}) | return Icons.Icon({itemName, type='item', qty = amount, notext=true}) | ||
end | |||
local function getObstacleIcon(obstacle) | |||
local obs = obstacle.Obstacle | |||
return Icons.getExpansionIcon(obs.id) .. Icons.Icon({obs.name, type='agility'}) | |||
end | end | ||
Line 26: | Line 30: | ||
local obstacle = Agility.getObstacle(name) or Agility.getPillar(name) | local obstacle = Agility.getObstacle(name) or Agility.getPillar(name) | ||
if obstacle == nil then | if obstacle == nil then | ||
error("Unknown Agility obstacle or pillar name: " .. name) | error("Unknown Agility obstacle or pillar name: " .. (name or '<name is nil>')) | ||
end | end | ||
Line 148: | Line 152: | ||
function p._getCourseList(args) | function p._getCourseList(args) | ||
-- Parse optional parameters | -- Parse optional parameters | ||
local costReduction = { | local costReduction = { | ||
['GP'] = args['gpCostReduction'] | ['GP'] = Num.toNumberOrDefault(args['gpCostReduction'], 0), | ||
['SC'] = args['scCostReduction'] | ['SC'] = Num.toNumberOrDefault(args['scCostReduction'], 0), | ||
['Item'] = args['itemCostReduction'] | ['Item'] = Num.toNumberOrDefault(args['itemCostReduction'], 0), | ||
} | } | ||
Line 164: | Line 164: | ||
local div = html:tag('div') | local div = html:tag('div') | ||
if includeObstacles then | if yesno(args['includeObstacles'], true) == true then | ||
div:tag('b'):wikitext('Obstacles') | div:tag('b'):wikitext('Obstacles') | ||
local tbl = mw.html.create("table") | local tbl = mw.html.create("table") | ||
Line 179: | Line 179: | ||
:wikitext(v.Slot) | :wikitext(v.Slot) | ||
:tag('td') | :tag('td') | ||
:wikitext( | :wikitext(getObstacleIcon(v)) | ||
end | end | ||
Line 186: | Line 186: | ||
end | end | ||
if | if yesno(args['includeitems'], true) then | ||
div:tag('b'):wikitext('Items Required') | div:tag('b'):wikitext('Items Required') | ||
local ul = div:tag('ul') | local ul = div:tag('ul') | ||
Line 196: | Line 196: | ||
if courseItems['SC'] then ul:tag('li'):wikitext(getItemIcon('SC', courseItems['SC'])) end | if courseItems['SC'] then ul:tag('li'):wikitext(getItemIcon('SC', courseItems['SC'])) end | ||
local itemList = Shared.sortDictionary(courseItems['Items'], | |||
local itemList = Shared.sortDictionary(courseItems, | |||
function(a, b) return a.item < b.item end, | function(a, b) return a.item < b.item end, | ||
function(a, b) return {item = a, amount = b} end) | function(a, b) return {item = a, amount = b} end) | ||
Line 209: | Line 206: | ||
end | end | ||
if | if yesno(args['includeskills'], true) then | ||
div:tag('b'):wikitext('Skills Required') | div:tag('b'):wikitext('Skills Required') | ||
local ul2 = div:tag('ul') | local ul2 = div:tag('ul') | ||
Line 295: | Line 292: | ||
--== Parse optional parameters==-- | --== Parse optional parameters==-- | ||
local showTotals = yesno(args['showtotals'], true) | local showTotals = yesno(args['showtotals'], false) | ||
local showbonus = yesno(args['showbonus'], true) | |||
local showrequirements = yesno(args['showrequirements'], true) | |||
local showcosts = yesno(args['showcosts'], true) | |||
local obstacleMastery = yesno(args['obstacleMastery'], false) | local obstacleMastery = yesno(args['obstacleMastery'], false) | ||
local costReduction = { | local costReduction = { | ||
['GP'] = args['gpCostReduction'] | ['GP'] = Num.toNumberOrDefault(args['gpCostReduction'], 0), | ||
['SC'] = args['scCostReduction'] | ['SC'] = Num.toNumberOrDefault(args['scCostReduction'], 0), | ||
['Item'] = args['itemCostReduction'] | ['Item'] = Num.toNumberOrDefault(args['itemCostReduction'], 0), | ||
} | } | ||
Line 309: | Line 309: | ||
--== 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') | local thr = tbl:tag('tr') | ||
thr:tag('th'):wikitext('Slot') | |||
thr:tag('th'):wikitext('Obstacle') | |||
if showbonus then | |||
thr:tag('th'):wikitext('Bonuses') | |||
end | |||
if showrequirements then | |||
thr:tag('th'):wikitext('Requirements') | |||
end | |||
if showcosts then | |||
thr: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(getObstacleIcon(obstacle)) | |||
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 :tag('td') | |||
:wikitext(getTotalBonuses(courseRequirements.Obstacles)) | |||
end | |||
if showrequirements then | |||
tr :tag('td') | |||
:wikitext(getRequirements(courseRequirements.CourseLevelRequirements)) | |||
end | |||
if showcosts then | |||
tr :tag('td') | |||
:wikitext(getCosts(courseRequirements.CourseItemCosts)) | |||
end | |||
end | end | ||
Line 346: | Line 366: | ||
function p.test() | function p.test() | ||
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) | ||
mw.logObject(getObstacle('rope trap')) | |||
end | end | ||
return p | return p |
edits