name: Appliancer
card_text: Banish as many "Appliancer" Link Monsters from your Main Monster Zone as possible, then you can Special Summon your banished "Appliancer" Link Monsters up to the number banished by this effect. During your Main Phase, if this card is in your GY, except the turn it was sent there: You can banish 1 other "Appliancer" Spell/Trap from your GY; add this card to your hand. You can only use each effect of "Appliancer Conversion" once per turn.
external_ids: local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local SETCARD_ID_0 = 0x14b --Appliancer
  
lua: local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local SETCARD_ID_0 = 0x14b --Appliancer
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_REMOVE + CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMING_END_PHASE)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--to hand
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_TOHAND)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_GRAVE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCondition(aux.exccon)
  	e2:SetCost(s.thcost)
  	e2:SetTarget(s.thtg)
  	e2:SetOperation(s.thop)
  	c:RegisterEffect(e2)
  end
  function s.filter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_LINK) and c:GetSequence() < 5 and c:IsAbleToRemove()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_MZONE, 0, nil)
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, g, g:GetCount(), 0, 0)
  end
  function s.spfilter(c, e, tp)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_LINK) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_MZONE, 0, nil)
  	if Duel.Remove(g, POS_FACEUP, REASON_EFFECT) ~= 0 then
  		local ct = Duel.GetOperatedGroup():Filter(Card.IsLocation, nil, LOCATION_REMOVED):GetCount()
  		local sg = Duel.GetMatchingGroup(s.spfilter, tp, LOCATION_REMOVED, 0, nil, e, tp)
  		local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  		if ft > 1 and Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  			ft = 1
  		end
  		ct = math.min(ct, ft)
  		if ct > 0 and sg:GetCount() > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 2)) then
  			Duel.BreakEffect()
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  			local tg = sg:Select(tp, 1, ct, nil)
  			Duel.SpecialSummon(tg, 0, tp, tp, false, false, POS_FACEUP)
  		end
  	end
  end
  function s.costfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_SPELL + TYPE_TRAP) and c:IsAbleToRemoveAsCost()
  end
  function s.thcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.costfilter, tp, LOCATION_GRAVE, 0, 1, c)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectMatchingCard(tp, s.costfilter, tp, LOCATION_GRAVE, 0, 1, 1, c)
  	Duel.Remove(g, POS_FACEUP, REASON_COST)
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsAbleToHand()
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, e:GetHandler(), 1, 0, 0)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) then
  		Duel.SendtoHand(c, nil, REASON_EFFECT)
  	end
  end
  
  
source_text: Appliancer
  Banish as many "Appliancer" Link Monsters from your Main Monster Zone as possible, then you can Special Summon your banished "Appliancer" Link Monsters up to the number banished by this effect. During your Main Phase, if this card is in your GY, except the turn it was sent there: You can banish 1 other "Appliancer" Spell/Trap from your GY; add this card to your hand. You can only use each effect of "Appliancer Conversion" once per turn.
target_text: -- Appliancer
  local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local SETCARD_ID_0 = 0x14b --Appliancer
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_REMOVE + CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMING_END_PHASE)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--to hand
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_TOHAND)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_GRAVE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCondition(aux.exccon)
  	e2:SetCost(s.thcost)
  	e2:SetTarget(s.thtg)
  	e2:SetOperation(s.thop)
  	c:RegisterEffect(e2)
  end
  function s.filter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_LINK) and c:GetSequence() < 5 and c:IsAbleToRemove()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_MZONE, 0, nil)
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, g, g:GetCount(), 0, 0)
  end
  function s.spfilter(c, e, tp)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_LINK) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_MZONE, 0, nil)
  	if Duel.Remove(g, POS_FACEUP, REASON_EFFECT) ~= 0 then
  		local ct = Duel.GetOperatedGroup():Filter(Card.IsLocation, nil, LOCATION_REMOVED):GetCount()
  		local sg = Duel.GetMatchingGroup(s.spfilter, tp, LOCATION_REMOVED, 0, nil, e, tp)
  		local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  		if ft > 1 and Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  			ft = 1
  		end
  		ct = math.min(ct, ft)
  		if ct > 0 and sg:GetCount() > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 2)) then
  			Duel.BreakEffect()
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  			local tg = sg:Select(tp, 1, ct, nil)
  			Duel.SpecialSummon(tg, 0, tp, tp, false, false, POS_FACEUP)
  		end
  	end
  end
  function s.costfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_SPELL + TYPE_TRAP) and c:IsAbleToRemoveAsCost()
  end
  function s.thcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.costfilter, tp, LOCATION_GRAVE, 0, 1, c)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectMatchingCard(tp, s.costfilter, tp, LOCATION_GRAVE, 0, 1, 1, c)
  	Duel.Remove(g, POS_FACEUP, REASON_COST)
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsAbleToHand()
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, e:GetHandler(), 1, 0, 0)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) then
  		Duel.SendtoHand(c, nil, REASON_EFFECT)
  	end
  end
  
  