name: Dark
card_text: This card's name becomes "Dark Magician" while on the field. You can only use each of the following effects of "Dark Magician the Magician of Black Magic" once per turn. If "Shining Sarcophagus" is on the field: You can Special Summon this card from your hand. If this card is destroyed by card effect and a Level 5 or higher monster is on the field: You can Special Summon this card, then you can Set 1 Spell/Trap from your Deck that mentions "Dark Magician".
external_ids: local CARD_ID_0 = 46986414 --Dark Magician
  local CARD_ID_1 = 79791878 --Shining Sarcophagus
  
lua: local CARD_ID_0 = 46986414 --Dark Magician
  local CARD_ID_1 = 79791878 --Shining Sarcophagus
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_1)
  	aux.EnableChangeCode(c, CARD_ID_0)
  	--
  	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:SetCondition(s.spcon1)
  	e1:SetTarget(s.sptg1)
  	e1:SetOperation(s.spop1)
  	c:RegisterEffect(e1)
  	--
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_DESTROYED)
  	e2:SetCountLimit(1, id + o)
  	e2:SetProperty(EFFECT_FLAG_DELAY)
  	e2:SetCondition(s.spcon2)
  	e2:SetTarget(s.sptg2)
  	e2:SetOperation(s.spop2)
  	c:RegisterEffect(e2)
  end
  function s.cfilter1(c)
  	return c:IsCode(CARD_ID_1) and c:IsFaceup()
  end
  function s.spcon1(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.cfilter1, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, nil)
  end
  function s.sptg1(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.spop1(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) then
  		Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.cfilter2(c)
  	return c:IsLevelAbove(5) and c:IsFaceup()
  end
  function s.spcon2(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsReason(REASON_EFFECT)
  end
  function s.sptg2(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  			and Duel.IsExistingMatchingCard(s.cfilter2, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
  			and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.setfilter(c)
  	return aux.IsCodeListed(c, CARD_ID_0) and c:IsType(TYPE_SPELL + TYPE_TRAP) and c:IsSSetable()
  end
  function s.spop2(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if
  		c:IsRelateToEffect(e)
  		and Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP) ~= 0
  		and Duel.IsExistingMatchingCard(s.setfilter, tp, LOCATION_DECK, 0, 1, nil)
  		and Duel.SelectYesNo(tp, aux.Stringid(id, 2))
  	then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SET)
  		Duel.BreakEffect()
  		local g = Duel.SelectMatchingCard(tp, s.setfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  		if g:GetCount() > 0 then
  			Duel.SSet(tp, g:GetFirst())
  		end
  	end
  end
  
  
source_text: Dark
  This card's name becomes "Dark Magician" while on the field. You can only use each of the following effects of "Dark Magician the Magician of Black Magic" once per turn. If "Shining Sarcophagus" is on the field: You can Special Summon this card from your hand. If this card is destroyed by card effect and a Level 5 or higher monster is on the field: You can Special Summon this card, then you can Set 1 Spell/Trap from your Deck that mentions "Dark Magician".
target_text: -- Dark
  local CARD_ID_0 = 46986414 --Dark Magician
  local CARD_ID_1 = 79791878 --Shining Sarcophagus
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_1)
  	aux.EnableChangeCode(c, CARD_ID_0)
  	--
  	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:SetCondition(s.spcon1)
  	e1:SetTarget(s.sptg1)
  	e1:SetOperation(s.spop1)
  	c:RegisterEffect(e1)
  	--
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_DESTROYED)
  	e2:SetCountLimit(1, id + o)
  	e2:SetProperty(EFFECT_FLAG_DELAY)
  	e2:SetCondition(s.spcon2)
  	e2:SetTarget(s.sptg2)
  	e2:SetOperation(s.spop2)
  	c:RegisterEffect(e2)
  end
  function s.cfilter1(c)
  	return c:IsCode(CARD_ID_1) and c:IsFaceup()
  end
  function s.spcon1(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.cfilter1, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, nil)
  end
  function s.sptg1(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.spop1(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) then
  		Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.cfilter2(c)
  	return c:IsLevelAbove(5) and c:IsFaceup()
  end
  function s.spcon2(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsReason(REASON_EFFECT)
  end
  function s.sptg2(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  			and Duel.IsExistingMatchingCard(s.cfilter2, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
  			and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.setfilter(c)
  	return aux.IsCodeListed(c, CARD_ID_0) and c:IsType(TYPE_SPELL + TYPE_TRAP) and c:IsSSetable()
  end
  function s.spop2(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if
  		c:IsRelateToEffect(e)
  		and Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP) ~= 0
  		and Duel.IsExistingMatchingCard(s.setfilter, tp, LOCATION_DECK, 0, 1, nil)
  		and Duel.SelectYesNo(tp, aux.Stringid(id, 2))
  	then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SET)
  		Duel.BreakEffect()
  		local g = Duel.SelectMatchingCard(tp, s.setfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  		if g:GetCount() > 0 then
  			Duel.SSet(tp, g:GetFirst())
  		end
  	end
  end
  
  