name: Miracle
card_text: Shuffle into the Deck, from your hand, field, or GY, the Fusion Materials that are mentioned on an "Elemental HERO" Fusion Monster that mentions "Elemental HERO Neos" as material, then Special Summon that Fusion Monster from your Extra Deck, ignoring its Summoning conditions.
external_ids: local CARD_ID_0 = 89943723 --Elemental HERO Neos
  local SETCARD_ID_0 = 0x3008 --Elemental
  
lua: local CARD_ID_0 = 89943723 --Elemental HERO Neos
  local SETCARD_ID_0 = 0x3008 --Elemental
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	aux.AddSetNameMonsterList(c, SETCARD_ID_0)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.filter1(c, e)
  	return c:IsAbleToDeck() and not c:IsImmuneToEffect(e)
  end
  function s.filter2(c, e, tp, m, chkf)
  	return c:IsSetCard(SETCARD_ID_0)
  		and c:IsType(TYPE_FUSION)
  		and aux.IsMaterialListCode(c, CARD_ID_0)
  		and c:IsCanBeSpecialSummoned(e, 0, tp, true, false)
  		and c:CheckFusionMaterial(m, nil, chkf, true)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		local chkf = tp | 0x200
  		local mg = Duel.GetMatchingGroup(s.filter1, tp, LOCATION_HAND + LOCATION_GRAVE + LOCATION_MZONE, 0, nil, e)
  		return Duel.IsExistingMatchingCard(s.filter2, tp, LOCATION_EXTRA, 0, 1, nil, e, tp, mg, chkf)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_EXTRA)
  end
  function s.cffilter(c)
  	return c:IsLocation(LOCATION_HAND) or (c:IsLocation(LOCATION_MZONE) and c:IsFacedown())
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local chkf = tp | 0x200
  	local mg = Duel.GetMatchingGroup(aux.NecroValleyFilter(s.filter1), tp, LOCATION_HAND + LOCATION_GRAVE + LOCATION_MZONE, 0, nil, e)
  	local sg = Duel.GetMatchingGroup(s.filter2, tp, LOCATION_EXTRA, 0, nil, e, tp, mg, chkf)
  	if sg:GetCount() > 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local tg = sg:Select(tp, 1, 1, nil)
  		local tc = tg:GetFirst()
  		local mat = Duel.SelectFusionMaterial(tp, tc, mg, nil, chkf, true)
  		local cf = mat:Filter(s.cffilter, nil)
  		if cf:GetCount() > 0 then
  			Duel.ConfirmCards(1 - tp, cf)
  		end
  		Duel.SendtoDeck(mat, nil, SEQ_DECKSHUFFLE, REASON_EFFECT)
  		Duel.SpecialSummon(tc, 0, tp, tp, true, false, POS_FACEUP)
  	end
  end
  
  
source_text: Miracle
  Shuffle into the Deck, from your hand, field, or GY, the Fusion Materials that are mentioned on an "Elemental HERO" Fusion Monster that mentions "Elemental HERO Neos" as material, then Special Summon that Fusion Monster from your Extra Deck, ignoring its Summoning conditions.
target_text: -- Miracle
  local CARD_ID_0 = 89943723 --Elemental HERO Neos
  local SETCARD_ID_0 = 0x3008 --Elemental
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	aux.AddSetNameMonsterList(c, SETCARD_ID_0)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.filter1(c, e)
  	return c:IsAbleToDeck() and not c:IsImmuneToEffect(e)
  end
  function s.filter2(c, e, tp, m, chkf)
  	return c:IsSetCard(SETCARD_ID_0)
  		and c:IsType(TYPE_FUSION)
  		and aux.IsMaterialListCode(c, CARD_ID_0)
  		and c:IsCanBeSpecialSummoned(e, 0, tp, true, false)
  		and c:CheckFusionMaterial(m, nil, chkf, true)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		local chkf = tp | 0x200
  		local mg = Duel.GetMatchingGroup(s.filter1, tp, LOCATION_HAND + LOCATION_GRAVE + LOCATION_MZONE, 0, nil, e)
  		return Duel.IsExistingMatchingCard(s.filter2, tp, LOCATION_EXTRA, 0, 1, nil, e, tp, mg, chkf)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_EXTRA)
  end
  function s.cffilter(c)
  	return c:IsLocation(LOCATION_HAND) or (c:IsLocation(LOCATION_MZONE) and c:IsFacedown())
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local chkf = tp | 0x200
  	local mg = Duel.GetMatchingGroup(aux.NecroValleyFilter(s.filter1), tp, LOCATION_HAND + LOCATION_GRAVE + LOCATION_MZONE, 0, nil, e)
  	local sg = Duel.GetMatchingGroup(s.filter2, tp, LOCATION_EXTRA, 0, nil, e, tp, mg, chkf)
  	if sg:GetCount() > 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local tg = sg:Select(tp, 1, 1, nil)
  		local tc = tg:GetFirst()
  		local mat = Duel.SelectFusionMaterial(tp, tc, mg, nil, chkf, true)
  		local cf = mat:Filter(s.cffilter, nil)
  		if cf:GetCount() > 0 then
  			Duel.ConfirmCards(1 - tp, cf)
  		end
  		Duel.SendtoDeck(mat, nil, SEQ_DECKSHUFFLE, REASON_EFFECT)
  		Duel.SpecialSummon(tc, 0, tp, tp, true, false, POS_FACEUP)
  	end
  end
  
  