name: Spiritual
card_text: Once per turn, during either player's turn: You can banish 1 "Ritual Beast" card from your Graveyard; for the rest of this turn, all "Ritual Beast" monsters you control will gain 500 ATK and DEF. You can only Special Summon "Spiritual Beast Apelio(s)" once per turn.
external_ids: local SETCARD_ID_0 = 0xb5 --Ritual
  
lua: local SETCARD_ID_0 = 0xb5 --Ritual
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:SetSPSummonOnce(id)
  	--atk
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP)
  	e1:SetHintTiming(TIMING_DAMAGE_STEP, TIMING_DAMAGE_STEP + TIMINGS_CHECK_MONSTER)
  	e1:SetCountLimit(1)
  	e1:SetCondition(aux.dscon)
  	e1:SetCost(s.atkcost)
  	e1:SetOperation(s.atkop)
  	c:RegisterEffect(e1)
  end
  function s.cfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsAbleToRemoveAsCost()
  end
  function s.atkcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectMatchingCard(tp, s.cfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.Remove(g, POS_FACEUP, REASON_COST)
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_UPDATE_ATTACK)
  	e1:SetTargetRange(LOCATION_MZONE, 0)
  	e1:SetTarget(s.atktg)
  	e1:SetValue(500)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  	local e2 = e1:Clone()
  	e2:SetCode(EFFECT_UPDATE_DEFENSE)
  	Duel.RegisterEffect(e2, tp)
  end
  function s.atktg(e, c)
  	return c:IsSetCard(SETCARD_ID_0)
  end
  
  
source_text: Spiritual
  Once per turn, during either player's turn: You can banish 1 "Ritual Beast" card from your Graveyard; for the rest of this turn, all "Ritual Beast" monsters you control will gain 500 ATK and DEF. You can only Special Summon "Spiritual Beast Apelio(s)" once per turn.
target_text: -- Spiritual
  local SETCARD_ID_0 = 0xb5 --Ritual
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:SetSPSummonOnce(id)
  	--atk
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP)
  	e1:SetHintTiming(TIMING_DAMAGE_STEP, TIMING_DAMAGE_STEP + TIMINGS_CHECK_MONSTER)
  	e1:SetCountLimit(1)
  	e1:SetCondition(aux.dscon)
  	e1:SetCost(s.atkcost)
  	e1:SetOperation(s.atkop)
  	c:RegisterEffect(e1)
  end
  function s.cfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsAbleToRemoveAsCost()
  end
  function s.atkcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectMatchingCard(tp, s.cfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.Remove(g, POS_FACEUP, REASON_COST)
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_UPDATE_ATTACK)
  	e1:SetTargetRange(LOCATION_MZONE, 0)
  	e1:SetTarget(s.atktg)
  	e1:SetValue(500)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  	local e2 = e1:Clone()
  	e2:SetCode(EFFECT_UPDATE_DEFENSE)
  	Duel.RegisterEffect(e2, tp)
  end
  function s.atktg(e, c)
  	return c:IsSetCard(SETCARD_ID_0)
  end
  
  