Module:Calculator/AgilityObstacle: Difference between revisions

From Melvor Idle
(Created page with "local p = {} local number = require('Module:Number') function p.main(frame) local args = frame:getParent().args return p._main(args) end function p._main(args) end return p")
 
(First version)
Line 1: Line 1:
local p = {}
local p = {}


local number = require('Module:Number')
local Num = require('Module:Number')
local Constants = require('Module:Constants')
local Agility = require('Module:Skills/Agility')
local Shared = require('Module:Shared')
local Skills = require('Module:Skills')
local Items = require('Module:Items')
local Icons = require('Module:Icons')
 
local function getLevelRequirements(obstacle)
local levelRequirements = {}
-- Add agility level requirement.
table.insert(levelRequirements, {
SkillName = 'Agility',
SkillLevel = Skills.getRecipeLevel('Agility', obstacle)
})
-- Add other level requirements.
if type(obstacle.skillRequirements) == 'table' then
for i, skillReq in ipairs(obstacle.skillRequirements) do
local skillName = Constants.getSkillName(skillReq.skillID)
if skillName ~= nil then
table.insert(levelRequirements, {
SkillName = skillName,
SkillLevel = skillReq.level
})
end
end
end
return levelRequirements
end
 
local function getObstacle(name)
name = Shared.titleCase(name)
local obstacle = Agility.getObstacle(name)
if obstacle == nil then
return nil
end
 
local obstacleInfo = {
Name,
LevelRequirements = {},
ItemCosts = {},
}
 
local levelRequirements = getLevelRequirements(obstacle)
-- Build and return obstacle information
mw.log(levelRequirements)
end


function p.main(frame)
function p.main(frame)
Line 11: Line 60:
function p._main(args)
function p._main(args)


end
function p.test()
local obst = 'pipe climb'
getObstacle(obst)
end
end


return p
return p

Revision as of 15:36, 21 April 2024

Documentation for this module may be created at Module:Calculator/AgilityObstacle/doc

local p = {}

local Num = require('Module:Number')
local Constants = require('Module:Constants')
local Agility = require('Module:Skills/Agility')
local Shared = require('Module:Shared')
local Skills = require('Module:Skills')
local Items = require('Module:Items')
local Icons = require('Module:Icons')

local function getLevelRequirements(obstacle)
	local levelRequirements = {}
	
	-- Add agility level requirement.
	table.insert(levelRequirements, {
		SkillName = 'Agility',
		SkillLevel = Skills.getRecipeLevel('Agility', obstacle)
	})
	
	-- Add other level requirements.
	if type(obstacle.skillRequirements) == 'table' then
		for i, skillReq in ipairs(obstacle.skillRequirements) do
			local skillName = Constants.getSkillName(skillReq.skillID)
			if skillName ~= nil then
				table.insert(levelRequirements, {
					SkillName = skillName,
					SkillLevel = skillReq.level
				})
			end
		end
	end
	
	return levelRequirements
end

local function getObstacle(name)
	name = Shared.titleCase(name)
	local obstacle = Agility.getObstacle(name)
	if obstacle == nil then
		return nil
	end

	local obstacleInfo = {
		Name,
		LevelRequirements = {},
		ItemCosts = {},
	}

	local levelRequirements = getLevelRequirements(obstacle)
	-- Build and return obstacle information
	mw.log(levelRequirements)
end

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

end

function p._main(args)

end

function p.test()
	local obst = 'pipe climb'
	getObstacle(obst)
end

return p