--SP-翻车
function c87593002.initial_effect(c)
	--Activate
	local e1=Effect.CreateEffect(c)
	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_FREE_CHAIN)
	e1:SetCondition(c87593002.condition)
	e1:SetOperation(c87593002.activate)
	c:RegisterEffect(e1)
end
function c87593002.cfilter(c,e,tp,cou)
	return c:IsFaceup() and c:GetLevel()>=cou and cou>0
end
function c87593002.condition(e,tp,eg,ep,ev,re,r,rp)
	local f=Duel.GetMatchingGroup(Card.IsCode,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,nil,87593200):GetFirst()
	if f:GetControler()==tp then cou=0x872 else cou=0x871 end
	return Duel.GetCurrentPhase()==PHASE_MAIN2
		and Duel.IsExistingMatchingCard(c87593002.cfilter,tp,0,LOCATION_MZONE,1,nil,e,tp,f:GetCounter(cou))
end
function c87593002.activate(e,tp,eg,ep,ev,re,r,rp)
	local f=Duel.GetMatchingGroup(Card.IsCode,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,nil,87593200):GetFirst()
	if f:GetControler()==tp then cou=0x872 else cou=0x871 end
	if f:RemoveCounter(tp,cou,f:GetCounter(cou),0) then
	local e1=Effect.CreateEffect(e:GetHandler())
	e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
	e1:SetCode(EVENT_DAMAGE)
	e1:SetLabel(cou)
	e1:SetLabelObject(f)
	e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END+RESET_OPPO_TURN,3)
	e1:SetOperation(c87593002.spop)
	Duel.RegisterEffect(e1,tp)
	end
end
function c87593002.spop(e,tp,eg,ep,ev,re,r,rp)
	if ep==tp then
	e:GetLabelObject():AddCounter(e:GetLabel(),1)
	end
end
