name: Cybernetic
card_text: (This card is always treated as a "Cyberdark" card.)
  Send 2 Dragon and/or Machine "Cyber" monsters with different Attributes to the GY, 1 each from your hand and Deck; add 1 Dragon or Machine "Cyber" monster from your Deck to your hand, and if you do, send 1 Machine "Cyber" Fusion Monster from your Extra Deck to the GY. You can only activate 1 "Cybernetic Horizon" per turn. You cannot Special Summon monsters from the Extra Deck the turn you activate this card, except Machine monsters.
external_ids: local SETCARD_ID_0 = 0x93 --Cyber
  
lua: local SETCARD_ID_0 = 0x93 --Cyber
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH + CATEGORY_TOGRAVE)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	Duel.AddCustomActivityCounter(id, ACTIVITY_SPSUMMON, s.counterfilter)
  end
  function s.counterfilter(c)
  	return not c:IsSummonLocation(LOCATION_EXTRA) or c:IsRace(RACE_MACHINE)
  end
  function s.costfilter(c)
  	return c:IsRace(RACE_DRAGON + RACE_MACHINE) and c:IsSetCard(SETCARD_ID_0) and c:IsAbleToGraveAsCost()
  end
  function s.thfilter(c)
  	return c:IsRace(RACE_DRAGON + RACE_MACHINE) and c:IsSetCard(SETCARD_ID_0) and c:IsAbleToHand()
  end
  function s.fselect(g, tp)
  	local sg = g:Clone()
  	local res = true
  	for c in aux.Next(sg) do
  		res = res and not sg:IsExists(Card.IsAttribute, 1, c, c:GetAttribute())
  	end
  	return g:GetClassCount(Card.GetLocation) == g:GetCount() and res and Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, g)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local g = Duel.GetMatchingGroup(s.costfilter, tp, LOCATION_HAND + LOCATION_DECK, 0, nil)
  	if chk == 0 then
  		return Duel.GetCustomActivityCount(id, tp, ACTIVITY_SPSUMMON) == 0 and g:CheckSubGroup(s.fselect, 2, 2, tp)
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_OATH)
  	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	e1:SetTargetRange(1, 0)
  	e1:SetTarget(s.splimit)
  	Duel.RegisterEffect(e1, tp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local sg = g:SelectSubGroup(tp, s.fselect, false, 2, 2, tp)
  	Duel.SendtoGrave(sg, REASON_COST)
  end
  function s.splimit(e, c)
  	return c:IsLocation(LOCATION_EXTRA) and not c:IsRace(RACE_MACHINE)
  end
  function s.tgfilter(c)
  	return c:IsRace(RACE_MACHINE) and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_FUSION) and c:IsAbleToGrave()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil) and Duel.IsExistingMatchingCard(s.tgfilter, tp, LOCATION_EXTRA, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 1, tp, LOCATION_EXTRA)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local tc = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil):GetFirst()
  	if tc and Duel.SendtoHand(tc, nil, REASON_EFFECT) ~= 0 then
  		Duel.ConfirmCards(1 - tp, tc)
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  		local g = Duel.SelectMatchingCard(tp, s.tgfilter, tp, LOCATION_EXTRA, 0, 1, 1, nil)
  		if g:GetCount() > 0 then
  			Duel.SendtoGrave(g, REASON_EFFECT)
  		end
  	end
  end
  
  
source_text: Cybernetic
  (This card is always treated as a "Cyberdark" card.)
  Send 2 Dragon and/or Machine "Cyber" monsters with different Attributes to the GY, 1 each from your hand and Deck; add 1 Dragon or Machine "Cyber" monster from your Deck to your hand, and if you do, send 1 Machine "Cyber" Fusion Monster from your Extra Deck to the GY. You can only activate 1 "Cybernetic Horizon" per turn. You cannot Special Summon monsters from the Extra Deck the turn you activate this card, except Machine monsters.
target_text: -- Cybernetic
  local SETCARD_ID_0 = 0x93 --Cyber
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH + CATEGORY_TOGRAVE)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	Duel.AddCustomActivityCounter(id, ACTIVITY_SPSUMMON, s.counterfilter)
  end
  function s.counterfilter(c)
  	return not c:IsSummonLocation(LOCATION_EXTRA) or c:IsRace(RACE_MACHINE)
  end
  function s.costfilter(c)
  	return c:IsRace(RACE_DRAGON + RACE_MACHINE) and c:IsSetCard(SETCARD_ID_0) and c:IsAbleToGraveAsCost()
  end
  function s.thfilter(c)
  	return c:IsRace(RACE_DRAGON + RACE_MACHINE) and c:IsSetCard(SETCARD_ID_0) and c:IsAbleToHand()
  end
  function s.fselect(g, tp)
  	local sg = g:Clone()
  	local res = true
  	for c in aux.Next(sg) do
  		res = res and not sg:IsExists(Card.IsAttribute, 1, c, c:GetAttribute())
  	end
  	return g:GetClassCount(Card.GetLocation) == g:GetCount() and res and Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, g)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local g = Duel.GetMatchingGroup(s.costfilter, tp, LOCATION_HAND + LOCATION_DECK, 0, nil)
  	if chk == 0 then
  		return Duel.GetCustomActivityCount(id, tp, ACTIVITY_SPSUMMON) == 0 and g:CheckSubGroup(s.fselect, 2, 2, tp)
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_OATH)
  	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	e1:SetTargetRange(1, 0)
  	e1:SetTarget(s.splimit)
  	Duel.RegisterEffect(e1, tp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local sg = g:SelectSubGroup(tp, s.fselect, false, 2, 2, tp)
  	Duel.SendtoGrave(sg, REASON_COST)
  end
  function s.splimit(e, c)
  	return c:IsLocation(LOCATION_EXTRA) and not c:IsRace(RACE_MACHINE)
  end
  function s.tgfilter(c)
  	return c:IsRace(RACE_MACHINE) and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_FUSION) and c:IsAbleToGrave()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil) and Duel.IsExistingMatchingCard(s.tgfilter, tp, LOCATION_EXTRA, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 1, tp, LOCATION_EXTRA)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local tc = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil):GetFirst()
  	if tc and Duel.SendtoHand(tc, nil, REASON_EFFECT) ~= 0 then
  		Duel.ConfirmCards(1 - tp, tc)
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  		local g = Duel.SelectMatchingCard(tp, s.tgfilter, tp, LOCATION_EXTRA, 0, 1, 1, nil)
  		if g:GetCount() > 0 then
  			Duel.SendtoGrave(g, REASON_EFFECT)
  		end
  	end
  end
  
  