Red
2 Tuners + "Red Dragon Archfiend"
Gains 500 ATK for each Tuner in your GY. Cannot be destroyed by an opponent's card effects. When an opponent's monster declares an attack: You can target the attacking monster; banish this card, and if you do, negate that attack. Once per turn, during the End Phase, if this card was banished by its effect this turn: Special Summon this banished card.
local CARD_ID_0 = 70902743 --Red Dragon Archfiend

local CARD_ID_0 = 70902743 --Red Dragon Archfiend
local s, id, o = GetID()
function s.initial_effect(c)
	aux.AddMaterialCodeList(c, CARD_ID_0)
	--synchro summon
	aux.AddSynchroMixProcedure(c, aux.Tuner(nil), aux.Tuner(nil), nil, aux.FilterBoolFunction(Card.IsCode, CARD_ID_0), 1, 1)
	c:EnableReviveLimit()
	--atk
	local e2 = Effect.CreateEffect(c)
	e2:SetType(EFFECT_TYPE_SINGLE)
	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
	e2:SetRange(LOCATION_MZONE)
	e2:SetCode(EFFECT_UPDATE_ATTACK)
	e2:SetValue(s.atkval)
	c:RegisterEffect(e2)
	--indestructable
	local e3 = Effect.CreateEffect(c)
	e3:SetType(EFFECT_TYPE_SINGLE)
	e3:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
	e3:SetRange(LOCATION_MZONE)
	e3:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
	e3:SetValue(s.indval)
	c:RegisterEffect(e3)
	--negate attack
	local e4 = Effect.CreateEffect(c)
	e4:SetDescription(aux.Stringid(id, 0))
	e4:SetCategory(CATEGORY_REMOVE)
	e4:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
	e4:SetProperty(EFFECT_FLAG_CARD_TARGET)
	e4:SetCode(EVENT_ATTACK_ANNOUNCE)
	e4:SetRange(LOCATION_MZONE)
	e4:SetCondition(s.nacon)
	e4:SetTarget(s.natg)
	e4:SetOperation(s.naop)
	c:RegisterEffect(e4)
	--special summon
	local e5 = Effect.CreateEffect(c)
	e5:SetDescription(aux.Stringid(id, 1))
	e5:SetCategory(CATEGORY_SPECIAL_SUMMON)
	e5:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
	e5:SetCode(EVENT_PHASE + PHASE_END)
	e5:SetRange(LOCATION_REMOVED)
	e5:SetCountLimit(1)
	e5:SetCondition(s.spcon)
	e5:SetTarget(s.sptg)
	e5:SetOperation(s.spop)
	c:RegisterEffect(e5)
	--double tuner
	local e6 = Effect.CreateEffect(c)
	e6:SetType(EFFECT_TYPE_SINGLE)
	e6:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
	e6:SetCode(21142671)
	c:RegisterEffect(e6)
end
s.material_type = TYPE_SYNCHRO
function s.atkval(e, c)
	return Duel.GetMatchingGroupCount(Card.IsType, c:GetControler(), LOCATION_GRAVE, 0, nil, TYPE_TUNER) * 500
end
function s.indval(e, re, tp)
	return e:GetHandler():GetControler() ~= tp
end
function s.nacon(e, tp, eg, ep, ev, re, r, rp)
	return Duel.GetAttacker():GetControler() ~= tp
end
function s.natg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
	if chkc then
		return chkc == Duel.GetAttacker()
	end
	if chk == 0 then
		return e:GetHandler():IsAbleToRemove() and Duel.GetAttacker():IsCanBeEffectTarget(e) and not e:GetHandler():IsStatus(STATUS_CHAINING)
	end
	Duel.SetTargetCard(Duel.GetAttacker())
	Duel.SetOperationInfo(0, CATEGORY_REMOVE, e:GetHandler(), 1, 0, 0)
end
function s.naop(e, tp, eg, ep, ev, re, r, rp)
	Duel.NegateAttack()
	local c = e:GetHandler()
	if c:IsRelateToEffect(e) and Duel.Remove(c, POS_FACEUP, REASON_EFFECT) ~= 0 then
		c:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END, 0, 1)
	end
end
function s.spcon(e, tp, eg, ep, ev, re, r, rp)
	return e:GetHandler():GetFlagEffect(id) ~= 0
end
function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return true
	end
	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
end
function s.spop(e, tp, eg, ep, ev, re, r, rp)
	local c = e:GetHandler()
	if not c:IsRelateToEffect(e) then
		return
	end
	Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
