name: Penguin
card_text: When this card is sent directly from your Deck to the Graveyard by an effect of a card controlled by your opponent, unite your Graveyard cards and your own Deck, shuffle them and form a new Deck.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--to deck
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TODECK)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e1:SetCode(EVENT_TO_GRAVE)
  	e1:SetCondition(s.tdcon)
  	e1:SetTarget(s.tdtg)
  	e1:SetOperation(s.tdop)
  	c:RegisterEffect(e1)
  end
  function s.tdcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsPreviousLocation(LOCATION_DECK) and bit.band(r, REASON_EFFECT) ~= 0 and rp == 1 - tp
  end
  function s.tdtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local g = Duel.GetFieldGroup(tp, LOCATION_GRAVE, 0)
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, g, g:GetCount(), 0, 0)
  end
  function s.tdop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetFieldGroup(tp, LOCATION_GRAVE, 0)
  	if aux.NecroValleyNegateCheck(g) then
  		return
  	end
  	if Duel.SendtoDeck(g, nil, SEQ_DECKSHUFFLE, REASON_EFFECT) ~= 0 then
  		if g:IsExists(Card.IsLocation, 1, nil, LOCATION_DECK) then
  			Duel.ShuffleDeck(tp)
  		end
  	end
  end
  
  
source_text: Penguin
  When this card is sent directly from your Deck to the Graveyard by an effect of a card controlled by your opponent, unite your Graveyard cards and your own Deck, shuffle them and form a new Deck.
target_text: -- Penguin
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--to deck
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TODECK)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e1:SetCode(EVENT_TO_GRAVE)
  	e1:SetCondition(s.tdcon)
  	e1:SetTarget(s.tdtg)
  	e1:SetOperation(s.tdop)
  	c:RegisterEffect(e1)
  end
  function s.tdcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsPreviousLocation(LOCATION_DECK) and bit.band(r, REASON_EFFECT) ~= 0 and rp == 1 - tp
  end
  function s.tdtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local g = Duel.GetFieldGroup(tp, LOCATION_GRAVE, 0)
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, g, g:GetCount(), 0, 0)
  end
  function s.tdop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetFieldGroup(tp, LOCATION_GRAVE, 0)
  	if aux.NecroValleyNegateCheck(g) then
  		return
  	end
  	if Duel.SendtoDeck(g, nil, SEQ_DECKSHUFFLE, REASON_EFFECT) ~= 0 then
  		if g:IsExists(Card.IsLocation, 1, nil, LOCATION_DECK) then
  			Duel.ShuffleDeck(tp)
  		end
  	end
  end
  
  