name: Shining
card_text: Target 3 monsters in your Graveyard; Special Summon all 3, but their effects are negated. Immediately after this effect resolves, Xyz Summon 1 "Utopia" or "Utopic" Xyz Monster using only those 3 monsters. You cannot Special Summon other monsters during the turn you activate this card.
external_ids: local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local SETCARD_ID_0 = 0x7f --Utopic
  
lua: local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local SETCARD_ID_0 = 0x7f --Utopic
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetActivityCount(tp, ACTIVITY_SPSUMMON) == 0
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_OATH)
  	e1:SetTargetRange(1, 0)
  	e1:SetTarget(s.splimit)
  	e1:SetLabelObject(e)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.splimit(e, c, sump, sumtype, sumpos, targetp, se)
  	return se ~= e:GetLabelObject() and c:GetFlagEffect(id) == 0
  end
  function s.filter(c, e, tp)
  	return c:IsCanBeEffectTarget(e) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.xyzfilter(c, mg)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsXyzSummonable(mg, 3, 3)
  end
  function s.mfilter1(c, mg, exg)
  	return mg:IsExists(s.mfilter2, 1, c, c, mg, exg)
  end
  function s.mfilter2(c, mc, mg, exg)
  	return mg:IsExists(s.mfilter3, 1, c, c, mc, exg)
  end
  function s.mfilter3(c, mc1, mc2, exg)
  	return c ~= mc2 and exg:IsExists(Card.IsXyzSummonable, 1, nil, Group.FromCards(c, mc1, mc2), 3, 3)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return false
  	end
  	local mg = Duel.GetMatchingGroup(s.filter, tp, LOCATION_GRAVE, 0, nil, e, tp)
  	local exg = Duel.GetMatchingGroup(s.xyzfilter, tp, LOCATION_EXTRA, 0, nil, mg)
  	if chk == 0 then
  		return Duel.IsPlayerCanSpecialSummonCount(tp, 2)
  			and not Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0)
  			and Duel.GetLocationCount(tp, LOCATION_MZONE) > 2
  			and mg:IsExists(s.mfilter1, 1, nil, mg, exg)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local sg1 = mg:FilterSelect(tp, s.mfilter1, 1, 1, nil, mg, exg)
  	local tc1 = sg1:GetFirst()
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local sg2 = mg:FilterSelect(tp, s.mfilter2, 1, 1, tc1, tc1, mg, exg)
  	local tc2 = sg2:GetFirst()
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local sg3 = mg:FilterSelect(tp, s.mfilter3, 1, 1, tc2, tc2, tc1, exg)
  	sg1:Merge(sg2)
  	sg1:Merge(sg3)
  	Duel.SetTargetCard(sg1)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, sg1, 3, 0, 0)
  end
  function s.filter2(c, e, tp)
  	return c:IsRelateToEffect(e) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  		return
  	end
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) < 3 then
  		return
  	end
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS):Filter(s.filter2, nil, e, tp)
  	if g:GetCount() < 3 then
  		return
  	end
  	local tc = g:GetFirst()
  	while tc do
  		Duel.SpecialSummonStep(tc, 0, tp, tp, false, false, POS_FACEUP)
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_DISABLE)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		tc:RegisterEffect(e1)
  		local e2 = e1:Clone()
  		e2:SetCode(EFFECT_DISABLE_EFFECT)
  		e2:SetValue(RESET_TURN_SET)
  		tc:RegisterEffect(e2)
  		tc = g:GetNext()
  	end
  	Duel.SpecialSummonComplete()
  	Duel.AdjustAll()
  	if g:FilterCount(Card.IsLocation, nil, LOCATION_MZONE) < 3 then
  		return
  	end
  	local xyzg = Duel.GetMatchingGroup(s.xyzfilter, tp, LOCATION_EXTRA, 0, nil, g)
  	if xyzg:GetCount() > 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local xyz = xyzg:Select(tp, 1, 1, nil):GetFirst()
  		xyz:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD, 0, 1)
  		Duel.XyzSummon(tp, xyz, g)
  	end
  end
  
  
