name: Gishki
card_text: When this card is sent to the Graveyard by a card effect: Look at the top 3 cards of your Deck, then return them all to the top or to the bottom of the Deck, in any order.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--confirm
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e1:SetCode(EVENT_TO_GRAVE)
  	e1:SetCondition(s.condition)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return bit.band(r, REASON_EFFECT) ~= 0 and Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) >= 3
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) < 3 then
  		return
  	end
  	Duel.SortDecktop(tp, tp, 3)
  	if Duel.SelectOption(tp, aux.Stringid(id, 1), aux.Stringid(id, 2)) == 1 then
  		for i = 1, 3 do
  			local mg = Duel.GetDecktopGroup(tp, 1)
  			Duel.MoveSequence(mg:GetFirst(), SEQ_DECKBOTTOM)
  		end
  	end
  end
  
  
source_text: Gishki
  When this card is sent to the Graveyard by a card effect: Look at the top 3 cards of your Deck, then return them all to the top or to the bottom of the Deck, in any order.
target_text: -- Gishki
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--confirm
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e1:SetCode(EVENT_TO_GRAVE)
  	e1:SetCondition(s.condition)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return bit.band(r, REASON_EFFECT) ~= 0 and Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) >= 3
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) < 3 then
  		return
  	end
  	Duel.SortDecktop(tp, tp, 3)
  	if Duel.SelectOption(tp, aux.Stringid(id, 1), aux.Stringid(id, 2)) == 1 then
  		for i = 1, 3 do
  			local mg = Duel.GetDecktopGroup(tp, 1)
  			Duel.MoveSequence(mg:GetFirst(), SEQ_DECKBOTTOM)
  		end
  	end
  end
  
  