name: Dragunity
card_text: If only your opponent controls a monster: You can Special Summon 1 "Dragunity" Tuner and 1 Winged Beast "Dragunity" monster from your Deck, but negate their effects, then if your opponent controls a monster that was Special Summoned from the Extra Deck, immediately after this effect resolves you can Synchro Summon 1 Dragon Synchro Monster using only "Dragunity" monsters you control. For the rest of this turn after this card resolves, you cannot Special Summon monsters from the Extra Deck, except Dragon monsters. You can only activate 1 "Dragunity Whirlwind" per turn.
external_ids: local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local SETCARD_ID_0 = 0x29 --Dragunity
  
lua: local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local SETCARD_ID_0 = 0x29 --Dragunity
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	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:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetFieldGroupCount(tp, LOCATION_MZONE, 0) == 0 and Duel.GetFieldGroupCount(tp, 0, LOCATION_MZONE) > 0
  end
  function s.filter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and (c:IsType(TYPE_TUNER) or c:IsRace(RACE_WINDBEAST)) 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 g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_DECK, 0, nil, e, tp)
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 1
  			and not Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0)
  			and g:CheckSubGroup(aux.gffcheck, 2, 2, Card.IsType, TYPE_TUNER, Card.IsRace, RACE_WINDBEAST)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 2, tp, LOCATION_DECK)
  end
  function s.cfilter(c)
  	return c:IsSummonLocation(LOCATION_EXTRA)
  end
  function s.scfilter(c, mg)
  	return c:IsRace(RACE_DRAGON) and c:IsSynchroSummonable(nil, mg)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if e:IsHasType(EFFECT_TYPE_ACTIVATE) then
  		local e3 = Effect.CreateEffect(c)
  		e3:SetType(EFFECT_TYPE_FIELD)
  		e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e3:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  		e3:SetTargetRange(1, 0)
  		e3:SetTarget(s.splimit)
  		e3:SetReset(RESET_PHASE + PHASE_END)
  		Duel.RegisterEffect(e3, tp)
  	end
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) < 2 or Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  		return
  	end
  	local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_DECK, 0, nil, e, tp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local sg = g:SelectSubGroup(tp, aux.gffcheck, false, 2, 2, Card.IsType, TYPE_TUNER, Card.IsRace, RACE_WINDBEAST)
  	if not sg then
  		return
  	end
  	local ca = sg:GetFirst()
  	local cb = sg:GetNext()
  	local success = false
  	if Duel.SpecialSummonStep(ca, 0, tp, tp, false, false, POS_FACEUP) and Duel.SpecialSummonStep(cb, 0, tp, tp, false, false, POS_FACEUP) then
  		success = true
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_DISABLE)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		ca:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_DISABLE_EFFECT)
  		e2:SetValue(RESET_TURN_SET)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  		ca:RegisterEffect(e2)
  		local e3 = e1:Clone()
  		cb:RegisterEffect(e3)
  		local e4 = e2:Clone()
  		cb:RegisterEffect(e4)
  	end
  	Duel.SpecialSummonComplete()
  	local mg = Duel.GetSynchroMaterial(tp):Filter(Card.IsSetCard, nil, 0x29)
  	if
  		success
  		and Duel.IsExistingMatchingCard(s.cfilter, tp, 0, LOCATION_MZONE, 1, nil)
  		and Duel.IsExistingMatchingCard(s.scfilter, tp, LOCATION_EXTRA, 0, 1, nil, mg)
  		and Duel.SelectYesNo(tp, aux.Stringid(id, 1))
  	then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local tc = Duel.SelectMatchingCard(tp, s.scfilter, tp, LOCATION_EXTRA, 0, 1, 1, nil, mg):GetFirst()
  		Duel.SynchroSummon(tp, tc, nil, mg)
  	end
  end
  function s.splimit(e, c)
  	return not c:IsRace(RACE_DRAGON) and c:IsLocation(LOCATION_EXTRA)
  end
  
  