source_text: Shining
  Target 3 monsters in your Graveyard; Special Summon all 3, but their effects are negated. Immediately after this effect resolves, Xyz Summon 1 "Utopia" or "Utopic" Xyz Monster using only those 3 monsters. You cannot Special Summon other monsters during the turn you activate this card.
target_text: -- Shining
  local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local SETCARD_ID_0 = 0x7f --Utopic
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetActivityCount(tp, ACTIVITY_SPSUMMON) == 0
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_OATH)
  	e1:SetTargetRange(1, 0)
  	e1:SetTarget(s.splimit)
  	e1:SetLabelObject(e)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.splimit(e, c, sump, sumtype, sumpos, targetp, se)
  	return se ~= e:GetLabelObject() and c:GetFlagEffect(id) == 0
  end
  function s.filter(c, e, tp)
  	return c:IsCanBeEffectTarget(e) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.xyzfilter(c, mg)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsXyzSummonable(mg, 3, 3)
  end
  function s.mfilter1(c, mg, exg)
  	return mg:IsExists(s.mfilter2, 1, c, c, mg, exg)
  end
  function s.mfilter2(c, mc, mg, exg)
  	return mg:IsExists(s.mfilter3, 1, c, c, mc, exg)
  end
  function s.mfilter3(c, mc1, mc2, exg)
  	return c ~= mc2 and exg:IsExists(Card.IsXyzSummonable, 1, nil, Group.FromCards(c, mc1, mc2), 3, 3)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return false
  	end
  	local mg = Duel.GetMatchingGroup(s.filter, tp, LOCATION_GRAVE, 0, nil, e, tp)
  	local exg = Duel.GetMatchingGroup(s.xyzfilter, tp, LOCATION_EXTRA, 0, nil, mg)
  	if chk == 0 then
  		return Duel.IsPlayerCanSpecialSummonCount(tp, 2)
  			and not Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0)
  			and Duel.GetLocationCount(tp, LOCATION_MZONE) > 2
  			and mg:IsExists(s.mfilter1, 1, nil, mg, exg)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local sg1 = mg:FilterSelect(tp, s.mfilter1, 1, 1, nil, mg, exg)
  	local tc1 = sg1:GetFirst()
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local sg2 = mg:FilterSelect(tp, s.mfilter2, 1, 1, tc1, tc1, mg, exg)
  	local tc2 = sg2:GetFirst()
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local sg3 = mg:FilterSelect(tp, s.mfilter3, 1, 1, tc2, tc2, tc1, exg)
  	sg1:Merge(sg2)
  	sg1:Merge(sg3)
  	Duel.SetTargetCard(sg1)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, sg1, 3, 0, 0)
  end
  function s.filter2(c, e, tp)
  	return c:IsRelateToEffect(e) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  		return
  	end
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) < 3 then
  		return
  	end
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS):Filter(s.filter2, nil, e, tp)
  	if g:GetCount() < 3 then
  		return
  	end
  	local tc = g:GetFirst()
  	while tc do
  		Duel.SpecialSummonStep(tc, 0, tp, tp, false, false, POS_FACEUP)
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_DISABLE)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		tc:RegisterEffect(e1)
  		local e2 = e1:Clone()
  		e2:SetCode(EFFECT_DISABLE_EFFECT)
  		e2:SetValue(RESET_TURN_SET)
  		tc:RegisterEffect(e2)
  		tc = g:GetNext()
  	end
  	Duel.SpecialSummonComplete()
  	Duel.AdjustAll()
  	if g:FilterCount(Card.IsLocation, nil, LOCATION_MZONE) < 3 then
  		return
  	end
  	local xyzg = Duel.GetMatchingGroup(s.xyzfilter, tp, LOCATION_EXTRA, 0, nil, g)
  	if xyzg:GetCount() > 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local xyz = xyzg:Select(tp, 1, 1, nil):GetFirst()
  		xyz:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD, 0, 1)
  		Duel.XyzSummon(tp, xyz, g)
  	end
  end
  
  