name: Dark
card_text: You can banish 1 Level 8 Dragon monster from your Extra Deck; Special Summon this card from your hand, also you cannot Special Summon for the rest of this turn, except Dragon monsters. You can activate 1 of these effects;
  ● Fusion Summon 1 Fusion Monster from your Extra Deck, using monsters from your hand or field.
  ● Target 1 other Attack Position monster on the field; make this card lose exactly 500 ATK/DEF, and if you do, destroy that monster.
  You can only use each effect of "Dark End Evaporation Dragon" once per turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	-- self special summon from hand
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id)
  	e1:SetCost(s.spcost)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	-- fusion summon
  	local e2 = FusionSpell.CreateSummonEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetHintTiming(0, TIMING_MAIN_END)
  	e2:SetCountLimit(1, id + o)
  	c:RegisterEffect(e2)
  	-- destroy
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 2))
  	e3:SetCategory(CATEGORY_ATKCHANGE + CATEGORY_DESTROY)
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1, id + o)
  	e3:SetTarget(s.atktg)
  	e3:SetOperation(s.atkop)
  	c:RegisterEffect(e3)
  end
  
  function s.costfilter(c)
  	return c:IsRace(RACE_DRAGON) and c:IsLevel(8) and c:IsAbleToRemoveAsCost()
  end
  
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.costfilter, tp, LOCATION_EXTRA, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectMatchingCard(tp, s.costfilter, tp, LOCATION_EXTRA, 0, 1, 1, nil)
  	Duel.Remove(g, POS_FACEUP, REASON_COST)
  end
  
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if e:GetHandler():IsRelateToEffect(e) then
  		Duel.SpecialSummon(e:GetHandler(), 0, tp, tp, false, false, POS_FACEUP)
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e1:SetTargetRange(1, 0)
  	e1:SetTarget(s.spelimit)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  
  function s.spelimit(e, c)
  	return not c:IsRace(RACE_DRAGON)
  end
  
  function s.atkfilter(c)
  	return c:IsFaceup() and c:IsPosition(POS_ATTACK)
  end
  
  function s.atktg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local c = e:GetHandler()
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc ~= c and s.atkfilter(chkc)
  	end
  	if chk == 0 then
  		return c:IsAttackAbove(500) and c:IsDefenseAbove(500) and Duel.IsExistingTarget(s.atkfilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, c)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	local tc = Duel.SelectTarget(tp, s.atkfilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, 1, c)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, tc, 1, 0, 0)
  end
  
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if c:IsRelateToEffect(e) and c:IsFaceup() and c:IsAttackAbove(500) and c:IsDefenseAbove(500) then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetValue(-500)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		c:RegisterEffect(e1)
  		local e2 = e1:Clone()
  		e2:SetCode(EFFECT_UPDATE_DEFENSE)
  		c:RegisterEffect(e2)
  		if not c:IsHasEffect(EFFECT_REVERSE_UPDATE) and tc:IsType(TYPE_MONSTER) and tc:IsRelateToEffect(e) then
  			Duel.Destroy(tc, REASON_EFFECT)
  		end
  	end
  end
  
  
source_text: Dark
  You can banish 1 Level 8 Dragon monster from your Extra Deck; Special Summon this card from your hand, also you cannot Special Summon for the rest of this turn, except Dragon monsters. You can activate 1 of these effects;
  ● Fusion Summon 1 Fusion Monster from your Extra Deck, using monsters from your hand or field.
  ● Target 1 other Attack Position monster on the field; make this card lose exactly 500 ATK/DEF, and if you do, destroy that monster.
  You can only use each effect of "Dark End Evaporation Dragon" once per turn.
target_text: -- Dark
  local s, id, o = GetID()
  function s.initial_effect(c)
  	-- self special summon from hand
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id)
  	e1:SetCost(s.spcost)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	-- fusion summon
  	local e2 = FusionSpell.CreateSummonEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetHintTiming(0, TIMING_MAIN_END)
  	e2:SetCountLimit(1, id + o)
  	c:RegisterEffect(e2)
  	-- destroy
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 2))
  	e3:SetCategory(CATEGORY_ATKCHANGE + CATEGORY_DESTROY)
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1, id + o)
  	e3:SetTarget(s.atktg)
  	e3:SetOperation(s.atkop)
  	c:RegisterEffect(e3)
  end
  
  function s.costfilter(c)
  	return c:IsRace(RACE_DRAGON) and c:IsLevel(8) and c:IsAbleToRemoveAsCost()
  end
  
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.costfilter, tp, LOCATION_EXTRA, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectMatchingCard(tp, s.costfilter, tp, LOCATION_EXTRA, 0, 1, 1, nil)
  	Duel.Remove(g, POS_FACEUP, REASON_COST)
  end
  
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if e:GetHandler():IsRelateToEffect(e) then
  		Duel.SpecialSummon(e:GetHandler(), 0, tp, tp, false, false, POS_FACEUP)
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e1:SetTargetRange(1, 0)
  	e1:SetTarget(s.spelimit)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  
  function s.spelimit(e, c)
  	return not c:IsRace(RACE_DRAGON)
  end
  
  function s.atkfilter(c)
  	return c:IsFaceup() and c:IsPosition(POS_ATTACK)
  end
  
  function s.atktg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local c = e:GetHandler()
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc ~= c and s.atkfilter(chkc)
  	end
  	if chk == 0 then
  		return c:IsAttackAbove(500) and c:IsDefenseAbove(500) and Duel.IsExistingTarget(s.atkfilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, c)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	local tc = Duel.SelectTarget(tp, s.atkfilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, 1, c)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, tc, 1, 0, 0)
  end
  
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if c:IsRelateToEffect(e) and c:IsFaceup() and c:IsAttackAbove(500) and c:IsDefenseAbove(500) then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetValue(-500)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		c:RegisterEffect(e1)
  		local e2 = e1:Clone()
  		e2:SetCode(EFFECT_UPDATE_DEFENSE)
  		c:RegisterEffect(e2)
  		if not c:IsHasEffect(EFFECT_REVERSE_UPDATE) and tc:IsType(TYPE_MONSTER) and tc:IsRelateToEffect(e) then
  			Duel.Destroy(tc, REASON_EFFECT)
  		end
  	end
  end
  
  