Destiny of Spirits Wiki
Advertisement

Documentation for this module may be created at Module:Counter/doc

local p = {}
p.type = {
	w = "weak",
	weak = "weak",
	n = "normal",
	normal = "normal",
	p = "powerful",
	powerful = "powerful",
	sp = "super-powerful",
	super = "super-powerful",
	["super-powerful"] = "super-powerful"
	}
p.damage = {
	weak = "30%",
	normal = "50%",
	powerful = "80%",
	["super-powerful"] = "100%"
	}
p.target = {
	one = "one ally",
	ally = "one ally",
	all = "all allies",
	allies = "all allies",
	self = "self only"
	}

-- Empty table, we'll fill this within the function
p.args = {}

-- Default string the rest is built on
p.s = "[[:Template:Counter|Counterattack]] chance"
-- Counterattack icon inclusion string
p.icon = "[[File:Counter.png|link=:Template:Counter|22px]] "

p.main=function(frame)
	-- Generate p.args table excluding skipped args
	for k,v in pairs(frame.args) do if v ~= "{{{"..k.."}}}" then table.insert(p.args,v) else break end end

	-- Bail if the first arg isn't a number, is over 100, or is under 1
	if type(tonumber(p.args[1])) ~= "number" or p.args[1]*1<1 or p.args[1]*1>100 then return p.icon..p.s
	else
		-- Add in counter chance
		p.s = p.args[1].."% "..p.s
		-- Add in counter damage
		if p.args[2] and p.type[p.args[2]] then p.s = p.s.." for "..p.damage[p.type[p.args[2]]].." damage" end
		-- Add in affected parties, default to all allies
		if p.args[3] and p.target[p.args[3]] then p.s = p.s.." ("..p.target[p.args[3]]..")" else p.s = p.s.." (all allies)" end
		-- Add in number of times effective (for counter battle skills)
		if p.args[4] and type(tonumber(p.args[4])) == "number" and p.args[4]*1>0 then p.s = p.s.." up to "..p.args[4].." times" end
	end
	-- Box it, ship it, call it good.
	return p.icon..p.s.."."
end

return p
Advertisement