name: Ancient
card_text: If you control "Ancient Warriors" monsters with 2 or more different Attributes: You can declare 1 Attribute; your opponent cannot activate the effects of monsters they currently control with that Attribute, until the end of this turn (even if this card leaves the field). If your opponent Special Summons a monster(s), or you activate an "Ancient Warriors" monster's effect (except during the Damage Step): You can make all "Ancient Warriors" monsters you control gain 300 ATK for each "Ancient Warriors" monster you control until the end of this turn (even if this card leaves the field). You can only use each effect of "Ancient Warriors Saga - Sun-Liu Alliance" once per turn.
external_ids: local SETCARD_ID_0 = 0x137 --Ancient
  
lua: local SETCARD_ID_0 = 0x137 --Ancient
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e0 = Effect.CreateEffect(c)
  	e0:SetType(EFFECT_TYPE_ACTIVATE)
  	e0:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e0)
  	--can not activate effect
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_ANNOUNCE)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_SZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.actcon)
  	e1:SetTarget(s.acttg)
  	e1:SetOperation(s.actop)
  	c:RegisterEffect(e1)
  	--atk up
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_ATKCHANGE)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e2:SetProperty(EFFECT_FLAG_DELAY)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCondition(s.atkcon)
  	e2:SetTarget(s.atktg)
  	e2:SetOperation(s.atkop)
  	c:RegisterEffect(e2)
  	local e4 = e2:Clone()
  	e4:SetCode(EVENT_CHAINING)
  	e4:SetCondition(s.atkcon2)
  	c:RegisterEffect(e4)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.actcon(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetFieldGroup(tp, LOCATION_MZONE, 0)
  	local sg = g:Filter(s.cfilter, nil)
  	return sg and sg:GetClassCount(Card.GetAttribute) >= 2
  end
  function s.acttg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local g = Duel.GetMatchingGroup(Card.IsFaceup, tp, 0, LOCATION_MZONE, nil)
  	if chk == 0 then
  		return aux.GetAttributeCount(g) > 0
  	end
  	local tc = g:GetFirst()
  	local att = 0
  	while tc do
  		att = bit.bor(att, tc:GetAttribute())
  		tc = g:GetNext()
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATTRIBUTE)
  	local ac = Duel.AnnounceAttribute(tp, 1, att)
  	e:SetLabel(ac)
  end
  function s.actop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(Card.IsFaceup, tp, 0, LOCATION_MZONE, nil)
  	local sg = g:Filter(Card.IsAttribute, nil, e:GetLabel())
  	if sg:GetCount() <= 0 then
  		return
  	end
  	local tc = sg:GetFirst()
  	while tc do
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_CANNOT_TRIGGER)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		tc:RegisterEffect(e1, true)
  		tc = sg:GetNext()
  	end
  end
  function s.atkfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.atkcon(e, tp, eg, ep, ev, re, r, rp)
  	return rp == 1 - tp
  end
  function s.atktg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.atkfilter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.atkfilter, tp, LOCATION_MZONE, 0, nil)
  	local gc = g:GetCount()
  	if gc > 0 then
  		local tc = g:GetFirst()
  		while tc do
  			local e1 = Effect.CreateEffect(e:GetHandler())
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_UPDATE_ATTACK)
  			e1:SetValue(gc * 300)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			tc:RegisterEffect(e1)
  			tc = g:GetNext()
  		end
  	end
  end
  function s.atkcon2(e, tp, eg, ep, ev, re, r, rp)
  	return re:IsActiveType(TYPE_MONSTER) and re:GetHandler():IsSetCard(SETCARD_ID_0) and rp == tp
  end
  
  
source_text: Ancient
  If you control "Ancient Warriors" monsters with 2 or more different Attributes: You can declare 1 Attribute; your opponent cannot activate the effects of monsters they currently control with that Attribute, until the end of this turn (even if this card leaves the field). If your opponent Special Summons a monster(s), or you activate an "Ancient Warriors" monster's effect (except during the Damage Step): You can make all "Ancient Warriors" monsters you control gain 300 ATK for each "Ancient Warriors" monster you control until the end of this turn (even if this card leaves the field). You can only use each effect of "Ancient Warriors Saga - Sun-Liu Alliance" once per turn.
target_text: -- Ancient
  local SETCARD_ID_0 = 0x137 --Ancient
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e0 = Effect.CreateEffect(c)
  	e0:SetType(EFFECT_TYPE_ACTIVATE)
  	e0:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e0)
  	--can not activate effect
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_ANNOUNCE)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_SZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.actcon)
  	e1:SetTarget(s.acttg)
  	e1:SetOperation(s.actop)
  	c:RegisterEffect(e1)
  	--atk up
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_ATKCHANGE)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e2:SetProperty(EFFECT_FLAG_DELAY)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCondition(s.atkcon)
  	e2:SetTarget(s.atktg)
  	e2:SetOperation(s.atkop)
  	c:RegisterEffect(e2)
  	local e4 = e2:Clone()
  	e4:SetCode(EVENT_CHAINING)
  	e4:SetCondition(s.atkcon2)
  	c:RegisterEffect(e4)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.actcon(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetFieldGroup(tp, LOCATION_MZONE, 0)
  	local sg = g:Filter(s.cfilter, nil)
  	return sg and sg:GetClassCount(Card.GetAttribute) >= 2
  end
  function s.acttg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local g = Duel.GetMatchingGroup(Card.IsFaceup, tp, 0, LOCATION_MZONE, nil)
  	if chk == 0 then
  		return aux.GetAttributeCount(g) > 0
  	end
  	local tc = g:GetFirst()
  	local att = 0
  	while tc do
  		att = bit.bor(att, tc:GetAttribute())
  		tc = g:GetNext()
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATTRIBUTE)
  	local ac = Duel.AnnounceAttribute(tp, 1, att)
  	e:SetLabel(ac)
  end
  function s.actop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(Card.IsFaceup, tp, 0, LOCATION_MZONE, nil)
  	local sg = g:Filter(Card.IsAttribute, nil, e:GetLabel())
  	if sg:GetCount() <= 0 then
  		return
  	end
  	local tc = sg:GetFirst()
  	while tc do
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_CANNOT_TRIGGER)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		tc:RegisterEffect(e1, true)
  		tc = sg:GetNext()
  	end
  end
  function s.atkfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.atkcon(e, tp, eg, ep, ev, re, r, rp)
  	return rp == 1 - tp
  end
  function s.atktg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.atkfilter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.atkfilter, tp, LOCATION_MZONE, 0, nil)
  	local gc = g:GetCount()
  	if gc > 0 then
  		local tc = g:GetFirst()
  		while tc do
  			local e1 = Effect.CreateEffect(e:GetHandler())
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_UPDATE_ATTACK)
  			e1:SetValue(gc * 300)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			tc:RegisterEffect(e1)
  			tc = g:GetNext()
  		end
  	end
  end
  function s.atkcon2(e, tp, eg, ep, ev, re, r, rp)
  	return re:IsActiveType(TYPE_MONSTER) and re:GetHandler():IsSetCard(SETCARD_ID_0) and rp == tp
  end
  
  