name: Allure
card_text: When this card is activated: You can add 1 "Allure Queen" monster or 1 "Allure Palace" from your Deck to your hand. Each "Allure Queen" monster you control gains ATK, equal to the ATK of the monsters equipped to it by its effect. You can send 1 other Spell/Trap you control to the GY; Special Summon as many "Allure Queen" monsters with different names as possible from your GY. You can only use this effect of "Allure Dance" once per turn. You can only activate 1 "Allure Dance" per turn.
external_ids: local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local CARD_ID_1 = 31322640 --Allure Palace
  local SETCARD_ID_0 = 0x3 --Allure
  
lua: local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local CARD_ID_1 = 31322640 --Allure Palace
  local SETCARD_ID_0 = 0x3 --Allure
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_1)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--update atk
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_UPDATE_ATTACK)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetTargetRange(LOCATION_MZONE, 0)
  	e2:SetTarget(s.atktg)
  	e2:SetValue(s.val)
  	c:RegisterEffect(e2)
  	--spsummon
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCountLimit(1, id + o)
  	e3:SetCost(s.spcost)
  	e3:SetTarget(s.sptg)
  	e3:SetOperation(s.spop)
  	c:RegisterEffect(e3)
  end
  function s.filter(c)
  	return (c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) or c:IsCode(CARD_ID_1)) and c:IsAbleToHand()
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_DECK, 0, nil)
  	if g:GetCount() > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 0)) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  		local sg = g:Select(tp, 1, 1, nil)
  		Duel.SendtoHand(sg, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, sg)
  	end
  end
  function s.atkfilter(c, code)
  	return c:IsFaceup() and bit.band(c:GetOriginalType(), TYPE_MONSTER) == TYPE_MONSTER and c:GetFlagEffect(code) ~= 0
  end
  function s.atktg(e, c)
  	return c:IsSetCard(SETCARD_ID_0)
  end
  function s.val(e, c)
  	local g = c:GetEquipGroup():Filter(s.atkfilter, nil, FLAG_ID_ALLURE_QUEEN)
  	if g:GetCount() > 0 then
  		return g:GetSum(Card.GetBaseAttack)
  	else
  		return 0
  	end
  end
  function s.spcfilter(c, tp)
  	return c:IsType(TYPE_SPELL + TYPE_TRAP) and c:IsAbleToGraveAsCost() and Duel.GetMZoneCount(tp, c) > 0
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.spcfilter, tp, LOCATION_ONFIELD, 0, 1, c, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.spcfilter, tp, LOCATION_ONFIELD, 0, 1, 1, c, tp)
  	Duel.SendtoGrave(g, REASON_COST)
  end
  function s.sfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.sfilter, tp, LOCATION_GRAVE, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_GRAVE)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(aux.NecroValleyFilter(s.sfilter), tp, LOCATION_GRAVE, 0, nil, e, tp)
  	local ft = math.min(Duel.GetLocationCount(tp, LOCATION_MZONE), g:GetClassCount(Card.GetCode))
  	if ft <= 0 then
  		return
  	end
  	if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  		ft = 1
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local sg = g:SelectSubGroup(tp, aux.dncheck, false, ft, ft)
  	if sg then
  		Duel.SpecialSummon(sg, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  
  
source_text: Allure
  When this card is activated: You can add 1 "Allure Queen" monster or 1 "Allure Palace" from your Deck to your hand. Each "Allure Queen" monster you control gains ATK, equal to the ATK of the monsters equipped to it by its effect. You can send 1 other Spell/Trap you control to the GY; Special Summon as many "Allure Queen" monsters with different names as possible from your GY. You can only use this effect of "Allure Dance" once per turn. You can only activate 1 "Allure Dance" per turn.
target_text: -- Allure
  local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local CARD_ID_1 = 31322640 --Allure Palace
  local SETCARD_ID_0 = 0x3 --Allure
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_1)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--update atk
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_UPDATE_ATTACK)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetTargetRange(LOCATION_MZONE, 0)
  	e2:SetTarget(s.atktg)
  	e2:SetValue(s.val)
  	c:RegisterEffect(e2)
  	--spsummon
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCountLimit(1, id + o)
  	e3:SetCost(s.spcost)
  	e3:SetTarget(s.sptg)
  	e3:SetOperation(s.spop)
  	c:RegisterEffect(e3)
  end
  function s.filter(c)
  	return (c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) or c:IsCode(CARD_ID_1)) and c:IsAbleToHand()
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_DECK, 0, nil)
  	if g:GetCount() > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 0)) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  		local sg = g:Select(tp, 1, 1, nil)
  		Duel.SendtoHand(sg, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, sg)
  	end
  end
  function s.atkfilter(c, code)
  	return c:IsFaceup() and bit.band(c:GetOriginalType(), TYPE_MONSTER) == TYPE_MONSTER and c:GetFlagEffect(code) ~= 0
  end
  function s.atktg(e, c)
  	return c:IsSetCard(SETCARD_ID_0)
  end
  function s.val(e, c)
  	local g = c:GetEquipGroup():Filter(s.atkfilter, nil, FLAG_ID_ALLURE_QUEEN)
  	if g:GetCount() > 0 then
  		return g:GetSum(Card.GetBaseAttack)
  	else
  		return 0
  	end
  end
  function s.spcfilter(c, tp)
  	return c:IsType(TYPE_SPELL + TYPE_TRAP) and c:IsAbleToGraveAsCost() and Duel.GetMZoneCount(tp, c) > 0
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.spcfilter, tp, LOCATION_ONFIELD, 0, 1, c, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.spcfilter, tp, LOCATION_ONFIELD, 0, 1, 1, c, tp)
  	Duel.SendtoGrave(g, REASON_COST)
  end
  function s.sfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.sfilter, tp, LOCATION_GRAVE, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_GRAVE)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(aux.NecroValleyFilter(s.sfilter), tp, LOCATION_GRAVE, 0, nil, e, tp)
  	local ft = math.min(Duel.GetLocationCount(tp, LOCATION_MZONE), g:GetClassCount(Card.GetCode))
  	if ft <= 0 then
  		return
  	end
  	if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  		ft = 1
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local sg = g:SelectSubGroup(tp, aux.dncheck, false, ft, ft)
  	if sg then
  		Duel.SpecialSummon(sg, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  
  