name: Marmiting
card_text: When this card is Normal Summoned: You can shuffle 1 card from your hand into the Deck, then draw 1 card, then you can Special Summon it if it is a monster.
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 + CATEGORY_DRAW + CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanDraw(tp, 1) and Duel.IsExistingMatchingCard(Card.IsAbleToDeck, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, nil, 1, tp, LOCATION_HAND)
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, 1)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  	local g = Duel.SelectMatchingCard(tp, Card.IsAbleToDeck, tp, LOCATION_HAND, 0, 1, 1, nil)
  	if g:GetCount() > 0 and Duel.SendtoDeck(g, nil, SEQ_DECKSHUFFLE, REASON_EFFECT) ~= 0 then
  		Duel.ShuffleDeck(tp)
  		Duel.BreakEffect()
  		if Duel.Draw(tp, 1, REASON_EFFECT) == 0 then
  			return
  		end
  		local dg = Duel.GetOperatedGroup()
  		local dc = dg:GetFirst()
  		if Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and dc:IsCanBeSpecialSummoned(e, 0, tp, false, false) and Duel.SelectYesNo(tp, aux.Stringid(id, 1)) then
  			Duel.SpecialSummon(dc, 0, tp, tp, false, false, POS_FACEUP)
  		end
  	end
  end
  
  
source_text: Marmiting
  When this card is Normal Summoned: You can shuffle 1 card from your hand into the Deck, then draw 1 card, then you can Special Summon it if it is a monster.
target_text: -- Marmiting
  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 + CATEGORY_DRAW + CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanDraw(tp, 1) and Duel.IsExistingMatchingCard(Card.IsAbleToDeck, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, nil, 1, tp, LOCATION_HAND)
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, 1)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  	local g = Duel.SelectMatchingCard(tp, Card.IsAbleToDeck, tp, LOCATION_HAND, 0, 1, 1, nil)
  	if g:GetCount() > 0 and Duel.SendtoDeck(g, nil, SEQ_DECKSHUFFLE, REASON_EFFECT) ~= 0 then
  		Duel.ShuffleDeck(tp)
  		Duel.BreakEffect()
  		if Duel.Draw(tp, 1, REASON_EFFECT) == 0 then
  			return
  		end
  		local dg = Duel.GetOperatedGroup()
  		local dc = dg:GetFirst()
  		if Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and dc:IsCanBeSpecialSummoned(e, 0, tp, false, false) and Duel.SelectYesNo(tp, aux.Stringid(id, 1)) then
  			Duel.SpecialSummon(dc, 0, tp, tp, false, false, POS_FACEUP)
  		end
  	end
  end
  
  