name: Sea
card_text: Send this card to the Graveyard during your opponent's 3rd End Phase after activation. WATER monsters you control cannot be destroyed by your opponent's card effects.
lua: 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)
  	e1:SetTarget(s.target)
  	c:RegisterEffect(e1)
  	--indes
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetTargetRange(LOCATION_MZONE, 0)
  	e2:SetTarget(aux.TargetBoolFunction(Card.IsAttribute, ATTRIBUTE_WATER))
  	e2:SetValue(aux.indoval)
  	c:RegisterEffect(e2)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	e:GetHandler():SetTurnCounter(0)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e1:SetCode(EVENT_PHASE + PHASE_END)
  	e1:SetCountLimit(1)
  	e1:SetRange(LOCATION_SZONE)
  	e1:SetCondition(s.tgcon)
  	e1:SetOperation(s.tgop)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END + RESET_OPPO_TURN, 3)
  	e:GetHandler():RegisterEffect(e1)
  end
  function s.tgcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() ~= tp
  end
  function s.tgop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local ct = c:GetTurnCounter()
  	ct = ct + 1
  	c:SetTurnCounter(ct)
  	if ct == 3 then
  		Duel.SendtoGrave(c, REASON_RULE)
  	end
  end
  
  
source_text: Sea
  Send this card to the Graveyard during your opponent's 3rd End Phase after activation. WATER monsters you control cannot be destroyed by your opponent's card effects.
target_text: -- Sea
  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)
  	e1:SetTarget(s.target)
  	c:RegisterEffect(e1)
  	--indes
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetTargetRange(LOCATION_MZONE, 0)
  	e2:SetTarget(aux.TargetBoolFunction(Card.IsAttribute, ATTRIBUTE_WATER))
  	e2:SetValue(aux.indoval)
  	c:RegisterEffect(e2)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	e:GetHandler():SetTurnCounter(0)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e1:SetCode(EVENT_PHASE + PHASE_END)
  	e1:SetCountLimit(1)
  	e1:SetRange(LOCATION_SZONE)
  	e1:SetCondition(s.tgcon)
  	e1:SetOperation(s.tgop)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END + RESET_OPPO_TURN, 3)
  	e:GetHandler():RegisterEffect(e1)
  end
  function s.tgcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() ~= tp
  end
  function s.tgop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local ct = c:GetTurnCounter()
  	ct = ct + 1
  	c:SetTurnCounter(ct)
  	if ct == 3 then
  		Duel.SendtoGrave(c, REASON_RULE)
  	end
  end
  
  