name: Snowdust
card_text: 2 Level 4 WATER monsters
  Once per turn: You can detach 1 Xyz Material from this card; reveal any number of WATER monsters from your hand, and place that many Ice Counters on face-up monsters on the field. Non-WATER monsters on the field lose 200 ATK for each Ice Counter on the field.
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)
  	--xyz summon
  	aux.AddXyzProcedure(c, aux.FilterBoolFunction(Card.IsAttribute, ATTRIBUTE_WATER), 4, 2)
  	c:EnableReviveLimit()
  	--counter
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetCountLimit(1)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  	--atkdown
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_UPDATE_ATTACK)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetTargetRange(LOCATION_MZONE, LOCATION_MZONE)
  	e2:SetTarget(s.atktg)
  	e2:SetValue(s.atkval)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c)
  	return c:IsAttribute(ATTRIBUTE_WATER) and not c:IsPublic()
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_COST)
  	end
  	e:GetHandler():RemoveOverlayCard(tp, 1, 1, REASON_COST)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_HAND, 0, 1, nil) and Duel.IsExistingMatchingCard(Card.IsCanAddCounter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil, 0x1015, 1)
  	end
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(Card.IsCanAddCounter, tp, LOCATION_MZONE, LOCATION_MZONE, nil, 0x1015, 1)
  	if g:GetCount() == 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONFIRM)
  	local cg = Duel.SelectMatchingCard(tp, s.cfilter, tp, LOCATION_HAND, 0, 1, 99, nil)
  	Duel.ConfirmCards(1 - tp, cg)
  	Duel.ShuffleHand(tp)
  	local ct = cg:GetCount()
  	for i = 1, ct do
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_COUNTER)
  		local tc = g:Select(tp, 1, 1, nil):GetFirst()
  		tc:AddCounter(COUNTER_ID_0, 1)
  	end
  end
  function s.atktg(e, c)
  	return c:IsNonAttribute(ATTRIBUTE_WATER)
  end
  function s.atkval(e, c)
  	return Duel.GetCounter(0, 1, 1, COUNTER_ID_0) * -200
  end
  
  
source_text: Snowdust
  2 Level 4 WATER monsters
  Once per turn: You can detach 1 Xyz Material from this card; reveal any number of WATER monsters from your hand, and place that many Ice Counters on face-up monsters on the field. Non-WATER monsters on the field lose 200 ATK for each Ice Counter on the field.
target_text: -- Snowdust
  local COUNTER_ID_0 = 0x1015 --Ice
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, aux.FilterBoolFunction(Card.IsAttribute, ATTRIBUTE_WATER), 4, 2)
  	c:EnableReviveLimit()
  	--counter
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetCountLimit(1)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  	--atkdown
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_UPDATE_ATTACK)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetTargetRange(LOCATION_MZONE, LOCATION_MZONE)
  	e2:SetTarget(s.atktg)
  	e2:SetValue(s.atkval)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c)
  	return c:IsAttribute(ATTRIBUTE_WATER) and not c:IsPublic()
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_COST)
  	end
  	e:GetHandler():RemoveOverlayCard(tp, 1, 1, REASON_COST)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_HAND, 0, 1, nil) and Duel.IsExistingMatchingCard(Card.IsCanAddCounter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil, 0x1015, 1)
  	end
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(Card.IsCanAddCounter, tp, LOCATION_MZONE, LOCATION_MZONE, nil, 0x1015, 1)
  	if g:GetCount() == 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONFIRM)
  	local cg = Duel.SelectMatchingCard(tp, s.cfilter, tp, LOCATION_HAND, 0, 1, 99, nil)
  	Duel.ConfirmCards(1 - tp, cg)
  	Duel.ShuffleHand(tp)
  	local ct = cg:GetCount()
  	for i = 1, ct do
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_COUNTER)
  		local tc = g:Select(tp, 1, 1, nil):GetFirst()
  		tc:AddCounter(COUNTER_ID_0, 1)
  	end
  end
  function s.atktg(e, c)
  	return c:IsNonAttribute(ATTRIBUTE_WATER)
  end
  function s.atkval(e, c)
  	return Duel.GetCounter(0, 1, 1, COUNTER_ID_0) * -200
  end
  
  