name: Dragon
card_text: If you control a Spellcaster monster: You can target up to 2 Dragon monsters in your GY, including at least 1 Normal Monster; Special Summon them, also for the rest of this turn after this card resolves, your opponent takes no damage. You can only activate 1 "Dragon Revival Rhapsody" 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:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	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.cfilter(c)
  	return c:IsFaceup() and c:IsRace(RACE_SPELLCASTER)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil)
  end
  function s.filter(c, e, tp)
  	return c:IsRace(RACE_DRAGON) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.nfilter(c, e, tp)
  	return s.filter(c, e, tp) and c:IsType(TYPE_NORMAL)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return false
  	end
  	local ct = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	if chk == 0 then
  		return ct > 0 and Duel.IsExistingTarget(s.nfilter, tp, LOCATION_GRAVE, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g1 = Duel.SelectTarget(tp, s.nfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  	if ct > 1 and not Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) and Duel.IsExistingTarget(s.filter, tp, LOCATION_GRAVE, 0, 1, g1, e, tp) and Duel.SelectYesNo(tp, aux.Stringid(id, 0)) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local g2 = Duel.SelectTarget(tp, s.filter, tp, LOCATION_GRAVE, 0, 1, 1, g1, e, tp)
  		g1:Merge(g2)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g1, g1:GetCount(), 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	if e:IsHasType(EFFECT_TYPE_ACTIVATE) then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetCode(EFFECT_CHANGE_DAMAGE)
  		e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e1:SetTargetRange(0, 1)
  		e1:SetValue(0)
  		e1:SetReset(RESET_PHASE + PHASE_END)
  		Duel.RegisterEffect(e1, tp)
  		local e2 = e1:Clone()
  		e2:SetCode(EFFECT_NO_EFFECT_DAMAGE)
  		e2:SetReset(RESET_PHASE + PHASE_END)
  		Duel.RegisterEffect(e2, tp)
  	end
  	local ct = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	if ct < 1 then
  		return
  	end
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToEffect, nil, e)
  	if g:GetCount() == 0 then
  		return
  	end
  	if g:GetCount() > ct or (g:GetCount() > 1 and Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0)) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		g = g:Select(tp, 1, 1, nil)
  	end
  	Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  end
  
  
source_text: Dragon
  If you control a Spellcaster monster: You can target up to 2 Dragon monsters in your GY, including at least 1 Normal Monster; Special Summon them, also for the rest of this turn after this card resolves, your opponent takes no damage. You can only activate 1 "Dragon Revival Rhapsody" per turn.
target_text: -- Dragon
  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:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	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.cfilter(c)
  	return c:IsFaceup() and c:IsRace(RACE_SPELLCASTER)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil)
  end
  function s.filter(c, e, tp)
  	return c:IsRace(RACE_DRAGON) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.nfilter(c, e, tp)
  	return s.filter(c, e, tp) and c:IsType(TYPE_NORMAL)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return false
  	end
  	local ct = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	if chk == 0 then
  		return ct > 0 and Duel.IsExistingTarget(s.nfilter, tp, LOCATION_GRAVE, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g1 = Duel.SelectTarget(tp, s.nfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  	if ct > 1 and not Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) and Duel.IsExistingTarget(s.filter, tp, LOCATION_GRAVE, 0, 1, g1, e, tp) and Duel.SelectYesNo(tp, aux.Stringid(id, 0)) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local g2 = Duel.SelectTarget(tp, s.filter, tp, LOCATION_GRAVE, 0, 1, 1, g1, e, tp)
  		g1:Merge(g2)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g1, g1:GetCount(), 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	if e:IsHasType(EFFECT_TYPE_ACTIVATE) then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetCode(EFFECT_CHANGE_DAMAGE)
  		e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e1:SetTargetRange(0, 1)
  		e1:SetValue(0)
  		e1:SetReset(RESET_PHASE + PHASE_END)
  		Duel.RegisterEffect(e1, tp)
  		local e2 = e1:Clone()
  		e2:SetCode(EFFECT_NO_EFFECT_DAMAGE)
  		e2:SetReset(RESET_PHASE + PHASE_END)
  		Duel.RegisterEffect(e2, tp)
  	end
  	local ct = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	if ct < 1 then
  		return
  	end
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToEffect, nil, e)
  	if g:GetCount() == 0 then
  		return
  	end
  	if g:GetCount() > ct or (g:GetCount() > 1 and Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0)) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		g = g:Select(tp, 1, 1, nil)
  	end
  	Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  end
  
  