name: 赤鬼
card_text: このカードが召喚に成功した時、自分の手札を任意の枚数墓地に送る事で、その枚数分だけフィールド上のカードを持ち主の手札に戻す。
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--to hand
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TOHAND)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.costfilter(c)
  	return c:IsAbleToGraveAsCost()
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.costfilter, tp, LOCATION_HAND, 0, 1, e:GetHandler())
  	end
  	local rt = Duel.GetTargetCount(Card.IsAbleToHand, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, nil)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local cg = Duel.SelectMatchingCard(tp, s.costfilter, tp, LOCATION_HAND, 0, 1, rt, nil)
  	Duel.SendtoGrave(cg, REASON_COST)
  	e:SetLabel(cg:GetCount())
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsOnField() and chkc:IsAbleToHand()
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(Card.IsAbleToHand, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, nil)
  	end
  	local ct = e:GetLabel()
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RTOHAND)
  	local eg = Duel.SelectTarget(tp, Card.IsAbleToHand, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, ct, ct, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, eg, ct, 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local tg = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
  	local rg = tg:Filter(Card.IsRelateToEffect, nil, e)
  	if rg:GetCount() > 0 then
  		Duel.SendtoHand(rg, nil, REASON_EFFECT)
  	end
  end
  
  
source_text: 赤鬼
  このカードが召喚に成功した時、自分の手札を任意の枚数墓地に送る事で、その枚数分だけフィールド上のカードを持ち主の手札に戻す。
target_text: -- 赤鬼
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--to hand
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TOHAND)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.costfilter(c)
  	return c:IsAbleToGraveAsCost()
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.costfilter, tp, LOCATION_HAND, 0, 1, e:GetHandler())
  	end
  	local rt = Duel.GetTargetCount(Card.IsAbleToHand, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, nil)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local cg = Duel.SelectMatchingCard(tp, s.costfilter, tp, LOCATION_HAND, 0, 1, rt, nil)
  	Duel.SendtoGrave(cg, REASON_COST)
  	e:SetLabel(cg:GetCount())
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsOnField() and chkc:IsAbleToHand()
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(Card.IsAbleToHand, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, nil)
  	end
  	local ct = e:GetLabel()
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RTOHAND)
  	local eg = Duel.SelectTarget(tp, Card.IsAbleToHand, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, ct, ct, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, eg, ct, 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local tg = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
  	local rg = tg:Filter(Card.IsRelateToEffect, nil, e)
  	if rg:GetCount() > 0 then
  		Duel.SendtoHand(rg, nil, REASON_EFFECT)
  	end
  end
  
  