name: Summon
card_text: The first time a monster(s) is Summoned to your opponent's side of the field each turn, inflict 800 damage to your opponent. During the Battle Phase of the turn this effect is activated, you can negate the attack of 1 monster your opponent controls. You can send 1 face-up "Trap Reactor ・Y FI", 1 face-up "Spell Reactor ・RE", and this face-up card you control to the Graveyard to Special Summon 1 "Flying Fortress SKY FIRE" from your hand, Deck, or Graveyard.
external_ids: local CARD_ID_0 = 52286175 --Trap Reactor ・Y FI
  local CARD_ID_1 = 15175429 --Spell Reactor ・RE
  local CARD_ID_2 = 16898077 --Flying Fortress SKY FIRE
  
lua: local CARD_ID_0 = 52286175 --Trap Reactor ・Y FI
  local CARD_ID_1 = 15175429 --Spell Reactor ・RE
  local CARD_ID_2 = 16898077 --Flying Fortress SKY FIRE
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--damage
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DAMAGE)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, EFFECT_COUNT_CODE_SINGLE)
  	e1:SetCondition(s.damcon)
  	e1:SetTarget(s.damtg)
  	e1:SetOperation(s.damop)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e2)
  	local e3 = e1:Clone()
  	e3:SetCode(EVENT_FLIP_SUMMON_SUCCESS)
  	c:RegisterEffect(e3)
  	--negate attack
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 1))
  	e4:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e4:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetCountLimit(1)
  	e4:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e4:SetCondition(s.nacon)
  	e4:SetTarget(s.natg)
  	e4:SetOperation(s.naop)
  	c:RegisterEffect(e4)
  	--spsummon
  	local e5 = Effect.CreateEffect(c)
  	e5:SetDescription(aux.Stringid(id, 2))
  	e5:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e5:SetType(EFFECT_TYPE_IGNITION)
  	e5:SetRange(LOCATION_MZONE)
  	e5:SetCost(s.spcost)
  	e5:SetTarget(s.sptg)
  	e5:SetOperation(s.spop)
  	c:RegisterEffect(e5)
  end
  s.spchecks = aux.CreateChecks(Card.IsCode, { CARD_ID_1, CARD_ID_0 })
  function s.damcon(e, tp, eg, ep, ev, re, r, rp)
  	return eg:IsExists(Card.IsControler, 1, nil, 1 - tp)
  end
  function s.damtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	e:GetHandler():RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END, 0, 1)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, 800)
  end
  function s.damop(e, tp, eg, ep, ev, re, r, rp)
  	if e:GetHandler():IsRelateToEffect(e) then
  		Duel.Damage(1 - tp, 800, REASON_EFFECT)
  	end
  end
  function s.nacon(e, tp, eg, ep, ev, re, r, rp)
  	return eg:GetFirst():IsControler(1 - tp) and e:GetHandler():GetFlagEffect(id) ~= 0
  end
  function s.natg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local tg = Duel.GetAttacker()
  	if chkc then
  		return chkc == tg
  	end
  	if chk == 0 then
  		return tg:IsOnField() and tg:IsCanBeEffectTarget(e)
  	end
  	Duel.SetTargetCard(tg)
  end
  function s.naop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetAttacker()
  	if tc:IsRelateToEffect(e) and tc:IsFaceup() then
  		Duel.NegateAttack()
  	end
  end
  function s.spcostfilter(c)
  	return c:IsAbleToGraveAsCost() and c:IsCode(CARD_ID_1, CARD_ID_0)
  end
  function s.fgoal(g, tp, c)
  	local sg = Group.FromCards(c)
  	sg:Merge(g)
  	return Duel.GetMZoneCount(tp, sg) > 0
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	local g = Duel.GetMatchingGroup(s.spcostfilter, tp, LOCATION_MZONE, 0, c)
  	if chk == 0 then
  		return c:IsAbleToGraveAsCost() and g:CheckSubGroupEach(s.spchecks, s.fgoal, tp, c)
  	end
  	local sg = g:SelectSubGroupEach(tp, s.spchecks, false, s.fgoal, tp, c)
  	sg:AddCard(c)
  	Duel.SendtoGrave(sg, REASON_COST)
  end
  function s.spfilter(c, e, tp)
  	return c:IsCode(CARD_ID_2) and c:IsCanBeSpecialSummoned(e, 0, tp, true, true)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.spfilter, tp, 0x13, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND + LOCATION_DECK + LOCATION_GRAVE)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.spfilter), tp, 0x13, 0, 1, 1, nil, e, tp)
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, true, true, POS_FACEUP)
  		g:GetFirst():CompleteProcedure()
  	end
  end
  
  
