Fix x/y complete story message
This commit is contained in:
@@ -177,21 +177,47 @@ public class StoryService : IStoryService
|
|||||||
bool worldComplete = sectionsInWorld.Count > 0;
|
bool worldComplete = sectionsInWorld.Count > 0;
|
||||||
foreach (var s in sectionsInWorld)
|
foreach (var s in sectionsInWorld)
|
||||||
{
|
{
|
||||||
var charas = s.IsLeaderSelect ? charaIds : new[] { 0 };
|
int released = 0, finished = 0;
|
||||||
int released = 0, finished = 0, charasWithChapters = 0;
|
bool sectionFinished;
|
||||||
foreach (var c in charas)
|
|
||||||
|
if (s.IsLeaderSelect)
|
||||||
{
|
{
|
||||||
if (!chaptersBySectionChara.TryGetValue((s.Id, c), out var chapters) || chapters.Count == 0)
|
// released_chara_count = charas with playable chapters in the catalog
|
||||||
continue;
|
// (chapter 1 is always unlocked, so a chara is "released" the moment it has
|
||||||
charasWithChapters++;
|
// any chapter row). Drives the "X/Y complete" label, which the client only
|
||||||
int doneCount = chapters.Count(x =>
|
// renders when released > 0. Counter is per-catalog, NOT per-viewer-progress.
|
||||||
allProgress.TryGetValue(x.StoryId, out var p) && (p.IsFinish || p.IsSkipped));
|
// finished_chara_count = charas where the viewer has cleared every chapter.
|
||||||
if (doneCount > 0) released++;
|
int charasWithChapters = 0;
|
||||||
if (doneCount == chapters.Count) finished++;
|
foreach (var c in charaIds)
|
||||||
|
{
|
||||||
|
if (!chaptersBySectionChara.TryGetValue((s.Id, c), out var chapters) || chapters.Count == 0)
|
||||||
|
continue;
|
||||||
|
charasWithChapters++;
|
||||||
|
int doneCount = chapters.Count(x =>
|
||||||
|
allProgress.TryGetValue(x.StoryId, out var p) && (p.IsFinish || p.IsSkipped));
|
||||||
|
if (doneCount == chapters.Count) finished++;
|
||||||
|
}
|
||||||
|
released = charasWithChapters;
|
||||||
|
sectionFinished = released > 0 && finished == released;
|
||||||
}
|
}
|
||||||
// Compare against charas that actually have chapters, not the canonical 1-8 list —
|
else
|
||||||
// otherwise a section missing a class would never be `IsFinished`.
|
{
|
||||||
bool sectionFinished = charasWithChapters > 0 && finished == charasWithChapters;
|
// Non-leader-select sections (Limited / Event story) use chara_id=0 and don't
|
||||||
|
// expose chara counters — prod emits released=finished=0 regardless of progress.
|
||||||
|
// is_finished is derived from completion of the single chara=0 chapter set.
|
||||||
|
chaptersBySectionChara.TryGetValue((s.Id, 0), out var chapters);
|
||||||
|
if (chapters is { Count: > 0 })
|
||||||
|
{
|
||||||
|
int doneCount = chapters.Count(x =>
|
||||||
|
allProgress.TryGetValue(x.StoryId, out var p) && (p.IsFinish || p.IsSkipped));
|
||||||
|
sectionFinished = doneCount == chapters.Count;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sectionFinished = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!sectionFinished) worldComplete = false;
|
if (!sectionFinished) worldComplete = false;
|
||||||
worldDto.SectionList.Add(new SectionEntry
|
worldDto.SectionList.Add(new SectionEntry
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user