name: Cyber
card_text: If you control "Jinzo": Target 1 card on the field; destroy it, then, if it was a Trap, you can apply 1 of these effects.
  ● Negate the effects of 1 face-up card on the field until the end of this turn.
  ● All "Jinzo" you control gain 800 ATK.
  You can only activate 1 "Cyber Energy Shock" per turn.
external_ids: local CARD_ID_0 = 77585513 --Jinzo
  
lua: local CARD_ID_0 = 77585513 --Jinzo
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DESTROY)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER)
  	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_0) 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.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsOnField() and chkc ~= e:GetHandler()
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, e:GetHandler())
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectTarget(tp, aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, 1, e:GetHandler())
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and Duel.Destroy(tc, REASON_EFFECT) ~= 0 and tc:IsType(TYPE_TRAP) then
  		local g1 = Duel.GetMatchingGroup(aux.NegateAnyFilter, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, c)
  		local g2 = Duel.GetMatchingGroup(s.cfilter, tp, LOCATION_MZONE, 0, nil)
  		local off = 1
  		local ops = {}
  		local opval = {}
  		ops[off] = aux.Stringid(id, 0)
  		opval[off - 1] = 0
  		off = off + 1
  		if #g1 > 0 then
  			ops[off] = aux.Stringid(id, 1)
  			opval[off - 1] = 1
  			off = off + 1
  		end
  		if #g2 > 0 then
  			ops[off] = aux.Stringid(id, 2)
  			opval[off - 1] = 2
  			off = off + 1
  		end
  		local op = 0
  		if #ops > 1 then
  			op = Duel.SelectOption(tp, table.unpack(ops))
  		end
  		if opval[op] == 1 then
  			Duel.BreakEffect()
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DISABLE)
  			local sg = g1:Select(tp, 1, 1, nil)
  			local tc = sg:GetFirst()
  			Duel.NegateRelatedChain(tc, RESET_TURN_SET)
  			local e1 = Effect.CreateEffect(c)
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  			e1:SetCode(EFFECT_DISABLE)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			tc:RegisterEffect(e1)
  			local e2 = Effect.CreateEffect(c)
  			e2:SetType(EFFECT_TYPE_SINGLE)
  			e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  			e2:SetCode(EFFECT_DISABLE_EFFECT)
  			e2:SetValue(RESET_TURN_SET)
  			e2:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			tc:RegisterEffect(e2)
  			if tc:IsType(TYPE_TRAPMONSTER) then
  				local e3 = Effect.CreateEffect(c)
  				e3:SetType(EFFECT_TYPE_SINGLE)
  				e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  				e3:SetCode(EFFECT_DISABLE_TRAPMONSTER)
  				e3:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  				tc:RegisterEffect(e3)
  			end
  		end
  		if opval[op] == 2 then
  			Duel.BreakEffect()
  			local tc = g2:GetFirst()
  			while tc do
  				local e1 = Effect.CreateEffect(c)
  				e1:SetType(EFFECT_TYPE_SINGLE)
  				e1:SetCode(EFFECT_UPDATE_ATTACK)
  				e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  				e1:SetValue(800)
  				tc:RegisterEffect(e1)
  				tc = g2:GetNext()
  			end
  		end
  	end
  end
  
  
source_text: Cyber
  If you control "Jinzo": Target 1 card on the field; destroy it, then, if it was a Trap, you can apply 1 of these effects.
  ● Negate the effects of 1 face-up card on the field until the end of this turn.
  ● All "Jinzo" you control gain 800 ATK.
  You can only activate 1 "Cyber Energy Shock" per turn.
target_text: -- Cyber
  local CARD_ID_0 = 77585513 --Jinzo
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DESTROY)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER)
  	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_0) 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.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsOnField() and chkc ~= e:GetHandler()
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, e:GetHandler())
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectTarget(tp, aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, 1, e:GetHandler())
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and Duel.Destroy(tc, REASON_EFFECT) ~= 0 and tc:IsType(TYPE_TRAP) then
  		local g1 = Duel.GetMatchingGroup(aux.NegateAnyFilter, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, c)
  		local g2 = Duel.GetMatchingGroup(s.cfilter, tp, LOCATION_MZONE, 0, nil)
  		local off = 1
  		local ops = {}
  		local opval = {}
  		ops[off] = aux.Stringid(id, 0)
  		opval[off - 1] = 0
  		off = off + 1
  		if #g1 > 0 then
  			ops[off] = aux.Stringid(id, 1)
  			opval[off - 1] = 1
  			off = off + 1
  		end
  		if #g2 > 0 then
  			ops[off] = aux.Stringid(id, 2)
  			opval[off - 1] = 2
  			off = off + 1
  		end
  		local op = 0
  		if #ops > 1 then
  			op = Duel.SelectOption(tp, table.unpack(ops))
  		end
  		if opval[op] == 1 then
  			Duel.BreakEffect()
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DISABLE)
  			local sg = g1:Select(tp, 1, 1, nil)
  			local tc = sg:GetFirst()
  			Duel.NegateRelatedChain(tc, RESET_TURN_SET)
  			local e1 = Effect.CreateEffect(c)
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  			e1:SetCode(EFFECT_DISABLE)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			tc:RegisterEffect(e1)
  			local e2 = Effect.CreateEffect(c)
  			e2:SetType(EFFECT_TYPE_SINGLE)
  			e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  			e2:SetCode(EFFECT_DISABLE_EFFECT)
  			e2:SetValue(RESET_TURN_SET)
  			e2:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			tc:RegisterEffect(e2)
  			if tc:IsType(TYPE_TRAPMONSTER) then
  				local e3 = Effect.CreateEffect(c)
  				e3:SetType(EFFECT_TYPE_SINGLE)
  				e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  				e3:SetCode(EFFECT_DISABLE_TRAPMONSTER)
  				e3:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  				tc:RegisterEffect(e3)
  			end
  		end
  		if opval[op] == 2 then
  			Duel.BreakEffect()
  			local tc = g2:GetFirst()
  			while tc do
  				local e1 = Effect.CreateEffect(c)
  				e1:SetType(EFFECT_TYPE_SINGLE)
  				e1:SetCode(EFFECT_UPDATE_ATTACK)
  				e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  				e1:SetValue(800)
  				tc:RegisterEffect(e1)
  				tc = g2:GetNext()
  			end
  		end
  	end
  end
  
  