name: Saffira,
card_text: You can Ritual Summon this card with "Blessing of the Voiceless Voice". If this card is Ritual Summoned while you have "Lo, the Prayers of the Voiceless Voice" on your field or in your GY: You can draw 2 cards, then discard 1 card. When an attack is declared involving a LIGHT Ritual Monster (Warrior or Dragon): You can discard 1 random card from your opponent's hand. During your opponent's End Phase: You can add 1 LIGHT monster from your GY to your hand. You can only use each effect of "Saffira, Divine Dragon of the Voiceless Voice" once per turn.
external_ids: local CARD_ID_2 = 25801745 --Lo, the Prayers of the Voiceless Voice
  
lua: local CARD_ID_2 = 25801745 --Lo, the Prayers of the Voiceless Voice
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DRAW)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.drcon)
  	e1:SetTarget(s.drtg)
  	e1:SetOperation(s.drop)
  	c:RegisterEffect(e1)
  	--
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_HANDES)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCondition(s.hscon)
  	e2:SetTarget(s.hstg)
  	e2:SetOperation(s.hsop)
  	c:RegisterEffect(e2)
  	--
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 2))
  	e3:SetCategory(CATEGORY_TOHAND)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCode(EVENT_PHASE + PHASE_END)
  	e3:SetCountLimit(1, id + 2)
  	e3:SetCondition(s.thcon)
  	e3:SetTarget(s.thtg)
  	e3:SetOperation(s.thop)
  	c:RegisterEffect(e3)
  end
  function s.cfilter(c)
  	return c:IsFaceupEx() and c:IsCode(CARD_ID_2)
  end
  function s.drcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_RITUAL)
  end
  function s.drtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_ONFIELD + LOCATION_GRAVE, 0, 1, nil) and Duel.IsPlayerCanDraw(tp, 2)
  	end
  	Duel.SetTargetPlayer(tp)
  	Duel.SetTargetParam(2)
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, 2)
  	Duel.SetOperationInfo(0, CATEGORY_HANDES, nil, 0, tp, 1)
  end
  function s.drop(e, tp, eg, ep, ev, re, r, rp)
  	local p = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER)
  	if Duel.Draw(p, 2, REASON_EFFECT) == 2 then
  		Duel.ShuffleHand(p)
  		Duel.BreakEffect()
  		Duel.DiscardHand(p, nil, 1, 1, REASON_EFFECT + REASON_DISCARD)
  	end
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsType(TYPE_RITUAL) and (c:IsRace(RACE_DRAGON) or c:IsRace(RACE_WARRIOR)) and c:IsAttribute(ATTRIBUTE_LIGHT)
  end
  function s.hscon(e, tp, eg, ep, ev, re, r, rp)
  	local a = Duel.GetAttacker()
  	local d = Duel.GetAttackTarget()
  	return s.filter(a) or (d and s.filter(d))
  end
  function s.hstg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetFieldGroupCount(tp, 0, LOCATION_HAND) > 0
  	end
  	Duel.SetOperationInfo(0, CATEGORY_HANDES, nil, 0, 1 - tp, 1)
  end
  function s.hsop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetFieldGroup(tp, 0, LOCATION_HAND)
  	if g:GetCount() == 0 then
  		return
  	end
  	local sg = g:RandomSelect(tp, 1)
  	Duel.SendtoGrave(sg, REASON_DISCARD + REASON_EFFECT)
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() ~= tp
  end
  function s.thfilter(c)
  	return c:IsAttribute(ATTRIBUTE_LIGHT) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_GRAVE)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  
  
source_text: Saffira,
  You can Ritual Summon this card with "Blessing of the Voiceless Voice". If this card is Ritual Summoned while you have "Lo, the Prayers of the Voiceless Voice" on your field or in your GY: You can draw 2 cards, then discard 1 card. When an attack is declared involving a LIGHT Ritual Monster (Warrior or Dragon): You can discard 1 random card from your opponent's hand. During your opponent's End Phase: You can add 1 LIGHT monster from your GY to your hand. You can only use each effect of "Saffira, Divine Dragon of the Voiceless Voice" once per turn.
target_text: -- Saffira,
  local CARD_ID_2 = 25801745 --Lo, the Prayers of the Voiceless Voice
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DRAW)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.drcon)
  	e1:SetTarget(s.drtg)
  	e1:SetOperation(s.drop)
  	c:RegisterEffect(e1)
  	--
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_HANDES)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCondition(s.hscon)
  	e2:SetTarget(s.hstg)
  	e2:SetOperation(s.hsop)
  	c:RegisterEffect(e2)
  	--
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 2))
  	e3:SetCategory(CATEGORY_TOHAND)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCode(EVENT_PHASE + PHASE_END)
  	e3:SetCountLimit(1, id + 2)
  	e3:SetCondition(s.thcon)
  	e3:SetTarget(s.thtg)
  	e3:SetOperation(s.thop)
  	c:RegisterEffect(e3)
  end
  function s.cfilter(c)
  	return c:IsFaceupEx() and c:IsCode(CARD_ID_2)
  end
  function s.drcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_RITUAL)
  end
  function s.drtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_ONFIELD + LOCATION_GRAVE, 0, 1, nil) and Duel.IsPlayerCanDraw(tp, 2)
  	end
  	Duel.SetTargetPlayer(tp)
  	Duel.SetTargetParam(2)
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, 2)
  	Duel.SetOperationInfo(0, CATEGORY_HANDES, nil, 0, tp, 1)
  end
  function s.drop(e, tp, eg, ep, ev, re, r, rp)
  	local p = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER)
  	if Duel.Draw(p, 2, REASON_EFFECT) == 2 then
  		Duel.ShuffleHand(p)
  		Duel.BreakEffect()
  		Duel.DiscardHand(p, nil, 1, 1, REASON_EFFECT + REASON_DISCARD)
  	end
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsType(TYPE_RITUAL) and (c:IsRace(RACE_DRAGON) or c:IsRace(RACE_WARRIOR)) and c:IsAttribute(ATTRIBUTE_LIGHT)
  end
  function s.hscon(e, tp, eg, ep, ev, re, r, rp)
  	local a = Duel.GetAttacker()
  	local d = Duel.GetAttackTarget()
  	return s.filter(a) or (d and s.filter(d))
  end
  function s.hstg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetFieldGroupCount(tp, 0, LOCATION_HAND) > 0
  	end
  	Duel.SetOperationInfo(0, CATEGORY_HANDES, nil, 0, 1 - tp, 1)
  end
  function s.hsop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetFieldGroup(tp, 0, LOCATION_HAND)
  	if g:GetCount() == 0 then
  		return
  	end
  	local sg = g:RandomSelect(tp, 1)
  	Duel.SendtoGrave(sg, REASON_DISCARD + REASON_EFFECT)
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() ~= tp
  end
  function s.thfilter(c)
  	return c:IsAttribute(ATTRIBUTE_LIGHT) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_GRAVE)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  
  