name: Meklord
card_text: Cannot be Normal Summoned/Set. Must first be Special Summoned (from your hand) by banishing 3 "Meklord" monsters with different names from your GY. Once per turn, when this card declares an attack: You can look at your opponent's Extra Deck and equip 1 monster from it to this card. This card gains ATK equal to the combined ATK of those equipped monsters. While equipped with a Synchro Monster, this card can make up to 3 attacks on monsters during each Battle Phase.
external_ids: local SETCARD_ID_0 = 0x13 --Meklord
  
lua: local SETCARD_ID_0 = 0x13 --Meklord
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--special summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_SPSUMMON_PROC)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e2:SetRange(LOCATION_HAND)
  	e2:SetCondition(s.spcon)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  	--equip
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_EQUIP)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e3:SetCountLimit(1)
  	e3:SetTarget(s.eqtg)
  	e3:SetOperation(s.eqop)
  	c:RegisterEffect(e3)
  	--attack thrice
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE)
  	e4:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e4:SetCode(EFFECT_EXTRA_ATTACK_MONSTER)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetCondition(s.pcon)
  	e4:SetValue(2)
  	c:RegisterEffect(e4)
  end
  function s.spfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsAbleToRemoveAsCost()
  end
  function s.spcon(e, c)
  	if c == nil then
  		return true
  	end
  	if Duel.GetLocationCount(c:GetControler(), LOCATION_MZONE) <= 0 then
  		return false
  	end
  	local g = Duel.GetMatchingGroup(s.spfilter, c:GetControler(), LOCATION_GRAVE, 0, nil)
  	local ct = g:GetClassCount(Card.GetCode)
  	return ct >= 3
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, c)
  	local g = Duel.GetMatchingGroup(s.spfilter, tp, LOCATION_GRAVE, 0, nil)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	aux.GCheckAdditional = aux.dncheck
  	local rg = g:SelectSubGroup(tp, aux.TRUE, true, 3, 3)
  	aux.GCheckAdditional = nil
  	if rg then
  		rg:KeepAlive()
  		e:SetLabelObject(rg)
  		return true
  	else
  		return false
  	end
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp, c)
  	local rg = e:GetLabelObject()
  	Duel.Remove(rg, POS_FACEUP, REASON_SPSUMMON)
  	rg:DeleteGroup()
  end
  function s.eqfilter(c, tp)
  	return not c:IsForbidden() and c:CheckUniqueOnField(tp, LOCATION_SZONE)
  end
  function s.filter(c, tp)
  	return c:IsFacedown() or s.eqfilter(c, tp)
  end
  function s.eqtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local g = Duel.GetFieldGroup(tp, 0, LOCATION_EXTRA)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_SZONE) > 0 and g:GetCount() > 0 and g:IsExists(s.filter, 1, nil, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_EQUIP, nil, 1, 1 - tp, LOCATION_EXTRA)
  end
  function s.eqop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if Duel.GetLocationCount(tp, LOCATION_SZONE) <= 0 or c:IsFacedown() or not c:IsRelateToEffect(e) then
  		return
  	end
  	local g = Duel.GetFieldGroup(tp, 0, LOCATION_EXTRA)
  	Duel.ConfirmCards(tp, g, true)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_EQUIP)
  	local sg = g:FilterSelect(tp, s.eqfilter, 1, 1, nil, tp)
  	local tc = sg:GetFirst()
  	if tc then
  		if Duel.Equip(tp, tc, c) then
  			local atk = tc:GetTextAttack()
  			--Add Equip limit
  			local e1 = Effect.CreateEffect(c)
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_EQUIP_LIMIT)
  			e1:SetProperty(EFFECT_FLAG_OWNER_RELATE)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  			e1:SetValue(s.eqlimit)
  			tc:RegisterEffect(e1)
  			if atk > 0 then
  				local e2 = Effect.CreateEffect(c)
  				e2:SetType(EFFECT_TYPE_EQUIP)
  				e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE + EFFECT_FLAG_OWNER_RELATE)
  				e2:SetCode(EFFECT_UPDATE_ATTACK)
  				e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  				e2:SetValue(atk)
  				tc:RegisterEffect(e2)
  			end
  		end
  	end
  	Duel.ShuffleExtra(1 - tp)
  end
  function s.eqlimit(e, c)
  	return e:GetOwner() == c
  end
  function s.xatkfilter(c)
  	return c:IsFaceup() and c:GetOriginalType() & TYPE_SYNCHRO ~= 0
  end
  function s.pcon(e)
  	return e:GetHandler():GetEquipGroup():IsExists(s.xatkfilter, 1, nil)
  end
  
  
