name: Voltanis
card_text: After 1 of your Counter Trap Cards has been activated and has resolved, you can Tribute all monsters you control to Special Summon this card. If this card is Special Summoned in this way, you can destroy cards your opponent controls up to the number of Fairy-Type monsters you Tributed.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--counter
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EVENT_CHAINING)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetOperation(s.chop1)
  	c:RegisterEffect(e1)
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EVENT_CHAIN_SOLVED)
  	e2:SetRange(LOCATION_HAND)
  	e2:SetOperation(s.chop2)
  	c:RegisterEffect(e2)
  	--special summon
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetProperty(EFFECT_FLAG_DELAY)
  	e3:SetCode(EVENT_CHAIN_END)
  	e3:SetRange(LOCATION_HAND)
  	e3:SetCondition(s.sumcon)
  	e3:SetCost(s.sumcost)
  	e3:SetTarget(s.sumtg)
  	e3:SetOperation(s.sumop)
  	c:RegisterEffect(e3)
  	e1:SetLabelObject(e3)
  	e2:SetLabelObject(e3)
  	--destroy
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 1))
  	e4:SetCategory(CATEGORY_DESTROY)
  	e4:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e4:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e4:SetProperty(EFFECT_FLAG_DELAY)
  	e4:SetCondition(s.descon)
  	e4:SetTarget(s.destg)
  	e4:SetOperation(s.desop)
  	c:RegisterEffect(e4)
  	e3:SetLabelObject(e4)
  end
  function s.chop1(e, tp, eg, ep, ev, re, r, rp)
  	e:GetLabelObject():SetLabel(0)
  end
  function s.chop2(e, tp, eg, ep, ev, re, r, rp)
  	if rp == 1 - tp or not re:IsHasType(EFFECT_TYPE_ACTIVATE) or not re:IsActiveType(TYPE_COUNTER) then
  		return
  	end
  	e:GetLabelObject():SetLabel(1)
  end
  function s.sumcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetLabel() == 1
  end
  function s.sumcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckReleaseGroup(tp, nil, 1, nil)
  	end
  	local g = Duel.GetReleaseGroup(tp)
  	local ct = g:FilterCount(Card.IsRace, nil, RACE_FAIRY)
  	aux.UseExtraReleaseCount(g, tp)
  	Duel.Release(g, REASON_COST)
  	e:GetLabelObject():SetLabel(ct)
  end
  function s.sumtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.sumop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) then
  		Duel.SpecialSummon(c, SUMMON_VALUE_SELF, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():GetSummonType() == SUMMON_TYPE_SPECIAL + SUMMON_VALUE_SELF
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(aux.TRUE, tp, 0, LOCATION_ONFIELD, 1, nil) and e:GetLabel() > 0
  	end
  	local g = Duel.GetMatchingGroup(aux.TRUE, tp, 0, LOCATION_ONFIELD, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(aux.TRUE, tp, 0, LOCATION_ONFIELD, nil)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local dg = g:Select(tp, 1, e:GetLabel(), nil)
  	Duel.HintSelection(dg)
  	Duel.Destroy(dg, REASON_EFFECT)
  end
  
  
source_text: Voltanis
  After 1 of your Counter Trap Cards has been activated and has resolved, you can Tribute all monsters you control to Special Summon this card. If this card is Special Summoned in this way, you can destroy cards your opponent controls up to the number of Fairy-Type monsters you Tributed.
target_text: -- Voltanis
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--counter
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EVENT_CHAINING)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetOperation(s.chop1)
  	c:RegisterEffect(e1)
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EVENT_CHAIN_SOLVED)
  	e2:SetRange(LOCATION_HAND)
  	e2:SetOperation(s.chop2)
  	c:RegisterEffect(e2)
  	--special summon
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetProperty(EFFECT_FLAG_DELAY)
  	e3:SetCode(EVENT_CHAIN_END)
  	e3:SetRange(LOCATION_HAND)
  	e3:SetCondition(s.sumcon)
  	e3:SetCost(s.sumcost)
  	e3:SetTarget(s.sumtg)
  	e3:SetOperation(s.sumop)
  	c:RegisterEffect(e3)
  	e1:SetLabelObject(e3)
  	e2:SetLabelObject(e3)
  	--destroy
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 1))
  	e4:SetCategory(CATEGORY_DESTROY)
  	e4:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e4:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e4:SetProperty(EFFECT_FLAG_DELAY)
  	e4:SetCondition(s.descon)
  	e4:SetTarget(s.destg)
  	e4:SetOperation(s.desop)
  	c:RegisterEffect(e4)
  	e3:SetLabelObject(e4)
  end
  function s.chop1(e, tp, eg, ep, ev, re, r, rp)
  	e:GetLabelObject():SetLabel(0)
  end
  function s.chop2(e, tp, eg, ep, ev, re, r, rp)
  	if rp == 1 - tp or not re:IsHasType(EFFECT_TYPE_ACTIVATE) or not re:IsActiveType(TYPE_COUNTER) then
  		return
  	end
  	e:GetLabelObject():SetLabel(1)
  end
  function s.sumcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetLabel() == 1
  end
  function s.sumcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckReleaseGroup(tp, nil, 1, nil)
  	end
  	local g = Duel.GetReleaseGroup(tp)
  	local ct = g:FilterCount(Card.IsRace, nil, RACE_FAIRY)
  	aux.UseExtraReleaseCount(g, tp)
  	Duel.Release(g, REASON_COST)
  	e:GetLabelObject():SetLabel(ct)
  end
  function s.sumtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.sumop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) then
  		Duel.SpecialSummon(c, SUMMON_VALUE_SELF, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():GetSummonType() == SUMMON_TYPE_SPECIAL + SUMMON_VALUE_SELF
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(aux.TRUE, tp, 0, LOCATION_ONFIELD, 1, nil) and e:GetLabel() > 0
  	end
  	local g = Duel.GetMatchingGroup(aux.TRUE, tp, 0, LOCATION_ONFIELD, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(aux.TRUE, tp, 0, LOCATION_ONFIELD, nil)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local dg = g:Select(tp, 1, e:GetLabel(), nil)
  	Duel.HintSelection(dg)
  	Duel.Destroy(dg, REASON_EFFECT)
  end
  
  