Don
During each of your opponent's End Phases: Gain Life Points equal to the number of times you took battle damage this turn x 500. When a "Number" monster you control is targeted for an attack, except "Number C" monsters: You can send this card to the Graveyard; negate the attack, then Special Summon, from your Extra Deck, 1 "Number C" monster with the same number in its name as that "Number" monster you control, by using it as the Xyz Material. (This Special Summon is treated as an Xyz Summon. Xyz Materials attached to it also become Xyz Materials on the Summoned monster.) You can only control 1 "Don Thousand's Throne".
local SETCARD_ID_0 = 0x1048 --Number
local SETCARD_ID_1 = 0x48 --Number

local SETCARD_ID_0 = 0x1048 --Number
local SETCARD_ID_1 = 0x48 --Number
local s, id, o = GetID()
function s.initial_effect(c)
	c:SetUniqueOnField(1, 0, id)
	--activate
	local e1 = Effect.CreateEffect(c)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_FREE_CHAIN)
	e1:SetHintTiming(0, TIMING_END_PHASE)
	c:RegisterEffect(e1)
	--recover
	local e2 = Effect.CreateEffect(c)
	e2:SetDescription(aux.Stringid(id, 0))
	e2:SetCategory(CATEGORY_RECOVER)
	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
	e2:SetCode(EVENT_PHASE + PHASE_END)
	e2:SetRange(LOCATION_SZONE)
	e2:SetCountLimit(1)
	e2:SetCondition(s.reccon)
	e2:SetTarget(s.rectg)
	e2:SetOperation(s.recop)
	c:RegisterEffect(e2)
	--
	local e3 = Effect.CreateEffect(c)
	e3:SetDescription(aux.Stringid(id, 1))
	e3:SetType(EFFECT_TYPE_QUICK_O)
	e3:SetRange(LOCATION_SZONE)
	e3:SetCode(EVENT_BE_BATTLE_TARGET)
	e3:SetCondition(s.spcon)
	e3:SetCost(s.spcost)
	e3:SetTarget(s.sptg)
	e3:SetOperation(s.spop)
	c:RegisterEffect(e3)
	if not s.global_check then
		s.global_check = true
		local ge1 = Effect.CreateEffect(c)
		ge1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
		ge1:SetCode(EVENT_BATTLE_DAMAGE)
		ge1:SetOperation(s.checkop)
		Duel.RegisterEffect(ge1, 0)
	end
end
function s.checkop(e, tp, eg, ep, ev, re, r, rp)
	Duel.RegisterFlagEffect(ep, id, RESET_PHASE + PHASE_END, 0, 1)
end
function s.reccon(e, tp, eg, ep, ev, re, r, rp)
	return Duel.GetTurnPlayer() ~= tp
end
function s.rectg(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return true
	end
	local ct = Duel.GetFlagEffect(tp, id)
	Duel.SetTargetPlayer(tp)
	Duel.SetOperationInfo(0, CATEGORY_RECOVER, nil, 0, tp, ct * 500)
end
function s.recop(e, tp, eg, ep, ev, re, r, rp)
	local p = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER)
	local ct = Duel.GetFlagEffect(tp, id)
	Duel.Recover(p, ct * 500, REASON_EFFECT)
end
function s.spcon(e, tp, eg, ep, ev, re, r, rp)
	local at = Duel.GetAttackTarget()
	return at:IsFaceup() and at:IsControler(tp) and at:IsSetCard(0x48) and not at:IsSetCard(SETCARD_ID_1)
end
function s.spcost(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.filter(c, e, tp, mc, no)
	return aux.GetXyzNumber(c) == no
		and c:IsSetCard(SETCARD_ID_1)
		and mc:IsCanBeXyzMaterial(c)
		and c:IsCanBeSpecialSummoned(e, SUMMON_TYPE_XYZ, tp, false, false)
		and Duel.GetLocationCountFromEx(tp, tp, mc, c) > 0
end
function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		local at = Duel.GetAttackTarget()
		local no = aux.GetXyzNumber(at)
		return no and aux.MustMaterialCheck(at, tp, EFFECT_MUST_BE_XMATERIAL) and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_EXTRA, 0, 1, nil, e, tp, at, no)
	end
	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_EXTRA)
end
function s.spop(e, tp, eg, ep, ev, re, r, rp)
	if not Duel.NegateAttack() then
		return
	end
	local tc = Duel.GetAttackTarget()
	if not aux.MustMaterialCheck(tc, tp, EFFECT_MUST_BE_XMATERIAL) then
		return
	end
	local no = aux.GetXyzNumber(tc)
	if tc:IsFacedown() or not tc:IsRelateToBattle() or tc:IsControler(1 - tp) or tc:IsImmuneToEffect(e) or not no then
		return
	end
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_EXTRA, 0, 1, 1, nil, e, tp, tc, no)
	local sc = g:GetFirst()
	if sc then
		local mg = tc:GetOverlayGroup()
		if mg:GetCount() ~= 0 then
			Duel.Overlay(sc, mg)
		end
		sc:SetMaterial(Group.FromCards(tc))
		Duel.Overlay(sc, Group.FromCards(tc))
		Duel.SpecialSummon(sc, SUMMON_TYPE_XYZ, tp, tp, false, false, POS_FACEUP)
		sc:CompleteProcedure()
	end
