name: Atlantean
card_text: All your Level 3 or lower Sea Serpent monsters can attack directly. If this card is sent to the GY to activate a WATER monster's effect: Add 1 Sea Serpent monster from your Deck to your hand, except "Atlantean Dragoons".
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--direct attack
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_DIRECT_ATTACK)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetTargetRange(LOCATION_MZONE, 0)
  	e1:SetTarget(s.datg)
  	c:RegisterEffect(e1)
  	--search
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e2:SetCode(EVENT_TO_GRAVE)
  	e2:SetCondition(s.thcon)
  	e2:SetTarget(s.thtg)
  	e2:SetOperation(s.thop)
  	c:RegisterEffect(e2)
  end
  function s.datg(e, c)
  	return c:IsLevelBelow(3) and c:IsRace(RACE_SEASERPENT)
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsReason(REASON_COST) and re:IsActivated() and re:IsActiveType(TYPE_MONSTER) and re:GetHandler():IsAttribute(ATTRIBUTE_WATER)
  end
  function s.thfilter(c)
  	return not c:IsCode(id) and c:IsRace(RACE_SEASERPENT) and c:IsAbleToHand()
  end
  function s.thtg(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.thop(e, tp, eg, ep, ev, re, r, rp, c)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  
  
source_text: Atlantean
  All your Level 3 or lower Sea Serpent monsters can attack directly. If this card is sent to the GY to activate a WATER monster's effect: Add 1 Sea Serpent monster from your Deck to your hand, except "Atlantean Dragoons".
target_text: -- Atlantean
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--direct attack
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_DIRECT_ATTACK)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetTargetRange(LOCATION_MZONE, 0)
  	e1:SetTarget(s.datg)
  	c:RegisterEffect(e1)
  	--search
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e2:SetCode(EVENT_TO_GRAVE)
  	e2:SetCondition(s.thcon)
  	e2:SetTarget(s.thtg)
  	e2:SetOperation(s.thop)
  	c:RegisterEffect(e2)
  end
  function s.datg(e, c)
  	return c:IsLevelBelow(3) and c:IsRace(RACE_SEASERPENT)
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsReason(REASON_COST) and re:IsActivated() and re:IsActiveType(TYPE_MONSTER) and re:GetHandler():IsAttribute(ATTRIBUTE_WATER)
  end
  function s.thfilter(c)
  	return not c:IsCode(id) and c:IsRace(RACE_SEASERPENT) and c:IsAbleToHand()
  end
  function s.thtg(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.thop(e, tp, eg, ep, ev, re, r, rp, c)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  
  