name: Thunder
card_text: Target 1 Thunder monster in your GY; Special Summon it, then you can Special Summon as many monsters with that same name as possible from your GY. The monster(s) Special Summoned by this effect are banished when they leave the field, also while they are face-up on the field, you cannot Special Summon monsters, except Thunder monsters. You can only activate 1 "Thunder Dragons' Hundred Thunders" per turn.
external_ids: local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  
lua: local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  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:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetHintTiming(0, TIMING_END_PHASE)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.filter(c, e, tp)
  	return c:IsRace(RACE_THUNDER) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.filter(chkc, e, tp)
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingTarget(s.filter, tp, LOCATION_GRAVE, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 1, 0, 0)
  end
  function s.gfilter(c, e, tp, code)
  	return c:IsCode(code) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	if ft <= 0 then
  		return
  	end
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and Duel.SpecialSummonStep(tc, 0, tp, tp, false, false, POS_FACEUP) then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_LEAVE_FIELD_REDIRECT)
  		e1:SetReset(RESET_EVENT + RESETS_REDIRECT)
  		e1:SetValue(LOCATION_REMOVED)
  		tc:RegisterEffect(e1, true)
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_FIELD)
  		e2:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  		e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e2:SetRange(LOCATION_MZONE)
  		e2:SetAbsoluteRange(tp, 1, 0)
  		e2:SetTarget(s.splimit)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  		tc:RegisterEffect(e2)
  		Duel.SpecialSummonComplete()
  		ft = ft - 1
  		local g = Duel.GetMatchingGroup(s.gfilter, tp, LOCATION_GRAVE, 0, nil, e, tp, tc:GetCode())
  		if g:GetCount() > 0 and ft > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 0)) then
  			Duel.BreakEffect()
  			ft = math.min(ft, g:GetCount())
  			if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  				ft = 1
  			end
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  			local sg = g:Select(tp, ft, ft, nil)
  			for tc2 in aux.Next(sg) do
  				Duel.SpecialSummonStep(tc2, 0, tp, tp, false, false, POS_FACEUP)
  				local e3 = Effect.CreateEffect(c)
  				e3:SetType(EFFECT_TYPE_SINGLE)
  				e3:SetCode(EFFECT_LEAVE_FIELD_REDIRECT)
  				e3:SetReset(RESET_EVENT + RESETS_REDIRECT)
  				e3:SetValue(LOCATION_REMOVED)
  				tc2:RegisterEffect(e3, true)
  				local e4 = Effect.CreateEffect(c)
  				e4:SetType(EFFECT_TYPE_FIELD)
  				e4:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  				e4:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  				e4:SetRange(LOCATION_MZONE)
  				e4:SetAbsoluteRange(tp, 1, 0)
  				e4:SetTarget(s.splimit)
  				e4:SetReset(RESET_EVENT + RESETS_STANDARD)
  				tc2:RegisterEffect(e4)
  			end
  			Duel.SpecialSummonComplete()
  		end
  	end
  end
  function s.splimit(e, c)
  	return not c:IsRace(RACE_THUNDER)
  end
  
  
source_text: Thunder
  Target 1 Thunder monster in your GY; Special Summon it, then you can Special Summon as many monsters with that same name as possible from your GY. The monster(s) Special Summoned by this effect are banished when they leave the field, also while they are face-up on the field, you cannot Special Summon monsters, except Thunder monsters. You can only activate 1 "Thunder Dragons' Hundred Thunders" per turn.
target_text: -- Thunder
  local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  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:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetHintTiming(0, TIMING_END_PHASE)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.filter(c, e, tp)
  	return c:IsRace(RACE_THUNDER) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.filter(chkc, e, tp)
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingTarget(s.filter, tp, LOCATION_GRAVE, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 1, 0, 0)
  end
  function s.gfilter(c, e, tp, code)
  	return c:IsCode(code) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	if ft <= 0 then
  		return
  	end
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and Duel.SpecialSummonStep(tc, 0, tp, tp, false, false, POS_FACEUP) then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_LEAVE_FIELD_REDIRECT)
  		e1:SetReset(RESET_EVENT + RESETS_REDIRECT)
  		e1:SetValue(LOCATION_REMOVED)
  		tc:RegisterEffect(e1, true)
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_FIELD)
  		e2:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  		e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e2:SetRange(LOCATION_MZONE)
  		e2:SetAbsoluteRange(tp, 1, 0)
  		e2:SetTarget(s.splimit)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  		tc:RegisterEffect(e2)
  		Duel.SpecialSummonComplete()
  		ft = ft - 1
  		local g = Duel.GetMatchingGroup(s.gfilter, tp, LOCATION_GRAVE, 0, nil, e, tp, tc:GetCode())
  		if g:GetCount() > 0 and ft > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 0)) then
  			Duel.BreakEffect()
  			ft = math.min(ft, g:GetCount())
  			if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  				ft = 1
  			end
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  			local sg = g:Select(tp, ft, ft, nil)
  			for tc2 in aux.Next(sg) do
  				Duel.SpecialSummonStep(tc2, 0, tp, tp, false, false, POS_FACEUP)
  				local e3 = Effect.CreateEffect(c)
  				e3:SetType(EFFECT_TYPE_SINGLE)
  				e3:SetCode(EFFECT_LEAVE_FIELD_REDIRECT)
  				e3:SetReset(RESET_EVENT + RESETS_REDIRECT)
  				e3:SetValue(LOCATION_REMOVED)
  				tc2:RegisterEffect(e3, true)
  				local e4 = Effect.CreateEffect(c)
  				e4:SetType(EFFECT_TYPE_FIELD)
  				e4:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  				e4:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  				e4:SetRange(LOCATION_MZONE)
  				e4:SetAbsoluteRange(tp, 1, 0)
  				e4:SetTarget(s.splimit)
  				e4:SetReset(RESET_EVENT + RESETS_STANDARD)
  				tc2:RegisterEffect(e4)
  			end
  			Duel.SpecialSummonComplete()
  		end
  	end
  end
  function s.splimit(e, c)
  	return not c:IsRace(RACE_THUNDER)
  end
  
  