name: Bond
card_text: If you control "Dark Magician": Special Summon 1 "Dark Magician Girl" from your hand, Deck, or GY, then, you can Set 1 "Dark Magic Attack", "Dark Burning Attack", "Dark Burning Magic", or "Dark Magic Twin Burst" directly from your Deck. You can only activate 1 "Bond Between Teacher and Student" per turn.
external_ids: local CARD_ID_0 = 75190122 --Dark Burning Magic
  local CARD_ID_1 = 2314238 --Dark Magic Attack
  local CARD_ID_2 = 49702428 --Dark Burning Attack
  local CARD_ID_3 = 38033121 --Dark Magician Girl
  local CARD_ID_4 = 46986414 --Dark Magician
  local CARD_ID_5 = 70168345 --Dark Magic Twin Burst
  
lua: local CARD_ID_0 = 75190122 --Dark Burning Magic
  local CARD_ID_1 = 2314238 --Dark Magic Attack
  local CARD_ID_2 = 49702428 --Dark Burning Attack
  local CARD_ID_3 = 38033121 --Dark Magician Girl
  local CARD_ID_4 = 46986414 --Dark Magician
  local CARD_ID_5 = 70168345 --Dark Magic Twin Burst
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_4, CARD_ID_3)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cfilter(c)
  	return c:IsCode(CARD_ID_4) and c:IsFaceup()
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_ONFIELD, 0, 1, nil)
  end
  function s.spfilter(c, e, tp)
  	return c:IsCode(CARD_ID_3) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_HAND + LOCATION_DECK + LOCATION_GRAVE, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND + LOCATION_DECK + LOCATION_GRAVE)
  end
  function s.setfilter(c)
  	return c:IsCode(CARD_ID_1, CARD_ID_0, CARD_ID_2, CARD_ID_5) and c:IsSSetable()
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) < 1 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.spfilter), tp, LOCATION_HAND + LOCATION_DECK + LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  	local sc = g:GetFirst()
  	if sc and Duel.SpecialSummon(sc, 0, tp, tp, false, false, POS_FACEUP) > 0 then
  		local g2 = Duel.GetMatchingGroup(s.setfilter, tp, LOCATION_DECK, 0, nil)
  		if g2:GetCount() > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 0)) then
  			Duel.BreakEffect()
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SET)
  			local tc = g2:Select(tp, 1, 1, nil)
  			Duel.SSet(tp, tc)
  		end
  	end
  end
  
  
source_text: Bond
  If you control "Dark Magician": Special Summon 1 "Dark Magician Girl" from your hand, Deck, or GY, then, you can Set 1 "Dark Magic Attack", "Dark Burning Attack", "Dark Burning Magic", or "Dark Magic Twin Burst" directly from your Deck. You can only activate 1 "Bond Between Teacher and Student" per turn.
target_text: -- Bond
  local CARD_ID_0 = 75190122 --Dark Burning Magic
  local CARD_ID_1 = 2314238 --Dark Magic Attack
  local CARD_ID_2 = 49702428 --Dark Burning Attack
  local CARD_ID_3 = 38033121 --Dark Magician Girl
  local CARD_ID_4 = 46986414 --Dark Magician
  local CARD_ID_5 = 70168345 --Dark Magic Twin Burst
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_4, CARD_ID_3)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cfilter(c)
  	return c:IsCode(CARD_ID_4) and c:IsFaceup()
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_ONFIELD, 0, 1, nil)
  end
  function s.spfilter(c, e, tp)
  	return c:IsCode(CARD_ID_3) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_HAND + LOCATION_DECK + LOCATION_GRAVE, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND + LOCATION_DECK + LOCATION_GRAVE)
  end
  function s.setfilter(c)
  	return c:IsCode(CARD_ID_1, CARD_ID_0, CARD_ID_2, CARD_ID_5) and c:IsSSetable()
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) < 1 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.spfilter), tp, LOCATION_HAND + LOCATION_DECK + LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  	local sc = g:GetFirst()
  	if sc and Duel.SpecialSummon(sc, 0, tp, tp, false, false, POS_FACEUP) > 0 then
  		local g2 = Duel.GetMatchingGroup(s.setfilter, tp, LOCATION_DECK, 0, nil)
  		if g2:GetCount() > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 0)) then
  			Duel.BreakEffect()
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SET)
  			local tc = g2:Select(tp, 1, 1, nil)
  			Duel.SSet(tp, tc)
  		end
  	end
  end
  
  