name: Indulged
card_text: If this card is Normal or Special Summoned: You can take 2 "Darklord" monsters from your hand or Deck with different Levels, except "Indulged Darklord", Special Summon 1 of them to your opponent's field in Defense Position and add the other to your hand, also you cannot activate monster effects for the rest of this turn, except Fairy monsters. You can only use this effect of "Indulged Darklord" once per turn.
external_ids: local SETCARD_ID_0 = 0xef --Darklord
  
lua: local SETCARD_ID_0 = 0xef --Darklord
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--spsummon/to hand
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_SEARCH + CATEGORY_TOHAND)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e2)
  end
  function s.filter(c)
  	return c:IsSetCard(SETCARD_ID_0) and not c:IsCode(id) and c:IsType(TYPE_MONSTER) and c:IsLevelAbove(1)
  end
  function s.fselect(g, e, tp)
  	return aux.dlvcheck(g) and g:IsExists(s.fcheck, 1, nil, g, e, tp)
  end
  function s.fcheck(c, g, e, tp)
  	return c:IsLocation(LOCATION_HAND + LOCATION_DECK) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_DEFENSE, 1 - tp) and g:IsExists(s.fcheck2, 1, c)
  end
  function s.fcheck2(c)
  	return c:IsLocation(LOCATION_DECK) and c:IsAbleToHand()
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_HAND + LOCATION_DECK, 0, nil)
  	if chk == 0 then
  		return Duel.GetLocationCount(1 - tp, LOCATION_MZONE, tp) > 0 and g:CheckSubGroup(s.fselect, 2, 2, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND + LOCATION_DECK)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.cfilter(c, e, tp)
  	return c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_DEFENSE, 1 - tp) and (c:IsLocation(LOCATION_HAND) or not c:IsAbleToHand())
  end
  function s.cfilter2(c, e, tp)
  	return not c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_DEFENSE, 1 - tp) and c:IsLocation(LOCATION_DECK) and c:IsAbleToHand()
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(1 - tp, LOCATION_MZONE, tp) > 0 then
  		local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_HAND + LOCATION_DECK, 0, nil)
  		local sc = nil
  		local hc = nil
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_OPERATECARD)
  		local sg = g:SelectSubGroup(tp, s.fselect, false, 2, 2, e, tp)
  		if sg and sg:GetCount() == 2 then
  			if sg:IsExists(s.cfilter, 1, nil, e, tp) then
  				sc = sg:Filter(s.cfilter, nil, e, tp):GetFirst()
  				hc = sg:GetFirst()
  				if hc == sc then
  					hc = sg:GetNext()
  				end
  			elseif sg:IsExists(s.cfilter2, 1, nil, e, tp) then
  				hc = sg:Filter(s.cfilter2, nil, e, tp):GetFirst()
  				sc = sg:GetFirst()
  				if sc == hc then
  					sc = sg:GetNext()
  				end
  			else
  				Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  				sc = sg:FilterSelect(tp, s.fcheck, 1, 1, nil, sg, e, tp):GetFirst()
  				hc = sg:GetFirst()
  				if hc == sc then
  					hc = sg:GetNext()
  				end
  			end
  			if sc and Duel.SpecialSummon(sc, 0, tp, 1 - tp, false, false, POS_FACEUP_DEFENSE) ~= 0 and hc then
  				Duel.SendtoHand(hc, nil, REASON_EFFECT)
  				Duel.ConfirmCards(1 - tp, hc)
  			end
  		end
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetCode(EFFECT_CANNOT_ACTIVATE)
  	e1:SetTargetRange(1, 0)
  	e1:SetValue(s.aclimit)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.aclimit(e, re, tp)
  	return re:IsActiveType(TYPE_MONSTER) and not re:GetHandler():IsRace(RACE_FAIRY)
  end
  
  
source_text: Indulged
  If this card is Normal or Special Summoned: You can take 2 "Darklord" monsters from your hand or Deck with different Levels, except "Indulged Darklord", Special Summon 1 of them to your opponent's field in Defense Position and add the other to your hand, also you cannot activate monster effects for the rest of this turn, except Fairy monsters. You can only use this effect of "Indulged Darklord" once per turn.
target_text: -- Indulged
  local SETCARD_ID_0 = 0xef --Darklord
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--spsummon/to hand
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_SEARCH + CATEGORY_TOHAND)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e2)
  end
  function s.filter(c)
  	return c:IsSetCard(SETCARD_ID_0) and not c:IsCode(id) and c:IsType(TYPE_MONSTER) and c:IsLevelAbove(1)
  end
  function s.fselect(g, e, tp)
  	return aux.dlvcheck(g) and g:IsExists(s.fcheck, 1, nil, g, e, tp)
  end
  function s.fcheck(c, g, e, tp)
  	return c:IsLocation(LOCATION_HAND + LOCATION_DECK) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_DEFENSE, 1 - tp) and g:IsExists(s.fcheck2, 1, c)
  end
  function s.fcheck2(c)
  	return c:IsLocation(LOCATION_DECK) and c:IsAbleToHand()
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_HAND + LOCATION_DECK, 0, nil)
  	if chk == 0 then
  		return Duel.GetLocationCount(1 - tp, LOCATION_MZONE, tp) > 0 and g:CheckSubGroup(s.fselect, 2, 2, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND + LOCATION_DECK)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.cfilter(c, e, tp)
  	return c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_DEFENSE, 1 - tp) and (c:IsLocation(LOCATION_HAND) or not c:IsAbleToHand())
  end
  function s.cfilter2(c, e, tp)
  	return not c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_DEFENSE, 1 - tp) and c:IsLocation(LOCATION_DECK) and c:IsAbleToHand()
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(1 - tp, LOCATION_MZONE, tp) > 0 then
  		local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_HAND + LOCATION_DECK, 0, nil)
  		local sc = nil
  		local hc = nil
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_OPERATECARD)
  		local sg = g:SelectSubGroup(tp, s.fselect, false, 2, 2, e, tp)
  		if sg and sg:GetCount() == 2 then
  			if sg:IsExists(s.cfilter, 1, nil, e, tp) then
  				sc = sg:Filter(s.cfilter, nil, e, tp):GetFirst()
  				hc = sg:GetFirst()
  				if hc == sc then
  					hc = sg:GetNext()
  				end
  			elseif sg:IsExists(s.cfilter2, 1, nil, e, tp) then
  				hc = sg:Filter(s.cfilter2, nil, e, tp):GetFirst()
  				sc = sg:GetFirst()
  				if sc == hc then
  					sc = sg:GetNext()
  				end
  			else
  				Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  				sc = sg:FilterSelect(tp, s.fcheck, 1, 1, nil, sg, e, tp):GetFirst()
  				hc = sg:GetFirst()
  				if hc == sc then
  					hc = sg:GetNext()
  				end
  			end
  			if sc and Duel.SpecialSummon(sc, 0, tp, 1 - tp, false, false, POS_FACEUP_DEFENSE) ~= 0 and hc then
  				Duel.SendtoHand(hc, nil, REASON_EFFECT)
  				Duel.ConfirmCards(1 - tp, hc)
  			end
  		end
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetCode(EFFECT_CANNOT_ACTIVATE)
  	e1:SetTargetRange(1, 0)
  	e1:SetValue(s.aclimit)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.aclimit(e, re, tp)
  	return re:IsActiveType(TYPE_MONSTER) and not re:GetHandler():IsRace(RACE_FAIRY)
  end
  
  