name: Yosenju
card_text: If you control 3 or more "Yosenju" Monster Cards with different names: Return as many "Yosenju" Monster Cards you control to the hand as possible, then you can draw until you have 5 cards in your hand. You can only activate 1 "Yosenju Wind Worship" per turn.
external_ids: local SETCARD_ID_0 = 0xb3 --Yosenju
  
lua: local SETCARD_ID_0 = 0xb3 --Yosenju
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_DRAW)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:GetOriginalType() & TYPE_MONSTER ~= 0
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.cfilter, tp, LOCATION_ONFIELD, 0, nil)
  	return g:GetClassCount(Card.GetCode) >= 3
  end
  function s.filter(c)
  	return s.cfilter(c) and c:IsAbleToHand()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_ONFIELD, 0, 1, nil)
  	end
  	local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_ONFIELD, 0, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g, g:GetCount(), 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local sg = Duel.GetMatchingGroup(s.filter, tp, LOCATION_ONFIELD, 0, nil)
  	if Duel.SendtoHand(sg, nil, REASON_EFFECT) > 0 then
  		local ct = 5 - Duel.GetFieldGroupCount(tp, LOCATION_HAND, 0)
  		if ct > 0 and Duel.IsPlayerCanDraw(tp, ct) and Duel.SelectYesNo(tp, aux.Stringid(id, 0)) then
  			Duel.BreakEffect()
  			Duel.Draw(tp, ct, REASON_EFFECT)
  		end
  	end
  end
  
  
source_text: Yosenju
  If you control 3 or more "Yosenju" Monster Cards with different names: Return as many "Yosenju" Monster Cards you control to the hand as possible, then you can draw until you have 5 cards in your hand. You can only activate 1 "Yosenju Wind Worship" per turn.
target_text: -- Yosenju
  local SETCARD_ID_0 = 0xb3 --Yosenju
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_DRAW)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:GetOriginalType() & TYPE_MONSTER ~= 0
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.cfilter, tp, LOCATION_ONFIELD, 0, nil)
  	return g:GetClassCount(Card.GetCode) >= 3
  end
  function s.filter(c)
  	return s.cfilter(c) and c:IsAbleToHand()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_ONFIELD, 0, 1, nil)
  	end
  	local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_ONFIELD, 0, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g, g:GetCount(), 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local sg = Duel.GetMatchingGroup(s.filter, tp, LOCATION_ONFIELD, 0, nil)
  	if Duel.SendtoHand(sg, nil, REASON_EFFECT) > 0 then
  		local ct = 5 - Duel.GetFieldGroupCount(tp, LOCATION_HAND, 0)
  		if ct > 0 and Duel.IsPlayerCanDraw(tp, ct) and Duel.SelectYesNo(tp, aux.Stringid(id, 0)) then
  			Duel.BreakEffect()
  			Duel.Draw(tp, ct, REASON_EFFECT)
  		end
  	end
  end
  
  