--高速决斗技能-与恐龙一心同体
Duel.LoadScript("speed_duel_common.lua")
function c100730223.initial_effect(c)
	aux.SpeedDuelAtMainPhase(c,c100730223.skill,c100730223.con,aux.Stringid(100730223,1))
	aux.RegisterSpeedDuelSkillCardCommon()
end
function c100730223.con(e,tp)
	tp=e:GetLabelObject():GetOwner()
	return aux.SpeedDuelAtMainPhaseCondition(e,tp)
		and Duel.IsExistingMatchingCard(c100730223.filter,tp,LOCATION_HAND,0,1,nil,e,tp)
		and Duel.IsPlayerCanSpecialSummon(tp)
		and Duel.GetMZoneCount(tp)>0
		and Duel.GetTurnCount()>=3
end
function c100730223.filter(c,e,tp)
	return c:IsCanBeSpecialSummoned(e,0,tp,false,false) and c:IsLevelAbove(7) and c:IsRace(RACE_DINOSAUR)
end
function c100730223.skill(e,tp,eg,ep,ev,re,r,rp)
	tp=e:GetLabelObject():GetOwner()
	local c=e:GetHandler()
	Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
	local g=Duel.SelectMatchingCard(tp,c100730223.filter,tp,LOCATION_HAND,0,1,1,nil,e,tp)
	local tc=g:GetFirst()
	if tc then
		Duel.SpecialSummonStep(tc,0,tp,tp,false,false,POS_FACEUP)
		local e1=Effect.CreateEffect(c)
		e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
		e1:SetCode(EVENT_LEAVE_FIELD)
		e1:SetLabel(1-tp)
		e1:SetOperation(c100730223.leaveop)
		e1:SetReset(RESET_EVENT+0xc020000)
		tc:RegisterEffect(e1,true)
		local e2=Effect.CreateEffect(c)
		e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
		e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
		e2:SetCode(EVENT_SPSUMMON_SUCCESS)
		e2:SetCondition(c100730223.lvcon)
		e2:SetOperation(c100730223.lvop)
		tc:RegisterEffect(e2)
		Duel.SpecialSummonComplete()
	end
	e:Reset()
end
function c100730223.lvcon(e,tp,eg,ep,ev,re,r,rp)
	return re and re:GetHandler()
end
function c100730223.lvop(e,tp,eg,ep,ev,re,r,rp)
	local c=e:GetHandler()
	local e1=Effect.CreateEffect(c)
	e1:SetType(EFFECT_TYPE_SINGLE)
	e1:SetCode(EFFECT_CHANGE_LEVEL)
	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
	e1:SetRange(LOCATION_MZONE)
	e1:SetValue(12)
	e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_DISABLE)
	c:RegisterEffect(e1)
	local e2=e1:Clone()
	e2:SetCode(EFFECT_SET_BASE_ATTACK)
	e2:SetValue(Duel.GetLP(tp))
	c:RegisterEffect(e2)
	local e3=e2:Clone()
	e3:SetCode(EFFECT_SET_BASE_DEFENSE)
	e3:SetValue(Duel.GetLP(tp))
	c:RegisterEffect(e3)
end
function c100730223.leaveop(e,tp,eg,ep,ev,re,r,rp)
	Duel.Hint(HINT_CARD,0,100730223)
	Duel.Win(1-tp,WIN_REASON_LAST_TURN)
end