name: Thunderspeed
card_text: During the Main or Battle Phase: Immediately after this effect resolves, Normal Summon 1 Level 10 monster, or, if you control "Queen's Knight", "King's Knight", and "Jack's Knight", you can apply this effect instead.
  ● Add 1 Level 10 non-DARK monster with ? ATK from your Deck to your hand, then, immediately after this effect resolves, you can Normal Summon 1 Level 10 monster.
  You can only activate 1 "Thunderspeed Summon" per turn.
external_ids: local CARD_ID_0 = 64788463 --King's Knight
  local CARD_ID_1 = 90876561 --Jack's Knight
  local CARD_ID_2 = 25652259 --Queen's Knight
  
lua: local CARD_ID_0 = 64788463 --King's Knight
  local CARD_ID_1 = 90876561 --Jack's Knight
  local CARD_ID_2 = 25652259 --Queen's Knight
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_2, CARD_ID_0, CARD_ID_1)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SUMMON + CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMING_MAIN_END + TIMING_BATTLE_START)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	local ph = Duel.GetCurrentPhase()
  	return ph == PHASE_MAIN1 or ph == PHASE_MAIN2 or (ph >= PHASE_BATTLE_START and ph <= PHASE_BATTLE)
  end
  function s.checkfilter(c)
  	return c:IsFaceup() and c:IsCode(CARD_ID_0, CARD_ID_2, CARD_ID_1)
  end
  function s.sumfilter(c)
  	return c:IsSummonable(true, nil) and c:IsLevel(10)
  end
  function s.thfilter(c)
  	return c:GetTextAttack() == -2 and c:IsAbleToHand() and c:IsType(TYPE_MONSTER) and c:IsLevel(10) and c:IsNonAttribute(ATTRIBUTE_DARK)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	local g = Duel.GetMatchingGroup(s.checkfilter, tp, LOCATION_MZONE, 0, nil)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.sumfilter, tp, LOCATION_HAND + LOCATION_MZONE, 0, 1, nil)
  			or (g:GetClassCount(Card.GetCode) == 3 and Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil))
  	end
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.checkfilter, tp, LOCATION_MZONE, 0, nil)
  	local check1 = g:GetClassCount(Card.GetCode) == 3
  	local check2 = Duel.IsExistingMatchingCard(s.sumfilter, tp, LOCATION_HAND + LOCATION_MZONE, 0, 1, nil)
  	if check1 and Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil) and (not check2 or Duel.SelectYesNo(tp, aux.Stringid(id, 1))) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  		local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  		if Duel.IsExistingMatchingCard(s.sumfilter, tp, LOCATION_HAND + LOCATION_MZONE, 0, 1, nil) and Duel.SelectYesNo(tp, aux.Stringid(id, 2)) then
  			Duel.BreakEffect()
  			Duel.ShuffleHand(tp)
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SUMMON)
  			local sg = Duel.SelectMatchingCard(tp, s.sumfilter, tp, LOCATION_HAND + LOCATION_MZONE, 0, 1, 1, nil)
  			Duel.Summon(tp, sg:GetFirst(), true, nil)
  		end
  	elseif check2 then
  		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
  end
  
  
source_text: Thunderspeed
  During the Main or Battle Phase: Immediately after this effect resolves, Normal Summon 1 Level 10 monster, or, if you control "Queen's Knight", "King's Knight", and "Jack's Knight", you can apply this effect instead.
  ● Add 1 Level 10 non-DARK monster with ? ATK from your Deck to your hand, then, immediately after this effect resolves, you can Normal Summon 1 Level 10 monster.
  You can only activate 1 "Thunderspeed Summon" per turn.
target_text: -- Thunderspeed
  local CARD_ID_0 = 64788463 --King's Knight
  local CARD_ID_1 = 90876561 --Jack's Knight
  local CARD_ID_2 = 25652259 --Queen's Knight
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_2, CARD_ID_0, CARD_ID_1)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SUMMON + CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMING_MAIN_END + TIMING_BATTLE_START)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	local ph = Duel.GetCurrentPhase()
  	return ph == PHASE_MAIN1 or ph == PHASE_MAIN2 or (ph >= PHASE_BATTLE_START and ph <= PHASE_BATTLE)
  end
  function s.checkfilter(c)
  	return c:IsFaceup() and c:IsCode(CARD_ID_0, CARD_ID_2, CARD_ID_1)
  end
  function s.sumfilter(c)
  	return c:IsSummonable(true, nil) and c:IsLevel(10)
  end
  function s.thfilter(c)
  	return c:GetTextAttack() == -2 and c:IsAbleToHand() and c:IsType(TYPE_MONSTER) and c:IsLevel(10) and c:IsNonAttribute(ATTRIBUTE_DARK)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	local g = Duel.GetMatchingGroup(s.checkfilter, tp, LOCATION_MZONE, 0, nil)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.sumfilter, tp, LOCATION_HAND + LOCATION_MZONE, 0, 1, nil)
  			or (g:GetClassCount(Card.GetCode) == 3 and Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil))
  	end
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.checkfilter, tp, LOCATION_MZONE, 0, nil)
  	local check1 = g:GetClassCount(Card.GetCode) == 3
  	local check2 = Duel.IsExistingMatchingCard(s.sumfilter, tp, LOCATION_HAND + LOCATION_MZONE, 0, 1, nil)
  	if check1 and Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil) and (not check2 or Duel.SelectYesNo(tp, aux.Stringid(id, 1))) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  		local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  		if Duel.IsExistingMatchingCard(s.sumfilter, tp, LOCATION_HAND + LOCATION_MZONE, 0, 1, nil) and Duel.SelectYesNo(tp, aux.Stringid(id, 2)) then
  			Duel.BreakEffect()
  			Duel.ShuffleHand(tp)
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SUMMON)
  			local sg = Duel.SelectMatchingCard(tp, s.sumfilter, tp, LOCATION_HAND + LOCATION_MZONE, 0, 1, 1, nil)
  			Duel.Summon(tp, sg:GetFirst(), true, nil)
  		end
  	elseif check2 then
  		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
  end
  
  