Module:Sandbox

---   -- Here You can test your code. --   -- NOTICE -- This is a Test Module. It will be peridoicly cleared. -- please dont use it while it is in use by another person. --- local p = {}

local getArgs = require('Module:Arguments').getArgs local slot = require( Module:Inventory slot ).slot local craftingTable = require( Module:UI ).craftingTable local formatResList = require('Module:List')._resourceList local string = require(Module:String) local formatNum = string._formatNum local ucfirst = string._ucfirst local toRoman = string._toRoman local toArabic = string._toArabic local roundNumber = string.roundNumber local _error = string._error local table = require(Module:Table) local colorText = require('Module:Color')._colorTemplates local yesno = require(Module:Yesno) local bazaar = require(Module:Bazaar) local formatCoins = require('Module:Currency')._coins local processResource = require('Module:Item')._resourceDisplay local processItem = require('Module:Item')._itemDisplay

local minionData = mw.loadData('Module:Minion/Data')

local TIERS = { "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI" }

local function _actionsPerMinute(minion, tier) -- TBA*2 = SECONDS_PER_FULL_ACTIONS : Each action either picks up or places, so 2 actions are needed for every collection. -- 60/SECONDS_PER_FULL_ACTIONS = ACTIONS_PER_MINION : This gives us a number that can be used as a multiplier to find all other action/time related questions. return 60/(minionData[minion].stats[tier].tba*2) end

local lang = mw.getContentLanguage local title = mw.title.getCurrentTitle.text

-- Template:GetMinionData -- -- Returns a specified piece of data from the /Data module based on inputs

function p.getMinionData(frame) local args = getArgs(frame) local minion = args[1] or args["minion"] or args["m"] local tier = args["tier"] or args["t"] local data = args[2] or args["data"] or args["d"] local item = args[3] or args["i"] or args["item"] if not minion then return _error('Inputs expected, got none') end if not data then return _error('Invalid Argument to #2: paramater "data" is required.') end if not tier and minion:match('(.+) ([%dIVXivx]+)') then minion, tier = minion:match('(.+) ([%dIVXivx]+)') else tier = tier minion = minion end return p._getMinionData(minion, data, tier, item) end

function p._getMinionData(minionName, data, tier, item) local minionData = minionData[minionName] local aliases = { ['s']='storage'; ['str']='storage'; ['store']='storage'; ['storage']='storage'; ['tba']='time between actions'; ['time b a']='time between actions'; ['time betw a']='time between actions'; ['time between a']='time between actions'; ['time b act']='time between actions'; ['time b actions']='time between actions'; ['time betw act']='time between actions'; ['time between act']='time between actions'; ['time between actions']='time between actions'; ['time between action']='time between actions'; ['ci']='crafting item'; ['c item']='crafting item'; ['cra i']='crafting item'; ['craft i']='crafting item'; ['cra item']='crafting item'; ['craft item']='crafting item'; ['crafting item']='crafting item'; ['cn']='crafting number'; ['cra n']='crafting number'; ['craft n']='crafting number'; ['crafting n']='crafting number'; ['cra n']='crafting number'; ['cra num']='crafting number'; ['cra number']='crafting number'; ['c n']='crafting number'; ['c num']='crafting number'; ['c number']='crafting number'; ['craft num']='crafting number'; ['crafting num']='crafting number'; ['crafting number']='crafting number'; ['desc']='description'; ['d']='description'; ['descr']='description'; ['descrip']='description'; ['description']='description'; ['ai']='average item'; ['avg i']='average item'; ['avrg i']='average item'; ['averag i']='average item'; ['average i']='average item'; ['avg item']='average item'; ['avrg item']='average item'; ['averag item']='average item'; ['average item']='average item'; ['avg i']='average item'; ['a i']='average item'; ['a item']='average item'; ['an']='average number'; ['avg n']='average number'; ['avrg n']='average number'; ['averag n']='average number'; ['average n']='average number'; ['avg num']='average number'; ['avrg num']='average number'; ['averag num']='average number'; ['average num']='average number'; ['avg number']='average number'; ['avrg number']='average number'; ['averag number']='average number'; ['average number']='average number'; }   local data = aliases[data:lower] local tier = tonumber(toArabic(tier or 0)) local item = tonumber(item) if data == "storage" then ret = minionData.stats[tier].storage elseif data == "time between actions" then ret = minionData.stats[tier].tba elseif data == "crafting item" then ret = minionData.stats[tier].crafting.item elseif data == "crafting number" then ret = minionData.stats[tier].crafting.num elseif data == "description" then ret = minionData.description elseif data == "average item" then ret = minionData.items[item].item elseif data == "average number" then ret = minionData.items[item].avg else ret = _error("Invalid Argument to \"data\": unknown data type (help)") end return ret end - -- Template: Minion Drops Table -- -- Returns a table with minion drops - function p.minionDropsTableExp(frame) local args = getArgs(frame) local minion = args.minion or args.m or args[1] or title return p._minionDropsTable(minion) end

