local EFFECT_DEFS = dofile("../defs/effect_defs.lua")
Effect = class("Effect")

function Effect:new(def)
	local effect = instance(self)
	effect.def = def	
	return effect
end

function Effect:init_stats(stats)
	for effect_type, amt in pairs(self.def) do
		local edef = EFFECT_DEFS[effect_type]		
		assert(edef.init_stats, effect_type)
		edef.init_stats(self, stats, amt)
	end
end

function Effect:apply_to(ent, src, power)	
	local any_aggressive = false
	local power = power or 1
	for effect_type, amt in pairs(self.def) do
		local edef = EFFECT_DEFS[effect_type]
		if ent.aspects[edef.aspect] then
			--ok to apply
			edef.apply(self, ent, amt*power, src)
			if edef.aggressive then
				any_aggressive = true
			end
		end	
	end
	if any_aggressive and src and ent.aggressive_action_by then
		ent:aggressive_action_by(src)
	end
end
