1
0
mirror of synced 2024-11-23 22:41:01 +01:00

Add ai section data to song best data

This commit is contained in:
asesidaa 2022-09-21 22:30:09 +08:00
parent 5647dabfbe
commit a04f1bf285
3 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,22 @@
using SharedProject.Enums;
namespace SharedProject.Models;
public class AiSectionBestData
{
public int SectionIndex { get; set; }
public CrownType Crown { get; set; }
public bool IsWin { get; set; }
public uint Score { get; set; }
public uint GoodCount { get; set; }
public uint OkCount { get; set; }
public uint MissCount { get; set; }
public uint DrumrollCount { get; set; }
}

View File

@ -42,4 +42,6 @@ public class SongBestData
public uint HitCount { get; set; }
public uint DrumrollCount { get; set; }
public List<AiSectionBestData> AiSectionBestData { get; set; }
}

View File

@ -42,6 +42,10 @@ public class SongBestDatumService : ISongBestDatumService
var result = songbestDbData.Select(datum => datum.CopyPropertiesToNew<SongBestData>()).ToList();
var aiSectionBest = await context.AiScoreData.Where(datum => datum.Baid == baid)
.Include(datum => datum.AiSectionScoreData)
.ToListAsync();
var playLogs = await context.SongPlayData.Where(datum => datum.Baid == baid).ToListAsync();
foreach (var bestData in result)
{
@ -64,6 +68,16 @@ public class SongBestDatumService : ISongBestDatumService
nameof(SongPlayDatum.DrumrollCount),
nameof(SongPlayDatum.ComboCount)
);
var aiSection = aiSectionBest.FirstOrDefault(datum => datum.Difficulty == bestData.Difficulty &&
datum.SongId == bestData.SongId);
if (aiSection is null)
{
continue;
}
bestData.AiSectionBestData = aiSection.AiSectionScoreData
.Select(datum => datum.CopyPropertiesToNew<AiSectionBestData>()).ToList();
}
return result;