name: Darklord
card_text: Send 1 "Darklord" monster from your hand or face-up field to the GY; take control of 1 face-up monster your opponent controls until the End Phase. You can only activate 1 "Darklord Enchantment" 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)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_CONTROL)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.costfilter(c, tp)
  	return c:IsSetCard(SETCARD_ID_0)
  		and c:IsType(TYPE_MONSTER)
  		and c:IsAbleToGraveAsCost()
  		and (c:IsLocation(LOCATION_HAND) or c:IsFaceup())
  		and Duel.GetMZoneCount(tp, c, tp, LOCATION_REASON_CONTROL) > 0
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	e:SetLabel(100)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.costfilter, tp, LOCATION_HAND + LOCATION_MZONE, 0, 1, nil, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.costfilter, tp, LOCATION_HAND + LOCATION_MZONE, 0, 1, 1, nil, tp)
  	Duel.SendtoGrave(g, REASON_COST)
  end
  function s.filter(c, check)
  	return c:IsControlerCanBeChanged(check) and c:IsFaceup()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		local check = e:GetLabel() == 100
  		e:SetLabel(0)
  		return Duel.IsExistingMatchingCard(s.filter, tp, 0, LOCATION_MZONE, 1, nil, check)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_CONTROL, nil, 1, 0, 0)
  end
  function s.filter2(c)
  	return c:IsControlerCanBeChanged() and c:IsFaceup()
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONTROL)
  	local g = Duel.SelectMatchingCard(tp, s.filter2, tp, 0, LOCATION_MZONE, 1, 1, nil)
  	local tc = g:GetFirst()
  	if tc then
  		Duel.GetControl(tc, tp, PHASE_END, 1)
  	end
  end
  
  
source_text: Darklord
  Send 1 "Darklord" monster from your hand or face-up field to the GY; take control of 1 face-up monster your opponent controls until the End Phase. You can only activate 1 "Darklord Enchantment" per turn.
target_text: -- Darklord
  local SETCARD_ID_0 = 0xef --Darklord
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_CONTROL)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.costfilter(c, tp)
  	return c:IsSetCard(SETCARD_ID_0)
  		and c:IsType(TYPE_MONSTER)
  		and c:IsAbleToGraveAsCost()
  		and (c:IsLocation(LOCATION_HAND) or c:IsFaceup())
  		and Duel.GetMZoneCount(tp, c, tp, LOCATION_REASON_CONTROL) > 0
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	e:SetLabel(100)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.costfilter, tp, LOCATION_HAND + LOCATION_MZONE, 0, 1, nil, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.costfilter, tp, LOCATION_HAND + LOCATION_MZONE, 0, 1, 1, nil, tp)
  	Duel.SendtoGrave(g, REASON_COST)
  end
  function s.filter(c, check)
  	return c:IsControlerCanBeChanged(check) and c:IsFaceup()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		local check = e:GetLabel() == 100
  		e:SetLabel(0)
  		return Duel.IsExistingMatchingCard(s.filter, tp, 0, LOCATION_MZONE, 1, nil, check)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_CONTROL, nil, 1, 0, 0)
  end
  function s.filter2(c)
  	return c:IsControlerCanBeChanged() and c:IsFaceup()
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONTROL)
  	local g = Duel.SelectMatchingCard(tp, s.filter2, tp, 0, LOCATION_MZONE, 1, 1, nil)
  	local tc = g:GetFirst()
  	if tc then
  		Duel.GetControl(tc, tp, PHASE_END, 1)
  	end
  end
  
  