name: Maharaghi
card_text: This card cannot be Special Summoned. This card returns to the owner's hand during the End Phase of the turn that this card is Normal Summoned or flipped face-up. If this card is Normal Summoned or flipped face-up, look at 1 card on the top of your Deck during your next Draw Phase (before you draw), and return the card to the top or the bottom of your Deck.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--spirit return
  	aux.EnableSpiritReturn(c, EVENT_SUMMON_SUCCESS, EVENT_FLIP)
  	--cannot special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_SPSUMMON_CONDITION)
  	e1:SetValue(aux.FALSE)
  	c:RegisterEffect(e1)
  	--summon success
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 1))
  	e4:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e4:SetCode(EVENT_SUMMON_SUCCESS)
  	e4:SetOperation(s.regop)
  	c:RegisterEffect(e4)
  	local e5 = e4:Clone()
  	e5:SetCode(EVENT_FLIP)
  	c:RegisterEffect(e5)
  end
  function s.regop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetFlagEffect(tp, id) ~= 0 then
  		return
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EVENT_PREDRAW)
  	e1:SetCondition(s.condition)
  	e1:SetOperation(s.operation)
  	e1:SetReset(RESET_PHASE + PHASE_DRAW + RESET_SELF_TURN, 1)
  	Duel.RegisterEffect(e1, tp)
  	Duel.RegisterFlagEffect(tp, id, RESET_PHASE + PHASE_END, 0, 2)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return tp == Duel.GetTurnPlayer() and Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) > 0
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetDecktopGroup(tp, 1)
  	Duel.ConfirmCards(tp, g)
  	local tc = g:GetFirst()
  	local opt = Duel.SelectOption(tp, aux.Stringid(id, 2), aux.Stringid(id, 3))
  	if opt == 1 then
  		Duel.MoveSequence(tc, opt)
  	end
  end
  
  
source_text: Maharaghi
  This card cannot be Special Summoned. This card returns to the owner's hand during the End Phase of the turn that this card is Normal Summoned or flipped face-up. If this card is Normal Summoned or flipped face-up, look at 1 card on the top of your Deck during your next Draw Phase (before you draw), and return the card to the top or the bottom of your Deck.
target_text: -- Maharaghi
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--spirit return
  	aux.EnableSpiritReturn(c, EVENT_SUMMON_SUCCESS, EVENT_FLIP)
  	--cannot special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_SPSUMMON_CONDITION)
  	e1:SetValue(aux.FALSE)
  	c:RegisterEffect(e1)
  	--summon success
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 1))
  	e4:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e4:SetCode(EVENT_SUMMON_SUCCESS)
  	e4:SetOperation(s.regop)
  	c:RegisterEffect(e4)
  	local e5 = e4:Clone()
  	e5:SetCode(EVENT_FLIP)
  	c:RegisterEffect(e5)
  end
  function s.regop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetFlagEffect(tp, id) ~= 0 then
  		return
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EVENT_PREDRAW)
  	e1:SetCondition(s.condition)
  	e1:SetOperation(s.operation)
  	e1:SetReset(RESET_PHASE + PHASE_DRAW + RESET_SELF_TURN, 1)
  	Duel.RegisterEffect(e1, tp)
  	Duel.RegisterFlagEffect(tp, id, RESET_PHASE + PHASE_END, 0, 2)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return tp == Duel.GetTurnPlayer() and Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) > 0
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetDecktopGroup(tp, 1)
  	Duel.ConfirmCards(tp, g)
  	local tc = g:GetFirst()
  	local opt = Duel.SelectOption(tp, aux.Stringid(id, 2), aux.Stringid(id, 3))
  	if opt == 1 then
  		Duel.MoveSequence(tc, opt)
  	end
  end
  
  