name: Runick
card_text: Activate 1 of these effects, but skip your next Battle Phase after activation;
  ● Banish cards from the top of your opponent's Deck, up to the number of cards they control.
  ● Special Summon 1 "Runick" monster from your Extra Deck to the Extra Monster Zone.
  You can only activate 1 "Runick Smiting Storm" per turn.
external_ids: local SETCARD_ID_0 = 0x17f --Runick
  
lua: local SETCARD_ID_0 = 0x17f --Runick
  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)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--spsummon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_ACTIVATE)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetFieldGroupCount(tp, 0, LOCATION_ONFIELD) > 0 and Duel.GetDecktopGroup(1 - tp, 1):FilterCount(Card.IsAbleToRemove, nil) > 0
  	end
  	Duel.Hint(HINT_OPSELECTED, 1 - tp, e:GetDescription())
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, nil, 1, 1 - tp, LOCATION_DECK)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local ct1 = Duel.GetFieldGroupCount(tp, 0, LOCATION_ONFIELD)
  	local ct2 = Duel.GetDecktopGroup(1 - tp, ct1):FilterCount(Card.IsAbleToRemove, nil)
  	if ct1 > 0 and ct2 > 0 then
  		local num = {}
  		local i = 1
  		while i <= ct1 and i <= ct2 do
  			num[i] = i
  			i = i + 1
  		end
  		Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 2))
  		local ct = Duel.AnnounceNumber(tp, table.unpack(num))
  		local g = Duel.GetDecktopGroup(1 - tp, ct)
  		Duel.DisableShuffleCheck()
  		Duel.Remove(g, POS_FACEUP, REASON_EFFECT)
  	end
  	s.skipop(e, tp)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false) and Duel.GetLocationCountFromEx(tp, tp, nil, c, 0x60) > 0
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_EXTRA, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_OPSELECTED, 1 - tp, e:GetDescription())
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_EXTRA)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_EXTRA, 0, 1, 1, nil, e, tp)
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP, 0x60)
  	end
  	s.skipop(e, tp)
  end
  function s.skipop(e, tp)
  	if e:IsHasType(EFFECT_TYPE_ACTIVATE) then
  		local ph = Duel.GetCurrentPhase()
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetCode(EFFECT_SKIP_BP)
  		e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_OATH)
  		e1:SetTargetRange(1, 0)
  		if Duel.GetTurnPlayer() == tp and ph > PHASE_MAIN1 and ph < PHASE_MAIN2 then
  			e1:SetLabel(Duel.GetTurnCount())
  			e1:SetCondition(s.skipcon)
  			e1:SetReset(RESET_PHASE + PHASE_BATTLE + RESET_SELF_TURN, 2)
  		else
  			e1:SetReset(RESET_PHASE + PHASE_BATTLE + RESET_SELF_TURN, 1)
  		end
  		Duel.RegisterEffect(e1, tp)
  	end
  end
  function s.skipcon(e)
  	return Duel.GetTurnCount() ~= e:GetLabel()
  end
  
  
source_text: Runick
  Activate 1 of these effects, but skip your next Battle Phase after activation;
  ● Banish cards from the top of your opponent's Deck, up to the number of cards they control.
  ● Special Summon 1 "Runick" monster from your Extra Deck to the Extra Monster Zone.
  You can only activate 1 "Runick Smiting Storm" per turn.
target_text: -- Runick
  local SETCARD_ID_0 = 0x17f --Runick
  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)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--spsummon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_ACTIVATE)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetFieldGroupCount(tp, 0, LOCATION_ONFIELD) > 0 and Duel.GetDecktopGroup(1 - tp, 1):FilterCount(Card.IsAbleToRemove, nil) > 0
  	end
  	Duel.Hint(HINT_OPSELECTED, 1 - tp, e:GetDescription())
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, nil, 1, 1 - tp, LOCATION_DECK)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local ct1 = Duel.GetFieldGroupCount(tp, 0, LOCATION_ONFIELD)
  	local ct2 = Duel.GetDecktopGroup(1 - tp, ct1):FilterCount(Card.IsAbleToRemove, nil)
  	if ct1 > 0 and ct2 > 0 then
  		local num = {}
  		local i = 1
  		while i <= ct1 and i <= ct2 do
  			num[i] = i
  			i = i + 1
  		end
  		Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 2))
  		local ct = Duel.AnnounceNumber(tp, table.unpack(num))
  		local g = Duel.GetDecktopGroup(1 - tp, ct)
  		Duel.DisableShuffleCheck()
  		Duel.Remove(g, POS_FACEUP, REASON_EFFECT)
  	end
  	s.skipop(e, tp)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false) and Duel.GetLocationCountFromEx(tp, tp, nil, c, 0x60) > 0
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_EXTRA, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_OPSELECTED, 1 - tp, e:GetDescription())
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_EXTRA)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_EXTRA, 0, 1, 1, nil, e, tp)
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP, 0x60)
  	end
  	s.skipop(e, tp)
  end
  function s.skipop(e, tp)
  	if e:IsHasType(EFFECT_TYPE_ACTIVATE) then
  		local ph = Duel.GetCurrentPhase()
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetCode(EFFECT_SKIP_BP)
  		e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_OATH)
  		e1:SetTargetRange(1, 0)
  		if Duel.GetTurnPlayer() == tp and ph > PHASE_MAIN1 and ph < PHASE_MAIN2 then
  			e1:SetLabel(Duel.GetTurnCount())
  			e1:SetCondition(s.skipcon)
  			e1:SetReset(RESET_PHASE + PHASE_BATTLE + RESET_SELF_TURN, 2)
  		else
  			e1:SetReset(RESET_PHASE + PHASE_BATTLE + RESET_SELF_TURN, 1)
  		end
  		Duel.RegisterEffect(e1, tp)
  	end
  end
  function s.skipcon(e)
  	return Duel.GetTurnCount() ~= e:GetLabel()
  end
  
  