source_text: Dragunity
  If only your opponent controls a monster: You can Special Summon 1 "Dragunity" Tuner and 1 Winged Beast "Dragunity" monster from your Deck, but negate their effects, then if your opponent controls a monster that was Special Summoned from the Extra Deck, immediately after this effect resolves you can Synchro Summon 1 Dragon Synchro Monster using only "Dragunity" monsters you control. For the rest of this turn after this card resolves, you cannot Special Summon monsters from the Extra Deck, except Dragon monsters. You can only activate 1 "Dragunity Whirlwind" per turn.
target_text: -- Dragunity
  local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local SETCARD_ID_0 = 0x29 --Dragunity
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	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:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetFieldGroupCount(tp, LOCATION_MZONE, 0) == 0 and Duel.GetFieldGroupCount(tp, 0, LOCATION_MZONE) > 0
  end
  function s.filter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and (c:IsType(TYPE_TUNER) or c:IsRace(RACE_WINDBEAST)) 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 g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_DECK, 0, nil, e, tp)
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 1
  			and not Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0)
  			and g:CheckSubGroup(aux.gffcheck, 2, 2, Card.IsType, TYPE_TUNER, Card.IsRace, RACE_WINDBEAST)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 2, tp, LOCATION_DECK)
  end
  function s.cfilter(c)
  	return c:IsSummonLocation(LOCATION_EXTRA)
  end
  function s.scfilter(c, mg)
  	return c:IsRace(RACE_DRAGON) and c:IsSynchroSummonable(nil, mg)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if e:IsHasType(EFFECT_TYPE_ACTIVATE) then
  		local e3 = Effect.CreateEffect(c)
  		e3:SetType(EFFECT_TYPE_FIELD)
  		e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e3:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  		e3:SetTargetRange(1, 0)
  		e3:SetTarget(s.splimit)
  		e3:SetReset(RESET_PHASE + PHASE_END)
  		Duel.RegisterEffect(e3, tp)
  	end
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) < 2 or Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  		return
  	end
  	local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_DECK, 0, nil, e, tp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local sg = g:SelectSubGroup(tp, aux.gffcheck, false, 2, 2, Card.IsType, TYPE_TUNER, Card.IsRace, RACE_WINDBEAST)
  	if not sg then
  		return
  	end
  	local ca = sg:GetFirst()
  	local cb = sg:GetNext()
  	local success = false
  	if Duel.SpecialSummonStep(ca, 0, tp, tp, false, false, POS_FACEUP) and Duel.SpecialSummonStep(cb, 0, tp, tp, false, false, POS_FACEUP) then
  		success = true
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_DISABLE)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		ca:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_DISABLE_EFFECT)
  		e2:SetValue(RESET_TURN_SET)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  		ca:RegisterEffect(e2)
  		local e3 = e1:Clone()
  		cb:RegisterEffect(e3)
  		local e4 = e2:Clone()
  		cb:RegisterEffect(e4)
  	end
  	Duel.SpecialSummonComplete()
  	local mg = Duel.GetSynchroMaterial(tp):Filter(Card.IsSetCard, nil, 0x29)
  	if
  		success
  		and Duel.IsExistingMatchingCard(s.cfilter, tp, 0, LOCATION_MZONE, 1, nil)
  		and Duel.IsExistingMatchingCard(s.scfilter, tp, LOCATION_EXTRA, 0, 1, nil, mg)
  		and Duel.SelectYesNo(tp, aux.Stringid(id, 1))
  	then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local tc = Duel.SelectMatchingCard(tp, s.scfilter, tp, LOCATION_EXTRA, 0, 1, 1, nil, mg):GetFirst()
  		Duel.SynchroSummon(tp, tc, nil, mg)
  	end
  end
  function s.splimit(e, c)
  	return not c:IsRace(RACE_DRAGON) and c:IsLocation(LOCATION_EXTRA)
  end
  
  