name: Condemned
card_text: 2 Fairy monsters
  You can Tribute Summon Fairy monsters that require 2 Tributes by banishing 2 monsters from your GY instead of Tributing (it is still treated as a Tribute Summon). You can discard 1 card; take 1 "Darklord" monster from your Deck, and either add it to your hand or send it to the GY. You can only use this effect of "Condemned Darklord" once per turn. Once per turn, during your End Phase: Gain 500 LP for each Fairy monster on the field.
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)
  	--link summon
  	c:EnableReviveLimit()
  	aux.AddLinkProcedure(c, aux.FilterBoolFunction(Card.IsLinkRace, RACE_FAIRY), 2, 2)
  	--summon proc
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_SUMMON_PROC)
  	e1:SetTargetRange(LOCATION_HAND, 0)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCondition(s.otcon)
  	e1:SetTarget(s.ottg)
  	e1:SetOperation(s.otop)
  	e1:SetValue(SUMMON_TYPE_ADVANCE)
  	c:RegisterEffect(e1)
  	local e4 = e1:Clone()
  	e4:SetCode(EFFECT_SET_PROC)
  	c:RegisterEffect(e4)
  	--tohand
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH + CATEGORY_TOGRAVE)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id)
  	e2:SetCost(s.thcost)
  	e2:SetTarget(s.thtg)
  	e2:SetOperation(s.thop)
  	c:RegisterEffect(e2)
  	--recover
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 2))
  	e3:SetCategory(CATEGORY_RECOVER)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e3:SetCode(EVENT_PHASE + PHASE_END)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e3:SetCountLimit(1)
  	e3:SetCondition(s.reccon)
  	e3:SetTarget(s.rectg)
  	e3:SetOperation(s.recop)
  	c:RegisterEffect(e3)
  end
  function s.rmfilter(c)
  	return c:IsType(TYPE_MONSTER) and c:IsAbleToRemoveAsCost()
  end
  function s.otcon(e, c, minc)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	return minc <= 2 and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.rmfilter, tp, LOCATION_GRAVE, 0, 2, nil)
  end
  function s.ottg(e, c)
  	local mi, ma = c:GetTributeRequirement()
  	return mi <= 2 and ma >= 2 and c:IsRace(RACE_FAIRY)
  end
  function s.otop(e, tp, eg, ep, ev, re, r, rp, c)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectMatchingCard(tp, s.rmfilter, tp, LOCATION_GRAVE, 0, 2, 2, nil)
  	Duel.Remove(g, POS_FACEUP, REASON_COST)
  	c:SetMaterial(nil)
  end
  function s.thcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsDiscardable, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.DiscardHand(tp, Card.IsDiscardable, 1, 1, REASON_COST + REASON_DISCARD)
  end
  function s.thfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and (c:IsAbleToHand() or c:IsAbleToGrave())
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 1, tp, LOCATION_DECK)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_OPERATECARD)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		local tc = g:GetFirst()
  		if tc and tc:IsAbleToHand() and (not tc:IsAbleToGrave() or Duel.SelectOption(tp, 1190, 1191) == 0) then
  			Duel.SendtoHand(tc, nil, REASON_EFFECT)
  			Duel.ConfirmCards(1 - tp, tc)
  		else
  			Duel.SendtoGrave(tc, REASON_EFFECT)
  		end
  	end
  end
  function s.reccon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() == tp
  end
  function s.recfilter(c)
  	return c:IsFaceup() and c:IsRace(RACE_FAIRY)
  end
  function s.rectg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local rec = Duel.GetMatchingGroupCount(s.recfilter, tp, LOCATION_MZONE, LOCATION_MZONE, nil) * 500
  	Duel.SetTargetPlayer(tp)
  	Duel.SetTargetParam(rec)
  	Duel.SetOperationInfo(0, CATEGORY_RECOVER, nil, 0, tp, rec)
  end
  function s.recop(e, tp, eg, ep, ev, re, r, rp)
  	local rec = Duel.GetMatchingGroupCount(s.recfilter, tp, LOCATION_MZONE, LOCATION_MZONE, nil) * 500
  	local p = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER)
  	Duel.Recover(p, rec, REASON_EFFECT)
  end
  
  
