name: Fire
card_text: (Quick Effect): You can discard this card; inflict 1000 damage to your opponent, and if you do, skip your next Draw Phase. You can only use this effect of "Fire Cracker" once per turn. Each time your opponent takes effect damage, place 1 counter on this card. Once per turn, during the End Phase: Remove all counters from this card that were placed by its effect, and if you do, inflict 300 damage to your opponent for each.
external_ids: local COUNTER_ID_0 = 0x42 --Counter(Fire
  
lua: local COUNTER_ID_0 = 0x42 --Counter(Fire
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableCounterPermit(0x42)
  	--damage
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DAMAGE)
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCost(s.damcost1)
  	e1:SetTarget(s.damtg1)
  	e1:SetOperation(s.damop1)
  	c:RegisterEffect(e1)
  	--counter
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EVENT_DAMAGE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCondition(s.ctcon)
  	e2:SetOperation(s.ctop)
  	c:RegisterEffect(e2)
  	--damage
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_DAMAGE)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e3:SetCode(EVENT_PHASE + PHASE_END)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1)
  	e3:SetTarget(s.damtg2)
  	e3:SetOperation(s.damop2)
  	c:RegisterEffect(e3)
  end
  function s.damcost1(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsDiscardable()
  	end
  	Duel.SendtoGrave(e:GetHandler(), REASON_COST + REASON_DISCARD)
  end
  function s.damtg1(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetTargetPlayer(1 - tp)
  	Duel.SetTargetParam(1000)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, 1000)
  end
  function s.damop1(e, tp, eg, ep, ev, re, r, rp)
  	local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	if Duel.Damage(p, d, REASON_EFFECT) ~= 0 then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e1:SetCode(EFFECT_SKIP_DP)
  		e1:SetTargetRange(1, 0)
  		e1:SetReset(RESET_PHASE + PHASE_DRAW + RESET_SELF_TURN)
  		Duel.RegisterEffect(e1, tp)
  	end
  end
  function s.ctcon(e, tp, eg, ep, ev, re, r, rp)
  	return ep ~= tp and bit.band(r, REASON_EFFECT) ~= 0
  end
  function s.ctop(e, tp, eg, ep, ev, re, r, rp)
  	e:GetHandler():AddCounter(COUNTER_ID_0, 1)
  end
  function s.damtg2(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local ct = e:GetHandler():GetCounter(COUNTER_ID_0)
  	Duel.SetTargetPlayer(1 - tp)
  	Duel.SetTargetParam(ct)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, ct)
  end
  function s.damop2(e, tp, eg, ep, ev, re, r, rp)
  	local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	local c = e:GetHandler()
  	local ct = c:GetCounter(COUNTER_ID_0)
  	if c:RemoveCounter(tp, COUNTER_ID_0, ct, REASON_EFFECT) then
  		Duel.Damage(p, ct * 300, REASON_EFFECT)
  	end
  end
  
  
source_text: Fire
  (Quick Effect): You can discard this card; inflict 1000 damage to your opponent, and if you do, skip your next Draw Phase. You can only use this effect of "Fire Cracker" once per turn. Each time your opponent takes effect damage, place 1 counter on this card. Once per turn, during the End Phase: Remove all counters from this card that were placed by its effect, and if you do, inflict 300 damage to your opponent for each.
target_text: -- Fire
  local COUNTER_ID_0 = 0x42 --Counter(Fire
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableCounterPermit(0x42)
  	--damage
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DAMAGE)
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCost(s.damcost1)
  	e1:SetTarget(s.damtg1)
  	e1:SetOperation(s.damop1)
  	c:RegisterEffect(e1)
  	--counter
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EVENT_DAMAGE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCondition(s.ctcon)
  	e2:SetOperation(s.ctop)
  	c:RegisterEffect(e2)
  	--damage
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_DAMAGE)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e3:SetCode(EVENT_PHASE + PHASE_END)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1)
  	e3:SetTarget(s.damtg2)
  	e3:SetOperation(s.damop2)
  	c:RegisterEffect(e3)
  end
  function s.damcost1(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsDiscardable()
  	end
  	Duel.SendtoGrave(e:GetHandler(), REASON_COST + REASON_DISCARD)
  end
  function s.damtg1(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetTargetPlayer(1 - tp)
  	Duel.SetTargetParam(1000)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, 1000)
  end
  function s.damop1(e, tp, eg, ep, ev, re, r, rp)
  	local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	if Duel.Damage(p, d, REASON_EFFECT) ~= 0 then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e1:SetCode(EFFECT_SKIP_DP)
  		e1:SetTargetRange(1, 0)
  		e1:SetReset(RESET_PHASE + PHASE_DRAW + RESET_SELF_TURN)
  		Duel.RegisterEffect(e1, tp)
  	end
  end
  function s.ctcon(e, tp, eg, ep, ev, re, r, rp)
  	return ep ~= tp and bit.band(r, REASON_EFFECT) ~= 0
  end
  function s.ctop(e, tp, eg, ep, ev, re, r, rp)
  	e:GetHandler():AddCounter(COUNTER_ID_0, 1)
  end
  function s.damtg2(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local ct = e:GetHandler():GetCounter(COUNTER_ID_0)
  	Duel.SetTargetPlayer(1 - tp)
  	Duel.SetTargetParam(ct)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, ct)
  end
  function s.damop2(e, tp, eg, ep, ev, re, r, rp)
  	local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	local c = e:GetHandler()
  	local ct = c:GetCounter(COUNTER_ID_0)
  	if c:RemoveCounter(tp, COUNTER_ID_0, ct, REASON_EFFECT) then
  		Duel.Damage(p, ct * 300, REASON_EFFECT)
  	end
  end
  
  