end


Red
2 Tuners + "Red Dragon Archfiend"
Gains 500 ATK for each Tuner in your GY. Cannot be destroyed by an opponent's card effects. When an opponent's monster declares an attack: You can target the attacking monster; banish this card, and if you do, negate that attack. Once per turn, during the End Phase, if this card was banished by its effect this turn: Special Summon this banished card.
-- Red
local CARD_ID_0 = 70902743 --Red Dragon Archfiend
local s, id, o = GetID()
function s.initial_effect(c)
	aux.AddMaterialCodeList(c, CARD_ID_0)
	--synchro summon
	aux.AddSynchroMixProcedure(c, aux.Tuner(nil), aux.Tuner(nil), nil, aux.FilterBoolFunction(Card.IsCode, CARD_ID_0), 1, 1)
	c:EnableReviveLimit()
	--atk
	local e2 = Effect.CreateEffect(c)
	e2:SetType(EFFECT_TYPE_SINGLE)
	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
	e2:SetRange(LOCATION_MZONE)
	e2:SetCode(EFFECT_UPDATE_ATTACK)
	e2:SetValue(s.atkval)
	c:RegisterEffect(e2)
	--indestructable
	local e3 = Effect.CreateEffect(c)
	e3:SetType(EFFECT_TYPE_SINGLE)
	e3:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
	e3:SetRange(LOCATION_MZONE)
	e3:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
	e3:SetValue(s.indval)
	c:RegisterEffect(e3)
	--negate attack
	local e4 = Effect.CreateEffect(c)
	e4:SetDescription(aux.Stringid(id, 0))
	e4:SetCategory(CATEGORY_REMOVE)
	e4:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
	e4:SetProperty(EFFECT_FLAG_CARD_TARGET)
	e4:SetCode(EVENT_ATTACK_ANNOUNCE)
	e4:SetRange(LOCATION_MZONE)
	e4:SetCondition(s.nacon)
	e4:SetTarget(s.natg)
	e4:SetOperation(s.naop)
	c:RegisterEffect(e4)
	--special summon
	local e5 = Effect.CreateEffect(c)
	e5:SetDescription(aux.Stringid(id, 1))
	e5:SetCategory(CATEGORY_SPECIAL_SUMMON)
	e5:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
	e5:SetCode(EVENT_PHASE + PHASE_END)
	e5:SetRange(LOCATION_REMOVED)
	e5:SetCountLimit(1)
	e5:SetCondition(s.spcon)
	e5:SetTarget(s.sptg)
	e5:SetOperation(s.spop)
	c:RegisterEffect(e5)
	--double tuner
	local e6 = Effect.CreateEffect(c)
	e6:SetType(EFFECT_TYPE_SINGLE)
	e6:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
	e6:SetCode(21142671)
	c:RegisterEffect(e6)
end
s.material_type = TYPE_SYNCHRO
function s.atkval(e, c)
	return Duel.GetMatchingGroupCount(Card.IsType, c:GetControler(), LOCATION_GRAVE, 0, nil, TYPE_TUNER) * 500
end
function s.indval(e, re, tp)
	return e:GetHandler():GetControler() ~= tp
end
function s.nacon(e, tp, eg, ep, ev, re, r, rp)
	return Duel.GetAttacker():GetControler() ~= tp
end
function s.natg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
	if chkc then
		return chkc == Duel.GetAttacker()
	end
	if chk == 0 then
		return e:GetHandler():IsAbleToRemove() and Duel.GetAttacker():IsCanBeEffectTarget(e) and not e:GetHandler():IsStatus(STATUS_CHAINING)
	end
	Duel.SetTargetCard(Duel.GetAttacker())
	Duel.SetOperationInfo(0, CATEGORY_REMOVE, e:GetHandler(), 1, 0, 0)
end
function s.naop(e, tp, eg, ep, ev, re, r, rp)
	Duel.NegateAttack()
	local c = e:GetHandler()
	if c:IsRelateToEffect(e) and Duel.Remove(c, POS_FACEUP, REASON_EFFECT) ~= 0 then
		c:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END, 0, 1)
	end
end
function s.spcon(e, tp, eg, ep, ev, re, r, rp)
	return e:GetHandler():GetFlagEffect(id) ~= 0
end
function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return true
	end
	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
end
function s.spop(e, tp, eg, ep, ev, re, r, rp)
	local c = e:GetHandler()
	if not c:IsRelateToEffect(e) then
		return
	end
	Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
end

