Module:Heart of the Mountain

-- local p = {}

local getArgs = require('Module:Arguments').getArgs require('Module:LibraryUtil')

-- Invoked directly by Template:Calculator/HotM_perk_powder function p.calcPowderCostForLevel(frame) local args = getArgs(frame) local perk = args[1] or args["perk"] local target = args[2] or args["target"] or args["to"] assertTrue(perk, "perk must be specified", 0) assertTrue(target, "Must specify a target level", 0) return p._calcPowderCostForLevel(perk, target) end

function p._calcPowderCostForLevel(perk, target) checkType(1, perk, 'string') checkType(2, target, 'number', true) perk = perk:lower local functionData = { ["crystallized"] =			function(n) return math.floor(math.pow(n+1, 3.4)) end, ["daily powder"] =			function(n) return 182 + 18 * n end, ["efficient miner"] =		function(n) return math.floor(math.pow(n+1, 2.6)) end, ["luck of the cave"] =		function(n) return math.floor(math.pow(n+1, 3.07)) end, ["mining fortune"] =		function(n) return math.floor(math.pow(n+1, 3.05)) end, ["mining speed"] =			function(n) return math.floor(math.pow(n+1, 3)) end, ["orbiter"]	=				function(n) return 70 * n end, ["peak of the mountain"] =	function(n) return 25000 * n end, ["quick forge"]	=			function(n) return math.floor(math.pow(n+1, 4)) end, ["seasoned mineman"] =		function(n) return math.floor(math.pow(n+1, 2.3)) end, ["titanium insanium"] = 	function(n) return math.floor(math.pow(n+1, 3.1)) end, }   local calc = functionData[perk] assertTrue(calc, "Error: Invalid perk name specified", 0) local powder = 0 for i = 2,target,1 do       powder = powder + calc(i) end return powder end

return p