Anonymous

Module:Calculator/AgilityObstacle: Difference between revisions

From Melvor Idle
no edit summary
No edit summary
No edit summary
Line 9: Line 9:
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.
local function getItemIcon(itemName, amount)
if itemName == 'GP' then
return Icons.GP(amount)
end
if itemName == 'SC' then
return Icons.SC(amount)
end
return Icons.Icon({itemName, type='item', qty = amount, notext=true})
end


-- Gets all associated metadata from an obstacle based on its name.
-- Gets all associated metadata from an obstacle based on its name.
Line 109: Line 121:
end
end


function p.main(frame)
function p.getCourseList(args)
local args = frame:getParent().args
local args = frame:getParent().args
return p._main(args)
return p._getCourseList(args)
end
end


function p._main(args)
function p._getCourseList(args)
local obstacleNames = parseObstacleArgs(args)
local obstacleNames = parseObstacleArgs(args)
local courseRequirements = p.calculateCourse(obstacleNames, true)
local courseRequirements = p.calculateCourse(obstacleNames, true)
 
-------- TEMP --------
local includeItems = args['includeitems'] or true
local includeSkills = args['includeskills'] or true
local includeObstacles = args['includeObstacles'] or true
local html = mw.html.create()
local html = mw.html.create()
     local div = html:tag('div')
     local div = html:tag('div')
    div:tag('h2'):wikitext('Items Required')
      
      
     local ul = div:tag('ul')
     if includeItems then
    for k, v in pairs(courseRequirements.CourseItemCosts) do
    div:tag('h2'):wikitext('Items Required')
    ul:tag('li'):wikitext(k .. ': ' .. v)
    local ul = div:tag('ul')
   
    local itemList = Shared.sortDictionary(courseRequirements.CourseItemCosts,
    function(a, b) return a.item < b.item end,
    function(a, b) return {item = a, amount = b} end)
   
for _, v in pairs(itemList) do
    ul:tag('li'):wikitext(getItemIcon(item, amount))
    end
     end
     end
div:tag('h2'):wikitext('Skills Required')
div:tag('h2'):wikitext('Skills Required')
     local ul2 = div:tag('ul')
     local ul2 = div:tag('ul')
     for k, v in pairs(courseRequirements.CourseLevelRequirements) do
     for skill, level in pairs(courseRequirements.CourseLevelRequirements) do
     ul2:tag('li'):wikitext(k .. ': ' .. v)
     ul2:tag('li'):wikitext(Icons._SkillReq(skill, level))
     end
     end
      
      
Line 140: Line 162:
function p.test()
function p.test()
local obs = p.calculateCourse({'Elite Pillar of Conflict ', ' Cargo Net ',' Balance Beam','Pipe Climb'})
local obs = p.calculateCourse({'Elite Pillar of Conflict ', ' Cargo Net ',' Balance Beam','Pipe Climb'})
Debug.log(obs)
local func = function(a, b) return a.amount < b.amount end
local factory = function(a, b) return {item = a, amount = b} end
local sortedTable = Shared.sortDictionary(obs.CourseItemCosts, func, factory)
 
    Debug.log(sortedTable)
end
end


2,875

edits