name: Black-Winged
card_text: 1 Tuner + 1+ non-Tuner monsters
  If you would take damage from a card effect, place 1 Black Feather Counter on this card instead. This card loses 700 ATK for each Black Feather Counter on it. Once per turn: You can remove all Black Feather Counters from this card, then target 1 face-up monster your opponent controls; that target loses 700 ATK for each Black Feather Counter removed, and if it does, inflict damage to your opponent equal to the ATK lost by this effect.
external_ids: local COUNTER_ID_0 = 0x10 --Black
  
lua: local COUNTER_ID_0 = 0x10 --Black
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableCounterPermit(0x10)
  	--synchro summon
  	aux.AddSynchroProcedure(c, nil, aux.NonTuner(nil), 1)
  	c:EnableReviveLimit()
  	--damage reduce
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_REPLACE_DAMAGE)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetTargetRange(1, 0)
  	e1:SetValue(s.damval)
  	c:RegisterEffect(e1)
  	local e4 = e1:Clone()
  	e4:SetCode(EFFECT_NO_EFFECT_DAMAGE)
  	c:RegisterEffect(e4)
  	--atkdown-c
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCode(EFFECT_UPDATE_ATTACK)
  	e2:SetValue(s.atkval)
  	c:RegisterEffect(e2)
  	--atkdown
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1)
  	e3:SetCost(s.cost)
  	e3:SetTarget(s.target)
  	e3:SetOperation(s.operation)
  	c:RegisterEffect(e3)
  end
  function s.damval(e, re, val, r, rp, rc)
  	if bit.band(r, REASON_EFFECT) ~= 0 then
  		e:GetHandler():AddCounter(COUNTER_ID_0, 1)
  		return 0
  	end
  	return val
  end
  function s.atkval(e, c)
  	return c:GetCounter(COUNTER_ID_0) * -700
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():GetCounter(COUNTER_ID_0) > 0
  	end
  	local ct = e:GetHandler():GetCounter(COUNTER_ID_0)
  	e:SetLabel(ct * 700)
  	e:GetHandler():RemoveCounter(tp, COUNTER_ID_0, ct, REASON_COST)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1 - tp) and chkc:IsFaceup()
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(aux.nzatk, tp, 0, LOCATION_MZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	Duel.SelectTarget(tp, aux.nzatk, tp, 0, LOCATION_MZONE, 1, 1, nil)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and tc:IsFaceup() then
  		local val = e:GetLabel()
  		local atk = tc:GetAttack()
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetValue(-val)
  		tc:RegisterEffect(e1)
  		if val > atk then
  			Duel.Damage(1 - tp, atk, REASON_EFFECT)
  		else
  			Duel.Damage(1 - tp, val, REASON_EFFECT)
  		end
  	end
  end
  
  
source_text: Black-Winged
  1 Tuner + 1+ non-Tuner monsters
  If you would take damage from a card effect, place 1 Black Feather Counter on this card instead. This card loses 700 ATK for each Black Feather Counter on it. Once per turn: You can remove all Black Feather Counters from this card, then target 1 face-up monster your opponent controls; that target loses 700 ATK for each Black Feather Counter removed, and if it does, inflict damage to your opponent equal to the ATK lost by this effect.
target_text: -- Black-Winged
  local COUNTER_ID_0 = 0x10 --Black
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableCounterPermit(0x10)
  	--synchro summon
  	aux.AddSynchroProcedure(c, nil, aux.NonTuner(nil), 1)
  	c:EnableReviveLimit()
  	--damage reduce
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_REPLACE_DAMAGE)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetTargetRange(1, 0)
  	e1:SetValue(s.damval)
  	c:RegisterEffect(e1)
  	local e4 = e1:Clone()
  	e4:SetCode(EFFECT_NO_EFFECT_DAMAGE)
  	c:RegisterEffect(e4)
  	--atkdown-c
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCode(EFFECT_UPDATE_ATTACK)
  	e2:SetValue(s.atkval)
  	c:RegisterEffect(e2)
  	--atkdown
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1)
  	e3:SetCost(s.cost)
  	e3:SetTarget(s.target)
  	e3:SetOperation(s.operation)
  	c:RegisterEffect(e3)
  end
  function s.damval(e, re, val, r, rp, rc)
  	if bit.band(r, REASON_EFFECT) ~= 0 then
  		e:GetHandler():AddCounter(COUNTER_ID_0, 1)
  		return 0
  	end
  	return val
  end
  function s.atkval(e, c)
  	return c:GetCounter(COUNTER_ID_0) * -700
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():GetCounter(COUNTER_ID_0) > 0
  	end
  	local ct = e:GetHandler():GetCounter(COUNTER_ID_0)
  	e:SetLabel(ct * 700)
  	e:GetHandler():RemoveCounter(tp, COUNTER_ID_0, ct, REASON_COST)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1 - tp) and chkc:IsFaceup()
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(aux.nzatk, tp, 0, LOCATION_MZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	Duel.SelectTarget(tp, aux.nzatk, tp, 0, LOCATION_MZONE, 1, 1, nil)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and tc:IsFaceup() then
  		local val = e:GetLabel()
  		local atk = tc:GetAttack()
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetValue(-val)
  		tc:RegisterEffect(e1)
  		if val > atk then
  			Duel.Damage(1 - tp, atk, REASON_EFFECT)
  		else
  			Duel.Damage(1 - tp, val, REASON_EFFECT)
  		end
  	end
  end
  
  