--[决斗编年史]胜利的方程式
function c66666002.initial_effect(c)
	local e1=Effect.CreateEffect(c)
	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_FREE_CHAIN)
	e1:SetCost(c66666002.cost)
	e1:SetTarget(c66666002.target)
	e1:SetOperation(c66666002.activate)
	c:RegisterEffect(e1)
end

function c66666002.filter1(c,e,tp)
	return c:IsSetCard(0x48) and (not c:IsSetCard(0x1048)) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end

function c66666002.cost(e,tp,eg,ep,ev,re,r,rp,chk)
	if chk==0 then return true end
	Duel.Hint(HINT_MESSAGE,tp,aux.Stringid(66666002,0))
	Duel.Hint(HINT_MESSAGE,1-tp,aux.Stringid(66666002,0))
end
function c66666002.target(e,tp,eg,ep,ev,re,r,rp,chk)
	if chk==0 then return Duel.GetLocationCountFromEx(tp,tp,nil,TYPE_XYZ)>0
		and Duel.IsExistingMatchingCard(c66666002.filter1,tp,LOCATION_EXTRA,0,1,nil,e,tp)
		and Duel.IsExistingMatchingCard(nil,tp,0,LOCATION_MZONE,1,nil)
		and (not Duel.IsExistingMatchingCard(nil,tp,LOCATION_MZONE,0,1,nil)) end
	Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
end

function c66666002.activate(e,tp,eg,ep,ev,re,r,rp)
	local c = e:GetHandler()
	if Duel.GetLocationCountFromEx(tp,tp,nil,TYPE_XYZ) < 1 then return end
	Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
	local tc=Duel.SelectMatchingCard(tp,c66666002.filter1,tp,LOCATION_EXTRA,0,1,1,nil,e,tp):GetFirst()
	if tc and Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)~=0 then
		Duel.BreakEffect()
		c:CancelToGrave()
		Duel.Overlay(tc,c)
	end
	Duel.RegisterFlagEffect(tp,66666002,0,0,999)
end











