using System;

namespace XGame.Database
{
    public partial class ChapterTableRepo
    {
        public static ChapterTable Next(int chapterId)
        {
            var tables = GetAll();
            var index = Array.FindIndex(tables, (a) => a.Id == chapterId);
            if (index < 0)
            {
                Log.Error($"没有找到ChapterTable. chapterId: {chapterId}");
                return default;
            }
            if (index == tables.Length - 1)
            {
                Log.Debug($"ChapterTable已经是最后一个. chapterId: {chapterId}");
                return default;
            }
            return tables[index + 1];
        }
    }
}
