name: Grave
card_text: Turn the top card of your opponent's Deck face-up, then your opponent shuffles their Deck. When your opponent draws the face-up card, immediately send it to the Graveyard.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	Duel.EnableGlobalFlag(GLOBALFLAG_DECK_REVERSE_CHECK)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetFieldGroupCount(tp, 0, LOCATION_DECK) > 0
  	end
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	Duel.ConfirmDecktop(1 - tp, 1)
  	local g = Duel.GetDecktopGroup(1 - tp, 1)
  	if g:GetCount() > 0 then
  		local tc = g:GetFirst()
  		Duel.ShuffleDeck(1 - tp)
  		tc:ReverseInDeck()
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  		e1:SetCode(EVENT_DRAW)
  		e1:SetOperation(s.tgop)
  		e1:SetReset(RESET_EVENT + 0x1de0000)
  		tc:RegisterEffect(e1)
  	end
  end
  function s.tgop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.SendtoGrave(e:GetHandler(), REASON_EFFECT)
  end
  
  
source_text: Grave
  Turn the top card of your opponent's Deck face-up, then your opponent shuffles their Deck. When your opponent draws the face-up card, immediately send it to the Graveyard.
target_text: -- Grave
  local s, id, o = GetID()
  function s.initial_effect(c)
  	Duel.EnableGlobalFlag(GLOBALFLAG_DECK_REVERSE_CHECK)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetFieldGroupCount(tp, 0, LOCATION_DECK) > 0
  	end
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	Duel.ConfirmDecktop(1 - tp, 1)
  	local g = Duel.GetDecktopGroup(1 - tp, 1)
  	if g:GetCount() > 0 then
  		local tc = g:GetFirst()
  		Duel.ShuffleDeck(1 - tp)
  		tc:ReverseInDeck()
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  		e1:SetCode(EVENT_DRAW)
  		e1:SetOperation(s.tgop)
  		e1:SetReset(RESET_EVENT + 0x1de0000)
  		tc:RegisterEffect(e1)
  	end
  end
  function s.tgop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.SendtoGrave(e:GetHandler(), REASON_EFFECT)
  end
  
  