name: Horned
card_text: "Kaitoptera" + 1 Dinosaur or Dragon monster
  This card can attack directly the turn it is Special Summoned. You can only use each of the following effects of "Horned Saurus" once per turn. If this card is Fusion Summoned: You can place 1 Field Spell from your Deck or GY face-up in your Field Zone. During your Main Phase, you can: Immediately after this effect resolves, Normal Summon 1 Dinosaur or Dragon monster.
external_ids: local CARD_ID_1 = 50834074 --Kaitoptera
  
lua: local CARD_ID_1 = 50834074 --Kaitoptera
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--fusion material
  	c:EnableReviveLimit()
  	aux.AddFusionProcCodeFun(c, CARD_ID_1, s.matfilter, 1, true, true)
  	--move field
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.con)
  	e1:SetTarget(s.tg)
  	e1:SetOperation(s.op)
  	c:RegisterEffect(e1)
  	--direct_attack
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_DIRECT_ATTACK)
  	e2:SetCondition(s.pcon)
  	c:RegisterEffect(e2)
  	--summon
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_SUMMON)
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1, id + 1)
  	e3:SetTarget(s.sumtg)
  	e3:SetOperation(s.sumop)
  	c:RegisterEffect(e3)
  end
  function s.matfilter(c)
  	return c:IsRace(RACE_DRAGON + RACE_DINOSAUR)
  end
  function s.con(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_FUSION)
  end
  function s.pfilter(c, tp)
  	return not c:IsForbidden() and c:IsType(TYPE_FIELD) and c:CheckUniqueOnField(tp)
  end
  function s.tg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.pfilter, tp, LOCATION_DECK + LOCATION_GRAVE, 0, 1, nil, tp)
  	end
  end
  function s.op(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOFIELD)
  	local tc = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.pfilter), tp, LOCATION_DECK + LOCATION_GRAVE, 0, 1, 1, nil, tp):GetFirst()
  	if tc then
  		local fc = Duel.GetFieldCard(tp, LOCATION_FZONE, 0)
  		if fc then
  			Duel.SendtoGrave(fc, REASON_RULE)
  			Duel.BreakEffect()
  		end
  		Duel.MoveToField(tc, tp, tp, LOCATION_FZONE, POS_FACEUP, true)
  	end
  end
  function s.pcon(e, tp, eg, ep, ev, re, r, rp)
  	local ec = e:GetHandler()
  	return ec:IsStatus(STATUS_SPSUMMON_TURN)
  end
  function s.sumfilter(c)
  	return c:IsRace(RACE_DRAGON + RACE_DINOSAUR) and c:IsSummonable(true, nil)
  end
  function s.sumtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.sumfilter, tp, LOCATION_HAND + LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SUMMON, nil, 1, 0, 0)
  end
  function s.sumop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.sumfilter, tp, LOCATION_HAND + LOCATION_MZONE, 0, 1, 1, nil)
  	local tc = g:GetFirst()
  	if tc then
  		Duel.Summon(tp, tc, true, nil)
  	end
  end
  
  
source_text: Horned
  "Kaitoptera" + 1 Dinosaur or Dragon monster
  This card can attack directly the turn it is Special Summoned. You can only use each of the following effects of "Horned Saurus" once per turn. If this card is Fusion Summoned: You can place 1 Field Spell from your Deck or GY face-up in your Field Zone. During your Main Phase, you can: Immediately after this effect resolves, Normal Summon 1 Dinosaur or Dragon monster.
target_text: -- Horned
  local CARD_ID_1 = 50834074 --Kaitoptera
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--fusion material
  	c:EnableReviveLimit()
  	aux.AddFusionProcCodeFun(c, CARD_ID_1, s.matfilter, 1, true, true)
  	--move field
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.con)
  	e1:SetTarget(s.tg)
  	e1:SetOperation(s.op)
  	c:RegisterEffect(e1)
  	--direct_attack
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_DIRECT_ATTACK)
  	e2:SetCondition(s.pcon)
  	c:RegisterEffect(e2)
  	--summon
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_SUMMON)
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1, id + 1)
  	e3:SetTarget(s.sumtg)
  	e3:SetOperation(s.sumop)
  	c:RegisterEffect(e3)
  end
  function s.matfilter(c)
  	return c:IsRace(RACE_DRAGON + RACE_DINOSAUR)
  end
  function s.con(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_FUSION)
  end
  function s.pfilter(c, tp)
  	return not c:IsForbidden() and c:IsType(TYPE_FIELD) and c:CheckUniqueOnField(tp)
  end
  function s.tg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.pfilter, tp, LOCATION_DECK + LOCATION_GRAVE, 0, 1, nil, tp)
  	end
  end
  function s.op(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOFIELD)
  	local tc = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.pfilter), tp, LOCATION_DECK + LOCATION_GRAVE, 0, 1, 1, nil, tp):GetFirst()
  	if tc then
  		local fc = Duel.GetFieldCard(tp, LOCATION_FZONE, 0)
  		if fc then
  			Duel.SendtoGrave(fc, REASON_RULE)
  			Duel.BreakEffect()
  		end
  		Duel.MoveToField(tc, tp, tp, LOCATION_FZONE, POS_FACEUP, true)
  	end
  end
  function s.pcon(e, tp, eg, ep, ev, re, r, rp)
  	local ec = e:GetHandler()
  	return ec:IsStatus(STATUS_SPSUMMON_TURN)
  end
  function s.sumfilter(c)
  	return c:IsRace(RACE_DRAGON + RACE_DINOSAUR) and c:IsSummonable(true, nil)
  end
  function s.sumtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.sumfilter, tp, LOCATION_HAND + LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SUMMON, nil, 1, 0, 0)
  end
  function s.sumop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.sumfilter, tp, LOCATION_HAND + LOCATION_MZONE, 0, 1, 1, nil)
  	local tc = g:GetFirst()
  	if tc then
  		Duel.Summon(tp, tc, true, nil)
  	end
  end
  
  