name: Colosseum
card_text: Place 1 Counter on this card each time a monster is Special Summoned from either player's Deck. All "Gladiator Beast" monsters gain 100 ATK and DEF for each of these counters on this card. If this card would be destroyed by a card effect, you can discard 1 "Colosseum - Cage of the Gladiator Beasts" to prevent this card from being destroyed.
external_ids: local SETCARD_ID_0 = 0x1019 --Gladiator
  local COUNTER_ID_0 = 0x7 --Counter(Colosseum
  
lua: local SETCARD_ID_0 = 0x1019 --Gladiator
  local COUNTER_ID_0 = 0x7 --Counter(Colosseum
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableCounterPermit(0x7)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--Add counter
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_CONTINUOUS + EFFECT_TYPE_FIELD)
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e2:SetRange(LOCATION_FZONE)
  	e2:SetCondition(s.accon)
  	e2:SetOperation(s.acop)
  	c:RegisterEffect(e2)
  	--atkup
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetCode(EFFECT_UPDATE_ATTACK)
  	e3:SetRange(LOCATION_FZONE)
  	e3:SetTargetRange(LOCATION_MZONE, LOCATION_MZONE)
  	e3:SetTarget(aux.TargetBoolFunction(Card.IsSetCard, SETCARD_ID_0))
  	e3:SetValue(s.atkval)
  	c:RegisterEffect(e3)
  	local e4 = e3:Clone()
  	e4:SetCode(EFFECT_UPDATE_DEFENSE)
  	c:RegisterEffect(e4)
  	--Destroy replace
  	local e5 = Effect.CreateEffect(c)
  	e5:SetType(EFFECT_TYPE_CONTINUOUS + EFFECT_TYPE_SINGLE)
  	e5:SetCode(EFFECT_DESTROY_REPLACE)
  	e5:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e5:SetRange(LOCATION_FZONE)
  	e5:SetTarget(s.desreptg)
  	e5:SetOperation(s.desrepop)
  	c:RegisterEffect(e5)
  end
  function s.atkval(e, c)
  	return e:GetHandler():GetCounter(COUNTER_ID_0) * 100
  end
  function s.cfilter(c, tp)
  	return c:IsSummonLocation(LOCATION_DECK) and c:GetOriginalType() & TYPE_MONSTER ~= 0
  end
  function s.accon(e, tp, eg, ep, ev, re, r, rp)
  	return eg:IsExists(s.cfilter, 1, nil, tp)
  end
  function s.acop(e, tp, eg, ep, ev, re, r, rp)
  	e:GetHandler():AddCounter(COUNTER_ID_0, 1)
  end
  function s.desreptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return not e:GetHandler():IsReason(REASON_RULE) and Duel.IsExistingMatchingCard(Card.IsCode, tp, LOCATION_HAND, 0, 1, nil, id)
  	end
  	return Duel.SelectEffectYesNo(tp, e:GetHandler(), 96)
  end
  function s.desrepop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.DiscardHand(tp, Card.IsCode, 1, 1, REASON_EFFECT + REASON_DISCARD, nil, id)
  end
  
  
source_text: Colosseum
  Place 1 Counter on this card each time a monster is Special Summoned from either player's Deck. All "Gladiator Beast" monsters gain 100 ATK and DEF for each of these counters on this card. If this card would be destroyed by a card effect, you can discard 1 "Colosseum - Cage of the Gladiator Beasts" to prevent this card from being destroyed.
target_text: -- Colosseum
  local SETCARD_ID_0 = 0x1019 --Gladiator
  local COUNTER_ID_0 = 0x7 --Counter(Colosseum
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableCounterPermit(0x7)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--Add counter
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_CONTINUOUS + EFFECT_TYPE_FIELD)
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e2:SetRange(LOCATION_FZONE)
  	e2:SetCondition(s.accon)
  	e2:SetOperation(s.acop)
  	c:RegisterEffect(e2)
  	--atkup
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetCode(EFFECT_UPDATE_ATTACK)
  	e3:SetRange(LOCATION_FZONE)
  	e3:SetTargetRange(LOCATION_MZONE, LOCATION_MZONE)
  	e3:SetTarget(aux.TargetBoolFunction(Card.IsSetCard, SETCARD_ID_0))
  	e3:SetValue(s.atkval)
  	c:RegisterEffect(e3)
  	local e4 = e3:Clone()
  	e4:SetCode(EFFECT_UPDATE_DEFENSE)
  	c:RegisterEffect(e4)
  	--Destroy replace
  	local e5 = Effect.CreateEffect(c)
  	e5:SetType(EFFECT_TYPE_CONTINUOUS + EFFECT_TYPE_SINGLE)
  	e5:SetCode(EFFECT_DESTROY_REPLACE)
  	e5:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e5:SetRange(LOCATION_FZONE)
  	e5:SetTarget(s.desreptg)
  	e5:SetOperation(s.desrepop)
  	c:RegisterEffect(e5)
  end
  function s.atkval(e, c)
  	return e:GetHandler():GetCounter(COUNTER_ID_0) * 100
  end
  function s.cfilter(c, tp)
  	return c:IsSummonLocation(LOCATION_DECK) and c:GetOriginalType() & TYPE_MONSTER ~= 0
  end
  function s.accon(e, tp, eg, ep, ev, re, r, rp)
  	return eg:IsExists(s.cfilter, 1, nil, tp)
  end
  function s.acop(e, tp, eg, ep, ev, re, r, rp)
  	e:GetHandler():AddCounter(COUNTER_ID_0, 1)
  end
  function s.desreptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return not e:GetHandler():IsReason(REASON_RULE) and Duel.IsExistingMatchingCard(Card.IsCode, tp, LOCATION_HAND, 0, 1, nil, id)
  	end
  	return Duel.SelectEffectYesNo(tp, e:GetHandler(), 96)
  end
  function s.desrepop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.DiscardHand(tp, Card.IsCode, 1, 1, REASON_EFFECT + REASON_DISCARD, nil, id)
  end
  
  