name: Demise,
card_text: You can Ritual Summon this card with "Cycle of the World". This card's name becomes "Demise, King of Armageddon" while in the hand or on the field. While this Ritual Summoned card is on the field, your Ritual Monsters cannot be destroyed by battle. If all monsters used to Ritual Summon this card were Ritual Monsters, you do not pay LP to activate its effects. Once per turn: You can pay 2000 LP; destroy as many other cards on the field as possible, and if you do, inflict 200 damage to your opponent for each destroyed card they controlled.
external_ids: local CARD_ID_0 = 72426662 --Demise, King of Armageddon
  
lua: local CARD_ID_0 = 72426662 --Demise, King of Armageddon
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--code
  	aux.EnableChangeCode(c, CARD_ID_0, LOCATION_MZONE + LOCATION_HAND)
  	--indes
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetTargetRange(LOCATION_MZONE, 0)
  	e2:SetCondition(s.indcon)
  	e2:SetTarget(s.indtg)
  	e2:SetValue(1)
  	c:RegisterEffect(e2)
  	--cost change
  	local e0 = Effect.CreateEffect(c)
  	e0:SetType(EFFECT_TYPE_FIELD)
  	e0:SetCode(EFFECT_LPCOST_CHANGE)
  	e0:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e0:SetRange(LOCATION_MZONE)
  	e0:SetTargetRange(1, 1)
  	e0:SetCondition(s.costcon)
  	e0:SetValue(s.costval)
  	c:RegisterEffect(e0)
  	--destroy
  	local e3 = Effect.CreateEffect(c)
  	e3:SetCategory(CATEGORY_DESTROY + CATEGORY_DAMAGE)
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1)
  	e3:SetCost(s.descost)
  	e3:SetTarget(s.destg)
  	e3:SetOperation(s.desop)
  	c:RegisterEffect(e3)
  	--material check
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e4:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e4:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e4:SetCondition(s.matcon)
  	e4:SetOperation(s.matop)
  	c:RegisterEffect(e4)
  	local e5 = Effect.CreateEffect(c)
  	e5:SetType(EFFECT_TYPE_SINGLE)
  	e5:SetCode(EFFECT_MATERIAL_CHECK)
  	e5:SetValue(s.valcheck)
  	e5:SetLabelObject(e4)
  	c:RegisterEffect(e5)
  end
  function s.indcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_RITUAL)
  end
  function s.indtg(e, c)
  	return c:IsType(TYPE_RITUAL)
  end
  function s.mfilter(c)
  	return not c:IsType(TYPE_RITUAL)
  end
  function s.costcon(e)
  	return e:GetHandler():GetFlagEffect(id) > 0
  end
  function s.costval(e, re, rp, val)
  	if re and re:IsActivated() and re:GetHandler() == e:GetHandler() then
  		return 0
  	else
  		return val
  	end
  end
  function s.descost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckLPCost(tp, 2000)
  	end
  	Duel.PayLPCost(tp, 2000)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, e:GetHandler())
  	end
  	local g = Duel.GetMatchingGroup(aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, e:GetHandler())
  	local ct = g:FilterCount(Card.IsControler, nil, 1 - tp)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, g:GetCount(), 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, ct * 200)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, aux.ExceptThisCard(e))
  	Duel.Destroy(g, REASON_EFFECT)
  	local ct = Duel.GetOperatedGroup():FilterCount(Card.IsControler, nil, 1 - tp)
  	if ct > 0 then
  		Duel.Damage(1 - tp, ct * 200, REASON_EFFECT)
  	end
  end
  function s.matcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_RITUAL) and e:GetLabel() == 1
  end
  function s.matop(e, tp, eg, ep, ev, re, r, rp)
  	e:GetHandler():RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD, 0, 1)
  end
  function s.valcheck(e, c)
  	local g = c:GetMaterial()
  	if g:GetCount() > 0 and not g:IsExists(s.mfilter, 1, nil) then
  		e:GetLabelObject():SetLabel(1)
  	else
  		e:GetLabelObject():SetLabel(0)
  	end
  end
  
  
