name: Genex
card_text: Each time a monster(s) you control is sent to the Graveyard, place 1 Genex Counter on this card. Each time a card(s) in your opponent's Graveyard is banished, place 2 Genex Counters on this card. This card gains 100 ATK for each Genex Counter on the field. If this card is destroyed by battle and sent to the Graveyard: Inflict 300 damage to your opponent for each Genex Counter that was on this card.
external_ids: local COUNTER_ID_0 = 0xa --Genex
  
lua: local COUNTER_ID_0 = 0xa --Genex
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableCounterPermit(0xa)
  	--add counter
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EVENT_TO_GRAVE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetOperation(s.addc1)
  	c:RegisterEffect(e1)
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EVENT_REMOVE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetOperation(s.addc2)
  	c:RegisterEffect(e2)
  	--attackup
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE)
  	e3:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCode(EFFECT_UPDATE_ATTACK)
  	e3:SetValue(s.attackup)
  	c:RegisterEffect(e3)
  	--damage
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e4:SetCode(EVENT_LEAVE_FIELD_P)
  	e4:SetOperation(s.damp)
  	c:RegisterEffect(e4)
  	local e5 = Effect.CreateEffect(c)
  	e5:SetDescription(aux.Stringid(id, 0))
  	e5:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e5:SetCategory(CATEGORY_DAMAGE)
  	e5:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e5:SetCode(EVENT_BATTLE_DESTROYED)
  	e5:SetCondition(s.damcon)
  	e5:SetTarget(s.damtg)
  	e5:SetOperation(s.damop)
  	e5:SetLabelObject(e4)
  	c:RegisterEffect(e5)
  end
  function s.filter1(c, tp)
  	return c:IsPreviousControler(tp) and c:IsPreviousLocation(LOCATION_MZONE)
  end
  function s.addc1(e, tp, eg, ep, ev, re, r, rp)
  	if eg:IsExists(s.filter1, 1, nil, tp) then
  		e:GetHandler():AddCounter(COUNTER_ID_0, 1)
  	end
  end
  function s.filter2(c, tp)
  	return c:IsPreviousControler(1 - tp) and c:IsPreviousLocation(LOCATION_GRAVE)
  end
  function s.addc2(e, tp, eg, ep, ev, re, r, rp)
  	if eg:IsExists(s.filter2, 1, nil, tp) then
  		e:GetHandler():AddCounter(COUNTER_ID_0, 2)
  	end
  end
  function s.attackup(e, c)
  	return c:GetCounter(COUNTER_ID_0) * 100
  end
  function s.damp(e, tp, eg, ep, ev, re, r, rp)
  	e:SetLabel(e:GetHandler():GetCounter(COUNTER_ID_0))
  end
  function s.damcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsLocation(LOCATION_GRAVE) and e:GetHandler():IsReason(REASON_BATTLE)
  end
  function s.damtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local ct = e:GetLabelObject():GetLabel()
  	if chk == 0 then
  		return ct ~= 0
  	end
  	Duel.SetTargetPlayer(1 - tp)
  	Duel.SetTargetParam(ct * 300)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, ct * 300)
  end
  function s.damop(e, tp, eg, ep, ev, re, r, rp)
  	local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	Duel.Damage(p, d, REASON_EFFECT)
  end
  
  
source_text: Genex
  Each time a monster(s) you control is sent to the Graveyard, place 1 Genex Counter on this card. Each time a card(s) in your opponent's Graveyard is banished, place 2 Genex Counters on this card. This card gains 100 ATK for each Genex Counter on the field. If this card is destroyed by battle and sent to the Graveyard: Inflict 300 damage to your opponent for each Genex Counter that was on this card.
target_text: -- Genex
  local COUNTER_ID_0 = 0xa --Genex
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableCounterPermit(0xa)
  	--add counter
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EVENT_TO_GRAVE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetOperation(s.addc1)
  	c:RegisterEffect(e1)
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EVENT_REMOVE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetOperation(s.addc2)
  	c:RegisterEffect(e2)
  	--attackup
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE)
  	e3:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCode(EFFECT_UPDATE_ATTACK)
  	e3:SetValue(s.attackup)
  	c:RegisterEffect(e3)
  	--damage
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e4:SetCode(EVENT_LEAVE_FIELD_P)
  	e4:SetOperation(s.damp)
  	c:RegisterEffect(e4)
  	local e5 = Effect.CreateEffect(c)
  	e5:SetDescription(aux.Stringid(id, 0))
  	e5:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e5:SetCategory(CATEGORY_DAMAGE)
  	e5:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e5:SetCode(EVENT_BATTLE_DESTROYED)
  	e5:SetCondition(s.damcon)
  	e5:SetTarget(s.damtg)
  	e5:SetOperation(s.damop)
  	e5:SetLabelObject(e4)
  	c:RegisterEffect(e5)
  end
  function s.filter1(c, tp)
  	return c:IsPreviousControler(tp) and c:IsPreviousLocation(LOCATION_MZONE)
  end
  function s.addc1(e, tp, eg, ep, ev, re, r, rp)
  	if eg:IsExists(s.filter1, 1, nil, tp) then
  		e:GetHandler():AddCounter(COUNTER_ID_0, 1)
  	end
  end
  function s.filter2(c, tp)
  	return c:IsPreviousControler(1 - tp) and c:IsPreviousLocation(LOCATION_GRAVE)
  end
  function s.addc2(e, tp, eg, ep, ev, re, r, rp)
  	if eg:IsExists(s.filter2, 1, nil, tp) then
  		e:GetHandler():AddCounter(COUNTER_ID_0, 2)
  	end
  end
  function s.attackup(e, c)
  	return c:GetCounter(COUNTER_ID_0) * 100
  end
  function s.damp(e, tp, eg, ep, ev, re, r, rp)
  	e:SetLabel(e:GetHandler():GetCounter(COUNTER_ID_0))
  end
  function s.damcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsLocation(LOCATION_GRAVE) and e:GetHandler():IsReason(REASON_BATTLE)
  end
  function s.damtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local ct = e:GetLabelObject():GetLabel()
  	if chk == 0 then
  		return ct ~= 0
  	end
  	Duel.SetTargetPlayer(1 - tp)
  	Duel.SetTargetParam(ct * 300)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, ct * 300)
  end
  function s.damop(e, tp, eg, ep, ev, re, r, rp)
  	local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	Duel.Damage(p, d, REASON_EFFECT)
  end
  
  