name: Photon
card_text: Cannot be Normal Summoned/Set. Must first be Special Summoned (from your hand) while you control a "Photon" or "Galaxy" monster. Cannot attack the turn it is Special Summoned. You can only Special Summon "Photon Vanisher(s)" once per turn. If this card is Special Summoned: You can add 1 "Galaxy-Eyes Photon Dragon" from your Deck to your hand. An Xyz Monster that was Summoned using this card on the field as material gains this effect.
  ● Banish any monster destroyed by battle with this card.
external_ids: local CARD_ID_0 = 93717133 --Galaxy-Eyes Photon Dragon
  local SETCARD_ID_0 = 0x55 --Photon
  
lua: local CARD_ID_0 = 93717133 --Galaxy-Eyes Photon Dragon
  local SETCARD_ID_0 = 0x55 --Photon
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:SetSPSummonOnce(id)
  	c:EnableReviveLimit()
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCondition(s.sprcon)
  	c:RegisterEffect(e1)
  	--to hand
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_DELAY)
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e2:SetCountLimit(1, id)
  	e2:SetTarget(s.thtg)
  	e2:SetOperation(s.thop)
  	c:RegisterEffect(e2)
  	--cannot attack
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e3:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e3:SetOperation(s.atklimit)
  	c:RegisterEffect(e3)
  	--effect gain
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e4:SetCode(EVENT_BE_MATERIAL)
  	e4:SetProperty(EFFECT_FLAG_EVENT_PLAYER)
  	e4:SetCondition(s.effcon)
  	e4:SetOperation(s.effop)
  	c:RegisterEffect(e4)
  end
  function s.sprfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0, 0x7b)
  end
  function s.sprcon(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.sprfilter, tp, LOCATION_MZONE, 0, 1, nil)
  end
  function s.thfilter(c)
  	return c:IsCode(CARD_ID_0) 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_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  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_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  function s.atklimit(e, tp, eg, ep, ev, re, r, rp)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_CANNOT_ATTACK)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  	e:GetHandler():RegisterEffect(e1)
  end
  function s.effcon(e, tp, eg, ep, ev, re, r, rp)
  	return r == REASON_XYZ
  end
  function s.effop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local rc = c:GetReasonCard()
  	local e1 = Effect.CreateEffect(rc)
  	e1:SetDescription(aux.Stringid(id, 1))
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_CLIENT_HINT)
  	e1:SetCode(EFFECT_BATTLE_DESTROY_REDIRECT)
  	e1:SetValue(LOCATION_REMOVED)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  	rc:RegisterEffect(e1, true)
  	if not rc:IsType(TYPE_EFFECT) then
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_ADD_TYPE)
  		e2:SetValue(TYPE_EFFECT)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  		rc:RegisterEffect(e2, true)
  	end
  end
  
  
source_text: Photon
  Cannot be Normal Summoned/Set. Must first be Special Summoned (from your hand) while you control a "Photon" or "Galaxy" monster. Cannot attack the turn it is Special Summoned. You can only Special Summon "Photon Vanisher(s)" once per turn. If this card is Special Summoned: You can add 1 "Galaxy-Eyes Photon Dragon" from your Deck to your hand. An Xyz Monster that was Summoned using this card on the field as material gains this effect.
  ● Banish any monster destroyed by battle with this card.
target_text: -- Photon
  local CARD_ID_0 = 93717133 --Galaxy-Eyes Photon Dragon
  local SETCARD_ID_0 = 0x55 --Photon
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:SetSPSummonOnce(id)
  	c:EnableReviveLimit()
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCondition(s.sprcon)
  	c:RegisterEffect(e1)
  	--to hand
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_DELAY)
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e2:SetCountLimit(1, id)
  	e2:SetTarget(s.thtg)
  	e2:SetOperation(s.thop)
  	c:RegisterEffect(e2)
  	--cannot attack
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e3:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e3:SetOperation(s.atklimit)
  	c:RegisterEffect(e3)
  	--effect gain
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e4:SetCode(EVENT_BE_MATERIAL)
  	e4:SetProperty(EFFECT_FLAG_EVENT_PLAYER)
  	e4:SetCondition(s.effcon)
  	e4:SetOperation(s.effop)
  	c:RegisterEffect(e4)
  end
  function s.sprfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0, 0x7b)
  end
  function s.sprcon(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.sprfilter, tp, LOCATION_MZONE, 0, 1, nil)
  end
  function s.thfilter(c)
  	return c:IsCode(CARD_ID_0) 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_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  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_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  function s.atklimit(e, tp, eg, ep, ev, re, r, rp)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_CANNOT_ATTACK)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  	e:GetHandler():RegisterEffect(e1)
  end
  function s.effcon(e, tp, eg, ep, ev, re, r, rp)
  	return r == REASON_XYZ
  end
  function s.effop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local rc = c:GetReasonCard()
  	local e1 = Effect.CreateEffect(rc)
  	e1:SetDescription(aux.Stringid(id, 1))
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_CLIENT_HINT)
  	e1:SetCode(EFFECT_BATTLE_DESTROY_REDIRECT)
  	e1:SetValue(LOCATION_REMOVED)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  	rc:RegisterEffect(e1, true)
  	if not rc:IsType(TYPE_EFFECT) then
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_ADD_TYPE)
  		e2:SetValue(TYPE_EFFECT)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  		rc:RegisterEffect(e2, true)
  	end
  end
  
  