name: Cynet
card_text: If a "Code Talker" monster(s) is Special Summoned from the Extra Deck to your field (except during the Damage Step): You can target 1 of those monsters; add 1 Cyberse monster with the same Attribute from your Deck to your hand, also you cannot Special Summon monsters from the Extra Deck for the rest of this turn, except Cyberse monsters (even if this card leaves the field). You cannot add other monsters with that same Attribute to your hand by the effect of "Cynet Codec" this turn, and you can only activate the effect of "Cynet Codec" once per Chain.
external_ids: local SETCARD_ID_0 = 0x101 --code
  
lua: local SETCARD_ID_0 = 0x101 --code
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--search
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_DELAY)
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetCountLimit(1, id + EFFECT_COUNT_CODE_CHAIN)
  	e2:SetCondition(s.thcon)
  	e2:SetTarget(s.thtg)
  	e2:SetOperation(s.thop)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c, tp)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsControler(tp) and c:IsSummonLocation(LOCATION_EXTRA)
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	return eg:IsExists(s.cfilter, 1, nil, tp)
  end
  function s.tgfilter(c, tp, eg)
  	return eg:IsContains(c) and Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil, c:GetAttribute())
  end
  function s.thfilter(c, att)
  	return c:IsRace(RACE_CYBERSE) and c:IsAttribute(att) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.tgfilter(chkc, tp, eg)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.tgfilter, tp, LOCATION_MZONE, 0, 1, nil, tp, eg)
  	end
  	if eg:GetCount() == 1 then
  		Duel.SetTargetCard(eg)
  	else
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  		Duel.SelectTarget(tp, s.tgfilter, tp, LOCATION_MZONE, 0, 1, 1, nil, tp, eg)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and tc:IsFaceup() then
  		local att = tc:GetAttribute()
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  		local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil, att)
  		if g:GetCount() > 0 then
  			Duel.SendtoHand(g, nil, REASON_EFFECT)
  			Duel.ConfirmCards(1 - tp, g)
  			local e0 = Effect.CreateEffect(c)
  			e0:SetType(EFFECT_TYPE_FIELD)
  			e0:SetCode(EFFECT_CANNOT_TO_HAND)
  			e0:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  			e0:SetTargetRange(1, 0)
  			e0:SetTarget(s.thlimit)
  			e0:SetLabel(att)
  			e0:SetReset(RESET_PHASE + PHASE_END)
  			Duel.RegisterEffect(e0, tp)
  		end
  	end
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetTargetRange(1, 0)
  	e1:SetTarget(s.splimit)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.thlimit(e, c, tp, re)
  	return c:IsAttribute(e:GetLabel()) and re and re:GetHandler():IsCode(id)
  end
  function s.splimit(e, c)
  	return not c:IsRace(RACE_CYBERSE) and c:IsLocation(LOCATION_EXTRA)
  end
  
  
source_text: Cynet
  If a "Code Talker" monster(s) is Special Summoned from the Extra Deck to your field (except during the Damage Step): You can target 1 of those monsters; add 1 Cyberse monster with the same Attribute from your Deck to your hand, also you cannot Special Summon monsters from the Extra Deck for the rest of this turn, except Cyberse monsters (even if this card leaves the field). You cannot add other monsters with that same Attribute to your hand by the effect of "Cynet Codec" this turn, and you can only activate the effect of "Cynet Codec" once per Chain.
target_text: -- Cynet
  local SETCARD_ID_0 = 0x101 --code
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--search
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_DELAY)
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetCountLimit(1, id + EFFECT_COUNT_CODE_CHAIN)
  	e2:SetCondition(s.thcon)
  	e2:SetTarget(s.thtg)
  	e2:SetOperation(s.thop)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c, tp)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsControler(tp) and c:IsSummonLocation(LOCATION_EXTRA)
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	return eg:IsExists(s.cfilter, 1, nil, tp)
  end
  function s.tgfilter(c, tp, eg)
  	return eg:IsContains(c) and Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil, c:GetAttribute())
  end
  function s.thfilter(c, att)
  	return c:IsRace(RACE_CYBERSE) and c:IsAttribute(att) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.tgfilter(chkc, tp, eg)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.tgfilter, tp, LOCATION_MZONE, 0, 1, nil, tp, eg)
  	end
  	if eg:GetCount() == 1 then
  		Duel.SetTargetCard(eg)
  	else
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  		Duel.SelectTarget(tp, s.tgfilter, tp, LOCATION_MZONE, 0, 1, 1, nil, tp, eg)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and tc:IsFaceup() then
  		local att = tc:GetAttribute()
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  		local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil, att)
  		if g:GetCount() > 0 then
  			Duel.SendtoHand(g, nil, REASON_EFFECT)
  			Duel.ConfirmCards(1 - tp, g)
  			local e0 = Effect.CreateEffect(c)
  			e0:SetType(EFFECT_TYPE_FIELD)
  			e0:SetCode(EFFECT_CANNOT_TO_HAND)
  			e0:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  			e0:SetTargetRange(1, 0)
  			e0:SetTarget(s.thlimit)
  			e0:SetLabel(att)
  			e0:SetReset(RESET_PHASE + PHASE_END)
  			Duel.RegisterEffect(e0, tp)
  		end
  	end
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetTargetRange(1, 0)
  	e1:SetTarget(s.splimit)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.thlimit(e, c, tp, re)
  	return c:IsAttribute(e:GetLabel()) and re and re:GetHandler():IsCode(id)
  end
  function s.splimit(e, c)
  	return not c:IsRace(RACE_CYBERSE) and c:IsLocation(LOCATION_EXTRA)
  end
  
  