source_text: Summon
  The first time a monster(s) is Summoned to your opponent's side of the field each turn, inflict 800 damage to your opponent. During the Battle Phase of the turn this effect is activated, you can negate the attack of 1 monster your opponent controls. You can send 1 face-up "Trap Reactor ・Y FI", 1 face-up "Spell Reactor ・RE", and this face-up card you control to the Graveyard to Special Summon 1 "Flying Fortress SKY FIRE" from your hand, Deck, or Graveyard.
target_text: -- Summon
  local CARD_ID_0 = 52286175 --Trap Reactor ・Y FI
  local CARD_ID_1 = 15175429 --Spell Reactor ・RE
  local CARD_ID_2 = 16898077 --Flying Fortress SKY FIRE
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--damage
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DAMAGE)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, EFFECT_COUNT_CODE_SINGLE)
  	e1:SetCondition(s.damcon)
  	e1:SetTarget(s.damtg)
  	e1:SetOperation(s.damop)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e2)
  	local e3 = e1:Clone()
  	e3:SetCode(EVENT_FLIP_SUMMON_SUCCESS)
  	c:RegisterEffect(e3)
  	--negate attack
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 1))
  	e4:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e4:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetCountLimit(1)
  	e4:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e4:SetCondition(s.nacon)
  	e4:SetTarget(s.natg)
  	e4:SetOperation(s.naop)
  	c:RegisterEffect(e4)
  	--spsummon
  	local e5 = Effect.CreateEffect(c)
  	e5:SetDescription(aux.Stringid(id, 2))
  	e5:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e5:SetType(EFFECT_TYPE_IGNITION)
  	e5:SetRange(LOCATION_MZONE)
  	e5:SetCost(s.spcost)
  	e5:SetTarget(s.sptg)
  	e5:SetOperation(s.spop)
  	c:RegisterEffect(e5)
  end
  s.spchecks = aux.CreateChecks(Card.IsCode, { CARD_ID_1, CARD_ID_0 })
  function s.damcon(e, tp, eg, ep, ev, re, r, rp)
  	return eg:IsExists(Card.IsControler, 1, nil, 1 - tp)
  end
  function s.damtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	e:GetHandler():RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END, 0, 1)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, 800)
  end
  function s.damop(e, tp, eg, ep, ev, re, r, rp)
  	if e:GetHandler():IsRelateToEffect(e) then
  		Duel.Damage(1 - tp, 800, REASON_EFFECT)
  	end
  end
  function s.nacon(e, tp, eg, ep, ev, re, r, rp)
  	return eg:GetFirst():IsControler(1 - tp) and e:GetHandler():GetFlagEffect(id) ~= 0
  end
  function s.natg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local tg = Duel.GetAttacker()
  	if chkc then
  		return chkc == tg
  	end
  	if chk == 0 then
  		return tg:IsOnField() and tg:IsCanBeEffectTarget(e)
  	end
  	Duel.SetTargetCard(tg)
  end
  function s.naop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetAttacker()
  	if tc:IsRelateToEffect(e) and tc:IsFaceup() then
  		Duel.NegateAttack()
  	end
  end
  function s.spcostfilter(c)
  	return c:IsAbleToGraveAsCost() and c:IsCode(CARD_ID_1, CARD_ID_0)
  end
  function s.fgoal(g, tp, c)
  	local sg = Group.FromCards(c)
  	sg:Merge(g)
  	return Duel.GetMZoneCount(tp, sg) > 0
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	local g = Duel.GetMatchingGroup(s.spcostfilter, tp, LOCATION_MZONE, 0, c)
  	if chk == 0 then
  		return c:IsAbleToGraveAsCost() and g:CheckSubGroupEach(s.spchecks, s.fgoal, tp, c)
  	end
  	local sg = g:SelectSubGroupEach(tp, s.spchecks, false, s.fgoal, tp, c)
  	sg:AddCard(c)
  	Duel.SendtoGrave(sg, REASON_COST)
  end
  function s.spfilter(c, e, tp)
  	return c:IsCode(CARD_ID_2) and c:IsCanBeSpecialSummoned(e, 0, tp, true, true)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.spfilter, tp, 0x13, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND + LOCATION_DECK + LOCATION_GRAVE)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.spfilter), tp, 0x13, 0, 1, 1, nil, e, tp)
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, true, true, POS_FACEUP)
  		g:GetFirst():CompleteProcedure()
  	end
  end
  
  