name: Lord
card_text: You can Special Summon this card (from your hand) by banishing 3 cards from your GY (1 monster, 1 Spell, and 1 Trap). If this card is Special Summoned from the hand: You can banish 1 monster and 2 Spells/Traps from your opponent's field and/or GY. You can only use this effect of "Lord of the Missing Barrows" once per turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCondition(s.sprcon)
  	e1:SetTarget(s.sprtg)
  	e1:SetOperation(s.sprop)
  	c:RegisterEffect(e1)
  	--
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_REMOVE)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_DELAY)
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.rmcon)
  	e2:SetTarget(s.rmtg)
  	e2:SetOperation(s.rmop)
  	c:RegisterEffect(e2)
  end
  function s.sprfilter(c)
  	return c:IsAbleToRemoveAsCost()
  end
  function s.gcheck(g, tp)
  	return Duel.GetMZoneCount(tp, g) > 0 and g:FilterCount(Card.IsType, nil, TYPE_MONSTER) == 1 and g:FilterCount(Card.IsType, nil, TYPE_SPELL) == 1 and g:FilterCount(Card.IsType, nil, TYPE_TRAP) == 1
  end
  function s.sprcon(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	local g = Duel.GetMatchingGroup(s.sprfilter, tp, LOCATION_GRAVE, 0, e:GetHandler())
  	return g:CheckSubGroup(s.gcheck, 3, 3, tp)
  end
  function s.sprtg(e, tp, eg, ep, ev, re, r, rp, chk, c)
  	local g = Duel.GetMatchingGroup(s.sprfilter, tp, LOCATION_GRAVE, 0, e:GetHandler())
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local sg = g:SelectSubGroup(tp, s.gcheck, false, 3, 3, tp)
  	if sg then
  		sg:KeepAlive()
  		e:SetLabelObject(sg)
  		return true
  	else
  		return false
  	end
  end
  function s.sprop(e, tp, eg, ep, ev, re, r, rp, c)
  	local g = e:GetLabelObject()
  	Duel.Remove(g, POS_FACEUP, REASON_COST)
  	g:DeleteGroup()
  end
  function s.rmcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonLocation(LOCATION_HAND)
  end
  function s.rmfilter(c)
  	return c:IsAbleToRemove()
  end
  function s.rmfgilter(c, g)
  	return c:IsType(TYPE_MONSTER) and g:IsExists(Card.IsType, 2, c, TYPE_SPELL + TYPE_TRAP)
  end
  function s.rmcheck(g)
  	return g:IsExists(s.rmfgilter, 1, nil, g)
  end
  function s.rmtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local g = Duel.GetMatchingGroup(s.rmfilter, tp, 0, LOCATION_GRAVE + LOCATION_ONFIELD, nil)
  	if chk == 0 then
  		return g:CheckSubGroup(s.rmcheck, 3, 3, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, nil, 1, 1 - tp, LOCATION_GRAVE + LOCATION_ONFIELD)
  end
  function s.rmop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(aux.NecroValleyFilter(s.rmfilter), tp, 0, LOCATION_GRAVE + LOCATION_ONFIELD, nil)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local sg = g:SelectSubGroup(tp, s.rmcheck, false, 3, 3, tp)
  	if sg then
  		Duel.HintSelection(sg)
  		Duel.Remove(sg, POS_FACEUP, REASON_EFFECT)
  	end
  end
  
  
source_text: Lord
  You can Special Summon this card (from your hand) by banishing 3 cards from your GY (1 monster, 1 Spell, and 1 Trap). If this card is Special Summoned from the hand: You can banish 1 monster and 2 Spells/Traps from your opponent's field and/or GY. You can only use this effect of "Lord of the Missing Barrows" once per turn.
target_text: -- Lord
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCondition(s.sprcon)
  	e1:SetTarget(s.sprtg)
  	e1:SetOperation(s.sprop)
  	c:RegisterEffect(e1)
  	--
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_REMOVE)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_DELAY)
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.rmcon)
  	e2:SetTarget(s.rmtg)
  	e2:SetOperation(s.rmop)
  	c:RegisterEffect(e2)
  end
  function s.sprfilter(c)
  	return c:IsAbleToRemoveAsCost()
  end
  function s.gcheck(g, tp)
  	return Duel.GetMZoneCount(tp, g) > 0 and g:FilterCount(Card.IsType, nil, TYPE_MONSTER) == 1 and g:FilterCount(Card.IsType, nil, TYPE_SPELL) == 1 and g:FilterCount(Card.IsType, nil, TYPE_TRAP) == 1
  end
  function s.sprcon(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	local g = Duel.GetMatchingGroup(s.sprfilter, tp, LOCATION_GRAVE, 0, e:GetHandler())
  	return g:CheckSubGroup(s.gcheck, 3, 3, tp)
  end
  function s.sprtg(e, tp, eg, ep, ev, re, r, rp, chk, c)
  	local g = Duel.GetMatchingGroup(s.sprfilter, tp, LOCATION_GRAVE, 0, e:GetHandler())
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local sg = g:SelectSubGroup(tp, s.gcheck, false, 3, 3, tp)
  	if sg then
  		sg:KeepAlive()
  		e:SetLabelObject(sg)
  		return true
  	else
  		return false
  	end
  end
  function s.sprop(e, tp, eg, ep, ev, re, r, rp, c)
  	local g = e:GetLabelObject()
  	Duel.Remove(g, POS_FACEUP, REASON_COST)
  	g:DeleteGroup()
  end
  function s.rmcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonLocation(LOCATION_HAND)
  end
  function s.rmfilter(c)
  	return c:IsAbleToRemove()
  end
  function s.rmfgilter(c, g)
  	return c:IsType(TYPE_MONSTER) and g:IsExists(Card.IsType, 2, c, TYPE_SPELL + TYPE_TRAP)
  end
  function s.rmcheck(g)
  	return g:IsExists(s.rmfgilter, 1, nil, g)
  end
  function s.rmtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local g = Duel.GetMatchingGroup(s.rmfilter, tp, 0, LOCATION_GRAVE + LOCATION_ONFIELD, nil)
  	if chk == 0 then
  		return g:CheckSubGroup(s.rmcheck, 3, 3, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, nil, 1, 1 - tp, LOCATION_GRAVE + LOCATION_ONFIELD)
  end
  function s.rmop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(aux.NecroValleyFilter(s.rmfilter), tp, 0, LOCATION_GRAVE + LOCATION_ONFIELD, nil)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local sg = g:SelectSubGroup(tp, s.rmcheck, false, 3, 3, tp)
  	if sg then
  		Duel.HintSelection(sg)
  		Duel.Remove(sg, POS_FACEUP, REASON_EFFECT)
  	end
  end
  
  