name: You're
card_text: Reveal 3 "Danger!" monsters with different names from your Deck, your opponent randomly picks 1 for you to Special Summon, and you shuffle the rest into the Deck. During the End Phase, destroy that Special Summoned monster. You can only activate 1 "You're in Danger!" per turn.
external_ids: local SETCARD_ID_0 = 0x11e --Danger!
  
lua: local SETCARD_ID_0 = 0x11e --Danger!
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMING_END_PHASE)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		local dg = Duel.GetMatchingGroup(s.spfilter, tp, LOCATION_DECK, 0, nil, e, tp)
  		return dg:GetClassCount(Card.GetCode) >= 3 and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_DECK)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.spfilter, tp, LOCATION_DECK, 0, nil, e, tp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 or g:GetClassCount(Card.GetCode) < 3 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONFIRM)
  	local sg = g:SelectSubGroup(tp, aux.dncheck, false, 3, 3)
  	if sg then
  		Duel.ConfirmCards(1 - tp, sg)
  		local tc = sg:RandomSelect(1 - tp, 1):GetFirst()
  		Duel.ConfirmCards(tp, tc)
  		if Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP) > 0 then
  			local fid = tc:GetFieldID()
  			tc:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD, 0, 1, fid)
  			local e1 = Effect.CreateEffect(e:GetHandler())
  			e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  			e1:SetCode(EVENT_PHASE + PHASE_END)
  			e1:SetCountLimit(1)
  			e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  			e1:SetLabel(fid)
  			e1:SetLabelObject(tc)
  			e1:SetCondition(s.descon)
  			e1:SetOperation(s.desop)
  			Duel.RegisterEffect(e1, tp)
  		end
  		Duel.ShuffleDeck(tp)
  	end
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	local tc = e:GetLabelObject()
  	if tc:GetFlagEffectLabel(id) ~= e:GetLabel() then
  		e:Reset()
  		return false
  	else
  		return true
  	end
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = e:GetLabelObject()
  	Duel.Destroy(tc, REASON_EFFECT)
  end
  
  
source_text: You're
  Reveal 3 "Danger!" monsters with different names from your Deck, your opponent randomly picks 1 for you to Special Summon, and you shuffle the rest into the Deck. During the End Phase, destroy that Special Summoned monster. You can only activate 1 "You're in Danger!" per turn.
target_text: -- You're
  local SETCARD_ID_0 = 0x11e --Danger!
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMING_END_PHASE)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		local dg = Duel.GetMatchingGroup(s.spfilter, tp, LOCATION_DECK, 0, nil, e, tp)
  		return dg:GetClassCount(Card.GetCode) >= 3 and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_DECK)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.spfilter, tp, LOCATION_DECK, 0, nil, e, tp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 or g:GetClassCount(Card.GetCode) < 3 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONFIRM)
  	local sg = g:SelectSubGroup(tp, aux.dncheck, false, 3, 3)
  	if sg then
  		Duel.ConfirmCards(1 - tp, sg)
  		local tc = sg:RandomSelect(1 - tp, 1):GetFirst()
  		Duel.ConfirmCards(tp, tc)
  		if Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP) > 0 then
  			local fid = tc:GetFieldID()
  			tc:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD, 0, 1, fid)
  			local e1 = Effect.CreateEffect(e:GetHandler())
  			e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  			e1:SetCode(EVENT_PHASE + PHASE_END)
  			e1:SetCountLimit(1)
  			e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  			e1:SetLabel(fid)
  			e1:SetLabelObject(tc)
  			e1:SetCondition(s.descon)
  			e1:SetOperation(s.desop)
  			Duel.RegisterEffect(e1, tp)
  		end
  		Duel.ShuffleDeck(tp)
  	end
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	local tc = e:GetLabelObject()
  	if tc:GetFlagEffectLabel(id) ~= e:GetLabel() then
  		e:Reset()
  		return false
  	else
  		return true
  	end
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = e:GetLabelObject()
  	Duel.Destroy(tc, REASON_EFFECT)
  end
  
  