Module:Reward/GrandConquests

local Reward = require 'Module:Reward' local RewardTables = require 'Module:Reward/Tables' local Datetime = require 'Module:DatetimeUtil' local toboolean = require 'Module:Bool'.toboolean

local ROUNDS = 3 local ROUND_DURATION = 44 * 60 * 60 local BREAK_DURATION = 4 * 60 * 60

local tier = function (args, frame) args.columns = args.columns or 2 return RewardTables.score(args, function (reward, tier)		Reward.define(reward, 'GrandConquests', {source = 'tier', tier = tier}, frame)	end, 'Tier', frame) end

local score = function (args, frame) args.columns = args.columns or toboolean(args.old) and 2 or 3 args.reverse = true local t0 = frame:callParserFunction('#time', 'U', args.time or '') local t1 = Datetime.MAX_TIME return RewardTables.rank(args, function (reward)		for i = 0, ROUNDS - 1 do			Reward.define(reward, 'GrandConquests', { source = 'score', from = Datetime.to_iso8601(t0 + i * (ROUND_DURATION + BREAK_DURATION) + ROUND_DURATION), to = t1, }, frame)		end	end, toboolean(args.old) and 'Area count' or 'Score', frame) end

local rank = function (args, frame) local t0 = frame:callParserFunction('#time', 'U', args.time or '') local t1 = Datetime.MAX_TIME return RewardTables.rank(args, function (reward)		for i = 0, ROUNDS - 1 do			Reward.define(reward, 'GrandConquests', { source = 'rank', from = Datetime.to_iso8601(t0 + i * (ROUND_DURATION + BREAK_DURATION) + ROUND_DURATION), to = t1, }, frame)		end	end, nil, frame) end

return require 'Module:MakeMWModule'.makeMWModule { tier = tier, score = score, rank = rank, }