private void AddToBestNarratorGroup(string characterId) { // Need tests (and code here) to handle the following scenarios: // 0) number of narrators > number of books -> This should never happen! // 1) DONE: number of narrators == number of books -> Add narrator to first empty narrator group // 2) TODO: number of narrators > number of authors -> break up most prolific authors into multiple narrator groups // 3) DONE: number of narrators == number of authors -> add narrator to group with other books by same other, if any; otherwise first empty group // 4) TODO: number of narrators < number of authors -> shorter books share narrators // 5) DONE: single narrator -> EASY: only one group! CharacterGroup bestNarratorGroup = null; if (m_narratorGroupsByAuthor != null) { var author = BiblicalAuthors.GetAuthorOfBook(CharacterVerseData.GetBookCodeFromStandardCharacterId(characterId)); bestNarratorGroup = m_narratorGroupsByAuthor[author]; } if (bestNarratorGroup == null) { bestNarratorGroup = NarratorGroups.FirstOrDefault(g => !g.CharacterIds.Any()); bestNarratorGroup = bestNarratorGroup ?? NarratorGroups.First(); } bestNarratorGroup.CharacterIds.Add(characterId); }
internal bool IsGroupReservedForNarratorOrExtraBiblical(CharacterGroup group) { return(NarratorGroups.Contains(group) || ExtraBiblicalGroup == group); }