name: Ancient
card_text: If this card attacks, your opponent cannot activate any Spell/Trap Cards until the end of the Damage Step. This card gains the appropriate effects if you Normal Summon it by Tributing these monsters.
  ● Green Gadget: If this card attacks a Defense Position monster, inflict piercing battle damage to your opponent.
  ● Red Gadget: If this card inflicts battle damage to your opponent: Inflict 400 damage to your opponent.
  ● Yellow Gadget: If this card destroys an opponent's monster by battle: Inflict 600 damage to your opponent.
external_ids: local CARD_ID_0 = 86445415 --Red Gadget
  local CARD_ID_1 = 41172955 --Green Gadget
  local CARD_ID_2 = 13839120 --Yellow Gadget
  
lua: local CARD_ID_0 = 86445415 --Red Gadget
  local CARD_ID_1 = 41172955 --Green Gadget
  local CARD_ID_2 = 13839120 --Yellow Gadget
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_1, CARD_ID_0, CARD_ID_2)
  	--mat check
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_MATERIAL_CHECK)
  	e1:SetValue(s.valcheck)
  	c:RegisterEffect(e1)
  	--summon success
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e2:SetCode(EVENT_SUMMON_SUCCESS)
  	e2:SetCondition(s.regcon)
  	e2:SetOperation(s.regop)
  	c:RegisterEffect(e2)
  	e2:SetLabelObject(e1)
  	--actlimit
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e3:SetCode(EFFECT_CANNOT_ACTIVATE)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetTargetRange(0, 1)
  	e3:SetValue(s.aclimit)
  	e3:SetCondition(s.actcon)
  	c:RegisterEffect(e3)
  end
  function s.aclimit(e, re, tp)
  	return re:IsHasType(EFFECT_TYPE_ACTIVATE)
  end
  function s.actcon(e)
  	return Duel.GetAttacker() == e:GetHandler()
  end
  function s.valcheck(e, c)
  	local g = c:GetMaterial()
  	local flag = 0
  	local tc = g:GetFirst()
  	while tc do
  		local code = tc:GetCode()
  		if code == CARD_ID_1 then
  			flag = bit.bor(flag, 0x1)
  		elseif code == CARD_ID_0 then
  			flag = bit.bor(flag, 0x2)
  		elseif code == CARD_ID_2 then
  			flag = bit.bor(flag, 0x4)
  		end
  		tc = g:GetNext()
  	end
  	e:SetLabel(flag)
  end
  function s.regcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_ADVANCE)
  end
  function s.regop(e, tp, eg, ep, ev, re, r, rp)
  	local flag = e:GetLabelObject():GetLabel()
  	local c = e:GetHandler()
  	if bit.band(flag, 0x1) ~= 0 then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_PIERCE)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		c:RegisterEffect(e1)
  	end
  	if bit.band(flag, 0x2) ~= 0 then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetDescription(aux.Stringid(id, 0))
  		e1:SetCategory(CATEGORY_DAMAGE)
  		e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e1:SetCode(EVENT_BATTLE_DAMAGE)
  		e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  		e1:SetCondition(s.damcon1)
  		e1:SetTarget(s.damtg1)
  		e1:SetOperation(s.damop)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		c:RegisterEffect(e1)
  	end
  	if bit.band(flag, 0x4) ~= 0 then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetDescription(aux.Stringid(id, 1))
  		e1:SetCategory(CATEGORY_DAMAGE)
  		e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  		e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e1:SetCode(EVENT_BATTLE_DESTROYING)
  		e1:SetTarget(s.damtg2)
  		e1:SetOperation(s.damop)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		c:RegisterEffect(e1)
  	end
  end
  function s.damcon1(e, tp, eg, ep, ev, re, r, rp)
  	return ep ~= tp
  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(400)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, 400)
  end
  function s.damtg2(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetTargetPlayer(1 - tp)
  	Duel.SetTargetParam(600)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, 600)
  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: Ancient
  If this card attacks, your opponent cannot activate any Spell/Trap Cards until the end of the Damage Step. This card gains the appropriate effects if you Normal Summon it by Tributing these monsters.
  ● Green Gadget: If this card attacks a Defense Position monster, inflict piercing battle damage to your opponent.
  ● Red Gadget: If this card inflicts battle damage to your opponent: Inflict 400 damage to your opponent.
  ● Yellow Gadget: If this card destroys an opponent's monster by battle: Inflict 600 damage to your opponent.
target_text: -- Ancient
  local CARD_ID_0 = 86445415 --Red Gadget
  local CARD_ID_1 = 41172955 --Green Gadget
  local CARD_ID_2 = 13839120 --Yellow Gadget
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_1, CARD_ID_0, CARD_ID_2)
  	--mat check
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_MATERIAL_CHECK)
  	e1:SetValue(s.valcheck)
  	c:RegisterEffect(e1)
  	--summon success
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e2:SetCode(EVENT_SUMMON_SUCCESS)
  	e2:SetCondition(s.regcon)
  	e2:SetOperation(s.regop)
  	c:RegisterEffect(e2)
  	e2:SetLabelObject(e1)
  	--actlimit
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e3:SetCode(EFFECT_CANNOT_ACTIVATE)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetTargetRange(0, 1)
  	e3:SetValue(s.aclimit)
  	e3:SetCondition(s.actcon)
  	c:RegisterEffect(e3)
  end
  function s.aclimit(e, re, tp)
  	return re:IsHasType(EFFECT_TYPE_ACTIVATE)
  end
  function s.actcon(e)
  	return Duel.GetAttacker() == e:GetHandler()
  end
  function s.valcheck(e, c)
  	local g = c:GetMaterial()
  	local flag = 0
  	local tc = g:GetFirst()
  	while tc do
  		local code = tc:GetCode()
  		if code == CARD_ID_1 then
  			flag = bit.bor(flag, 0x1)
  		elseif code == CARD_ID_0 then
  			flag = bit.bor(flag, 0x2)
  		elseif code == CARD_ID_2 then
  			flag = bit.bor(flag, 0x4)
  		end
  		tc = g:GetNext()
  	end
  	e:SetLabel(flag)
  end
  function s.regcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_ADVANCE)
  end
  function s.regop(e, tp, eg, ep, ev, re, r, rp)
  	local flag = e:GetLabelObject():GetLabel()
  	local c = e:GetHandler()
  	if bit.band(flag, 0x1) ~= 0 then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_PIERCE)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		c:RegisterEffect(e1)
  	end
  	if bit.band(flag, 0x2) ~= 0 then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetDescription(aux.Stringid(id, 0))
  		e1:SetCategory(CATEGORY_DAMAGE)
  		e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e1:SetCode(EVENT_BATTLE_DAMAGE)
  		e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  		e1:SetCondition(s.damcon1)
  		e1:SetTarget(s.damtg1)
  		e1:SetOperation(s.damop)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		c:RegisterEffect(e1)
  	end
  	if bit.band(flag, 0x4) ~= 0 then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetDescription(aux.Stringid(id, 1))
  		e1:SetCategory(CATEGORY_DAMAGE)
  		e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  		e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e1:SetCode(EVENT_BATTLE_DESTROYING)
  		e1:SetTarget(s.damtg2)
  		e1:SetOperation(s.damop)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		c:RegisterEffect(e1)
  	end
  end
  function s.damcon1(e, tp, eg, ep, ev, re, r, rp)
  	return ep ~= tp
  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(400)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, 400)
  end
  function s.damtg2(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetTargetPlayer(1 - tp)
  	Duel.SetTargetParam(600)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, 600)
  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
  
  