source_text: Demise,
  You can Ritual Summon this card with "Cycle of the World". This card's name becomes "Demise, King of Armageddon" while in the hand or on the field. While this Ritual Summoned card is on the field, your Ritual Monsters cannot be destroyed by battle. If all monsters used to Ritual Summon this card were Ritual Monsters, you do not pay LP to activate its effects. Once per turn: You can pay 2000 LP; destroy as many other cards on the field as possible, and if you do, inflict 200 damage to your opponent for each destroyed card they controlled.
target_text: -- Demise,
  local CARD_ID_0 = 72426662 --Demise, King of Armageddon
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--code
  	aux.EnableChangeCode(c, CARD_ID_0, LOCATION_MZONE + LOCATION_HAND)
  	--indes
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetTargetRange(LOCATION_MZONE, 0)
  	e2:SetCondition(s.indcon)
  	e2:SetTarget(s.indtg)
  	e2:SetValue(1)
  	c:RegisterEffect(e2)
  	--cost change
  	local e0 = Effect.CreateEffect(c)
  	e0:SetType(EFFECT_TYPE_FIELD)
  	e0:SetCode(EFFECT_LPCOST_CHANGE)
  	e0:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e0:SetRange(LOCATION_MZONE)
  	e0:SetTargetRange(1, 1)
  	e0:SetCondition(s.costcon)
  	e0:SetValue(s.costval)
  	c:RegisterEffect(e0)
  	--destroy
  	local e3 = Effect.CreateEffect(c)
  	e3:SetCategory(CATEGORY_DESTROY + CATEGORY_DAMAGE)
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1)
  	e3:SetCost(s.descost)
  	e3:SetTarget(s.destg)
  	e3:SetOperation(s.desop)
  	c:RegisterEffect(e3)
  	--material check
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e4:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e4:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e4:SetCondition(s.matcon)
  	e4:SetOperation(s.matop)
  	c:RegisterEffect(e4)
  	local e5 = Effect.CreateEffect(c)
  	e5:SetType(EFFECT_TYPE_SINGLE)
  	e5:SetCode(EFFECT_MATERIAL_CHECK)
  	e5:SetValue(s.valcheck)
  	e5:SetLabelObject(e4)
  	c:RegisterEffect(e5)
  end
  function s.indcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_RITUAL)
  end
  function s.indtg(e, c)
  	return c:IsType(TYPE_RITUAL)
  end
  function s.mfilter(c)
  	return not c:IsType(TYPE_RITUAL)
  end
  function s.costcon(e)
  	return e:GetHandler():GetFlagEffect(id) > 0
  end
  function s.costval(e, re, rp, val)
  	if re and re:IsActivated() and re:GetHandler() == e:GetHandler() then
  		return 0
  	else
  		return val
  	end
  end
  function s.descost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckLPCost(tp, 2000)
  	end
  	Duel.PayLPCost(tp, 2000)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, e:GetHandler())
  	end
  	local g = Duel.GetMatchingGroup(aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, e:GetHandler())
  	local ct = g:FilterCount(Card.IsControler, nil, 1 - tp)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, g:GetCount(), 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, ct * 200)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, aux.ExceptThisCard(e))
  	Duel.Destroy(g, REASON_EFFECT)
  	local ct = Duel.GetOperatedGroup():FilterCount(Card.IsControler, nil, 1 - tp)
  	if ct > 0 then
  		Duel.Damage(1 - tp, ct * 200, REASON_EFFECT)
  	end
  end
  function s.matcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_RITUAL) and e:GetLabel() == 1
  end
  function s.matop(e, tp, eg, ep, ev, re, r, rp)
  	e:GetHandler():RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD, 0, 1)
  end
  function s.valcheck(e, c)
  	local g = c:GetMaterial()
  	if g:GetCount() > 0 and not g:IsExists(s.mfilter, 1, nil) then
  		e:GetLabelObject():SetLabel(1)
  	else
  		e:GetLabelObject():SetLabel(0)
  	end
  end
  
  