name: Ice
card_text: You can Special Summon this card (from your hand) by Tributing 2 WATER monsters. Once per turn: You can target 1 face-up monster on the field; place an Ice Counter on that target. You can Tribute this card; destroy all monsters with an Ice Counter(s).
external_ids: local COUNTER_ID_0 = 0x1015 --Ice
  
lua: local COUNTER_ID_0 = 0x1015 --Ice
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCondition(s.spcon)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--add counter
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_COUNTER)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetCountLimit(1)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetTarget(s.target)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  	--destroy
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_DESTROY)
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCost(s.descost)
  	e3:SetTarget(s.destg)
  	e3:SetOperation(s.desop)
  	c:RegisterEffect(e3)
  end
  function s.rfilter(c, tp)
  	return c:IsAttribute(ATTRIBUTE_WATER) and (c:IsControler(tp) or c:IsFaceup())
  end
  function s.spcon(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	local rg = Duel.GetReleaseGroup(tp, false, REASON_SPSUMMON):Filter(s.rfilter, nil, tp)
  	return rg:CheckSubGroup(aux.mzctcheckrel, 2, 2, tp, REASON_SPSUMMON)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, c)
  	local rg = Duel.GetReleaseGroup(tp, false, REASON_SPSUMMON):Filter(s.rfilter, nil, tp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RELEASE)
  	local sg = rg:SelectSubGroup(tp, aux.mzctcheckrel, true, 2, 2, tp, REASON_SPSUMMON)
  	if sg then
  		sg:KeepAlive()
  		e:SetLabelObject(sg)
  		return true
  	else
  		return false
  	end
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp, c)
  	local g = e:GetLabelObject()
  	Duel.Release(g, REASON_SPSUMMON)
  	g:DeleteGroup()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsCanAddCounter(COUNTER_ID_0, 1)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(Card.IsCanAddCounter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil, 0x1015, 1)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	Duel.SelectTarget(tp, Card.IsCanAddCounter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, 1, nil, 0x1015, 1)
  	Duel.SetOperationInfo(0, CATEGORY_COUNTER, nil, 1, 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc and tc:IsRelateToEffect(e) and tc:IsCanAddCounter(COUNTER_ID_0, 1) then
  		tc:AddCounter(COUNTER_ID_0, 1)
  	end
  end
  function s.descost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsReleasable()
  	end
  	Duel.Release(e:GetHandler(), REASON_COST)
  end
  function s.desfilter(c)
  	return c:GetCounter(COUNTER_ID_0) ~= 0
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.desfilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, e:GetHandler())
  	end
  	local g = Duel.GetMatchingGroup(s.desfilter, tp, LOCATION_MZONE, LOCATION_MZONE, e:GetHandler())
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, g:GetCount(), 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.desfilter, tp, LOCATION_MZONE, LOCATION_MZONE, aux.ExceptThisCard(e))
  	Duel.Destroy(g, REASON_EFFECT)
  end
  
  
source_text: Ice
  You can Special Summon this card (from your hand) by Tributing 2 WATER monsters. Once per turn: You can target 1 face-up monster on the field; place an Ice Counter on that target. You can Tribute this card; destroy all monsters with an Ice Counter(s).
target_text: -- Ice
  local COUNTER_ID_0 = 0x1015 --Ice
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCondition(s.spcon)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--add counter
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_COUNTER)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetCountLimit(1)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetTarget(s.target)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  	--destroy
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_DESTROY)
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCost(s.descost)
  	e3:SetTarget(s.destg)
  	e3:SetOperation(s.desop)
  	c:RegisterEffect(e3)
  end
  function s.rfilter(c, tp)
  	return c:IsAttribute(ATTRIBUTE_WATER) and (c:IsControler(tp) or c:IsFaceup())
  end
  function s.spcon(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	local rg = Duel.GetReleaseGroup(tp, false, REASON_SPSUMMON):Filter(s.rfilter, nil, tp)
  	return rg:CheckSubGroup(aux.mzctcheckrel, 2, 2, tp, REASON_SPSUMMON)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, c)
  	local rg = Duel.GetReleaseGroup(tp, false, REASON_SPSUMMON):Filter(s.rfilter, nil, tp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RELEASE)
  	local sg = rg:SelectSubGroup(tp, aux.mzctcheckrel, true, 2, 2, tp, REASON_SPSUMMON)
  	if sg then
  		sg:KeepAlive()
  		e:SetLabelObject(sg)
  		return true
  	else
  		return false
  	end
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp, c)
  	local g = e:GetLabelObject()
  	Duel.Release(g, REASON_SPSUMMON)
  	g:DeleteGroup()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsCanAddCounter(COUNTER_ID_0, 1)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(Card.IsCanAddCounter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil, 0x1015, 1)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	Duel.SelectTarget(tp, Card.IsCanAddCounter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, 1, nil, 0x1015, 1)
  	Duel.SetOperationInfo(0, CATEGORY_COUNTER, nil, 1, 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc and tc:IsRelateToEffect(e) and tc:IsCanAddCounter(COUNTER_ID_0, 1) then
  		tc:AddCounter(COUNTER_ID_0, 1)
  	end
  end
  function s.descost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsReleasable()
  	end
  	Duel.Release(e:GetHandler(), REASON_COST)
  end
  function s.desfilter(c)
  	return c:GetCounter(COUNTER_ID_0) ~= 0
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.desfilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, e:GetHandler())
  	end
  	local g = Duel.GetMatchingGroup(s.desfilter, tp, LOCATION_MZONE, LOCATION_MZONE, e:GetHandler())
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, g:GetCount(), 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.desfilter, tp, LOCATION_MZONE, LOCATION_MZONE, aux.ExceptThisCard(e))
  	Duel.Destroy(g, REASON_EFFECT)
  end
  
  