name: A・O・J
card_text: 1ターンに1度、手札を1枚捨てて発動できる。
  フィールド上のチューナーの数だけ、フィールド上の魔法・罠カードを選んで持ち主の手札に戻す。
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_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsDiscardable, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.DiscardHand(tp, Card.IsDiscardable, 1, 1, REASON_COST + REASON_DISCARD, nil)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsType(TYPE_TUNER)
  end
  function s.rfilter(c)
  	return c:IsType(TYPE_SPELL + TYPE_TRAP) and c:IsAbleToHand()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	local ct = Duel.GetMatchingGroupCount(s.cfilter, tp, LOCATION_MZONE, LOCATION_MZONE, nil)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.rfilter, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, ct, nil)
  	end
  	local rg = Duel.GetMatchingGroup(s.rfilter, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, rg, ct, 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local ct = Duel.GetMatchingGroupCount(s.cfilter, tp, LOCATION_MZONE, LOCATION_MZONE, nil)
  	local rg = Duel.GetMatchingGroup(s.rfilter, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, nil)
  	if rg:GetCount() < ct then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RTOHAND)
  	local sg = rg:Select(tp, ct, ct, nil)
  	Duel.HintSelection(sg)
  	Duel.SendtoHand(sg, nil, REASON_EFFECT)
  end
  
  
source_text: A・O・J
  1ターンに1度、手札を1枚捨てて発動できる。
  フィールド上のチューナーの数だけ、フィールド上の魔法・罠カードを選んで持ち主の手札に戻す。
target_text: -- A・O・J
  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_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsDiscardable, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.DiscardHand(tp, Card.IsDiscardable, 1, 1, REASON_COST + REASON_DISCARD, nil)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsType(TYPE_TUNER)
  end
  function s.rfilter(c)
  	return c:IsType(TYPE_SPELL + TYPE_TRAP) and c:IsAbleToHand()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	local ct = Duel.GetMatchingGroupCount(s.cfilter, tp, LOCATION_MZONE, LOCATION_MZONE, nil)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.rfilter, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, ct, nil)
  	end
  	local rg = Duel.GetMatchingGroup(s.rfilter, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, rg, ct, 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local ct = Duel.GetMatchingGroupCount(s.cfilter, tp, LOCATION_MZONE, LOCATION_MZONE, nil)
  	local rg = Duel.GetMatchingGroup(s.rfilter, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, nil)
  	if rg:GetCount() < ct then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RTOHAND)
  	local sg = rg:Select(tp, ct, ct, nil)
  	Duel.HintSelection(sg)
  	Duel.SendtoHand(sg, nil, REASON_EFFECT)
  end
  
  