name: Cerulean
card_text: You can Ritual Summon this card with "Rebirth of Nephthys". You can only use each of the following effects of "Cerulean Sacred Phoenix of Nephthys" once per turn.
  ● During your Main Phase: You can destroy "Nephthys" cards in your hand and/or face-up field, then destroy an equal number of monsters your opponent controls.
  ● During your next Standby Phase after this card was destroyed by battle or card effect and sent to the GY: You can Special Summon this card from the GY.
external_ids: local SETCARD_ID_0 = 0x11f --Nephthys
  
lua: local SETCARD_ID_0 = 0x11f --Nephthys
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--destroy
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DESTROY)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.destg)
  	e1:SetOperation(s.desop)
  	c:RegisterEffect(e1)
  	--spsummon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e2:SetCode(EVENT_TO_GRAVE)
  	e2:SetOperation(s.spr)
  	c:RegisterEffect(e2)
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetRange(LOCATION_GRAVE)
  	e3:SetCode(EVENT_PHASE + PHASE_STANDBY)
  	e3:SetCountLimit(1, id + 1)
  	e3:SetCondition(s.spcon)
  	e3:SetTarget(s.sptg)
  	e3:SetOperation(s.spop)
  	e3:SetLabelObject(e2)
  	c:RegisterEffect(e3)
  end
  function s.desfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and (c:IsFaceup() or not c:IsOnField())
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetFieldGroupCount(tp, 0, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.desfilter, tp, LOCATION_HAND + LOCATION_ONFIELD, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, nil, 2, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.desfilter, tp, LOCATION_HAND + LOCATION_ONFIELD, 0, nil)
  	local og = Duel.GetFieldGroup(tp, 0, LOCATION_MZONE)
  	if #g * #og == 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local sg = g:Select(tp, 1, #og, nil)
  	local oc = Duel.Destroy(sg, REASON_EFFECT)
  	if oc == 0 then
  		return
  	end
  	Duel.BreakEffect()
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local sg2 = og:Select(tp, oc, oc, nil)
  	Duel.Destroy(sg2, REASON_EFFECT)
  end
  function s.spr(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not (c:IsReason(REASON_BATTLE + REASON_EFFECT) and c:IsReason(REASON_DESTROY)) then
  		return
  	end
  	if Duel.GetTurnPlayer() == tp and Duel.GetCurrentPhase() == PHASE_STANDBY then
  		e:SetLabel(Duel.GetTurnCount())
  		c:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_STANDBY + RESET_SELF_TURN, 0, 2)
  	else
  		e:SetLabel(0)
  		c:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_STANDBY + RESET_SELF_TURN, 0, 1)
  	end
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsCanBeSpecialSummoned(e, 0, tp, false, false) and e:GetLabelObject():GetLabel() ~= Duel.GetTurnCount() and tp == Duel.GetTurnPlayer() and c:GetFlagEffect(id) > 0
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return c:IsCanBeSpecialSummoned(e, 0, tp, false, false) and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, c, 1, 0, 0)
  	c:ResetFlagEffect(id)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) then
  		Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  
  
source_text: Cerulean
  You can Ritual Summon this card with "Rebirth of Nephthys". You can only use each of the following effects of "Cerulean Sacred Phoenix of Nephthys" once per turn.
  ● During your Main Phase: You can destroy "Nephthys" cards in your hand and/or face-up field, then destroy an equal number of monsters your opponent controls.
  ● During your next Standby Phase after this card was destroyed by battle or card effect and sent to the GY: You can Special Summon this card from the GY.
target_text: -- Cerulean
  local SETCARD_ID_0 = 0x11f --Nephthys
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--destroy
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DESTROY)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.destg)
  	e1:SetOperation(s.desop)
  	c:RegisterEffect(e1)
  	--spsummon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e2:SetCode(EVENT_TO_GRAVE)
  	e2:SetOperation(s.spr)
  	c:RegisterEffect(e2)
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetRange(LOCATION_GRAVE)
  	e3:SetCode(EVENT_PHASE + PHASE_STANDBY)
  	e3:SetCountLimit(1, id + 1)
  	e3:SetCondition(s.spcon)
  	e3:SetTarget(s.sptg)
  	e3:SetOperation(s.spop)
  	e3:SetLabelObject(e2)
  	c:RegisterEffect(e3)
  end
  function s.desfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and (c:IsFaceup() or not c:IsOnField())
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetFieldGroupCount(tp, 0, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.desfilter, tp, LOCATION_HAND + LOCATION_ONFIELD, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, nil, 2, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.desfilter, tp, LOCATION_HAND + LOCATION_ONFIELD, 0, nil)
  	local og = Duel.GetFieldGroup(tp, 0, LOCATION_MZONE)
  	if #g * #og == 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local sg = g:Select(tp, 1, #og, nil)
  	local oc = Duel.Destroy(sg, REASON_EFFECT)
  	if oc == 0 then
  		return
  	end
  	Duel.BreakEffect()
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local sg2 = og:Select(tp, oc, oc, nil)
  	Duel.Destroy(sg2, REASON_EFFECT)
  end
  function s.spr(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not (c:IsReason(REASON_BATTLE + REASON_EFFECT) and c:IsReason(REASON_DESTROY)) then
  		return
  	end
  	if Duel.GetTurnPlayer() == tp and Duel.GetCurrentPhase() == PHASE_STANDBY then
  		e:SetLabel(Duel.GetTurnCount())
  		c:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_STANDBY + RESET_SELF_TURN, 0, 2)
  	else
  		e:SetLabel(0)
  		c:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_STANDBY + RESET_SELF_TURN, 0, 1)
  	end
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsCanBeSpecialSummoned(e, 0, tp, false, false) and e:GetLabelObject():GetLabel() ~= Duel.GetTurnCount() and tp == Duel.GetTurnPlayer() and c:GetFlagEffect(id) > 0
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return c:IsCanBeSpecialSummoned(e, 0, tp, false, false) and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, c, 1, 0, 0)
  	c:ResetFlagEffect(id)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) then
  		Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  
  