Mecha
2 Level 7 monsters
Once per turn: You can detach 1 material from this card; Special Summon 2 "Mecha Phantom Beast Tokens" (Machine/WIND/Level 3/ATK 0/DEF 0). While you control a Token, this card cannot be destroyed by battle or card effects. Once per turn: You can Tribute 1 "Mecha Phantom Beast" monster, then target 1 card on the field; destroy that target. This card cannot attack during the turn you activate this effect.
local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
local CARD_ID_1 = 22110648 --Mecha Phantom Beast Token
local CARD_ID_2 = 31533705 --Mecha Phantom Beast Token
local SETCARD_ID_0 = 0x101b --Mecha

local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
local CARD_ID_1 = 22110648 --Mecha Phantom Beast Token
local CARD_ID_2 = 31533705 --Mecha Phantom Beast Token
local SETCARD_ID_0 = 0x101b --Mecha
local s, id, o = GetID()
function s.initial_effect(c)
	--xyz summon
	aux.AddXyzProcedure(c, nil, 7, 2)
	c:EnableReviveLimit()
	--
	local e2 = Effect.CreateEffect(c)
	e2:SetType(EFFECT_TYPE_SINGLE)
	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
	e2:SetRange(LOCATION_MZONE)
	e2:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
	e2:SetCondition(aux.tkfcon)
	e2:SetValue(1)
	c:RegisterEffect(e2)
	local e3 = e2:Clone()
	e3:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
	c:RegisterEffect(e3)
	--token
	local e4 = Effect.CreateEffect(c)
	e4:SetDescription(aux.Stringid(id, 0))
	e4:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_TOKEN)
	e4:SetType(EFFECT_TYPE_IGNITION)
	e4:SetRange(LOCATION_MZONE)
	e4:SetCountLimit(1)
	e4:SetCost(s.spcost)
	e4:SetTarget(s.sptg)
	e4:SetOperation(s.spop)
	c:RegisterEffect(e4)
	--destroy
	local e5 = Effect.CreateEffect(c)
	e5:SetDescription(aux.Stringid(id, 1))
	e5:SetCategory(CATEGORY_DESTROY)
	e5:SetType(EFFECT_TYPE_IGNITION)
	e5:SetRange(LOCATION_MZONE)
	e5:SetProperty(EFFECT_FLAG_CARD_TARGET)
	e5:SetCountLimit(1)
	e5:SetCost(s.descost)
	e5:SetTarget(s.destg)
	e5:SetOperation(s.desop)
	c:RegisterEffect(e5)
end
function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_COST)
	end
	e:GetHandler():RemoveOverlayCard(tp, 1, 1, REASON_COST)
end
function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return not Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0)
			and Duel.GetLocationCount(tp, LOCATION_MZONE) > 1
			and Duel.IsPlayerCanSpecialSummonMonster(tp, CARD_ID_2, SETCARD_ID_0, TYPES_TOKEN_MONSTER, 0, 0, 3, RACE_MACHINE, ATTRIBUTE_WIND)
	end
	Duel.SetOperationInfo(0, CATEGORY_TOKEN, nil, 2, 0, 0)
	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 2, 0, 0)
end
function s.spop(e, tp, eg, ep, ev, re, r, rp)
	if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
		return
	end
	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 1 then
		return
	end
	if Duel.IsPlayerCanSpecialSummonMonster(tp, CARD_ID_2, SETCARD_ID_0, TYPES_TOKEN_MONSTER, 0, 0, 3, RACE_MACHINE, ATTRIBUTE_WIND) then
		local token1 = Duel.CreateToken(tp, id + 1)
		Duel.SpecialSummonStep(token1, 0, tp, tp, false, false, POS_FACEUP)
		local token2 = Duel.CreateToken(tp, id + 1)
		Duel.SpecialSummonStep(token2, 0, tp, tp, false, false, POS_FACEUP)
		Duel.SpecialSummonComplete()
	end
end
function s.descost(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return e:GetHandler():GetAttackAnnouncedCount() == 0 and Duel.CheckReleaseGroup(tp, Card.IsSetCard, 1, nil, 0x101b)
	end
	local g = Duel.SelectReleaseGroup(tp, Card.IsSetCard, 1, 1, nil, 0x101b)
	Duel.Release(g, REASON_COST)
	local e1 = Effect.CreateEffect(e:GetHandler())
	e1:SetType(EFFECT_TYPE_SINGLE)
	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_OATH)
	e1:SetCode(EFFECT_CANNOT_ATTACK)
	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
	e:GetHandler():RegisterEffect(e1)
end
function s.destg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
	if chkc then
		return chkc:IsOnField()
	end
	if chk == 0 then
		return Duel.GetFieldGroupCount(tp, LOCATION_ONFIELD, LOCATION_ONFIELD) > 1 and Duel.IsExistingTarget(aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, nil)
	end
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
	local g = Duel.SelectTarget(tp, aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, 1, nil)
	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
end
function s.desop(e, tp, eg, ep, ev, re, r, rp)
	local tc = Duel.GetFirstTarget()
	if tc and tc:IsRelateToEffect(e) then
		Duel.Destroy(tc, REASON_EFFECT)
	end
