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];
}
///
/// 查找最近的boss节点
///
///
///
public static ChapterTable FindNearestBoss(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;
}
for(var i = index; i < tables.Length; i++)
{
if (tables[i].Part_type == 1)
{
return tables[i];
}
}
return default;
}
}
}