name: Meklord
card_text: During your Main Phase: You can activate this effect; destroy this card, and if you do, Special Summon 2 "Meklord Army" monsters from your Deck in Defense Position, except "Meklord Army Deployer Obbligato", also you cannot Special Summon monsters for the rest of this turn, except Machine monsters. If this card is sent to the GY: You can activate this effect; during the End Phase of this turn, you can inflict 100 damage to your opponent for each "Meklord" monster you control. You can only use each effect of "Meklord Army Deployer Obbligato" once per turn.
external_ids: local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local SETCARD_ID_0 = 0x13 --Meklord
  local SETCARD_ID_1 = 0x6013 --Meklord
  
lua: local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local SETCARD_ID_0 = 0x13 --Meklord
  local SETCARD_ID_1 = 0x6013 --Meklord
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--self destroy
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DESTROY + CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetCountLimit(1, id)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--damage
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_TO_GRAVE)
  	e2:SetProperty(EFFECT_FLAG_DELAY)
  	e2:SetCountLimit(1, id + 100)
  	e2:SetOperation(s.regop)
  	c:RegisterEffect(e2)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_1) and not c:IsCode(id) 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.GetMZoneCount(tp, e:GetHandler()) > 1 and not Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_DECK, 0, 2, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, e:GetHandler(), 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 2, tp, LOCATION_DECK)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and Duel.Destroy(c, REASON_EFFECT) > 0 and Duel.GetLocationCount(tp, LOCATION_MZONE) >= 2 and not Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_DECK, 0, 2, 2, nil, e, tp)
  		if g:GetCount() > 0 then
  			Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP_DEFENSE)
  		end
  	end
  	local e1 = Effect.CreateEffect(c)
  	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)
  	return not c:IsRace(RACE_MACHINE)
  end
  function s.regop(e, tp, eg, ep, ev, re, r, rp)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EVENT_PHASE + PHASE_END)
  	e1:SetCountLimit(1)
  	e1:SetOperation(s.damop)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.damfilter(c)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsFaceup()
  end
  function s.damop(e, tp, eg, ep, ev, re, r, rp)
  	local ct = Duel.GetMatchingGroupCount(s.damfilter, tp, LOCATION_MZONE, 0, nil)
  	if ct == 0 then
  		return
  	end
  	Duel.Hint(HINT_CARD, 0, id)
  	Duel.Damage(1 - tp, ct * 100, REASON_EFFECT)
  end
  
  
source_text: Meklord
  During your Main Phase: You can activate this effect; destroy this card, and if you do, Special Summon 2 "Meklord Army" monsters from your Deck in Defense Position, except "Meklord Army Deployer Obbligato", also you cannot Special Summon monsters for the rest of this turn, except Machine monsters. If this card is sent to the GY: You can activate this effect; during the End Phase of this turn, you can inflict 100 damage to your opponent for each "Meklord" monster you control. You can only use each effect of "Meklord Army Deployer Obbligato" once per turn.
target_text: -- Meklord
  local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local SETCARD_ID_0 = 0x13 --Meklord
  local SETCARD_ID_1 = 0x6013 --Meklord
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--self destroy
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DESTROY + CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetCountLimit(1, id)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--damage
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_TO_GRAVE)
  	e2:SetProperty(EFFECT_FLAG_DELAY)
  	e2:SetCountLimit(1, id + 100)
  	e2:SetOperation(s.regop)
  	c:RegisterEffect(e2)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_1) and not c:IsCode(id) 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.GetMZoneCount(tp, e:GetHandler()) > 1 and not Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_DECK, 0, 2, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, e:GetHandler(), 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 2, tp, LOCATION_DECK)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and Duel.Destroy(c, REASON_EFFECT) > 0 and Duel.GetLocationCount(tp, LOCATION_MZONE) >= 2 and not Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_DECK, 0, 2, 2, nil, e, tp)
  		if g:GetCount() > 0 then
  			Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP_DEFENSE)
  		end
  	end
  	local e1 = Effect.CreateEffect(c)
  	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)
  	return not c:IsRace(RACE_MACHINE)
  end
  function s.regop(e, tp, eg, ep, ev, re, r, rp)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EVENT_PHASE + PHASE_END)
  	e1:SetCountLimit(1)
  	e1:SetOperation(s.damop)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.damfilter(c)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsFaceup()
  end
  function s.damop(e, tp, eg, ep, ev, re, r, rp)
  	local ct = Duel.GetMatchingGroupCount(s.damfilter, tp, LOCATION_MZONE, 0, nil)
  	if ct == 0 then
  		return
  	end
  	Duel.Hint(HINT_CARD, 0, id)
  	Duel.Damage(1 - tp, ct * 100, REASON_EFFECT)
  end
  
  