end


Mecha
2 Level 7 monsters
Once per turn: You can detach 1 material from this card; Special Summon 2 "Mecha Phantom Beast Tokens" (Machine/WIND/Level 3/ATK 0/DEF 0). While you control a Token, this card cannot be destroyed by battle or card effects. Once per turn: You can Tribute 1 "Mecha Phantom Beast" monster, then target 1 card on the field; destroy that target. This card cannot attack during the turn you activate this effect.
-- Mecha
local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
local CARD_ID_1 = 22110648 --Mecha Phantom Beast Token
local CARD_ID_2 = 31533705 --Mecha Phantom Beast Token
local SETCARD_ID_0 = 0x101b --Mecha
local s, id, o = GetID()
function s.initial_effect(c)
	--xyz summon
	aux.AddXyzProcedure(c, nil, 7, 2)
	c:EnableReviveLimit()
	--
	local e2 = Effect.CreateEffect(c)
	e2:SetType(EFFECT_TYPE_SINGLE)
	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
	e2:SetRange(LOCATION_MZONE)
	e2:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
	e2:SetCondition(aux.tkfcon)
	e2:SetValue(1)
	c:RegisterEffect(e2)
	local e3 = e2:Clone()
	e3:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
	c:RegisterEffect(e3)
	--token
	local e4 = Effect.CreateEffect(c)
	e4:SetDescription(aux.Stringid(id, 0))
	e4:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_TOKEN)
	e4:SetType(EFFECT_TYPE_IGNITION)
	e4:SetRange(LOCATION_MZONE)
	e4:SetCountLimit(1)
	e4:SetCost(s.spcost)
	e4:SetTarget(s.sptg)
	e4:SetOperation(s.spop)
	c:RegisterEffect(e4)
	--destroy
	local e5 = Effect.CreateEffect(c)
	e5:SetDescription(aux.Stringid(id, 1))
	e5:SetCategory(CATEGORY_DESTROY)
	e5:SetType(EFFECT_TYPE_IGNITION)
	e5:SetRange(LOCATION_MZONE)
	e5:SetProperty(EFFECT_FLAG_CARD_TARGET)
	e5:SetCountLimit(1)
	e5:SetCost(s.descost)
	e5:SetTarget(s.destg)
	e5:SetOperation(s.desop)
	c:RegisterEffect(e5)
end
function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_COST)
	end
	e:GetHandler():RemoveOverlayCard(tp, 1, 1, REASON_COST)
end
function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return not Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0)
			and Duel.GetLocationCount(tp, LOCATION_MZONE) > 1
			and Duel.IsPlayerCanSpecialSummonMonster(tp, CARD_ID_2, SETCARD_ID_0, TYPES_TOKEN_MONSTER, 0, 0, 3, RACE_MACHINE, ATTRIBUTE_WIND)
	end
	Duel.SetOperationInfo(0, CATEGORY_TOKEN, nil, 2, 0, 0)
	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 2, 0, 0)
end
function s.spop(e, tp, eg, ep, ev, re, r, rp)
	if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
		return
	end
	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 1 then
		return
	end
	if Duel.IsPlayerCanSpecialSummonMonster(tp, CARD_ID_2, SETCARD_ID_0, TYPES_TOKEN_MONSTER, 0, 0, 3, RACE_MACHINE, ATTRIBUTE_WIND) then
		local token1 = Duel.CreateToken(tp, id + 1)
		Duel.SpecialSummonStep(token1, 0, tp, tp, false, false, POS_FACEUP)
		local token2 = Duel.CreateToken(tp, id + 1)
		Duel.SpecialSummonStep(token2, 0, tp, tp, false, false, POS_FACEUP)
		Duel.SpecialSummonComplete()
	end
end
function s.descost(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return e:GetHandler():GetAttackAnnouncedCount() == 0 and Duel.CheckReleaseGroup(tp, Card.IsSetCard, 1, nil, 0x101b)
	end
	local g = Duel.SelectReleaseGroup(tp, Card.IsSetCard, 1, 1, nil, 0x101b)
	Duel.Release(g, REASON_COST)
	local e1 = Effect.CreateEffect(e:GetHandler())
	e1:SetType(EFFECT_TYPE_SINGLE)
	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_OATH)
	e1:SetCode(EFFECT_CANNOT_ATTACK)
	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
	e:GetHandler():RegisterEffect(e1)
end
function s.destg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
	if chkc then
		return chkc:IsOnField()
	end
	if chk == 0 then
		return Duel.GetFieldGroupCount(tp, LOCATION_ONFIELD, LOCATION_ONFIELD) > 1 and Duel.IsExistingTarget(aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, nil)
	end
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
	local g = Duel.SelectTarget(tp, aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, 1, nil)
	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
end
function s.desop(e, tp, eg, ep, ev, re, r, rp)
	local tc = Duel.GetFirstTarget()
	if tc and tc:IsRelateToEffect(e) then
		Duel.Destroy(tc, REASON_EFFECT)
	end
end

