Module:Reward/LogInBonus

local Reward = require 'Module:Reward' local parseArgs = require 'Module:ObjectArg'.parse local Error = require 'Module:Error'

local dailyReward = function (args, frame) if args['no cargo'] or mw.title.getCurrentTitle.namespace ~= 0 then return end

local name = args.name or '' local startTime = args.startTime and frame:callParserFunction('#time', 'U', args.startTime) local rewards = parseArgs(args.rewards or '[]')

for i, reward in ipairs(rewards) do		local rew, err = Reward.normalize(reward) if err then return Error.error(err) elseif #rew == 0 then return Error.error('Missing reward for day ' .. tostring(i)) elseif not startTime then return Error.error('Missing start parameter') end

Reward.define(rew, 'LogInBonus', { 			bonusName = name,			from = require 'Module:DatetimeUtil'.to_iso8601(startTime + 86400 * (i-1)),		}, frame) end end

local uniqueReward = function (args, frame) if args['no cargo'] or mw.title.getCurrentTitle.namespace ~= 0 then return end

local name = args.name or '' local rewards, err = Reward.parse(args.rewards)

if err then return Error.error(err) end

Reward.define(rewards, 'LogInBonus', { 		bonusName = name,	}, frame) end

return require 'Module:MakeMWModule'.makeMWModule { daily = dailyReward, oneTime = uniqueReward, }