name: Marincess
card_text: You can banish 1 "Marincess" monster from your GY; Special Summon this card from your hand. If this card is sent to the GY as material for the Link Summon of a WATER monster: You can send cards from the top of your Deck to the GY, equal to the number of "Marincess" monsters you control, then, if a "Marincess" card(s) was sent to the GY by this effect, inflict 200 damage to your opponent for each "Marincess" card sent. You can only use each effect of "Marincess Springirl" 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:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id)
  	e1:SetCost(s.spcost)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--mill
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_DECKDES + CATEGORY_TOGRAVE + CATEGORY_DAMAGE)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_DELAY)
  	e2:SetCode(EVENT_BE_MATERIAL)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCondition(s.tgcon)
  	e2:SetTarget(s.tgtg)
  	e2:SetOperation(s.tgop)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c)
  	return c:IsAbleToRemoveAsCost() and c:IsType(TYPE_MONSTER) and c:IsSetCard(SETCARD_ID_0)
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local sg = Duel.SelectMatchingCard(tp, s.cfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.Remove(sg, POS_FACEUP, REASON_COST)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) then
  		Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.tgcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsLocation(LOCATION_GRAVE) and r == REASON_LINK and c:GetReasonCard():IsAttribute(ATTRIBUTE_WATER)
  end
  function s.ctfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.tgtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local ct = Duel.GetMatchingGroupCount(s.ctfilter, tp, LOCATION_MZONE, 0, nil)
  	if chk == 0 then
  		return ct > 0 and Duel.IsPlayerCanDiscardDeck(tp, ct)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DECKDES, nil, 0, tp, ct)
  end
  function s.ctfilter2(c)
  	return c:IsLocation(LOCATION_GRAVE) and c:IsSetCard(SETCARD_ID_0)
  end
  function s.tgop(e, tp, eg, ep, ev, re, r, rp)
  	local ct1 = Duel.GetMatchingGroupCount(s.ctfilter, tp, LOCATION_MZONE, 0, nil)
  	if ct1 > 0 then
  		if Duel.DiscardDeck(tp, ct1, REASON_EFFECT) ~= 0 then
  			local og = Duel.GetOperatedGroup()
  			local ct2 = og:FilterCount(s.ctfilter2, nil)
  			if ct2 > 0 then
  				Duel.Damage(1 - tp, ct2 * 200, REASON_EFFECT)
  			end
  		end
  	end
  end
  
  
source_text: Marincess
  You can banish 1 "Marincess" monster from your GY; Special Summon this card from your hand. If this card is sent to the GY as material for the Link Summon of a WATER monster: You can send cards from the top of your Deck to the GY, equal to the number of "Marincess" monsters you control, then, if a "Marincess" card(s) was sent to the GY by this effect, inflict 200 damage to your opponent for each "Marincess" card sent. You can only use each effect of "Marincess Springirl" 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:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id)
  	e1:SetCost(s.spcost)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--mill
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_DECKDES + CATEGORY_TOGRAVE + CATEGORY_DAMAGE)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_DELAY)
  	e2:SetCode(EVENT_BE_MATERIAL)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCondition(s.tgcon)
  	e2:SetTarget(s.tgtg)
  	e2:SetOperation(s.tgop)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c)
  	return c:IsAbleToRemoveAsCost() and c:IsType(TYPE_MONSTER) and c:IsSetCard(SETCARD_ID_0)
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local sg = Duel.SelectMatchingCard(tp, s.cfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.Remove(sg, POS_FACEUP, REASON_COST)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) then
  		Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.tgcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsLocation(LOCATION_GRAVE) and r == REASON_LINK and c:GetReasonCard():IsAttribute(ATTRIBUTE_WATER)
  end
  function s.ctfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.tgtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local ct = Duel.GetMatchingGroupCount(s.ctfilter, tp, LOCATION_MZONE, 0, nil)
  	if chk == 0 then
  		return ct > 0 and Duel.IsPlayerCanDiscardDeck(tp, ct)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DECKDES, nil, 0, tp, ct)
  end
  function s.ctfilter2(c)
  	return c:IsLocation(LOCATION_GRAVE) and c:IsSetCard(SETCARD_ID_0)
  end
  function s.tgop(e, tp, eg, ep, ev, re, r, rp)
  	local ct1 = Duel.GetMatchingGroupCount(s.ctfilter, tp, LOCATION_MZONE, 0, nil)
  	if ct1 > 0 then
  		if Duel.DiscardDeck(tp, ct1, REASON_EFFECT) ~= 0 then
  			local og = Duel.GetOperatedGroup()
  			local ct2 = og:FilterCount(s.ctfilter2, nil)
  			if ct2 > 0 then
  				Duel.Damage(1 - tp, ct2 * 200, REASON_EFFECT)
  			end
  		end
  	end
  end
  
  