source_text: Condemned
  2 Fairy monsters
  You can Tribute Summon Fairy monsters that require 2 Tributes by banishing 2 monsters from your GY instead of Tributing (it is still treated as a Tribute Summon). You can discard 1 card; take 1 "Darklord" monster from your Deck, and either add it to your hand or send it to the GY. You can only use this effect of "Condemned Darklord" once per turn. Once per turn, during your End Phase: Gain 500 LP for each Fairy monster on the field.
target_text: -- Condemned
  local SETCARD_ID_0 = 0xef --Darklord
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	c:EnableReviveLimit()
  	aux.AddLinkProcedure(c, aux.FilterBoolFunction(Card.IsLinkRace, RACE_FAIRY), 2, 2)
  	--summon proc
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_SUMMON_PROC)
  	e1:SetTargetRange(LOCATION_HAND, 0)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCondition(s.otcon)
  	e1:SetTarget(s.ottg)
  	e1:SetOperation(s.otop)
  	e1:SetValue(SUMMON_TYPE_ADVANCE)
  	c:RegisterEffect(e1)
  	local e4 = e1:Clone()
  	e4:SetCode(EFFECT_SET_PROC)
  	c:RegisterEffect(e4)
  	--tohand
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH + CATEGORY_TOGRAVE)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id)
  	e2:SetCost(s.thcost)
  	e2:SetTarget(s.thtg)
  	e2:SetOperation(s.thop)
  	c:RegisterEffect(e2)
  	--recover
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 2))
  	e3:SetCategory(CATEGORY_RECOVER)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e3:SetCode(EVENT_PHASE + PHASE_END)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e3:SetCountLimit(1)
  	e3:SetCondition(s.reccon)
  	e3:SetTarget(s.rectg)
  	e3:SetOperation(s.recop)
  	c:RegisterEffect(e3)
  end
  function s.rmfilter(c)
  	return c:IsType(TYPE_MONSTER) and c:IsAbleToRemoveAsCost()
  end
  function s.otcon(e, c, minc)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	return minc <= 2 and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.rmfilter, tp, LOCATION_GRAVE, 0, 2, nil)
  end
  function s.ottg(e, c)
  	local mi, ma = c:GetTributeRequirement()
  	return mi <= 2 and ma >= 2 and c:IsRace(RACE_FAIRY)
  end
  function s.otop(e, tp, eg, ep, ev, re, r, rp, c)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectMatchingCard(tp, s.rmfilter, tp, LOCATION_GRAVE, 0, 2, 2, nil)
  	Duel.Remove(g, POS_FACEUP, REASON_COST)
  	c:SetMaterial(nil)
  end
  function s.thcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsDiscardable, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.DiscardHand(tp, Card.IsDiscardable, 1, 1, REASON_COST + REASON_DISCARD)
  end
  function s.thfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and (c:IsAbleToHand() or c:IsAbleToGrave())
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 1, tp, LOCATION_DECK)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_OPERATECARD)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		local tc = g:GetFirst()
  		if tc and tc:IsAbleToHand() and (not tc:IsAbleToGrave() or Duel.SelectOption(tp, 1190, 1191) == 0) then
  			Duel.SendtoHand(tc, nil, REASON_EFFECT)
  			Duel.ConfirmCards(1 - tp, tc)
  		else
  			Duel.SendtoGrave(tc, REASON_EFFECT)
  		end
  	end
  end
  function s.reccon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() == tp
  end
  function s.recfilter(c)
  	return c:IsFaceup() and c:IsRace(RACE_FAIRY)
  end
  function s.rectg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local rec = Duel.GetMatchingGroupCount(s.recfilter, tp, LOCATION_MZONE, LOCATION_MZONE, nil) * 500
  	Duel.SetTargetPlayer(tp)
  	Duel.SetTargetParam(rec)
  	Duel.SetOperationInfo(0, CATEGORY_RECOVER, nil, 0, tp, rec)
  end
  function s.recop(e, tp, eg, ep, ev, re, r, rp)
  	local rec = Duel.GetMatchingGroupCount(s.recfilter, tp, LOCATION_MZONE, LOCATION_MZONE, nil) * 500
  	local p = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER)
  	Duel.Recover(p, rec, REASON_EFFECT)
  end
  
  