name: Keldo
card_text: If this card is destroyed by battle and sent to the GY: Target 2 cards in your opponent's GY; shuffle them into the Deck.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--todeck
  	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:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_BATTLE_DESTROYED)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsLocation(LOCATION_GRAVE) and e:GetHandler():IsReason(REASON_BATTLE)
  end
  function s.filter(c, e)
  	return c:IsAbleToDeck() and c:IsCanBeEffectTarget(e)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(1 - tp) and s.filter(chkc, e)
  	end
  	if chk == 0 then
  		return true
  	end
  	local g = Duel.GetMatchingGroup(s.filter, tp, 0, LOCATION_GRAVE, nil, e)
  	if g:GetCount() >= 2 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  		local sg = g:Select(tp, 2, 2, nil)
  		Duel.SetTargetCard(sg)
  		Duel.SetOperationInfo(0, CATEGORY_TODECK, sg, 2, 0, 0)
  	end
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
  	if not g then
  		return
  	end
  	local sg = g:Filter(Card.IsRelateToEffect, nil, e)
  	Duel.SendtoDeck(sg, nil, SEQ_DECKSHUFFLE, REASON_EFFECT)
  end
  
  
source_text: Keldo
  If this card is destroyed by battle and sent to the GY: Target 2 cards in your opponent's GY; shuffle them into the Deck.
target_text: -- Keldo
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--todeck
  	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:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_BATTLE_DESTROYED)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsLocation(LOCATION_GRAVE) and e:GetHandler():IsReason(REASON_BATTLE)
  end
  function s.filter(c, e)
  	return c:IsAbleToDeck() and c:IsCanBeEffectTarget(e)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(1 - tp) and s.filter(chkc, e)
  	end
  	if chk == 0 then
  		return true
  	end
  	local g = Duel.GetMatchingGroup(s.filter, tp, 0, LOCATION_GRAVE, nil, e)
  	if g:GetCount() >= 2 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  		local sg = g:Select(tp, 2, 2, nil)
  		Duel.SetTargetCard(sg)
  		Duel.SetOperationInfo(0, CATEGORY_TODECK, sg, 2, 0, 0)
  	end
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
  	if not g then
  		return
  	end
  	local sg = g:Filter(Card.IsRelateToEffect, nil, e)
  	Duel.SendtoDeck(sg, nil, SEQ_DECKSHUFFLE, REASON_EFFECT)
  end
  
  