--魔力の棘
function c76291135.initial_effect(c)
	--Activate
	local e1=Effect.CreateEffect(c)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_FREE_CHAIN)
	c:RegisterEffect(e1)
	--damage
	local e2=Effect.CreateEffect(c)
	e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
	e2:SetProperty(EFFECT_FLAG_DELAY)
	e2:SetRange(LOCATION_SZONE)
	e2:SetCode(EVENT_TO_GRAVE)
	e2:SetOperation(c76291135.damop)
	c:RegisterEffect(e2)
end
function c76291135.filter(c,tp)
	return c:GetControler()~=tp and c:IsPreviousControler(1-tp) and not c:IsPreviousLocation(LOCATION_ONFIELD)
		and c:IsReason(REASON_EFFECT) and not c:IsReason(REASON_DESTROY) and not c:IsReason(REASON_BATTLE)
end
function c76291135.damop(e,tp,eg,ep,ev,re,r,rp)
	local ct=eg:FilterCount(c76291135.filter,nil,tp)
	Duel.Damage(1-tp,ct*500,REASON_EFFECT)
end