source_text: Meklord
  Cannot be Normal Summoned/Set. Must first be Special Summoned (from your hand) by banishing 3 "Meklord" monsters with different names from your GY. Once per turn, when this card declares an attack: You can look at your opponent's Extra Deck and equip 1 monster from it to this card. This card gains ATK equal to the combined ATK of those equipped monsters. While equipped with a Synchro Monster, this card can make up to 3 attacks on monsters during each Battle Phase.
target_text: -- Meklord
  local SETCARD_ID_0 = 0x13 --Meklord
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--special summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_SPSUMMON_PROC)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e2:SetRange(LOCATION_HAND)
  	e2:SetCondition(s.spcon)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  	--equip
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_EQUIP)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e3:SetCountLimit(1)
  	e3:SetTarget(s.eqtg)
  	e3:SetOperation(s.eqop)
  	c:RegisterEffect(e3)
  	--attack thrice
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE)
  	e4:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e4:SetCode(EFFECT_EXTRA_ATTACK_MONSTER)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetCondition(s.pcon)
  	e4:SetValue(2)
  	c:RegisterEffect(e4)
  end
  function s.spfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsAbleToRemoveAsCost()
  end
  function s.spcon(e, c)
  	if c == nil then
  		return true
  	end
  	if Duel.GetLocationCount(c:GetControler(), LOCATION_MZONE) <= 0 then
  		return false
  	end
  	local g = Duel.GetMatchingGroup(s.spfilter, c:GetControler(), LOCATION_GRAVE, 0, nil)
  	local ct = g:GetClassCount(Card.GetCode)
  	return ct >= 3
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, c)
  	local g = Duel.GetMatchingGroup(s.spfilter, tp, LOCATION_GRAVE, 0, nil)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	aux.GCheckAdditional = aux.dncheck
  	local rg = g:SelectSubGroup(tp, aux.TRUE, true, 3, 3)
  	aux.GCheckAdditional = nil
  	if rg then
  		rg:KeepAlive()
  		e:SetLabelObject(rg)
  		return true
  	else
  		return false
  	end
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp, c)
  	local rg = e:GetLabelObject()
  	Duel.Remove(rg, POS_FACEUP, REASON_SPSUMMON)
  	rg:DeleteGroup()
  end
  function s.eqfilter(c, tp)
  	return not c:IsForbidden() and c:CheckUniqueOnField(tp, LOCATION_SZONE)
  end
  function s.filter(c, tp)
  	return c:IsFacedown() or s.eqfilter(c, tp)
  end
  function s.eqtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local g = Duel.GetFieldGroup(tp, 0, LOCATION_EXTRA)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_SZONE) > 0 and g:GetCount() > 0 and g:IsExists(s.filter, 1, nil, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_EQUIP, nil, 1, 1 - tp, LOCATION_EXTRA)
  end
  function s.eqop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if Duel.GetLocationCount(tp, LOCATION_SZONE) <= 0 or c:IsFacedown() or not c:IsRelateToEffect(e) then
  		return
  	end
  	local g = Duel.GetFieldGroup(tp, 0, LOCATION_EXTRA)
  	Duel.ConfirmCards(tp, g, true)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_EQUIP)
  	local sg = g:FilterSelect(tp, s.eqfilter, 1, 1, nil, tp)
  	local tc = sg:GetFirst()
  	if tc then
  		if Duel.Equip(tp, tc, c) then
  			local atk = tc:GetTextAttack()
  			--Add Equip limit
  			local e1 = Effect.CreateEffect(c)
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_EQUIP_LIMIT)
  			e1:SetProperty(EFFECT_FLAG_OWNER_RELATE)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  			e1:SetValue(s.eqlimit)
  			tc:RegisterEffect(e1)
  			if atk > 0 then
  				local e2 = Effect.CreateEffect(c)
  				e2:SetType(EFFECT_TYPE_EQUIP)
  				e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE + EFFECT_FLAG_OWNER_RELATE)
  				e2:SetCode(EFFECT_UPDATE_ATTACK)
  				e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  				e2:SetValue(atk)
  				tc:RegisterEffect(e2)
  			end
  		end
  	end
  	Duel.ShuffleExtra(1 - tp)
  end
  function s.eqlimit(e, c)
  	return e:GetOwner() == c
  end
  function s.xatkfilter(c)
  	return c:IsFaceup() and c:GetOriginalType() & TYPE_SYNCHRO ~= 0
  end
  function s.pcon(e)
  	return e:GetHandler():GetEquipGroup():IsExists(s.xatkfilter, 1, nil)
  end
  
  