name: Mermaid
card_text: Once per turn: You can target 1 face-up Level 3 or lower monster you control; equip that target to this card. (You can only equip 1 monster at a time to this card with this effect.) While equipped with a monster by this effect, this card gains 800 ATK. If this card would be destroyed, you can destroy the monster equipped to it with this effect, instead.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--equip
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_EQUIP)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1)
  	e1:SetCondition(s.eqcon)
  	e1:SetTarget(s.eqtg)
  	e1:SetOperation(s.eqop)
  	c:RegisterEffect(e1)
  	--Destroy replace
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_CONTINUOUS + EFFECT_TYPE_SINGLE)
  	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCode(EFFECT_DESTROY_REPLACE)
  	e2:SetTarget(s.desreptg)
  	e2:SetOperation(s.desrepop)
  	e2:SetLabelObject(e1)
  	c:RegisterEffect(e2)
  end
  function s.eqcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local ec = e:GetLabelObject()
  	return ec == nil or not ec:IsHasCardTarget(c) or ec:GetFlagEffect(id) == 0
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsLevelBelow(3)
  end
  function s.eqtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.filter(chkc) and chkc ~= e:GetHandler()
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_SZONE) > 0 and Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE, 0, 1, e:GetHandler())
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_EQUIP)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE, 0, 1, 1, e:GetHandler())
  	Duel.SetOperationInfo(0, CATEGORY_EQUIP, g, 1, 0, 0)
  end
  function s.eqlimit(e, c)
  	return e:GetOwner() == c
  end
  function s.eqop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsFaceup() and tc:IsRelateToEffect(e) and tc:IsType(TYPE_MONSTER) then
  		if not Duel.Equip(tp, tc, c, false) then
  			return
  		end
  		--Add Equip limit
  		tc:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD, 0, 0)
  		e:SetLabelObject(tc)
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_EQUIP_LIMIT)
  		e1:SetProperty(EFFECT_FLAG_OWNER_RELATE)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		e1:SetValue(s.eqlimit)
  		tc:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_EQUIP)
  		e2:SetCode(EFFECT_UPDATE_ATTACK)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  		e2:SetValue(800)
  		tc:RegisterEffect(e2)
  	end
  end
  function s.desreptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	local ec = e:GetLabelObject():GetLabelObject()
  	if chk == 0 then
  		return ec and ec:IsHasCardTarget(c) and ec:GetFlagEffect(id) ~= 0 and ec:IsDestructable(e) and not ec:IsStatus(STATUS_DESTROY_CONFIRMED) and not c:IsReason(REASON_REPLACE)
  	end
  	return Duel.SelectEffectYesNo(tp, c, 96)
  end
  function s.desrepop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Destroy(e:GetLabelObject():GetLabelObject(), REASON_EFFECT + REASON_REPLACE)
  end
  
  
source_text: Mermaid
  Once per turn: You can target 1 face-up Level 3 or lower monster you control; equip that target to this card. (You can only equip 1 monster at a time to this card with this effect.) While equipped with a monster by this effect, this card gains 800 ATK. If this card would be destroyed, you can destroy the monster equipped to it with this effect, instead.
target_text: -- Mermaid
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--equip
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_EQUIP)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1)
  	e1:SetCondition(s.eqcon)
  	e1:SetTarget(s.eqtg)
  	e1:SetOperation(s.eqop)
  	c:RegisterEffect(e1)
  	--Destroy replace
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_CONTINUOUS + EFFECT_TYPE_SINGLE)
  	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCode(EFFECT_DESTROY_REPLACE)
  	e2:SetTarget(s.desreptg)
  	e2:SetOperation(s.desrepop)
  	e2:SetLabelObject(e1)
  	c:RegisterEffect(e2)
  end
  function s.eqcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local ec = e:GetLabelObject()
  	return ec == nil or not ec:IsHasCardTarget(c) or ec:GetFlagEffect(id) == 0
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsLevelBelow(3)
  end
  function s.eqtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.filter(chkc) and chkc ~= e:GetHandler()
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_SZONE) > 0 and Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE, 0, 1, e:GetHandler())
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_EQUIP)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE, 0, 1, 1, e:GetHandler())
  	Duel.SetOperationInfo(0, CATEGORY_EQUIP, g, 1, 0, 0)
  end
  function s.eqlimit(e, c)
  	return e:GetOwner() == c
  end
  function s.eqop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsFaceup() and tc:IsRelateToEffect(e) and tc:IsType(TYPE_MONSTER) then
  		if not Duel.Equip(tp, tc, c, false) then
  			return
  		end
  		--Add Equip limit
  		tc:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD, 0, 0)
  		e:SetLabelObject(tc)
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_EQUIP_LIMIT)
  		e1:SetProperty(EFFECT_FLAG_OWNER_RELATE)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		e1:SetValue(s.eqlimit)
  		tc:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_EQUIP)
  		e2:SetCode(EFFECT_UPDATE_ATTACK)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  		e2:SetValue(800)
  		tc:RegisterEffect(e2)
  	end
  end
  function s.desreptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	local ec = e:GetLabelObject():GetLabelObject()
  	if chk == 0 then
  		return ec and ec:IsHasCardTarget(c) and ec:GetFlagEffect(id) ~= 0 and ec:IsDestructable(e) and not ec:IsStatus(STATUS_DESTROY_CONFIRMED) and not c:IsReason(REASON_REPLACE)
  	end
  	return Duel.SelectEffectYesNo(tp, c, 96)
  end
  function s.desrepop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Destroy(e:GetLabelObject():GetLabelObject(), REASON_EFFECT + REASON_REPLACE)
  end
  
  