Anonymous

Module:Calculator/AgilityObstacle: Difference between revisions

From Melvor Idle
no edit summary
(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 Debug = require('Module:Debug') -- Comment out when Module is finalised.


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 stickyHeader")
       :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')
:tag('th'):wikitext('Bonuses')
:tag('th'):wikitext('Requirements')
if showbonus then
:tag('th'):wikitext('Costs')
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')
:tag('td')
tr  :tag('td')
:css('text-align', 'right')
:css('text-align', 'right')
:wikitext(obstacle.Slot)
:wikitext(obstacle.Slot)
:tag('td'):wikitext(Icons.Icon({obstacle.Name, type='agility'}))
:tag('td'):wikitext(Icons.Icon({obstacle.Name, type='agility'}))
:tag('td'):wikitext(getBonusses(obstacle.Obstacle))
:tag('td'):wikitext(getRequirements(obstacle.LevelRequirements))
if showbonus then
:tag('td'):wikitext(getCosts(obstacle.ItemCosts))
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')
:tag('th')
tr  :tag('th')
:attr('colspan', 2)
:attr('colspan', 2)
:wikitext('Totals')
:wikitext('Totals')
:tag('td')
if showbonus then
:wikitext(getTotalBonuses(courseRequirements.Obstacles))
tr:wikitext(getTotalBonuses(courseRequirements.Obstacles))
:tag('td')
end
:wikitext(getRequirements(courseRequirements.CourseLevelRequirements))
if showrequirements then
:tag('td')
tr:wikitext(getRequirements(courseRequirements.CourseLevelRequirements))
:wikitext(getCosts(courseRequirements.CourseItemCosts))
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)
Debug.log(obs.CourseItemCosts)
end
end
return p
return p
2,875

edits