name: Danger!
card_text: When your "Danger!" monster is destroyed by battle with an opponent's monster: You can destroy that opponent's monster. You can banish 3 "Danger!" Spells/Traps with different names from your GY; destroy all cards on the field, also you cannot Special Summon monsters for the rest of this turn, except "Danger!" monsters. You can only use this effect of "Danger! Disturbance! Disorder!" once per turn.
external_ids: local SETCARD_ID_0 = 0x11e --Danger!
  
lua: local SETCARD_ID_0 = 0x11e --Danger!
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--destroy
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_DESTROY)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_BATTLE_DESTROYED)
  	e2:SetRange(LOCATION_FZONE)
  	e2:SetCondition(s.bdcon)
  	e2:SetTarget(s.bdtg)
  	e2:SetOperation(s.bdop)
  	c:RegisterEffect(e2)
  	--destroy all
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_DESTROY)
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetRange(LOCATION_FZONE)
  	e3:SetCountLimit(1, id)
  	e3:SetCost(s.descost)
  	e3:SetTarget(s.destg)
  	e3:SetOperation(s.desop)
  	c:RegisterEffect(e3)
  end
  function s.cfilter(c, tp)
  	local rc = c:GetReasonCard()
  	return c:IsReason(REASON_BATTLE) and c:IsPreviousControler(tp) and c:IsSetCard(SETCARD_ID_0) and rc and rc:IsControler(1 - tp) and rc:IsRelateToBattle()
  end
  function s.bdcon(e, tp, eg, ep, ev, re, r, rp)
  	local dc = eg:Filter(s.cfilter, nil, tp):GetFirst()
  	if dc then
  		e:SetLabelObject(dc:GetReasonCard())
  		return true
  	else
  		return false
  	end
  end
  function s.bdtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, e:GetLabelObject(), 1, 0, 0)
  end
  function s.bdop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = e:GetLabelObject()
  	if tc and tc:IsRelateToBattle() then
  		Duel.Destroy(tc, REASON_EFFECT)
  	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.descost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local g = Duel.GetMatchingGroup(s.costfilter, tp, LOCATION_GRAVE, 0, nil)
  	if chk == 0 then
  		return g:GetClassCount(Card.GetCode) >= 3
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local rg = g:SelectSubGroup(tp, aux.dncheck, false, 3, 3)
  	Duel.Remove(rg, POS_FACEUP, REASON_COST)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(nil, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, nil)
  	end
  	local g = Duel.GetMatchingGroup(nil, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, g:GetCount(), 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(nil, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, nil)
  	Duel.Destroy(g, REASON_EFFECT)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetTargetRange(1, 0)
  	e1:SetTarget(s.splimit)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.splimit(e, c, sump, sumtype, sumpos, targetp, se)
  	return not c:IsSetCard(SETCARD_ID_0)
  end
  
  
source_text: Danger!
  When your "Danger!" monster is destroyed by battle with an opponent's monster: You can destroy that opponent's monster. You can banish 3 "Danger!" Spells/Traps with different names from your GY; destroy all cards on the field, also you cannot Special Summon monsters for the rest of this turn, except "Danger!" monsters. You can only use this effect of "Danger! Disturbance! Disorder!" once per turn.
target_text: -- Danger!
  local SETCARD_ID_0 = 0x11e --Danger!
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--destroy
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_DESTROY)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_BATTLE_DESTROYED)
  	e2:SetRange(LOCATION_FZONE)
  	e2:SetCondition(s.bdcon)
  	e2:SetTarget(s.bdtg)
  	e2:SetOperation(s.bdop)
  	c:RegisterEffect(e2)
  	--destroy all
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_DESTROY)
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetRange(LOCATION_FZONE)
  	e3:SetCountLimit(1, id)
  	e3:SetCost(s.descost)
  	e3:SetTarget(s.destg)
  	e3:SetOperation(s.desop)
  	c:RegisterEffect(e3)
  end
  function s.cfilter(c, tp)
  	local rc = c:GetReasonCard()
  	return c:IsReason(REASON_BATTLE) and c:IsPreviousControler(tp) and c:IsSetCard(SETCARD_ID_0) and rc and rc:IsControler(1 - tp) and rc:IsRelateToBattle()
  end
  function s.bdcon(e, tp, eg, ep, ev, re, r, rp)
  	local dc = eg:Filter(s.cfilter, nil, tp):GetFirst()
  	if dc then
  		e:SetLabelObject(dc:GetReasonCard())
  		return true
  	else
  		return false
  	end
  end
  function s.bdtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, e:GetLabelObject(), 1, 0, 0)
  end
  function s.bdop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = e:GetLabelObject()
  	if tc and tc:IsRelateToBattle() then
  		Duel.Destroy(tc, REASON_EFFECT)
  	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.descost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local g = Duel.GetMatchingGroup(s.costfilter, tp, LOCATION_GRAVE, 0, nil)
  	if chk == 0 then
  		return g:GetClassCount(Card.GetCode) >= 3
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local rg = g:SelectSubGroup(tp, aux.dncheck, false, 3, 3)
  	Duel.Remove(rg, POS_FACEUP, REASON_COST)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(nil, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, nil)
  	end
  	local g = Duel.GetMatchingGroup(nil, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, g:GetCount(), 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(nil, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, nil)
  	Duel.Destroy(g, REASON_EFFECT)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetTargetRange(1, 0)
  	e1:SetTarget(s.splimit)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.splimit(e, c, sump, sumtype, sumpos, targetp, se)
  	return not c:IsSetCard(SETCARD_ID_0)
  end
  
  