name: Thunderforce
card_text: This card's activation and effect cannot be negated. If you control a monster whose original name is "Slifer the Sky Dragon": Destroy as many face-up monsters your opponent controls as possible, then, if you activated this card during your Main Phase, you can apply the following effect.
  ● Draw cards equal to the number of monsters destroyed by this effect and sent to your opponent's GY, also you can only attack with 1 monster this turn.
  You can only activate 1 "Thunderforce Attack" per turn.
external_ids: local CARD_ID_0 = 10000020 --Slifer the Sky Dragon
  
lua: local CARD_ID_0 = 10000020 --Slifer the Sky Dragon
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DESTROY + CATEGORY_DRAW)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_INACTIVATE + EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_CAN_FORBIDDEN)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCondition(s.descon)
  	e1:SetTarget(s.destg)
  	e1:SetOperation(s.desop)
  	c:RegisterEffect(e1)
  end
  function s.actfilter(c)
  	return c:IsFaceup() and c:IsOriginalCodeRule(10000020)
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.actfilter, e:GetHandlerPlayer(), LOCATION_MZONE, 0, 1, nil)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsFaceup, tp, 0, LOCATION_MZONE, 1, nil)
  	end
  	local g = Duel.GetMatchingGroup(Card.IsFaceup, tp, 0, LOCATION_MZONE, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, g:GetCount(), 0, 0)
  	if g:GetCount() ~= 0 then
  		Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, g:GetCount())
  	end
  end
  function s.sgfilter(c, p)
  	return c:IsLocation(LOCATION_GRAVE) and c:IsControler(p)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(Card.IsFaceup, tp, 0, LOCATION_MZONE, nil)
  	Duel.Destroy(g, REASON_EFFECT)
  	local dc = Duel.GetOperatedGroup():FilterCount(s.sgfilter, nil, 1 - tp)
  	if dc ~= 0 and Duel.IsTurnPlayer(tp) and Duel.IsMainPhase() and Duel.IsPlayerCanDraw(tp, dc) and Duel.SelectYesNo(tp, aux.Stringid(id, 0)) then
  		Duel.BreakEffect()
  		Duel.Draw(tp, dc, REASON_EFFECT)
  		--cannot attack
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  		e1:SetCode(EFFECT_CANNOT_ATTACK_ANNOUNCE)
  		e1:SetTargetRange(LOCATION_MZONE, 0)
  		e1:SetCondition(s.atkcon)
  		e1:SetTarget(s.atktg)
  		e1:SetReset(RESET_PHASE + PHASE_END)
  		Duel.RegisterEffect(e1, tp)
  		--check
  		local e2 = Effect.CreateEffect(e:GetHandler())
  		e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e2:SetCode(EVENT_ATTACK_ANNOUNCE)
  		e2:SetReset(RESET_PHASE + PHASE_END)
  		e2:SetOperation(s.checkop)
  		e2:SetLabelObject(e1)
  		Duel.RegisterEffect(e2, tp)
  	end
  end
  function s.checkop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetFlagEffect(tp, id) ~= 0 then
  		return
  	end
  	local fid = eg:GetFirst():GetFieldID()
  	Duel.RegisterFlagEffect(tp, id, RESET_PHASE + PHASE_END, 0, 1)
  	e:GetLabelObject():SetLabel(fid)
  end
  function s.atkcon(e)
  	return Duel.GetFlagEffect(e:GetHandlerPlayer(), id) ~= 0
  end
  function s.atktg(e, c)
  	return c:GetFieldID() ~= e:GetLabel()
  end
  
  
source_text: Thunderforce
  This card's activation and effect cannot be negated. If you control a monster whose original name is "Slifer the Sky Dragon": Destroy as many face-up monsters your opponent controls as possible, then, if you activated this card during your Main Phase, you can apply the following effect.
  ● Draw cards equal to the number of monsters destroyed by this effect and sent to your opponent's GY, also you can only attack with 1 monster this turn.
  You can only activate 1 "Thunderforce Attack" per turn.
target_text: -- Thunderforce
  local CARD_ID_0 = 10000020 --Slifer the Sky Dragon
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DESTROY + CATEGORY_DRAW)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_INACTIVATE + EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_CAN_FORBIDDEN)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCondition(s.descon)
  	e1:SetTarget(s.destg)
  	e1:SetOperation(s.desop)
  	c:RegisterEffect(e1)
  end
  function s.actfilter(c)
  	return c:IsFaceup() and c:IsOriginalCodeRule(10000020)
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.actfilter, e:GetHandlerPlayer(), LOCATION_MZONE, 0, 1, nil)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsFaceup, tp, 0, LOCATION_MZONE, 1, nil)
  	end
  	local g = Duel.GetMatchingGroup(Card.IsFaceup, tp, 0, LOCATION_MZONE, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, g:GetCount(), 0, 0)
  	if g:GetCount() ~= 0 then
  		Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, g:GetCount())
  	end
  end
  function s.sgfilter(c, p)
  	return c:IsLocation(LOCATION_GRAVE) and c:IsControler(p)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(Card.IsFaceup, tp, 0, LOCATION_MZONE, nil)
  	Duel.Destroy(g, REASON_EFFECT)
  	local dc = Duel.GetOperatedGroup():FilterCount(s.sgfilter, nil, 1 - tp)
  	if dc ~= 0 and Duel.IsTurnPlayer(tp) and Duel.IsMainPhase() and Duel.IsPlayerCanDraw(tp, dc) and Duel.SelectYesNo(tp, aux.Stringid(id, 0)) then
  		Duel.BreakEffect()
  		Duel.Draw(tp, dc, REASON_EFFECT)
  		--cannot attack
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  		e1:SetCode(EFFECT_CANNOT_ATTACK_ANNOUNCE)
  		e1:SetTargetRange(LOCATION_MZONE, 0)
  		e1:SetCondition(s.atkcon)
  		e1:SetTarget(s.atktg)
  		e1:SetReset(RESET_PHASE + PHASE_END)
  		Duel.RegisterEffect(e1, tp)
  		--check
  		local e2 = Effect.CreateEffect(e:GetHandler())
  		e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e2:SetCode(EVENT_ATTACK_ANNOUNCE)
  		e2:SetReset(RESET_PHASE + PHASE_END)
  		e2:SetOperation(s.checkop)
  		e2:SetLabelObject(e1)
  		Duel.RegisterEffect(e2, tp)
  	end
  end
  function s.checkop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetFlagEffect(tp, id) ~= 0 then
  		return
  	end
  	local fid = eg:GetFirst():GetFieldID()
  	Duel.RegisterFlagEffect(tp, id, RESET_PHASE + PHASE_END, 0, 1)
  	e:GetLabelObject():SetLabel(fid)
  end
  function s.atkcon(e)
  	return Duel.GetFlagEffect(e:GetHandlerPlayer(), id) ~= 0
  end
  function s.atktg(e, c)
  	return c:GetFieldID() ~= e:GetLabel()
  end
  
  