name: ゴブリンのやりくり上手
card_text: 自分の墓地に存在する「ゴブリンのやりくり上手」の枚数+1枚を自分のデッキからドローし、自分の手札を1枚選択してデッキの一番下に戻す。
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DRAW + CATEGORY_TODECK)
  	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.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanDraw(tp, 1)
  	end
  	Duel.SetTargetPlayer(tp)
  	local ct = Duel.GetMatchingGroupCount(Card.IsCode, tp, LOCATION_GRAVE, 0, nil, id)
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, ct + 1)
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, nil, 1, tp, LOCATION_HAND)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local p = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER)
  	local d = Duel.GetMatchingGroupCount(Card.IsCode, p, LOCATION_GRAVE, 0, nil, id) + 1
  	Duel.Draw(p, d, REASON_EFFECT)
  	Duel.BreakEffect()
  	Duel.ShuffleHand(tp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  	local g = Duel.SelectMatchingCard(p, aux.TRUE, p, LOCATION_HAND, 0, 1, 1, nil)
  	Duel.SendtoDeck(g, nil, SEQ_DECKBOTTOM, REASON_EFFECT)
  end
  
  
source_text: ゴブリンのやりくり上手
  自分の墓地に存在する「ゴブリンのやりくり上手」の枚数+1枚を自分のデッキからドローし、自分の手札を1枚選択してデッキの一番下に戻す。
target_text: -- ゴブリンのやりくり上手
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DRAW + CATEGORY_TODECK)
  	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.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanDraw(tp, 1)
  	end
  	Duel.SetTargetPlayer(tp)
  	local ct = Duel.GetMatchingGroupCount(Card.IsCode, tp, LOCATION_GRAVE, 0, nil, id)
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, ct + 1)
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, nil, 1, tp, LOCATION_HAND)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local p = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER)
  	local d = Duel.GetMatchingGroupCount(Card.IsCode, p, LOCATION_GRAVE, 0, nil, id) + 1
  	Duel.Draw(p, d, REASON_EFFECT)
  	Duel.BreakEffect()
  	Duel.ShuffleHand(tp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  	local g = Duel.SelectMatchingCard(p, aux.TRUE, p, LOCATION_HAND, 0, 1, 1, nil)
  	Duel.SendtoDeck(g, nil, SEQ_DECKBOTTOM, REASON_EFFECT)
  end
  
  