end


Don
During each of your opponent's End Phases: Gain Life Points equal to the number of times you took battle damage this turn x 500. When a "Number" monster you control is targeted for an attack, except "Number C" monsters: You can send this card to the Graveyard; negate the attack, then Special Summon, from your Extra Deck, 1 "Number C" monster with the same number in its name as that "Number" monster you control, by using it as the Xyz Material. (This Special Summon is treated as an Xyz Summon. Xyz Materials attached to it also become Xyz Materials on the Summoned monster.) You can only control 1 "Don Thousand's Throne".
-- Don
local SETCARD_ID_0 = 0x1048 --Number
local SETCARD_ID_1 = 0x48 --Number
local s, id, o = GetID()
function s.initial_effect(c)
	c:SetUniqueOnField(1, 0, id)
	--activate
	local e1 = Effect.CreateEffect(c)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_FREE_CHAIN)
	e1:SetHintTiming(0, TIMING_END_PHASE)
	c:RegisterEffect(e1)
	--recover
	local e2 = Effect.CreateEffect(c)
	e2:SetDescription(aux.Stringid(id, 0))
	e2:SetCategory(CATEGORY_RECOVER)
	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
	e2:SetCode(EVENT_PHASE + PHASE_END)
	e2:SetRange(LOCATION_SZONE)
	e2:SetCountLimit(1)
	e2:SetCondition(s.reccon)
	e2:SetTarget(s.rectg)
	e2:SetOperation(s.recop)
	c:RegisterEffect(e2)
	--
	local e3 = Effect.CreateEffect(c)
	e3:SetDescription(aux.Stringid(id, 1))
	e3:SetType(EFFECT_TYPE_QUICK_O)
	e3:SetRange(LOCATION_SZONE)
	e3:SetCode(EVENT_BE_BATTLE_TARGET)
	e3:SetCondition(s.spcon)
	e3:SetCost(s.spcost)
	e3:SetTarget(s.sptg)
	e3:SetOperation(s.spop)
	c:RegisterEffect(e3)
	if not s.global_check then
		s.global_check = true
		local ge1 = Effect.CreateEffect(c)
		ge1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
		ge1:SetCode(EVENT_BATTLE_DAMAGE)
		ge1:SetOperation(s.checkop)
		Duel.RegisterEffect(ge1, 0)
	end
end
function s.checkop(e, tp, eg, ep, ev, re, r, rp)
	Duel.RegisterFlagEffect(ep, id, RESET_PHASE + PHASE_END, 0, 1)
end
function s.reccon(e, tp, eg, ep, ev, re, r, rp)
	return Duel.GetTurnPlayer() ~= tp
end
function s.rectg(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return true
	end
	local ct = Duel.GetFlagEffect(tp, id)
	Duel.SetTargetPlayer(tp)
	Duel.SetOperationInfo(0, CATEGORY_RECOVER, nil, 0, tp, ct * 500)
end
function s.recop(e, tp, eg, ep, ev, re, r, rp)
	local p = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER)
	local ct = Duel.GetFlagEffect(tp, id)
	Duel.Recover(p, ct * 500, REASON_EFFECT)
end
function s.spcon(e, tp, eg, ep, ev, re, r, rp)
	local at = Duel.GetAttackTarget()
	return at:IsFaceup() and at:IsControler(tp) and at:IsSetCard(0x48) and not at:IsSetCard(SETCARD_ID_1)
end
function s.spcost(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.filter(c, e, tp, mc, no)
	return aux.GetXyzNumber(c) == no
		and c:IsSetCard(SETCARD_ID_1)
		and mc:IsCanBeXyzMaterial(c)
		and c:IsCanBeSpecialSummoned(e, SUMMON_TYPE_XYZ, tp, false, false)
		and Duel.GetLocationCountFromEx(tp, tp, mc, c) > 0
end
function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		local at = Duel.GetAttackTarget()
		local no = aux.GetXyzNumber(at)
		return no and aux.MustMaterialCheck(at, tp, EFFECT_MUST_BE_XMATERIAL) and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_EXTRA, 0, 1, nil, e, tp, at, no)
	end
	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_EXTRA)
end
function s.spop(e, tp, eg, ep, ev, re, r, rp)
	if not Duel.NegateAttack() then
		return
	end
	local tc = Duel.GetAttackTarget()
	if not aux.MustMaterialCheck(tc, tp, EFFECT_MUST_BE_XMATERIAL) then
		return
	end
	local no = aux.GetXyzNumber(tc)
	if tc:IsFacedown() or not tc:IsRelateToBattle() or tc:IsControler(1 - tp) or tc:IsImmuneToEffect(e) or not no then
		return
	end
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_EXTRA, 0, 1, 1, nil, e, tp, tc, no)
	local sc = g:GetFirst()
	if sc then
		local mg = tc:GetOverlayGroup()
		if mg:GetCount() ~= 0 then
			Duel.Overlay(sc, mg)
		end
		sc:SetMaterial(Group.FromCards(tc))
		Duel.Overlay(sc, Group.FromCards(tc))
		Duel.SpecialSummon(sc, SUMMON_TYPE_XYZ, tp, tp, false, false, POS_FACEUP)
		sc:CompleteProcedure()
	end
end

