name: Ancient
card_text: During your Main Phase: You can Special Summon 1 "Ancient Warriors" monster from your hand, and if you do, take damage equal to its Level x 100. You can send this face-up card from the Spell & Trap Zone to the GY, then target 1 "Ancient Warriors" monster on the field; change it to any Attribute, then, if you targeted an opponent's monster, you can take control of it. You can only use each effect of "Ancient Warriors Saga - Deception and Betrayal" 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 e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--special summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_DAMAGE)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetCountLimit(1, id)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  	--change attribute
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_CONTROL)
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCountLimit(1, id + o)
  	e3:SetCost(s.attcost)
  	e3:SetTarget(s.atttg)
  	e3:SetOperation(s.attop)
  	c:RegisterEffect(e3)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_HAND, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, tp, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_HAND, 0, 1, 1, nil, e, tp)
  	local tc = g:GetFirst()
  	if tc and Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP) > 0 then
  		Duel.Damage(tp, tc:GetLevel() * 100, REASON_EFFECT)
  	end
  end
  function s.attcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsAbleToGraveAsCost()
  	end
  	Duel.SendtoGrave(e:GetHandler(), REASON_COST)
  end
  function s.attfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.atttg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and s.attfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.attfilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	local tc = Duel.SelectTarget(tp, s.attfilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, 1, nil):GetFirst()
  	e:SetLabel(tc:GetControler())
  end
  function s.attop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsFaceup() and tc:IsRelateToEffect(e) and not tc:IsImmuneToEffect(e) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATTRIBUTE)
  		local catt = tc:GetAttribute()
  		local att = Duel.AnnounceAttribute(tp, 1, ATTRIBUTE_ALL & ~catt)
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e1:SetCode(EFFECT_CHANGE_ATTRIBUTE)
  		e1:SetValue(att)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		tc:RegisterEffect(e1)
  		if e:GetLabel() == 1 - tp and tc:IsControler(1 - tp) and tc:IsControlerCanBeChanged() and Duel.SelectYesNo(tp, aux.Stringid(id, 2)) then
  			Duel.BreakEffect()
  			Duel.GetControl(tc, tp)
  		end
  	end
  end
  
  
source_text: Ancient
  During your Main Phase: You can Special Summon 1 "Ancient Warriors" monster from your hand, and if you do, take damage equal to its Level x 100. You can send this face-up card from the Spell & Trap Zone to the GY, then target 1 "Ancient Warriors" monster on the field; change it to any Attribute, then, if you targeted an opponent's monster, you can take control of it. You can only use each effect of "Ancient Warriors Saga - Deception and Betrayal" once per turn.
target_text: -- Ancient
  local SETCARD_ID_0 = 0x137 --Ancient
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--special summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_DAMAGE)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetCountLimit(1, id)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  	--change attribute
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_CONTROL)
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCountLimit(1, id + o)
  	e3:SetCost(s.attcost)
  	e3:SetTarget(s.atttg)
  	e3:SetOperation(s.attop)
  	c:RegisterEffect(e3)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_HAND, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, tp, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_HAND, 0, 1, 1, nil, e, tp)
  	local tc = g:GetFirst()
  	if tc and Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP) > 0 then
  		Duel.Damage(tp, tc:GetLevel() * 100, REASON_EFFECT)
  	end
  end
  function s.attcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsAbleToGraveAsCost()
  	end
  	Duel.SendtoGrave(e:GetHandler(), REASON_COST)
  end
  function s.attfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.atttg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and s.attfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.attfilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	local tc = Duel.SelectTarget(tp, s.attfilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, 1, nil):GetFirst()
  	e:SetLabel(tc:GetControler())
  end
  function s.attop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsFaceup() and tc:IsRelateToEffect(e) and not tc:IsImmuneToEffect(e) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATTRIBUTE)
  		local catt = tc:GetAttribute()
  		local att = Duel.AnnounceAttribute(tp, 1, ATTRIBUTE_ALL & ~catt)
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e1:SetCode(EFFECT_CHANGE_ATTRIBUTE)
  		e1:SetValue(att)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		tc:RegisterEffect(e1)
  		if e:GetLabel() == 1 - tp and tc:IsControler(1 - tp) and tc:IsControlerCanBeChanged() and Duel.SelectYesNo(tp, aux.Stringid(id, 2)) then
  			Duel.BreakEffect()
  			Duel.GetControl(tc, tp)
  		end
  	end
  end
  
  