name: Secure
card_text: 1 Cyberse Link Monster
  After this card is Special Summoned, you take no effect damage for the rest of this turn. Once per turn, if you would take battle or effect damage, you take no damage. Cannot be used as Link Material. You can only control 1 "Secure Gardna".
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	c:SetUniqueOnField(1, 0, id)
  	--link summon
  	c:EnableReviveLimit()
  	aux.AddLinkProcedure(c, s.matfilter, 1, 1)
  	--cannot link material
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCode(EFFECT_CANNOT_BE_LINK_MATERIAL)
  	e1:SetValue(1)
  	c:RegisterEffect(e1)
  	--change damage
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e2:SetOperation(s.regop)
  	c:RegisterEffect(e2)
  	--damage reduce
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e3:SetCode(EFFECT_CHANGE_DAMAGE)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetTargetRange(1, 0)
  	e3:SetValue(s.damval2)
  	c:RegisterEffect(e3)
  	local e4 = e3:Clone()
  	e4:SetCode(EFFECT_NO_EFFECT_DAMAGE)
  	e4:SetCondition(s.damcon)
  	c:RegisterEffect(e4)
  end
  function s.regop(e, tp, eg, ep, ev, re, r, rp)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CHANGE_DAMAGE)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetTargetRange(1, 0)
  	e1:SetValue(s.damval1)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  	local e2 = e1:Clone()
  	e2:SetCode(EFFECT_NO_EFFECT_DAMAGE)
  	e2:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e2, tp)
  end
  function s.matfilter(c)
  	return c:IsLinkRace(RACE_CYBERSE) and c:IsLinkType(TYPE_LINK)
  end
  function s.damval1(e, re, val, r, rp, rc)
  	if bit.band(r, REASON_EFFECT) ~= 0 then
  		return 0
  	else
  		return val
  	end
  end
  function s.damval2(e, re, val, r, rp, rc)
  	local c = e:GetHandler()
  	if bit.band(r, REASON_BATTLE + REASON_EFFECT) ~= 0 and c:GetFlagEffect(id) == 0 then
  		c:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END, 0, 1)
  		return 0
  	end
  	return val
  end
  function s.damcon(e)
  	return e:GetHandler():GetFlagEffect(id) == 0
  end
  
  
source_text: Secure
  1 Cyberse Link Monster
  After this card is Special Summoned, you take no effect damage for the rest of this turn. Once per turn, if you would take battle or effect damage, you take no damage. Cannot be used as Link Material. You can only control 1 "Secure Gardna".
target_text: -- Secure
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:SetUniqueOnField(1, 0, id)
  	--link summon
  	c:EnableReviveLimit()
  	aux.AddLinkProcedure(c, s.matfilter, 1, 1)
  	--cannot link material
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCode(EFFECT_CANNOT_BE_LINK_MATERIAL)
  	e1:SetValue(1)
  	c:RegisterEffect(e1)
  	--change damage
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e2:SetOperation(s.regop)
  	c:RegisterEffect(e2)
  	--damage reduce
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e3:SetCode(EFFECT_CHANGE_DAMAGE)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetTargetRange(1, 0)
  	e3:SetValue(s.damval2)
  	c:RegisterEffect(e3)
  	local e4 = e3:Clone()
  	e4:SetCode(EFFECT_NO_EFFECT_DAMAGE)
  	e4:SetCondition(s.damcon)
  	c:RegisterEffect(e4)
  end
  function s.regop(e, tp, eg, ep, ev, re, r, rp)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CHANGE_DAMAGE)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetTargetRange(1, 0)
  	e1:SetValue(s.damval1)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  	local e2 = e1:Clone()
  	e2:SetCode(EFFECT_NO_EFFECT_DAMAGE)
  	e2:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e2, tp)
  end
  function s.matfilter(c)
  	return c:IsLinkRace(RACE_CYBERSE) and c:IsLinkType(TYPE_LINK)
  end
  function s.damval1(e, re, val, r, rp, rc)
  	if bit.band(r, REASON_EFFECT) ~= 0 then
  		return 0
  	else
  		return val
  	end
  end
  function s.damval2(e, re, val, r, rp, rc)
  	local c = e:GetHandler()
  	if bit.band(r, REASON_BATTLE + REASON_EFFECT) ~= 0 and c:GetFlagEffect(id) == 0 then
  		c:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END, 0, 1)
  		return 0
  	end
  	return val
  end
  function s.damcon(e)
  	return e:GetHandler():GetFlagEffect(id) == 0
  end
  
  