function p._minionDropsTable(minion) local notBazaarItems = { ['Cactus Green'] = 1, ['White Wool'] = 2, ['Egg'] = 3, ['Poisonous Potato'] = 10, ['Iron Ore'] = 3, ['Gold Ore'] = 3 }	minion = minion:lower minion = minion:match('(.+) minion') or minion local needsToBeDividedByTwo = minion == "fishing" and true or false local dropData = minionData[ucfirst(minion)].items local hasNotBazaarItem, hasCondition = {false, false} for _,v in pairs(dropData) do		if notBazaarItems[v.item] then hasNotBazaarItem = true end if v.condition           then hasCondition = true     end end local wikitable = mw.html.create('table'):addClass('wikitable') local row = wikitable:tag('tr') row:tag('th'):attr({rowspan=2, colspan=2}):wikitext('Items'):done row:tag('th'):attr({rowspan=2}):wikitext('Chance'):done row:tag('th'):attr({rowspan=2}):wikitext('Average per harvest'):done if hasCondition then row:tag('th'):attr({rowspan=2}):wikitext('Condition'):done end row:tag('th'):attr({rowspan=2}):wikitext('Experience per Item'):done row:tag('th'):attr({colspan=2}):wikitext(hasNotBazaarItem and 'Bazaar/Merchant Sell Price' or 'Bazaar Sell Price'):done row:done row = wikitable:tag('tr') row:tag('th'):wikitext('1 Item'):done row:tag('th'):wikitext('Stack'):done row:done for _,v in pairs(dropData) do		row = wikitable:tag('tr') row:tag('td'):wikitext(slot{ v.item }):done row:tag('td'):wikitext(..v.item..):done local chance = '100%' if v.avg < 1 then if needsToBeDividedByTwo then chance = (v.avg/2*100)..'%' else chance = (v.avg*100)..'%' end end row:tag('td'):wikitext(chance):done row:tag('td'):wikitext(v.avg):done if v.condition then row:tag('td'):wikitext(processItem(v.condition)):done elseif hasCondition then row:tag('td'):wikitext(string.blankCell):done end if v.mexp then row:tag('td'):wikitext(v.mexp/10):done else row:tag('td'):wikitext('?'):done end if notBazaarItems[v.item] then row:tag('td'):wikitext(tostring(formatCoins(notBazaarItems[v.item]))):done row:tag('td'):wikitext(tostring(formatCoins(notBazaarItems[v.item]*64))):done else row:tag('td'):wikitext(tostring(bazaar._calcMaterialBuyPrices(, 'buy', true))):done row:tag('td'):wikitext(tostring(bazaar._calcMaterialBuyPrices(, 'buy', true))):done end row:done end return tostring(wikitable) end

-- Finish Module -- return p

-- In use: Don't use