name: Emissary
card_text: When this card is sent from the field to the Graveyard: Each player adds 1 Level 3 or lower Normal Monster from their Deck to their hand.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--search
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e1:SetCode(EVENT_TO_GRAVE)
  	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():IsPreviousLocation(LOCATION_ONFIELD)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.filter(c)
  	return c:IsLevelBelow(3) and c:IsType(TYPE_NORMAL) and c:IsAbleToHand()
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g1 = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	local tc1 = g1:GetFirst()
  	Duel.Hint(HINT_SELECTMSG, 1 - tp, HINTMSG_ATOHAND)
  	local g2 = Duel.SelectMatchingCard(1 - tp, s.filter, tp, 0, LOCATION_DECK, 1, 1, nil)
  	local tc2 = g2:GetFirst()
  	g1:Merge(g2)
  	Duel.SendtoHand(g1, nil, REASON_EFFECT)
  	if tc1 then
  		Duel.ConfirmCards(1 - tp, tc1)
  	end
  	if tc2 then
  		Duel.ConfirmCards(tp, tc2)
  	end
  end
  
  
source_text: Emissary
  When this card is sent from the field to the Graveyard: Each player adds 1 Level 3 or lower Normal Monster from their Deck to their hand.
target_text: -- Emissary
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--search
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e1:SetCode(EVENT_TO_GRAVE)
  	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():IsPreviousLocation(LOCATION_ONFIELD)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.filter(c)
  	return c:IsLevelBelow(3) and c:IsType(TYPE_NORMAL) and c:IsAbleToHand()
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g1 = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	local tc1 = g1:GetFirst()
  	Duel.Hint(HINT_SELECTMSG, 1 - tp, HINTMSG_ATOHAND)
  	local g2 = Duel.SelectMatchingCard(1 - tp, s.filter, tp, 0, LOCATION_DECK, 1, 1, nil)
  	local tc2 = g2:GetFirst()
  	g1:Merge(g2)
  	Duel.SendtoHand(g1, nil, REASON_EFFECT)
  	if tc1 then
  		Duel.ConfirmCards(1 - tp, tc1)
  	end
  	if tc2 then
  		Duel.ConfirmCards(tp, tc2)
  	end
  end
  
  