FANDOM


local p = {}
 
function p.noValue( frame )
    local value = frame.args[1]
	local isFalse = frame.args[2]
	local isTrue = frame.args[3]
 
	if value == nil or value == "" then
		if isFalse == nil or isFalse == "" then
			value = 0
		else
			value = frame.args[2]
		end
		return value
	else
		if isTrue == nil or isTrue == "" then
			value = frame.args[1]
		else
			value = frame.args[3]
		end
		return value
	end
	return value
end
 
local scatData = mw.loadData( 'Module:InfraRow/CatData' )
 
function p.scat( frame )
	local scatText = frame.args[1]
	return scatData[scatText] or scatData["#default"]
end
 
function p.built( frame )
    local buildtext = tonumber(frame.args[1])
    local rText
 
    if buildtext == 0 then
        rText = "Instant"
    elseif buildtext == 0.0166 then
        rText = "1 minute"
    elseif buildtext < 1 then
        if buildtext < 0.0166 then
            rText = math.ceil(buildtext*3600) .. " seconds"
        elseif math.ceil(buildtext*60) % 1 == 0 then
            rText = math.ceil(buildtext*60) .. " minutes"
        else
            rText = math.floor(buildtext*60) .. " minutes and " .. math.ceil(buildtext*3600) % 60 .. " seconds"
        end
    elseif buildtext == 1 then
        rText = "1 hour"
    elseif buildtext % 1 == 0 then
        rText = buildtext .. " hours"
    else
        rText = math.floor(buildtext) .. " hours and " .. (buildtext*60) % 60 .. " minutes"
    end
    return rText
end
 
function p.pReward( frame )
	local coinr = tonumber(frame.args.coinr) or tonumber(frame.args[1])
    local xpr = tonumber(frame.args.xpr) or tonumber(frame.args[2])
    local timer = tonumber(frame.args.timer) or tonumber(frame.args[3])
    local rText
 
    if timer == nil or coinr == nil or xpr == nil then
        rText = "No periodic benefits"
    elseif  timer == 0.0166 then
        rText = frame:expandTemplate{ title = 'coin', args = { coinr } } .. " and " .. frame:expandTemplate{ title = 'xp', args = { xpr } } .. " every 1 minute"
    elseif  timer < 1 then
        rText = frame:expandTemplate{ title = 'coin', args = { coinr } } .. " and " .. frame:expandTemplate{ title = 'xp', args = { xpr } } .. " every " .. math.ceil((timer*60) % 60) .. " minutes"
    elseif timer == 1 then
        rText = frame:expandTemplate{ title = 'coin', args = { coinr } } .. " and " .. frame:expandTemplate{ title = 'xp', args = { xpr } } .. " every 1 hour"
    elseif timer % 1 == 0 then
        rText = frame:expandTemplate{ title = 'coin', args = { coinr } } .. " and " .. frame:expandTemplate{ title = 'xp', args = { xpr } } .. " every " .. timer .. " hours"
    else
        rText = frame:expandTemplate{ title = 'coin', args = { coinr } } .. " and " .. frame:expandTemplate{ title = 'xp', args = { xpr } } .. " every " .. math.floor(timer) .. " hours and " .. (timer*60) % 60 .. " minutes"
    end
    return rText
end
 
function p.cpm( frame )
	local coinr = tonumber(frame.args.coinr) or tonumber(frame.args[1])
    local timer = tonumber(frame.args.timer) or tonumber(frame.args[2])
    local cpm
 
    if timer == nil or coinr == nil then
        cpm = "N/A"
    else
        cpm = coinr/(60*timer)
        cpm = frame:expandTemplate{ title = 'coin', args = { cpm } }
    end
    return cpm
end
 
function p.xpm( frame )
	local xpr = tonumber(frame.args.xpr) or tonumber(frame.args[1])
    local timer = tonumber(frame.args.timer) or tonumber(frame.args[2])
    local xpm
 
    if timer == nil or xpr == nil then
        xpm = "N/A"
    else
        xpm = xpr/(60*timer)
        xpm = frame:expandTemplate{ title = 'xp', args = { xpm } }
    end
    return xpm
end
 
function p.sell( frame )
    local selling = tonumber(frame.args.sell)
    local mb = tonumber(frame.args.mb)
 
    if selling == nil then
        if mb ~= nil then
            selling = (mb*100)
        else
            selling = 0
        end
    end
    selling = frame:expandTemplate{ title = 'coin', args = { selling } }
    return selling
end
 
function p.sellsort( frame )
    local selling = tonumber(frame.args.sell)
    local mb = tonumber(frame.args.mb)
 
    if selling == nil then
        if mb ~= nil then
            selling = (mb*100)
        else
            selling = 0
        end
    end
    return selling
end
 
function p.tag( frame )
    local tagname = frame.args[1]
    if not tagname == {} or nil or "" then
        tagtext = frame.args[2]
    end
    return tagtext
end
 
return p

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.