name: The
card_text: 3 DARK Fairy monsters
  Your opponent cannot target Fairy monsters you control with card effects. You can only use 1 of the following effects of "The First Darklord" per turn, and only once that turn.
  ● If this card is Fusion Summoned using "Darklord Morningstar" as material: You can destroy all cards your opponent controls.
  ● During the Main Phase (Quick Effect): You can pay 1000 LP; Special Summon 1 Fairy monster from your hand or GY in Defense Position.
external_ids: local CARD_ID_0 = 25451652 --Darklord Morningstar
  
lua: local CARD_ID_0 = 25451652 --Darklord Morningstar
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--fusion material
  	c:EnableReviveLimit()
  	aux.AddFusionProcFunRep(c, s.ffilter, 3, true)
  	--destroy
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DESTROY)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.descon)
  	e1:SetTarget(s.destg)
  	e1:SetOperation(s.desop)
  	c:RegisterEffect(e1)
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_MATERIAL_CHECK)
  	e2:SetValue(s.valcheck)
  	e2:SetLabelObject(e1)
  	c:RegisterEffect(e2)
  	--cannot be target
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  	e3:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetTargetRange(LOCATION_MZONE, 0)
  	e3:SetTarget(aux.TargetBoolFunction(Card.IsRace, RACE_FAIRY))
  	e3:SetValue(aux.tgoval)
  	c:RegisterEffect(e3)
  	--spsummon
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 1))
  	e4:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e4:SetType(EFFECT_TYPE_QUICK_O)
  	e4:SetCode(EVENT_FREE_CHAIN)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_MAIN_END)
  	e4:SetCountLimit(1, id)
  	e4:SetCondition(s.spcon)
  	e4:SetCost(s.spcost)
  	e4:SetTarget(s.sptg)
  	e4:SetOperation(s.spop)
  	c:RegisterEffect(e4)
  end
  function s.ffilter(c)
  	return c:IsFusionAttribute(ATTRIBUTE_DARK) and c:IsRace(RACE_FAIRY)
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetLabel() == 1 and e:GetHandler():IsSummonType(SUMMON_TYPE_FUSION)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local g = Duel.GetMatchingGroup(aux.TRUE, tp, 0, LOCATION_ONFIELD, nil)
  	if chk == 0 then
  		return g:GetCount() > 0
  	end
  	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(aux.TRUE, tp, 0, LOCATION_ONFIELD, nil)
  	if g:GetCount() > 0 then
  		Duel.Destroy(g, REASON_EFFECT)
  	end
  end
  function s.valcheck(e, c)
  	local g = c:GetMaterial()
  	if g:IsExists(Card.IsFusionCode, 1, nil, CARD_ID_0) then
  		e:GetLabelObject():SetLabel(1)
  	else
  		e:GetLabelObject():SetLabel(0)
  	end
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetCurrentPhase() == PHASE_MAIN1 or Duel.GetCurrentPhase() == PHASE_MAIN2
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckLPCost(tp, 1000)
  	end
  	Duel.PayLPCost(tp, 1000)
  end
  function s.spfilter(c, e, tp)
  	return c:IsRace(RACE_FAIRY) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_DEFENSE)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_HAND + LOCATION_GRAVE, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND + LOCATION_GRAVE)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.spfilter), tp, LOCATION_HAND + LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP_DEFENSE)
  	end
  end
  
  
source_text: The
  3 DARK Fairy monsters
  Your opponent cannot target Fairy monsters you control with card effects. You can only use 1 of the following effects of "The First Darklord" per turn, and only once that turn.
  ● If this card is Fusion Summoned using "Darklord Morningstar" as material: You can destroy all cards your opponent controls.
  ● During the Main Phase (Quick Effect): You can pay 1000 LP; Special Summon 1 Fairy monster from your hand or GY in Defense Position.
target_text: -- The
  local CARD_ID_0 = 25451652 --Darklord Morningstar
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--fusion material
  	c:EnableReviveLimit()
  	aux.AddFusionProcFunRep(c, s.ffilter, 3, true)
  	--destroy
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DESTROY)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.descon)
  	e1:SetTarget(s.destg)
  	e1:SetOperation(s.desop)
  	c:RegisterEffect(e1)
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_MATERIAL_CHECK)
  	e2:SetValue(s.valcheck)
  	e2:SetLabelObject(e1)
  	c:RegisterEffect(e2)
  	--cannot be target
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  	e3:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetTargetRange(LOCATION_MZONE, 0)
  	e3:SetTarget(aux.TargetBoolFunction(Card.IsRace, RACE_FAIRY))
  	e3:SetValue(aux.tgoval)
  	c:RegisterEffect(e3)
  	--spsummon
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 1))
  	e4:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e4:SetType(EFFECT_TYPE_QUICK_O)
  	e4:SetCode(EVENT_FREE_CHAIN)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_MAIN_END)
  	e4:SetCountLimit(1, id)
  	e4:SetCondition(s.spcon)
  	e4:SetCost(s.spcost)
  	e4:SetTarget(s.sptg)
  	e4:SetOperation(s.spop)
  	c:RegisterEffect(e4)
  end
  function s.ffilter(c)
  	return c:IsFusionAttribute(ATTRIBUTE_DARK) and c:IsRace(RACE_FAIRY)
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetLabel() == 1 and e:GetHandler():IsSummonType(SUMMON_TYPE_FUSION)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local g = Duel.GetMatchingGroup(aux.TRUE, tp, 0, LOCATION_ONFIELD, nil)
  	if chk == 0 then
  		return g:GetCount() > 0
  	end
  	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(aux.TRUE, tp, 0, LOCATION_ONFIELD, nil)
  	if g:GetCount() > 0 then
  		Duel.Destroy(g, REASON_EFFECT)
  	end
  end
  function s.valcheck(e, c)
  	local g = c:GetMaterial()
  	if g:IsExists(Card.IsFusionCode, 1, nil, CARD_ID_0) then
  		e:GetLabelObject():SetLabel(1)
  	else
  		e:GetLabelObject():SetLabel(0)
  	end
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetCurrentPhase() == PHASE_MAIN1 or Duel.GetCurrentPhase() == PHASE_MAIN2
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckLPCost(tp, 1000)
  	end
  	Duel.PayLPCost(tp, 1000)
  end
  function s.spfilter(c, e, tp)
  	return c:IsRace(RACE_FAIRY) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_DEFENSE)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_HAND + LOCATION_GRAVE, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND + LOCATION_GRAVE)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.spfilter), tp, LOCATION_HAND + LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP_DEFENSE)
  	end
  end
  
  