2,869
edits
No edit summary |
m (Fix derp again) |
||
(8 intermediate revisions by 2 users not shown) | |||
Line 4: | Line 4: | ||
local Num = require('Module:Number') | local Num = require('Module:Number') | ||
local Constants = require('Module:Constants') | local Constants = require('Module:Constants') | ||
local Modifiers = require('Module:Modifiers') | |||
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 iconTable = { | |||
['GP'] = function(amount) return Icons._Currency('GP', amount) end, | |||
['SC'] = function(amount) return Icons._Currency('SC', amount) end, | |||
['AP'] = function(amount) return Icons._Currency('AP', amount) end, | |||
['ASC'] = function(amount) return Icons._Currency('ASC', amount) end, | |||
} | |||
local function getItemIcon(itemName, amount) | local function getItemIcon(itemName, amount) | ||
if | local iconFunc = iconTable[itemName] | ||
if iconFunc then | |||
return iconFunc(amount) | |||
else | |||
return Icons.Icon({itemName, type='item', qty = amount, notext=true}) | |||
end | |||
end | |||
return Icons.Icon({ | local function getObstacleIcon(obstacle) | ||
local obs = obstacle.Obstacle | |||
return Icons.getExpansionIcon(obs.id) .. Icons.Icon({obs.name, type='agility'}) | |||
end | end | ||
Line 25: | Line 35: | ||
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 174: | Line 184: | ||
:wikitext(v.Slot) | :wikitext(v.Slot) | ||
:tag('td') | :tag('td') | ||
:wikitext( | :wikitext(getObstacleIcon(v)) | ||
end | end | ||
Line 226: | Line 236: | ||
--== Local Functions for formatting Obstacle MetaData ==-- | --== Local Functions for formatting Obstacle MetaData ==-- | ||
local function getBonusses(obstacle) | local function getBonusses(obstacle) | ||
if obstacle.modifiers == nil then | |||
return '<span style="color:red">None :(</span>' | |||
else | |||
return Modifiers.getModifiersText(obstacle.modifiers, true, false, 10) | |||
end | end | ||
end | end | ||
Line 266: | Line 273: | ||
local function getTotalBonuses(obstacles) | local function getTotalBonuses(obstacles) | ||
--[==[ | |||
local bonuses = {} | local bonuses = {} | ||
for _, obstacle in pairs(obstacles) do | for _, obstacle in pairs(obstacles) do | ||
Line 284: | Line 292: | ||
return table.concat(ret, '<br/>') | return table.concat(ret, '<br/>') | ||
--]==] | |||
return '' | |||
end | end | ||
--== Parse optional parameters==-- | --== Parse optional parameters==-- | ||
local showTotals = yesno(args['showtotals'], false) | local showTotals = yesno(args['showtotals'], false) | ||
local showbonus = yesno(args[' | local showbonus = yesno(args['showbonus'], true) | ||
local showrequirements = yesno(args[' | local showrequirements = yesno(args['showrequirements'], true) | ||
local showcosts = yesno(args[' | local showcosts = yesno(args['showcosts'], true) | ||
local obstacleMastery = yesno(args['obstacleMastery'], false) | local obstacleMastery = yesno(args['obstacleMastery'], false) | ||
Line 325: | Line 335: | ||
:css('text-align', 'right') | :css('text-align', 'right') | ||
:wikitext(obstacle.Slot) | :wikitext(obstacle.Slot) | ||
:tag('td'):wikitext( | :tag('td'):wikitext(getObstacleIcon(obstacle)) | ||
if showbonus then | if showbonus then | ||
Line 344: | Line 354: | ||
:wikitext('Totals') | :wikitext('Totals') | ||
if showbonus then | if showbonus then | ||
tr:wikitext(getTotalBonuses(courseRequirements.Obstacles)) | tr :tag('td') | ||
:wikitext(getTotalBonuses(courseRequirements.Obstacles)) | |||
end | end | ||
if showrequirements then | if showrequirements then | ||
tr:wikitext(getRequirements(courseRequirements.CourseLevelRequirements)) | tr :tag('td') | ||
:wikitext(getRequirements(courseRequirements.CourseLevelRequirements)) | |||
end | end | ||
if showcosts then | if showcosts then | ||
tr:wikitext(getCosts(courseRequirements.CourseItemCosts)) | tr :tag('td') | ||
:wikitext(getCosts(courseRequirements.CourseItemCosts)) | |||
end | end | ||
end | end | ||
Line 358: | Line 371: | ||
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