name: 光の召集
card_text: 1:自分の手札を全て捨てる。
  その後、この効果で墓地へ捨てられたカードの数だけ、自分の墓地から光属性モンスターを選んで手札に加える。
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_HANDES + CATEGORY_TOHAND)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.filter(c)
  	return c:IsAttribute(ATTRIBUTE_LIGHT) and c:IsAbleToHand()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		local hd = Duel.GetFieldGroupCount(tp, LOCATION_HAND, 0)
  		if e:GetHandler():IsLocation(LOCATION_HAND) then
  			hd = hd - 1
  		end
  		return hd > 0 and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_GRAVE, 0, hd, nil)
  	end
  	local sg = Duel.GetFieldGroup(tp, LOCATION_HAND, 0)
  	Duel.SetOperationInfo(0, CATEGORY_HANDES, sg, sg:GetCount(), 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, sg:GetCount(), tp, LOCATION_GRAVE)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local sg = Duel.GetFieldGroup(tp, LOCATION_HAND, 0)
  	Duel.SendtoGrave(sg, REASON_EFFECT + REASON_DISCARD)
  	local ct = sg:FilterCount(Card.IsLocation, nil, LOCATION_GRAVE)
  	local tg = Duel.GetMatchingGroup(s.filter, tp, LOCATION_GRAVE, 0, nil)
  	if ct > 0 and tg:GetCount() >= ct then
  		Duel.BreakEffect()
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  		local sel = tg:Select(tp, ct, ct, nil)
  		Duel.SendtoHand(sel, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, sel)
  	end
  end
  
  
source_text: 光の召集
  1:自分の手札を全て捨てる。
  その後、この効果で墓地へ捨てられたカードの数だけ、自分の墓地から光属性モンスターを選んで手札に加える。
target_text: -- 光の召集
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_HANDES + CATEGORY_TOHAND)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.filter(c)
  	return c:IsAttribute(ATTRIBUTE_LIGHT) and c:IsAbleToHand()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		local hd = Duel.GetFieldGroupCount(tp, LOCATION_HAND, 0)
  		if e:GetHandler():IsLocation(LOCATION_HAND) then
  			hd = hd - 1
  		end
  		return hd > 0 and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_GRAVE, 0, hd, nil)
  	end
  	local sg = Duel.GetFieldGroup(tp, LOCATION_HAND, 0)
  	Duel.SetOperationInfo(0, CATEGORY_HANDES, sg, sg:GetCount(), 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, sg:GetCount(), tp, LOCATION_GRAVE)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local sg = Duel.GetFieldGroup(tp, LOCATION_HAND, 0)
  	Duel.SendtoGrave(sg, REASON_EFFECT + REASON_DISCARD)
  	local ct = sg:FilterCount(Card.IsLocation, nil, LOCATION_GRAVE)
  	local tg = Duel.GetMatchingGroup(s.filter, tp, LOCATION_GRAVE, 0, nil)
  	if ct > 0 and tg:GetCount() >= ct then
  		Duel.BreakEffect()
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  		local sel = tg:Select(tp, ct, ct, nil)
  		Duel.SendtoHand(sel, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, sel)
  	end
  end
  
  