Module:Reward/HallOfForms

local Reward = require 'Module:Reward' local RewardTables = require 'Module:Reward/Tables' local RewardText = require 'Module:RewardText'._main

local daily = function(args, frame) args.columns = args.columns or 1 local start = mw.ext.cargo.query('HallOfForms', 'StartTime', {		where = ("_pageName='%s'"):format(mw.title.getCurrentTitle.text),		limit = 1,	 })[1] start = frame:callParserFunction('#time', 'U', start and start['StartTime'] or '') local nbDays = require 'Module:HashUtil'.count_if(args, function(v, k) return tonumber(k) end) local rewardList = {} for k, v in pairs(args) do		if tonumber(k) then local reward, err = Reward.parse(v) if err then return require 'Module:Error'.error(err) end rewardList[#rewardList + 1] = { k .. '/' .. nbDays, RewardText({reward, size = args.iconsize, iconfirst = '1'}, frame) } Reward.define(reward, 'HallOfForms', {from = require 'Module:DatetimeUtil'.to_iso8601(start + (tonumber(k) - 1) * 86400)}, frame) end end table.sort(rewardList, function (x, y) return x[1] < y[1] end) return RewardTables.createTable(rewardList, 'Day', args.columns or 1) end

local chambers = function(args, frame) local rewardList = {} for k, v in pairs(args) do		if mw.ustring.match(k, "[Cc]hamber") then local reward, err = Reward.parse(v) if err then return require 'Module:Error'.error(err) end rewardList[#rewardList + 1] = { k, RewardText({reward, size = args.iconsize, iconfirst = '1'}, frame) } Reward.define(reward, 'HallOfForms', {chamber = k}, frame) end end table.sort(rewardList, function (x, y) 		return tonumber(mw.ustring.match(x[1], "%d+") or 0) < tonumber(mw.ustring.match(y[1], "%d+") or 0) 	end)

return RewardTables.createTable(rewardList, "Chamber", args.columns or 3) end

return require 'Module:MakeMWModule'.makeMWModule { daily = daily, chambers = chambers, }