name: Moray
card_text: Shuffle 2 WATER monsters from your hand into the Deck, then draw 3 cards.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TODECK + CATEGORY_DRAW)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.filter(c)
  	return c:IsAttribute(ATTRIBUTE_WATER) and c:IsAbleToDeck()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanDraw(tp, 3) and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_HAND, 0, 2, e:GetHandler())
  	end
  	Duel.SetTargetPlayer(tp)
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, nil, 2, tp, LOCATION_HAND)
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, 3)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local p = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER)
  	local g = Duel.GetMatchingGroup(s.filter, p, LOCATION_HAND, 0, nil)
  	if g:GetCount() >= 2 then
  		Duel.Hint(HINT_SELECTMSG, p, HINTMSG_TODECK)
  		local sg = g:Select(p, 2, 2, nil)
  		Duel.ConfirmCards(1 - p, sg)
  		Duel.SendtoDeck(sg, nil, SEQ_DECKSHUFFLE, REASON_EFFECT)
  		Duel.ShuffleDeck(p)
  		Duel.BreakEffect()
  		Duel.Draw(p, 3, REASON_EFFECT)
  	end
  end
  
  
source_text: Moray
  Shuffle 2 WATER monsters from your hand into the Deck, then draw 3 cards.
target_text: -- Moray
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TODECK + CATEGORY_DRAW)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.filter(c)
  	return c:IsAttribute(ATTRIBUTE_WATER) and c:IsAbleToDeck()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanDraw(tp, 3) and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_HAND, 0, 2, e:GetHandler())
  	end
  	Duel.SetTargetPlayer(tp)
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, nil, 2, tp, LOCATION_HAND)
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, 3)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local p = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER)
  	local g = Duel.GetMatchingGroup(s.filter, p, LOCATION_HAND, 0, nil)
  	if g:GetCount() >= 2 then
  		Duel.Hint(HINT_SELECTMSG, p, HINTMSG_TODECK)
  		local sg = g:Select(p, 2, 2, nil)
  		Duel.ConfirmCards(1 - p, sg)
  		Duel.SendtoDeck(sg, nil, SEQ_DECKSHUFFLE, REASON_EFFECT)
  		Duel.ShuffleDeck(p)
  		Duel.BreakEffect()
  		Duel.Draw(p, 3, REASON_EFFECT)
  	end
  end
  
  