name: Ogdoadic
card_text: Special Summon 2 "Ogdoadic Tokens" (Reptile/DARK/Level 2/ATK 0/DEF 0), OR if you have 8 or more "Ogdoadic" monsters with different names in your GY, you can apply this effect instead.
  ● Special Summon 2 Reptile monsters with different names from your GY.
  You can only activate 1 "Ogdoadic Calling" per turn.
external_ids: local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local CARD_ID_1 = 23837055 --Ogdoadic Token
  local SETCARD_ID_0 = 0x161 --Ogdoadic
  
lua: local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local CARD_ID_1 = 23837055 --Ogdoadic Token
  local SETCARD_ID_0 = 0x161 --Ogdoadic
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_TOKEN + CATEGORY_GRAVE_SPSUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMING_END_PHASE)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.spfilter(c, e, tp)
  	return c:IsRace(RACE_REPTILE) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.cfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) or Duel.GetLocationCount(tp, LOCATION_MZONE) < 2 then
  			return false
  		end
  		local cg = Duel.GetMatchingGroup(s.cfilter, tp, LOCATION_GRAVE, 0, nil)
  		local tg = Duel.GetMatchingGroup(s.spfilter, tp, LOCATION_GRAVE, 0, nil, e, tp)
  		return Duel.IsPlayerCanSpecialSummonMonster(tp, id + 1, 0, TYPES_TOKEN_MONSTER, 0, 0, 2, RACE_REPTILE, ATTRIBUTE_DARK)
  			or cg:GetClassCount(Card.GetCode) >= 8 and tg:GetClassCount(Card.GetCode) >= 2
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOKEN, nil, 2, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 2, 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  		return
  	end
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) < 2 then
  		return
  	end
  	local cg = Duel.GetMatchingGroup(s.cfilter, tp, LOCATION_GRAVE, 0, nil)
  	local tg = Duel.GetMatchingGroup(aux.NecroValleyFilter(s.spfilter), tp, LOCATION_GRAVE, 0, nil, e, tp)
  	local res1 = Duel.IsPlayerCanSpecialSummonMonster(tp, id + 1, 0, TYPES_TOKEN_MONSTER, 0, 0, 2, RACE_REPTILE, ATTRIBUTE_DARK)
  	local res2 = cg:GetClassCount(Card.GetCode) >= 8 and tg:GetClassCount(Card.GetCode) >= 2
  	if res2 and (not res1 or Duel.SelectYesNo(tp, aux.Stringid(id, 0))) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local sg = tg:SelectSubGroup(tp, aux.dncheck, false, 2, 2)
  		Duel.SpecialSummon(sg, 0, tp, tp, false, false, POS_FACEUP)
  	elseif res1 then
  		for i = 1, 2 do
  			local token = Duel.CreateToken(tp, id + 1)
  			Duel.SpecialSummonStep(token, 0, tp, tp, false, false, POS_FACEUP)
  		end
  		Duel.SpecialSummonComplete()
  	end
  end
  
  
source_text: Ogdoadic
  Special Summon 2 "Ogdoadic Tokens" (Reptile/DARK/Level 2/ATK 0/DEF 0), OR if you have 8 or more "Ogdoadic" monsters with different names in your GY, you can apply this effect instead.
  ● Special Summon 2 Reptile monsters with different names from your GY.
  You can only activate 1 "Ogdoadic Calling" per turn.
target_text: -- Ogdoadic
  local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local CARD_ID_1 = 23837055 --Ogdoadic Token
  local SETCARD_ID_0 = 0x161 --Ogdoadic
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_TOKEN + CATEGORY_GRAVE_SPSUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMING_END_PHASE)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.spfilter(c, e, tp)
  	return c:IsRace(RACE_REPTILE) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.cfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) or Duel.GetLocationCount(tp, LOCATION_MZONE) < 2 then
  			return false
  		end
  		local cg = Duel.GetMatchingGroup(s.cfilter, tp, LOCATION_GRAVE, 0, nil)
  		local tg = Duel.GetMatchingGroup(s.spfilter, tp, LOCATION_GRAVE, 0, nil, e, tp)
  		return Duel.IsPlayerCanSpecialSummonMonster(tp, id + 1, 0, TYPES_TOKEN_MONSTER, 0, 0, 2, RACE_REPTILE, ATTRIBUTE_DARK)
  			or cg:GetClassCount(Card.GetCode) >= 8 and tg:GetClassCount(Card.GetCode) >= 2
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOKEN, nil, 2, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 2, 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  		return
  	end
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) < 2 then
  		return
  	end
  	local cg = Duel.GetMatchingGroup(s.cfilter, tp, LOCATION_GRAVE, 0, nil)
  	local tg = Duel.GetMatchingGroup(aux.NecroValleyFilter(s.spfilter), tp, LOCATION_GRAVE, 0, nil, e, tp)
  	local res1 = Duel.IsPlayerCanSpecialSummonMonster(tp, id + 1, 0, TYPES_TOKEN_MONSTER, 0, 0, 2, RACE_REPTILE, ATTRIBUTE_DARK)
  	local res2 = cg:GetClassCount(Card.GetCode) >= 8 and tg:GetClassCount(Card.GetCode) >= 2
  	if res2 and (not res1 or Duel.SelectYesNo(tp, aux.Stringid(id, 0))) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local sg = tg:SelectSubGroup(tp, aux.dncheck, false, 2, 2)
  		Duel.SpecialSummon(sg, 0, tp, tp, false, false, POS_FACEUP)
  	elseif res1 then
  		for i = 1, 2 do
  			local token = Duel.CreateToken(tp, id + 1)
  			Duel.SpecialSummonStep(token, 0, tp, tp, false, false, POS_FACEUP)
  		end
  		Duel.SpecialSummonComplete()
  	end
  end
  
  