name: Cold
card_text: You can discard 1 card to target 1 face-up monster on the field; place an Ice Counter on that target. This card gains 300 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)
  	--add counter
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_COUNTER)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  	--
  	local e2 = Effect.CreateEffect(c)
  	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_UPDATE_ATTACK)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetValue(s.atkval)
  	c:RegisterEffect(e2)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsDiscardable, tp, LOCATION_HAND, 0, 1, e:GetHandler())
  	end
  	Duel.DiscardHand(tp, Card.IsDiscardable, 1, 1, REASON_COST + REASON_DISCARD)
  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)
  	local g = 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.atkval(e, c)
  	return Duel.GetCounter(0, 1, 1, COUNTER_ID_0) * 300
  end
  
  
source_text: Cold
  You can discard 1 card to target 1 face-up monster on the field; place an Ice Counter on that target. This card gains 300 ATK for each Ice Counter on the field.
target_text: -- Cold
  local COUNTER_ID_0 = 0x1015 --Ice
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--add counter
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_COUNTER)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  	--
  	local e2 = Effect.CreateEffect(c)
  	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_UPDATE_ATTACK)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetValue(s.atkval)
  	c:RegisterEffect(e2)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsDiscardable, tp, LOCATION_HAND, 0, 1, e:GetHandler())
  	end
  	Duel.DiscardHand(tp, Card.IsDiscardable, 1, 1, REASON_COST + REASON_DISCARD)
  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)
  	local g = 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.atkval(e, c)
  	return Duel.GetCounter(0, 1, 1, COUNTER_ID_0) * 300
  end
  
  