name: Abyss-sphere
card_text: Special Summon 1 "Mermail" monster from your Deck. Its effects are negated. You cannot activate any Spell Cards. When this card leaves the field, destroy that monster. Destroy this card during your opponent's next End Phase after activation.
external_ids: local SETCARD_ID_0 = 0x74 --Mermail
  
lua: local SETCARD_ID_0 = 0x74 --Mermail
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMING_END_PHASE + TIMING_MAIN_END)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  	--act limit
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e2:SetCode(EFFECT_CANNOT_ACTIVATE)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetTargetRange(1, 0)
  	e2:SetValue(s.aclimit)
  	c:RegisterEffect(e2)
  	--destroy
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_CONTINUOUS + EFFECT_TYPE_SINGLE)
  	e3:SetCode(EVENT_LEAVE_FIELD)
  	e3:SetOperation(s.desop)
  	c:RegisterEffect(e3)
  	--disable
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_TARGET)
  	e4:SetCode(EFFECT_DISABLE)
  	e4:SetRange(LOCATION_SZONE)
  	c:RegisterEffect(e4)
  end
  function s.filter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_DECK, 0, 1, nil, e, tp)
  	end
  	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:SetRange(LOCATION_SZONE)
  	e1:SetCountLimit(1)
  	e1:SetCondition(s.sdescon)
  	e1:SetOperation(s.sdesop)
  	if Duel.GetCurrentPhase() == PHASE_END and Duel.GetTurnPlayer() ~= tp then
  		e1:SetLabel(Duel.GetTurnCount())
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END + RESET_OPPO_TURN, 2)
  	else
  		e1:SetLabel(0)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END + RESET_OPPO_TURN)
  	end
  	e:GetHandler():RegisterEffect(e1)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_DECK)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) or Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_DECK, 0, 1, 1, nil, e, tp)
  	local tc = g:GetFirst()
  	if tc and Duel.SpecialSummonStep(tc, 0, tp, tp, false, false, POS_FACEUP) then
  		c:SetCardTarget(tc)
  	end
  	Duel.SpecialSummonComplete()
  end
  function s.sdescon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() ~= tp and Duel.GetTurnCount() ~= e:GetLabel()
  end
  function s.sdesop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Destroy(e:GetHandler(), REASON_RULE)
  end
  function s.aclimit(e, re, tp)
  	return re:IsHasType(EFFECT_TYPE_ACTIVATE) and re:IsActiveType(TYPE_SPELL)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = e:GetHandler():GetFirstCardTarget()
  	if tc and tc:IsLocation(LOCATION_MZONE) then
  		Duel.Destroy(tc, REASON_EFFECT)
  	end
  end
  
  
source_text: Abyss-sphere
  Special Summon 1 "Mermail" monster from your Deck. Its effects are negated. You cannot activate any Spell Cards. When this card leaves the field, destroy that monster. Destroy this card during your opponent's next End Phase after activation.
target_text: -- Abyss-sphere
  local SETCARD_ID_0 = 0x74 --Mermail
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMING_END_PHASE + TIMING_MAIN_END)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  	--act limit
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e2:SetCode(EFFECT_CANNOT_ACTIVATE)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetTargetRange(1, 0)
  	e2:SetValue(s.aclimit)
  	c:RegisterEffect(e2)
  	--destroy
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_CONTINUOUS + EFFECT_TYPE_SINGLE)
  	e3:SetCode(EVENT_LEAVE_FIELD)
  	e3:SetOperation(s.desop)
  	c:RegisterEffect(e3)
  	--disable
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_TARGET)
  	e4:SetCode(EFFECT_DISABLE)
  	e4:SetRange(LOCATION_SZONE)
  	c:RegisterEffect(e4)
  end
  function s.filter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_DECK, 0, 1, nil, e, tp)
  	end
  	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:SetRange(LOCATION_SZONE)
  	e1:SetCountLimit(1)
  	e1:SetCondition(s.sdescon)
  	e1:SetOperation(s.sdesop)
  	if Duel.GetCurrentPhase() == PHASE_END and Duel.GetTurnPlayer() ~= tp then
  		e1:SetLabel(Duel.GetTurnCount())
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END + RESET_OPPO_TURN, 2)
  	else
  		e1:SetLabel(0)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END + RESET_OPPO_TURN)
  	end
  	e:GetHandler():RegisterEffect(e1)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_DECK)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) or Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_DECK, 0, 1, 1, nil, e, tp)
  	local tc = g:GetFirst()
  	if tc and Duel.SpecialSummonStep(tc, 0, tp, tp, false, false, POS_FACEUP) then
  		c:SetCardTarget(tc)
  	end
  	Duel.SpecialSummonComplete()
  end
  function s.sdescon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() ~= tp and Duel.GetTurnCount() ~= e:GetLabel()
  end
  function s.sdesop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Destroy(e:GetHandler(), REASON_RULE)
  end
  function s.aclimit(e, re, tp)
  	return re:IsHasType(EFFECT_TYPE_ACTIVATE) and re:IsActiveType(TYPE_SPELL)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = e:GetHandler():GetFirstCardTarget()
  	if tc and tc:IsLocation(LOCATION_MZONE) then
  		Duel.Destroy(tc, REASON_EFFECT)
  	end
  end
  
  