name: Marincess
card_text: You can target 1 "Marincess" card you control; Special Summon this card from your hand, and if you do, it gains this effect.
  ● While this card is in the Monster Zone, the targeted card cannot be destroyed by your opponent's card effects.
  You can banish this card from your GY, then target 1 "Marincess" Link Monster you control; equip it with 1 "Marincess" Link Monster from your GY. You can only use each effect of "Marincess Sleepy Maiden" once per turn.
external_ids: local SETCARD_ID_0 = 0x12b --Marincess
  
lua: local SETCARD_ID_0 = 0x12b --Marincess
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--equip
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_EQUIP)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetRange(LOCATION_GRAVE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCost(aux.bfgcost)
  	e2:SetTarget(s.eqtg)
  	e2:SetOperation(s.eqop)
  	c:RegisterEffect(e2)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local c = e:GetHandler()
  	if chkc then
  		return chkc:IsOnField() and chkc:IsControler(tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_ONFIELD, 0, 1, nil) and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	Duel.SelectTarget(tp, s.filter, tp, LOCATION_ONFIELD, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, c, 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	local tc = Duel.GetFirstTarget()
  	if Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP) ~= 0 and c:IsFaceup() and tc:IsRelateToEffect(e) and not tc:IsImmuneToEffect(e) then
  		c:SetCardTarget(tc)
  		--indes
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_TARGET)
  		e1:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  		e1:SetRange(LOCATION_MZONE)
  		e1:SetValue(aux.indoval)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		c:RegisterEffect(e1)
  	end
  end
  function s.tgfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_LINK)
  end
  function s.eqfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_LINK) and not c:IsForbidden()
  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.tgfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_SZONE) > 0
  			and Duel.IsExistingTarget(s.tgfilter, tp, LOCATION_MZONE, 0, 1, nil)
  			and Duel.IsExistingMatchingCard(s.eqfilter, tp, LOCATION_GRAVE, 0, 1, e:GetHandler())
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_EQUIP)
  	Duel.SelectTarget(tp, s.tgfilter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_EQUIP, nil, 1, tp, LOCATION_GRAVE)
  end
  function s.eqop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and tc:IsFaceup() and Duel.GetLocationCount(tp, LOCATION_SZONE) > 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_EQUIP)
  		local g = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.eqfilter), tp, LOCATION_GRAVE, 0, 1, 1, nil)
  		local ec = g:GetFirst()
  		if ec then
  			if not Duel.Equip(tp, ec, tc) then
  				return
  			end
  			--equip limit
  			local e1 = Effect.CreateEffect(e:GetHandler())
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_EQUIP_LIMIT)
  			e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  			e1:SetLabelObject(tc)
  			e1:SetValue(s.eqlimit)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  			ec:RegisterEffect(e1)
  		end
  	end
  end
  function s.eqlimit(e, c)
  	return c == e:GetLabelObject()
  end
  
  
source_text: Marincess
  You can target 1 "Marincess" card you control; Special Summon this card from your hand, and if you do, it gains this effect.
  ● While this card is in the Monster Zone, the targeted card cannot be destroyed by your opponent's card effects.
  You can banish this card from your GY, then target 1 "Marincess" Link Monster you control; equip it with 1 "Marincess" Link Monster from your GY. You can only use each effect of "Marincess Sleepy Maiden" once per turn.
target_text: -- Marincess
  local SETCARD_ID_0 = 0x12b --Marincess
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--equip
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_EQUIP)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetRange(LOCATION_GRAVE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCost(aux.bfgcost)
  	e2:SetTarget(s.eqtg)
  	e2:SetOperation(s.eqop)
  	c:RegisterEffect(e2)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local c = e:GetHandler()
  	if chkc then
  		return chkc:IsOnField() and chkc:IsControler(tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_ONFIELD, 0, 1, nil) and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	Duel.SelectTarget(tp, s.filter, tp, LOCATION_ONFIELD, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, c, 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	local tc = Duel.GetFirstTarget()
  	if Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP) ~= 0 and c:IsFaceup() and tc:IsRelateToEffect(e) and not tc:IsImmuneToEffect(e) then
  		c:SetCardTarget(tc)
  		--indes
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_TARGET)
  		e1:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  		e1:SetRange(LOCATION_MZONE)
  		e1:SetValue(aux.indoval)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		c:RegisterEffect(e1)
  	end
  end
  function s.tgfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_LINK)
  end
  function s.eqfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_LINK) and not c:IsForbidden()
  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.tgfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_SZONE) > 0
  			and Duel.IsExistingTarget(s.tgfilter, tp, LOCATION_MZONE, 0, 1, nil)
  			and Duel.IsExistingMatchingCard(s.eqfilter, tp, LOCATION_GRAVE, 0, 1, e:GetHandler())
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_EQUIP)
  	Duel.SelectTarget(tp, s.tgfilter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_EQUIP, nil, 1, tp, LOCATION_GRAVE)
  end
  function s.eqop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and tc:IsFaceup() and Duel.GetLocationCount(tp, LOCATION_SZONE) > 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_EQUIP)
  		local g = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.eqfilter), tp, LOCATION_GRAVE, 0, 1, 1, nil)
  		local ec = g:GetFirst()
  		if ec then
  			if not Duel.Equip(tp, ec, tc) then
  				return
  			end
  			--equip limit
  			local e1 = Effect.CreateEffect(e:GetHandler())
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_EQUIP_LIMIT)
  			e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  			e1:SetLabelObject(tc)
  			e1:SetValue(s.eqlimit)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  			ec:RegisterEffect(e1)
  		end
  	end
  end
  function s.eqlimit(e, c)
  	return c == e:GetLabelObject()
  end
  
  