Module:Heart of the Mountain

-- local loader = require('Module:Loader') local p = {}

local string, arguments, lu, itemM = loader.lazy.require('String', 'Arguments', 'LibU', 'Item')

local getArgs = arguments.getArgs local title = mw.title.getCurrentTitle.fullText local lang = mw.language.getContentLanguage

-- Time offset from UTC time: Hypixel's Server Timezone local serverTimeOffset = require('Module:HypixelServerTime') .. ' hours'

-- Invoked directly by Template:Calculator/HotM_perk_powder function p.getPowderTypeForPerk(frame) local args = getArgs(frame) local perk = args[1] lu.assertTrue(perk, 'perk must be specified', 0) return p._getPowderTypeForPerk(perk) end

-- 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'] lu.assertTrue(perk, 'perk must be specified', 0) lu.assertTrue(target, 'Must specify a target level', 0) return p._calcPowderCostForLevel(perk, target) end

function p._getPowderTypeForPerk(perk) lu.checkType(1, perk, 'string') perk = perk:lower local functionData = { ['crystallized'] =			'Mithril Powder', ['daily powder'] =			'Mithril Powder', ['efficient miner'] =      'Mithril Powder', ['fortunate'] =				'Gemstone Powder', ['great explorer'] =		'Gemstone Powder', ['lonesome miner'] =		'Gemstone Powder', ['luck of the cave'] =		'Mithril Powder', ['mining fortune'] =		'Mithril Powder', ['mining fortune ii'] =		'Gemstone Powder', ['mining speed'] =			'Mithril Powder', ['mining speed ii'] =		'Gemstone Powder', ['mole'] =					'Gemstone Powder', ['orbiter']	=				'Mithril Powder', ['peak of the mountain'] =	'Mithril Powder', ['powder buff'] =			'Gemstone Powder', ['professional'] =			'Gemstone Powder', ['quick forge']	=			'Mithril Powder', ['seasoned mineman'] =		'Mithril Powder', ['titanium insanium'] = 	'Mithril Powder', }	return functionData[perk] end

function p._calcPowderCostForLevel(perk, target) lu.checkType(1, perk, 'string') lu.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, ['fortunate'] =				function(n) return math.floor(math.pow(n+1, 3.05)) end, ['great explorer'] =		function(n) return math.floor(math.pow(n+1, 4)) end, ['lonesome miner'] =		function(n) return math.floor(math.pow(n+1, 3.07)) 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 fortune ii'] =		function(n) return math.floor(math.pow(n+1, 3.2)) end, ['mining speed'] =			function(n) return math.floor(math.pow(n+1, 3)) end, ['mining speed ii'] =		function(n) return math.floor(math.pow(n+1, 3.2)) end, ['mole'] =					function(n) return math.floor(math.pow(n+1, 2.2)) end, ['orbiter']	=				function(n) return 70 * n end, ['peak of the mountain'] =	function(n) return 25000 * n end, ['powder buff'] =			function(n) return math.floor(math.pow(n+1, 3.2)) end, ['professional'] =			function(n) return math.floor(math.pow(n+1, 2.3)) 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] lu.assertTrue(calc, 'Invalid perk name specified %q', 0, perk) local powder = 0 for i = 2,target,1 do 		powder = powder + calc(i) end return powder end

-- Invoked directly by Fetchur -- Not really HotM related, but semi related and didn't feel like making a new module function p.currentFetchurFetchQuest(frame) local args = getArgs(frame) -- Fetch Quest is based on current date local date = args[1] or args.date or lang:formatDate('Y-m-d', serverTimeOffset) local mode = args.mode return p._questItem(date, mode) end

function p._questItem(date, mode) local datestr = lang:formatDate('D Y/n/j', serverTimeOffset) if mode == 'date' then return datestr end local items = { { 'Yellow Stained Glass', 20, name='Yellow Stained Glass' }, { 'Compass', 1, name='Compass' }, { 'Mithril', 20, name='Mithril' }, { 'Firework Rocket', 1, name='Firework Rocket' }, { 'Cheap Coffee', 1, name='%s, %s, or %s', replace={ 'Cheap Coffee', 'Decent Coffee', 'Black Coffee' } }, { 'Oak Door', 1, name='Any %s or %s', replace={ 'Wooden Door', 'Iron Door' } }, { 'Rabbit\'s Foot', 3, name='Rabbit\'s Foot' }, { 'Superboom TNT', 1, name='Superboom TNT' }, { 'Pumpkin', 1, name='Pumpkin' }, { 'Flint and Steel', 1, name='Flint and Steel' }, { 'Emerald', 50, name='Emerald' }, { 'Red Wool', 50, name='Red Wool' }, }	local day = tonumber(lang:formatDate('j', date)) local i = day % (#items) if i == 0 then i = #items end local itemstr = '' if items[i].replace then replacements = {} for a = 1, #items[i].replace, 1 do			replacements[#replacements + 1] = itemM.resourceDisplay{('%sx %s'):format(items[i][2], items[i]['replace'][a])} end itemstr = items[i].name:format(unpack(replacements)) else itemstr = itemM.resourceDisplay{('%sx %s'):format(items[i][2], items[i][1] or items[i].name)} end return itemstr end

return p