public async Task <CharadesEntry> MakeNextCharadesEntry() { bool shouldGoToNextSource = nextEntryIndex == currentMergedList.Count; if (shouldGoToNextSource) { nextEntryIndex = 0; if (sources.Count != 0) { currentSource = sources.Dequeue(); await GetCurrentMergedListFromSource(); } else if (otherSources.Count != 0) { adaptationStrategy = AdaptationIncluding.OnlyKnownInOthers; currentSource = otherSources.Dequeue(); await GetCurrentMergedListFromSource(); } else { return(null); } } var entry = currentMergedList[nextEntryIndex++]; var nextCharades = await CreateNextCharades(entry); return(nextCharades); }
public SeriesEntry CreateFromManga(long id, AdaptationIncluding withdaptations = AdaptationIncluding.None) { var provider = providerFactory.Get(EntrySource.Manga); var mangaEntries = GetFranchiseEntries(id, provider); if (mangaEntries.Count == 0) { return(null); } switch (withdaptations) { case AdaptationIncluding.OnlyFromEntries: var animeEntries = GetEntriesAdaptations(mangaEntries, EntrySource.Anime); return(CreateFranchise(animeEntries, mangaEntries)); case AdaptationIncluding.All: case AdaptationIncluding.OnlyKnownInOthers: animeEntries = GetAllAdaptations(mangaEntries, EntrySource.Anime); return(CreateFranchise(animeEntries, mangaEntries)); case AdaptationIncluding.None: default: return(CreateFranchise(new List <IEntryInstance>(), mangaEntries)); } }
private void Reset() { charades = new List <CharadesEntry>(); sources.Clear(); otherSources.Clear(); nextEntryIndex = 0; currentMergedList.Clear(); adaptationStrategy = AdaptationIncluding.None; }
public void StartComposing(GetCharadesCriteria criteria) { Reset(); usernames = criteria.Usernames; sources.EnqueueRange(criteria.Sources); var allSources = Enum.GetValues(typeof(EntrySource)).Cast <EntrySource>(); var isAllDone = criteria.Sources.Count == allSources.Count(); if (isAllDone) { adaptationStrategy = AdaptationIncluding.All; } else if (criteria.IncludeKnownAdaptations && sources.Count != 0) { adaptationStrategy = AdaptationIncluding.OnlyFromEntries; var otherSources = allSources.Except(criteria.Sources); this.otherSources.EnqueueRange(otherSources); } }
public SeriesEntry CreateFranchise(IListEntry entry, IFranchiseService franchiseService, AdaptationIncluding withAdaptations) { var franchise = franchiseService.CreateFromAnime(entry.Id, withAdaptations); return(franchise); }