public async Task Parse() { try { var monsters = await _monsterProcessor.Process(_mmFileName, _localization); foreach (var monster in monsters) { monster.ContentSourceEnum = ContentSource.SnV; var monsterSearchTerm = _globalSearchTermRepository.CreateSearchTerm(monster.Name, GlobalSearchTermType.Monster, ContentType.Core, $"/rules/snv/monsters/{monster.Name}"); _globalSearchTermRepository.SearchTerms.Add(monsterSearchTerm); } await _tableStorage.AddBatchAsync <Monster>($"monsters{_localization.Language}", monsters, new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace }); } catch (StorageException) { Console.WriteLine("Failed to upload monsters."); } foreach (var monsterChapterName in SectionNames.MonsterChapterNames) { var monsterChapterSearchTerm = _globalSearchTermRepository.CreateSearchTerm(monsterChapterName.name, monsterChapterName.globalSearchTermType, ContentType.Core, monsterChapterName.pathOverride); _globalSearchTermRepository.SearchTerms.Add(monsterChapterSearchTerm); } }
public async Task Parse() { var extendedContentChapters = new List <ChapterRules>(); foreach (var ecFile in _expandedContentFileNames) { var extendedContent = await _expandedContentProcessor.Process(new List <string> { ecFile }, _localization); if (extendedContent.SingleOrDefault() != null) { extendedContentChapters.Add(extendedContent.Single()); } } await _cloudBlobContainer.CreateIfNotExistsAsync(BlobContainerPublicAccessType.Off, null, null); foreach (var ec in extendedContentChapters) { var json = JsonConvert.SerializeObject(ec); var blob = _cloudBlobContainer.GetBlockBlobReference($"{ec.ChapterName}.json"); await blob.UploadTextAsync(json); var searchTerm = _globalSearchTermRepository.CreateSearchTerm(ec.ChapterName, GlobalSearchTermType.ExpandedContent, ContentType.ExpandedContent, $"/rules/expandedContent/{ec.ChapterName}"); _globalSearchTermRepository.SearchTerms.Add(searchTerm); } }
public async Task <List <Power> > Parse() { var forcePowers = new List <Power>(); try { var forcePowersProcessor = new ExpandedContentForcePowersProcessor(); forcePowers = await forcePowersProcessor.Process(_ecForcePowersFileName, _localization); foreach (var forcePower in forcePowers) { forcePower.ContentSourceEnum = ContentSource.EC; var forcePowerSearchTerm = _globalSearchTermRepository.CreateSearchTerm(forcePower.Name, GlobalSearchTermType.ForcePower, ContentType.ExpandedContent, $"/characters/forcePowers/?search={forcePower.Name}"); _globalSearchTermRepository.SearchTerms.Add(forcePowerSearchTerm); } await _tableStorage.AddBatchAsync <Power>($"powers{_localization.Language}", forcePowers, new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace }); } catch (StorageException) { Console.WriteLine("Failed to upload EC force powers."); } return(forcePowers); }
public async Task Parse() { try { var expandedContentBackgroundProcessor = new ExpandedContentBackgroundProcessor(_localization); var backgrounds = await expandedContentBackgroundProcessor.Process(_ecBackgroundsFileName, _localization); foreach (var background in backgrounds) { background.ContentSourceEnum = ContentSource.EC; var backgroundSearchTerm = _globalSearchTermRepository.CreateSearchTerm(background.Name, GlobalSearchTermType.Background, ContentType.ExpandedContent, $"/characters/backgrounds/{background.Name}"); _globalSearchTermRepository.SearchTerms.Add(backgroundSearchTerm); } await _tableStorage.AddBatchAsync <Background>($"backgrounds{_localization.Language}", backgrounds, new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace }); } catch (StorageException) { Console.WriteLine("Failed to upload EC backgrounds."); } }
public async Task Parse() { try { var speciesImageUrlsLU = await _tableStorage.GetAllAsync<SpeciesImageUrlLU>("speciesImageUrlsLU"); var speciesProcessor = new ExpandedContentSpeciesProcessor(_localization, speciesImageUrlsLU.ToList()); var species = await speciesProcessor.Process(_ecSpeciesFileName, _localization); foreach (var specie in species) { specie.ContentSourceEnum = ContentSource.EC; var specieSearchTerm = _globalSearchTermRepository.CreateSearchTerm(specie.Name, GlobalSearchTermType.Species, ContentType.ExpandedContent, $"/characters/species/{specie.Name}"); _globalSearchTermRepository.SearchTerms.Add(specieSearchTerm); } await _tableStorage.AddBatchAsync<Species>($"species{_localization.Language}", species, new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace }); } catch (StorageException) { Console.WriteLine("Failed to upload EC species."); } }
public async Task Parse() { var extendedContentChapters = new List <ChapterRules>(); foreach (var ecFile in _expandedContentFileNames) { var expandedContentProcessor = new ExpandedContentProcessor(); var extendedContent = await expandedContentProcessor.Process(new List <string> { ecFile }, _localization); if (extendedContent.SingleOrDefault() != null) { extendedContentChapters.Add(extendedContent.Single()); } } await _blobContainerClient.CreateIfNotExistsAsync(); foreach (var ec in extendedContentChapters) { var json = JsonConvert.SerializeObject(ec); var blobClient = _blobContainerClient.GetBlobClient($"{ec.ChapterName}.json"); var content = Encoding.UTF8.GetBytes(json); using (var ms = new MemoryStream(content)) { await blobClient.UploadAsync(ms, true); } var searchTerm = _globalSearchTermRepository.CreateSearchTerm(ec.ChapterName, GlobalSearchTermType.ExpandedContent, ContentType.ExpandedContent, $"/rules/expandedContent/{ec.ChapterName}"); _globalSearchTermRepository.SearchTerms.Add(searchTerm); } }
public async Task Parse() { try { var classImageLus = await _tableStorage.GetAllAsync <ClassImageLU>("classImageLU"); var casterRatioLus = await _tableStorage.GetAllAsync <CasterRatioLU>("casterRatioLU"); var classes = await _tableStorage.GetAllAsync <Class>($"classes{_localization.Language}"); var archetypeProcessor = new ExpandedContentArchetypeProcessor(classImageLus.ToList(), casterRatioLus.ToList(), classes.ToList()); var archetypes = await archetypeProcessor.Process(_ecArchetypesFileName, _localization); foreach (var archetype in archetypes) { archetype.ContentSourceEnum = ContentSource.EC; var archetypeSearchTerm = _globalSearchTermRepository.CreateSearchTerm(archetype.Name, GlobalSearchTermType.Archetype, ContentType.ExpandedContent, $"/characters/archetypes/{Uri.EscapeDataString(archetype.Name)}"); _globalSearchTermRepository.SearchTerms.Add(archetypeSearchTerm); } try { var archetypeFeatures = archetypes.SelectMany(f => f.Features).ToList(); var featureLevels = (await _tableStorage.GetAllAsync <FeatureDataLU>("featureDataLU")).ToList(); foreach (var archetypeFeature in archetypeFeatures) { var featureLevel = featureLevels.SingleOrDefault(f => f.FeatureRowKey == archetypeFeature.RowKey); if (featureLevel != null) { archetypeFeature.Level = featureLevel.Level; } } var dupes = archetypeFeatures .GroupBy(i => i.RowKey) .Where(g => g.Count() > 1) .Select(g => g.Key); await _tableStorage.AddBatchAsync <Feature>($"features{_localization.Language}", archetypeFeatures, new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace }); } catch (StorageException se) { Console.WriteLine($"Failed to upload EC archetype features: {se}"); } await _tableStorage.AddBatchAsync <Archetype>($"archetypes{_localization.Language}", archetypes, new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace }); } catch (StorageException e) { Console.WriteLine($"Failed to upload EC archetypes: {e.Message}"); } }
public async Task Parse() { var rules = await _expandedContentVariantRulesProcessor.Process(_ecVariantRulesFileName, _localization); await _cloudBlobContainer.CreateIfNotExistsAsync(BlobContainerPublicAccessType.Off, null, null); foreach (var variantRule in rules) { var json = JsonConvert.SerializeObject(variantRule); var blob = _cloudBlobContainer.GetBlockBlobReference($"{variantRule.ChapterName}.json"); await blob.UploadTextAsync(json); var searchTerm = _globalSearchTermRepository.CreateSearchTerm(variantRule.ChapterName, GlobalSearchTermType.VariantRule, ContentType.ExpandedContent, $"/rules/variantRules/{variantRule.ChapterName}"); _globalSearchTermRepository.SearchTerms.Add(searchTerm); } }
public async Task Parse() { var rules = await _expandedContentVariantRulesProcessor.Process(_ecVariantRulesFileName, _localization); await _blobContainerClient.CreateIfNotExistsAsync(); foreach (var variantRule in rules) { var json = JsonConvert.SerializeObject(variantRule); var blobClient = _blobContainerClient.GetBlobClient($"{variantRule.ChapterName}.json"); var content = Encoding.UTF8.GetBytes(json); using (var ms = new MemoryStream(content)) { await blobClient.UploadAsync(ms, true); } var searchTerm = _globalSearchTermRepository.CreateSearchTerm(variantRule.ChapterName, GlobalSearchTermType.VariantRule, ContentType.ExpandedContent, $"/rules/variantRules/{variantRule.ChapterName}"); _globalSearchTermRepository.SearchTerms.Add(searchTerm); } }
public async Task Parse() { try { var ecFeats = await _expandedContentCustomizationOptionsProcessor.Process(_ecCustomizationOptionsFileName, _localization); foreach (var feat in ecFeats) { feat.ContentSourceEnum = ContentSource.EC; var featSearchTerm = _globalSearchTermRepository.CreateSearchTerm(feat.Name, GlobalSearchTermType.Feat, ContentType.ExpandedContent, $"/characters/feats/?search={feat.Name}"); _globalSearchTermRepository.SearchTerms.Add(featSearchTerm); } await _tableStorage.AddBatchAsync <Feat>($"feats{_localization.Language}", ecFeats, new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace }); } catch (StorageException) { Console.WriteLine("Failed to upload EC feats."); } }
public async Task Parse() { try { var enhancedItems = await _expandedContentEnhancedItemsProcessor.Process(_ecEnhancedItemsFileName, _localization); foreach (var enhancedItem in enhancedItems) { enhancedItem.ContentSourceEnum = ContentSource.EC; var enhancedItemSearchTerm = _globalSearchTermRepository.CreateSearchTerm(enhancedItem.Name, GlobalSearchTermType.EnhancedItem, ContentType.ExpandedContent, $"/loot/enhancedItems?search={enhancedItem.Name}"); _globalSearchTermRepository.SearchTerms.Add(enhancedItemSearchTerm); } await _tableStorage.AddBatchAsync <EnhancedItem>($"enhancedItems{_localization.Language}", enhancedItems, new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace }); } catch (StorageException) { Console.WriteLine("Failed to upload EC enhanced items."); } }
public override Task <List <ChapterRules> > FindBlocks(List <string> lines) { var chapters = new List <ChapterRules>(); var prefaceStartIndex = lines.FindIndex(f => f == Localization.PHBPrefaceStartLine); var whatsDifferentStartIndex = lines.FindIndex(f => f == Localization.PHBWhatsDifferentStartLine); var chapter0StartIndex = lines.FindIndex(f => f == Localization.PHBIntroductionStartLine); var chapter1StartIndex = lines.FindIndex(f => f == Localization.PHBChapter1StartLine); var chapter2StartIndex = lines.FindIndex(f => f == Localization.PHBChapter2StartLine); var chapter3StartIndex = lines.FindIndex(f => f == Localization.PHBChapter3StartLine); var chapter4StartIndex = lines.FindIndex(f => f == Localization.PHBChapter4StartLine); var chapter5StartIndex = lines.FindIndex(f => f == Localization.PHBChapter5StartLine); var chapter6StartIndex = lines.FindIndex(f => f == Localization.PHBChapter6StartLine); var chapter7StartIndex = lines.FindIndex(f => f == Localization.PHBChapter7StartLine); var chapter8StartIndex = lines.FindIndex(f => f == Localization.PHBChapter8StartLine); var chapter9StartIndex = lines.FindIndex(f => f == Localization.PHBChapter9StartLine); var chapter10StartIndex = lines.FindIndex(f => f == Localization.PHBChapter10StartLine); var chapter11StartIndex = lines.FindIndex(f => f == Localization.PHBChapter11StartLine); var appendixAStartIndex = lines.FindIndex(f => f == Localization.PHBAppendixAStartLine); var appendixBStartIndex = lines.FindIndex(f => f == Localization.PHBAppendixBStartLine); var changelogStartIndex = lines.FindIndex(f => f == Localization.PHBChangelogStartLine); var prefaceLines = lines.Skip(prefaceStartIndex).Take(whatsDifferentStartIndex - prefaceStartIndex) .CleanListOfStrings().ToList(); chapters.Add(CreateChapterRules(prefaceLines, -2, Localization.PHBPrefaceTitle)); var whatsDifferentLines = lines.Skip(whatsDifferentStartIndex).Take(chapter0StartIndex - whatsDifferentStartIndex) .CleanListOfStrings().ToList(); chapters.Add(CreateChapterRules(whatsDifferentLines, -1, Localization.PHBWhatsDifferentTitle)); var introLines = lines.Skip(chapter0StartIndex).Take(chapter1StartIndex - chapter0StartIndex) .CleanListOfStrings().ToList(); introLines[2] = introLines[2].Insert(0, "T"); chapters.Add(CreateChapterRules(introLines, 0, Localization.PHBIntroductionTitle)); var chapter1Lines = lines.Skip(chapter1StartIndex).Take(chapter2StartIndex - chapter1StartIndex) .CleanListOfStrings().ToList(); chapter1Lines[2] = chapter1Lines[2].Insert(0, "Y"); chapters.Add(CreateChapterRules(chapter1Lines, 1, Localization.PHBChapter1Title, SectionNames.PHBChapterOneSections, "stepByStep")); var chapter2EndIndex = lines.FindIndex(chapter2StartIndex, f => f.StartsWith("___")); var chapter2Lines = lines.Skip(chapter2StartIndex).Take(chapter2EndIndex - chapter2StartIndex) .CleanListOfStrings().ToList(); chapter2Lines[2] = chapter2Lines[2].Insert(0, "A "); chapters.Add(CreateChapterRules(chapter2Lines, 2, Localization.PHBChapter2Title, SectionNames.PHBChapterTwoSections, "species")); var chapter3EndIndex = lines.FindIndex(chapter3StartIndex, f => f.StartsWith(Localization.PHBClassesStartLine)); var chapter3Lines = lines.Skip(chapter3StartIndex).Take(chapter3EndIndex - chapter3StartIndex) .CleanListOfStrings().ToList(); chapter3Lines[2] = chapter3Lines[2].Insert(0, "A"); chapters.Add(CreateChapterRules(chapter3Lines, 3, Localization.PHBChapter3Title, SectionNames.PHBChapterThreeSections, "classes")); var chapter4EndIndex = lines.FindIndex(chapter4StartIndex, f => f.StartsWith(Localization.PHBBackgroundsStartLine)); var chapter4Lines = lines.Skip(chapter4StartIndex).Take(chapter4EndIndex - chapter4StartIndex) .CleanListOfStrings().ToList(); chapter4Lines[2] = chapter4Lines[2].Insert(0, "C"); chapters.Add(CreateChapterRules(chapter4Lines, 4, Localization.PHBChapter4Title, SectionNames.PHBChapterFourSections, "backgrounds")); var chapter5Lines = lines.Skip(chapter5StartIndex).Take(chapter6StartIndex - chapter5StartIndex) .CleanListOfStrings().ToList(); chapter5Lines[2] = chapter5Lines[2].Insert(0, "T"); chapters.Add(CreateChapterRules(chapter5Lines, 5, Localization.PHBChapter5Title, SectionNames.PHBChapterFiveSections, "equipment")); var chapter6EndIndex = lines.FindIndex(chapter6StartIndex, f => f.StartsWith(Localization.PHBFeatsStartLine)); var chapter6Lines = lines.Skip(chapter6StartIndex).Take(chapter6EndIndex - chapter6StartIndex) .CleanListOfStrings().ToList(); chapter6Lines[2] = chapter6Lines[2].Insert(0, "T"); chapters.Add(CreateChapterRules(chapter6Lines, 6, Localization.PHBChapter6Title, SectionNames.PHBChapterSixSections, "customization")); var chapter7Lines = lines.Skip(chapter7StartIndex).Take(chapter8StartIndex - chapter7StartIndex) .CleanListOfStrings().ToList(); chapter7Lines[2] = chapter7Lines[2].Insert(0, "S"); chapters.Add(CreateChapterRules(chapter7Lines, 7, Localization.PHBChapter7Title, SectionNames.PHBChapterSevenSections, "abilityScores")); var chapter8Lines = lines.Skip(chapter8StartIndex).Take(chapter9StartIndex - chapter8StartIndex) .CleanListOfStrings().ToList(); chapter8Lines[2] = chapter8Lines[2].Insert(0, "D"); chapters.Add(CreateChapterRules(chapter8Lines, 8, Localization.PHBChapter8Title, SectionNames.PHBChapterEightSections, "adventuring")); var chapter9Lines = lines.Skip(chapter9StartIndex).Take(chapter10StartIndex - chapter9StartIndex) .CleanListOfStrings().ToList(); chapter9Lines[2] = chapter9Lines[2].Insert(0, "T"); chapters.Add(CreateChapterRules(chapter9Lines, 9, Localization.PHBChapter9Title, SectionNames.PHBChapterNineSections, "combat")); var chapter10Lines = lines.Skip(chapter10StartIndex).Take(chapter11StartIndex - chapter10StartIndex) .CleanListOfStrings().ToList(); chapter10Lines[2] = chapter10Lines[2].Insert(0, "M"); chapters.Add(CreateChapterRules(chapter10Lines, 10, Localization.PHBChapter10Title, SectionNames.PHBChapterTenSections, "casting")); var appendixALines = lines.Skip(appendixAStartIndex).Take(appendixBStartIndex - appendixAStartIndex) .CleanListOfStrings().ToList(); appendixALines[2] = appendixALines[2].Insert(0, "C"); chapters.Add(CreateChapterRules(appendixALines, 13, Localization.PHBAppendixATitle, SectionNames.PHBAppendixAConditionsSections, "conditions")); var appendixBLines = lines.Skip(appendixBStartIndex).Take(changelogStartIndex - appendixBStartIndex).CleanListOfStrings().ToList(); appendixBLines[2] = appendixBLines[2].Insert(0, "H"); chapters.Add(CreateChapterRules(appendixBLines, 14, Localization.PHBAppendixBTitle, SectionNames.PHBAppendixBVariantRulesSections, "variantRules")); var changelogLines = lines.Skip(changelogStartIndex).CleanListOfStrings().ToList(); chapters.Add(CreateChapterRules(changelogLines, 99, Localization.PHBChangelogTitle)); foreach (var phbChapterName in SectionNames.PHBChapterNames) { var searchTerm = _globalSearchTermRepository.CreateSearchTerm(phbChapterName.name, phbChapterName.globalSearchTermType, ContentType.Core, phbChapterName.pathOverride); _globalSearchTermRepository.SearchTerms.Add(searchTerm); } return(Task.FromResult(chapters)); }
public async Task Parse() { try { var equipmentProcessor = new ExpandedContentEquipmentProcessor(_localization); var equipments = await equipmentProcessor.Process(_ecEquipmentFileName, _localization); foreach (var equipment in equipments) { equipment.ContentSourceEnum = ContentSource.EC; switch (equipment.EquipmentCategoryEnum) { case EquipmentCategory.Unknown: case EquipmentCategory.Ammunition: case EquipmentCategory.Explosive: case EquipmentCategory.Storage: case EquipmentCategory.AdventurePack: case EquipmentCategory.Communications: case EquipmentCategory.DataRecordingAndStorage: case EquipmentCategory.LifeSupport: case EquipmentCategory.Medical: case EquipmentCategory.WeaponOrArmorAccessory: case EquipmentCategory.Tool: case EquipmentCategory.Mount: case EquipmentCategory.Vehicle: case EquipmentCategory.TradeGood: case EquipmentCategory.Utility: case EquipmentCategory.GamingSet: case EquipmentCategory.MusicalInstrument: case EquipmentCategory.Droid: case EquipmentCategory.Clothing: case EquipmentCategory.Kit: var equipmentSearchTerm = _globalSearchTermRepository.CreateSearchTerm(equipment.Name, GlobalSearchTermType.AdventuringGear, ContentType.ExpandedContent, $"/loot/adventuringGear/?search={equipment.Name}"); _globalSearchTermRepository.SearchTerms.Add(equipmentSearchTerm); break; case EquipmentCategory.Weapon: var weaponSearchTerm = _globalSearchTermRepository.CreateSearchTerm(equipment.Name, GlobalSearchTermType.Weapon, ContentType.ExpandedContent, $"/loot/weapons/?search={equipment.Name}"); _globalSearchTermRepository.SearchTerms.Add(weaponSearchTerm); break; case EquipmentCategory.Armor: var searchTermType = GlobalSearchTermType.Armor; if (equipment.ArmorClassificationEnum == ArmorClassification.Shield) { searchTermType = GlobalSearchTermType.Shield; } var armorSearchTerm = _globalSearchTermRepository.CreateSearchTerm(equipment.Name, searchTermType, ContentType.ExpandedContent, $"/loot/armor/?search={equipment.Name}"); _globalSearchTermRepository.SearchTerms.Add(armorSearchTerm); break; default: throw new ArgumentOutOfRangeException(); } } await _tableStorage.AddBatchAsync <Equipment>($"equipment{_localization.Language}", equipments, new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace }); } catch (StorageException) { Console.WriteLine("Failed to upload EC equipment."); } }
public override Task <List <ChapterRules> > FindBlocks(List <string> lines) { var chapters = new List <ChapterRules>(); var chapter0StartIndex = lines.FindIndex(f => f == Localization.SOTGChapter0StartLine); var chapter1StartIndex = lines.FindIndex(f => f == Localization.SOTGChapter1StartLine); var chapter2StartIndex = lines.FindIndex(f => f == Localization.SOTGChapter2StartLine); var chapter3StartIndex = lines.FindIndex(f => f == Localization.SOTGChapter3StartLine); var chapter4StartIndex = lines.FindIndex(f => f == Localization.SOTGChapter4StartLine); var chapter5StartIndex = lines.FindIndex(f => f == Localization.SOTGChapter5StartLine); var chapter6StartIndex = lines.FindIndex(f => f == Localization.SOTGChapter6StartLine); var chapter7StartIndex = lines.FindIndex(f => f == Localization.SOTGChapter7StartLine); var chapter8StartIndex = lines.FindIndex(f => f == Localization.SOTGChapter8StartLine); var chapter9StartIndex = lines.FindIndex(f => f == Localization.SOTGChapter9StartLine); var chapter10StartIndex = lines.FindIndex(f => f == Localization.SOTGChapter10StartLine); var appendixAStartIndex = lines.FindIndex(f => f == Localization.SOTGAppendixAStartLine); var changelogStartIndex = lines.FindIndex(f => f == Localization.SOTGChangelogStartLine); var introLines = lines.Skip(chapter0StartIndex).Take(chapter1StartIndex - chapter0StartIndex) .CleanListOfStrings().ToList(); introLines[2] = introLines[2].Insert(0, "T"); chapters.Add(CreateStarshipChapterRules(introLines, 0, Localization.SOTGChapter0Title, SectionNames.SOTGChapterZeroSections, "")); var chapter1Lines = lines.Skip(chapter1StartIndex).Take(chapter2StartIndex - chapter1StartIndex) .CleanListOfStrings().ToList(); chapter1Lines[2] = chapter1Lines[2].Insert(0, "Y"); chapters.Add(CreateStarshipChapterRules(chapter1Lines, 1, Localization.SOTGChapter1Title, SectionNames.SOTGChapterOneSections, "stepByStep")); var chapter2EndIndex = lines.FindIndex(chapter2StartIndex, f => f == Localization.SOTGDeploymentsStartLine); var chapter2Lines = lines.Skip(chapter2StartIndex).Take(chapter2EndIndex - chapter2StartIndex) .CleanListOfStrings().ToList(); chapter2Lines[2] = chapter2Lines[2].Insert(0, "A"); chapters.Add(CreateStarshipChapterRules(chapter2Lines, 2, Localization.SOTGChapter2Title, SectionNames.PHBChapterTwoSections, "deployments")); var chapter3EndIndex = lines.FindIndex(chapter3StartIndex, f => f == Localization.SOTGShipSizeStartLine); var chapter3Lines = lines.Skip(chapter3StartIndex).Take(chapter3EndIndex - chapter3StartIndex) .CleanListOfStrings().ToList(); var variantStart = lines.FindIndex(chapter3StartIndex, f => f == "## Variant: Space Stations"); var variantLines = lines.Skip(variantStart).Take(chapter4StartIndex - variantStart).CleanListOfStrings().ToList(); chapter3Lines.AddRange(variantLines); chapter3Lines[2] = chapter3Lines[2].Insert(0, "C"); chapters.Add(CreateStarshipChapterRules(chapter3Lines, 3, Localization.SOTGChapter3Title, SectionNames.SOTGChapterThreeSections, "starshipSizes")); var chapter4EndIndex = lines.FindIndex(chapter4StartIndex, f => f == Localization.SOTGModificationsStart); var chapter4Lines = lines.Skip(chapter4StartIndex).Take(chapter4EndIndex - chapter4StartIndex) .CleanListOfStrings().ToList(); chapter4Lines[2] = chapter4Lines[2].Insert(0, "A"); chapters.Add(CreateStarshipChapterRules(chapter4Lines, 4, Localization.SOTGChapter4Title, SectionNames.SOTGChapterFourSections, "modifications")); var chapter5Lines = lines.Skip(chapter5StartIndex).Take(chapter6StartIndex - chapter5StartIndex) .CleanListOfStrings().ToList(); chapter5Lines[2] = chapter5Lines[2].Insert(0, "T"); chapters.Add(CreateStarshipChapterRules(chapter5Lines, 5, Localization.SOTGChapter5Title, SectionNames.SOTGChapterFiveSections, "equipment")); var chapter6EndIndex = lines.FindIndex(lines.FindIndex(chapter6StartIndex, f => f == Localization.SOTGVenturesStart), f => f.StartsWith("### ")); var chapter6Lines = lines.Skip(chapter6StartIndex).Take(chapter6EndIndex - chapter6StartIndex) .CleanListOfStrings().ToList(); chapter6Lines[2] = chapter6Lines[2].Insert(0, "T"); chapters.Add(CreateStarshipChapterRules(chapter6Lines, 6, Localization.SOTGChapter6Title, SectionNames.SOTGChapterSixSections, "customization")); var chapter7Lines = lines.Skip(chapter7StartIndex).Take(chapter8StartIndex - chapter7StartIndex) .CleanListOfStrings().ToList(); chapter7Lines[2] = chapter7Lines[2].Insert(0, "S"); chapters.Add(CreateStarshipChapterRules(chapter7Lines, 7, Localization.SOTGChapter7Title, SectionNames.SOTGChapterSevenSections, "abilityScores")); var chapter8Lines = lines.Skip(chapter8StartIndex).Take(chapter9StartIndex - chapter8StartIndex) .CleanListOfStrings().ToList(); chapter8Lines[2] = chapter8Lines[2].Insert(0, "D"); chapters.Add(CreateStarshipChapterRules(chapter8Lines, 8, Localization.SOTGChapter8Title, SectionNames.SOTGChapterEightSections, "adventuring")); var chapter9Lines = lines.Skip(chapter9StartIndex).Take(chapter10StartIndex - chapter9StartIndex).CleanListOfStrings().ToList(); chapter9Lines[2] = chapter9Lines[2].Insert(0, "A"); chapters.Add(CreateStarshipChapterRules(chapter9Lines, 9, Localization.SOTGChapter9Title, SectionNames.SOTGChapterNineSections, "combat")); var chapter10Lines = lines.Skip(chapter10StartIndex).Take(appendixAStartIndex - chapter10StartIndex).CleanListOfStrings().ToList(); chapter10Lines[2] = chapter10Lines[2].Insert(0, "C"); chapters.Add(CreateStarshipChapterRules(chapter10Lines, 10, Localization.SOTGChapter10Title, SectionNames.SOTGChapterTenSections, "generatingEncounters")); var appendixALines = lines.Skip(appendixAStartIndex).Take(changelogStartIndex - appendixAStartIndex).CleanListOfStrings().ToList(); appendixALines[2] = appendixALines[2].Insert(0, "C"); chapters.Add(CreateStarshipChapterRules(appendixALines, 11, Localization.SOTGAppendixATitle, SectionNames.SOTGAppendixAConditionsSections, "conditions")); var changelogLines = lines.Skip(changelogStartIndex).CleanListOfStrings().ToList(); chapters.Add(CreateStarshipChapterRules(changelogLines, 99, Localization.SOTGChangelogTitle)); foreach (var sotgChapterName in SectionNames.SOTGChapterNames) { var searchTerm = _globalSearchTermRepository.CreateSearchTerm(sotgChapterName.name, sotgChapterName.globalSearchTermType, ContentType.Core, sotgChapterName.pathOverride); _globalSearchTermRepository.SearchTerms.Add(searchTerm); } return(Task.FromResult(chapters)); }
public override Task <List <ChapterRules> > FindBlocks(List <string> lines) { var chapters = new List <ChapterRules>(); var chapter0StartIndex = lines.FindIndex(f => f == Localization.WHChapter0StartLine); var chapter1StartIndex = lines.FindIndex(f => f == Localization.WHChapter1StartLine); var chapter2StartIndex = lines.FindIndex(f => f == Localization.WHChapter2StartLine); var chapter3StartIndex = lines.FindIndex(f => f == Localization.WHChapter3StartLine); var chapter4StartIndex = lines.FindIndex(f => f == Localization.WHChapter4StartLine); var chapter5StartIndex = lines.FindIndex(f => f == Localization.WHChapter5StartLine); var chapter6StartIndex = lines.FindIndex(f => f == Localization.WHChapter6StartLine); var chapter7StartIndex = lines.FindIndex(f => f == Localization.WHChapter7StartLine); var chapter8StartIndex = lines.FindIndex(f => f == Localization.WHChapter8StartLine); var appendixAStartIndex = lines.FindIndex(f => f == Localization.WHAppendixAStartLine); var changelogStartIndex = lines.FindIndex(f => f == Localization.WHChangelogStartLine); var chapter0Lines = lines.Skip(chapter0StartIndex).Take(chapter1StartIndex - chapter0StartIndex) .CleanListOfStrings().ToList(); chapter0Lines[2] = chapter0Lines[2].Insert(0, "T"); chapters.Add(CreateWretchedHivesChapterRules(chapter0Lines, 1, Localization.WHChapter0Title, SectionNames.WHChapterZeroSections, "introduction")); var chapter1Lines = lines.Skip(chapter1StartIndex).Take(chapter2StartIndex - chapter1StartIndex) .CleanListOfStrings().ToList(); chapter1Lines[2] = chapter1Lines[2].Insert(0, "M"); chapters.Add(CreateWretchedHivesChapterRules(chapter1Lines, 1, Localization.WHChapter1Title, SectionNames.WHChapterOneSections, "stepByStep")); var chapter2Lines = lines.Skip(chapter2StartIndex).Take(chapter3StartIndex - chapter2StartIndex) .CleanListOfStrings().ToList(); chapter2Lines[2] = chapter2Lines[2].Insert(0, "A"); chapters.Add(CreateWretchedHivesChapterRules(chapter2Lines, 2, Localization.WHChapter2Title, SectionNames.WHChapterTwoSections, "downtime")); var chapter3Lines = lines.Skip(chapter3StartIndex).Take(chapter5StartIndex - chapter3StartIndex) .CleanListOfStrings().ToList(); chapter3Lines[2] = chapter3Lines[2].Insert(0, "A"); chapters.Add(CreateWretchedHivesChapterRules(chapter3Lines, 3, Localization.WHChapter3Title, SectionNames.WHChapterThreeSections, "factionsAndMembership")); var chapter4Lines = lines.Skip(chapter4StartIndex).Take(chapter5StartIndex - chapter4StartIndex) .CleanListOfStrings().ToList(); chapter4Lines[2] = chapter4Lines[2].Insert(0, "S"); chapters.Add(CreateWretchedHivesChapterRules(chapter4Lines, 4, Localization.WHChapter4Title, SectionNames.WHChapterFourSections, "abilityScores")); var chapter5Lines = lines.Skip(chapter5StartIndex).Take(chapter6StartIndex - chapter5StartIndex) .CleanListOfStrings().ToList(); chapter5Lines[2] = chapter5Lines[2].Insert(0, "T"); chapters.Add(CreateWretchedHivesChapterRules(chapter5Lines, 5, Localization.WHChapter5Title, SectionNames.WHChapterFiveSections, "equipment")); var chapter6Lines = lines.Skip(chapter6StartIndex).Take(chapter7StartIndex - chapter6StartIndex) .CleanListOfStrings().ToList(); chapter6Lines[2] = chapter6Lines[2].Insert(0, "T"); chapters.Add(CreateWretchedHivesChapterRules(chapter6Lines, 6, Localization.WHChapter6Title, SectionNames.WHChapterSixSections, "customizationOptions")); var chapter7Lines = lines.Skip(chapter7StartIndex).Take(chapter8StartIndex - chapter7StartIndex) .CleanListOfStrings().ToList(); chapter7Lines[2] = chapter7Lines[2].Insert(0, "T"); chapters.Add(CreateWretchedHivesChapterRules(chapter7Lines, 7, Localization.WHChapter7Title, SectionNames.WHChapterSevenSections, "enhancedItems")); var chapter8Lines = lines.Skip(chapter8StartIndex).Take(appendixAStartIndex - chapter8StartIndex) .CleanListOfStrings().ToList(); chapter8Lines[2] = chapter8Lines[2].Insert(0, "T"); chapters.Add(CreateWretchedHivesChapterRules(chapter8Lines, 8, Localization.WHChapter8Title, SectionNames.WHChapterEightSections, "toolProficiencies")); var changelogLines = lines.Skip(changelogStartIndex).CleanListOfStrings().ToList(); chapters.Add(CreateWretchedHivesChapterRules(changelogLines, 99, Localization.WHChangelogTitle)); foreach (var whChapterName in SectionNames.WHChapterNames) { var searchTerm = _globalSearchTermRepository.CreateSearchTerm(whChapterName.name, whChapterName.globalSearchTermType, ContentType.Core, whChapterName.pathOverride); _globalSearchTermRepository.SearchTerms.Add(searchTerm); } return(Task.FromResult(chapters)); }
public async Task Parse() { try { var ecFeats = await _expandedContentCustomizationOptionsFeatProcessor.Process(_ecCustomizationOptionsFileName, _localization); foreach (var feat in ecFeats) { feat.ContentSourceEnum = ContentSource.EC; var featSearchTerm = _globalSearchTermRepository.CreateSearchTerm(feat.Name, GlobalSearchTermType.Feat, ContentType.ExpandedContent, $"/characters/feats/?search={feat.Name}"); _globalSearchTermRepository.SearchTerms.Add(featSearchTerm); } await _tableStorage.AddBatchAsync <Feat>($"feats{_localization.Language}", ecFeats, new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace }); } catch (StorageException) { Console.WriteLine("Failed to upload EC feats."); } try { var expandedContentCustomizationOptionsLightsaberFormsProcessor = new ExpandedContentCustomizationOptionsLightsaberFormsProcessor(); var ecLightsaberForms = await expandedContentCustomizationOptionsLightsaberFormsProcessor.Process( _ecCustomizationOptionsFileName, _localization, ContentType.ExpandedContent); foreach (var lightsaberForm in ecLightsaberForms) { lightsaberForm.ContentSourceEnum = ContentSource.EC; var lightsaberFormSearchTerm = _globalSearchTermRepository.CreateSearchTerm(lightsaberForm.Name, GlobalSearchTermType.LightsaberForm, ContentType.ExpandedContent, $"/characters/lightsaberForms/?search={lightsaberForm.Name}"); _globalSearchTermRepository.SearchTerms.Add(lightsaberFormSearchTerm); } await _tableStorage.AddBatchAsync <LightsaberForm>($"lightsaberForms{_localization.Language}", ecLightsaberForms, new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace }); } catch (StorageException) { Console.WriteLine("Failed to upload EC fighting styles."); } //try //{ // var ecFightingStyles = // await _expandedContentCustomizationOptionsFightingStyleProcessor.Process( // _ecCustomizationOptionsFileName, _localization, ContentType.ExpandedContent); // foreach (var fightingStyle in ecFightingStyles) // { // fightingStyle.ContentSourceEnum = ContentSource.EC; // var fightingStyleSearchTerm = _globalSearchTermRepository.CreateSearchTerm(fightingStyle.Name, GlobalSearchTermType.FightingStyle, ContentType.ExpandedContent, // $"/characters/fightingStyles/?search={fightingStyle.Name}"); // _globalSearchTermRepository.SearchTerms.Add(fightingStyleSearchTerm); // } // await _tableStorage.AddBatchAsync<FightingStyle>($"fightingStyles{_localization.Language}", ecFightingStyles, // new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace }); //} //catch (StorageException) //{ // Console.WriteLine("Failed to upload EC fighting styles."); //} //try //{ // var ecFightingMasteries = // await _expandedContentCustomizationOptionsFightingMasteryProcessor.Process( // _ecCustomizationOptionsFileName, _localization, ContentType.ExpandedContent); // foreach (var fightingMastery in ecFightingMasteries) // { // fightingMastery.ContentSourceEnum = ContentSource.EC; // var fightingMasterySearchTerm = _globalSearchTermRepository.CreateSearchTerm(fightingMastery.Name, GlobalSearchTermType.FightingMastery, ContentType.ExpandedContent, // $"/characters/fightingMasteries/?search={fightingMastery.Name}"); // _globalSearchTermRepository.SearchTerms.Add(fightingMasterySearchTerm); // } // await _tableStorage.AddBatchAsync<FightingStyle>($"fightingMasteries{_localization.Language}", ecFightingMasteries, // new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace }); //} //catch (StorageException) //{ // Console.WriteLine("Failed to upload EC fighting masteries."); //} }
public override Task <List <ChapterRules> > FindBlocks(List <string> lines) { var chapters = new List <ChapterRules>(); var prefaceStartIndex = lines.FindIndex(f => f == Localization.PHBPrefaceStartLine); var whatsDifferentStartIndex = lines.FindIndex(f => f == Localization.PHBWhatsDifferentStartLine); var chapter0StartIndex = lines.FindIndex(f => f == Localization.PHBIntroductionStartLine); var chapter1StartIndex = lines.FindIndex(f => f == Localization.PHBChapter1StartLine); var chapter2StartIndex = lines.FindIndex(f => f == Localization.PHBChapter2StartLine); var chapter3StartIndex = lines.FindIndex(f => f == Localization.PHBChapter3StartLine); var chapter4StartIndex = lines.FindIndex(f => f == Localization.PHBChapter4StartLine); var chapter5StartIndex = lines.FindIndex(f => f == Localization.PHBChapter5StartLine); var chapter6StartIndex = lines.FindIndex(f => f == Localization.PHBChapter6StartLine); var chapter7StartIndex = lines.FindIndex(f => f == Localization.PHBChapter7StartLine); var chapter8StartIndex = lines.FindIndex(f => f == Localization.PHBChapter8StartLine); var chapter9StartIndex = lines.FindIndex(f => f == Localization.PHBChapter9StartLine); var chapter10StartIndex = lines.FindIndex(f => f == Localization.PHBChapter10StartLine); var chapter11StartIndex = lines.FindIndex(f => f == Localization.PHBChapter11StartLine); var appendixAStartIndex = lines.FindIndex(f => f == Localization.PHBAppendixAStartLine); var appendixBStartIndex = lines.FindIndex(f => f == Localization.PHBAppendixBStartLine); var changelogStartIndex = lines.FindIndex(f => f == Localization.PHBChangelogStartLine); var prefaceLines = lines.Skip(prefaceStartIndex).Take(whatsDifferentStartIndex - prefaceStartIndex) .CleanListOfStrings().ToList(); chapters.Add(CreateChapterRulesAndSearchTerms(prefaceLines, -2, Localization.PHBPrefaceTitle)); var whatsDifferentLines = lines.Skip(whatsDifferentStartIndex).Take(chapter0StartIndex - whatsDifferentStartIndex) .CleanListOfStrings().ToList(); chapters.Add(CreateChapterRulesAndSearchTerms(whatsDifferentLines, -1, Localization.PHBWhatsDifferentTitle)); var introLines = lines.Skip(chapter0StartIndex).Take(chapter1StartIndex - chapter0StartIndex) .CleanListOfStrings().ToList(); if (Localization.Language == Language.en) { introLines[2] = introLines[2].Insert(0, "T"); } chapters.Add(CreateChapterRulesAndSearchTerms(introLines, 0, Localization.PHBIntroductionTitle)); var chapter1Lines = lines.Skip(chapter1StartIndex).Take(chapter2StartIndex - chapter1StartIndex) .CleanListOfStrings().ToList(); if (Localization.Language == Language.en) { chapter1Lines[2] = chapter1Lines[2].Insert(0, "Y"); } chapters.Add(CreateChapterRulesAndSearchTerms(chapter1Lines, 1, Localization.PHBChapter1Title, "stepByStep")); var chapter2EndIndex = lines.FindIndex(chapter2StartIndex, f => f.StartsWith("___")); var chapter2Lines = lines.Skip(chapter2StartIndex).Take(chapter2EndIndex - chapter2StartIndex) .CleanListOfStrings().ToList(); if (Localization.Language == Language.en) { chapter2Lines[2] = chapter2Lines[2].Insert(0, "A "); } chapters.Add(CreateChapterRulesAndSearchTerms(chapter2Lines, 2, Localization.PHBChapter2Title, "species")); var chapter3EndIndex = lines.FindIndex(chapter3StartIndex, f => f.StartsWith(Localization.PHBClassesStartLine)); var chapter3Lines = lines.Skip(chapter3StartIndex).Take(chapter3EndIndex - chapter3StartIndex) .CleanListOfStrings().ToList(); if (Localization.Language == Language.en) { chapter3Lines[2] = chapter3Lines[2].Insert(0, "A"); } chapters.Add(CreateChapterRulesAndSearchTerms(chapter3Lines, 3, Localization.PHBChapter3Title, "classes")); var chapter4EndIndex = lines.FindIndex(chapter4StartIndex, f => f.StartsWith(Localization.PHBBackgroundsStartLine)); var chapter4Lines = lines.Skip(chapter4StartIndex).Take(chapter4EndIndex - chapter4StartIndex) .CleanListOfStrings().ToList(); if (Localization.Language == Language.en) { chapter4Lines[2] = chapter4Lines[2].Insert(0, "C"); } chapters.Add(CreateChapterRulesAndSearchTerms(chapter4Lines, 4, Localization.PHBChapter4Title, "backgrounds")); var chapter5Lines = lines.Skip(chapter5StartIndex).Take(chapter6StartIndex - chapter5StartIndex) .CleanListOfStrings().ToList(); if (Localization.Language == Language.en) { chapter5Lines[2] = chapter5Lines[2].Insert(0, "T"); } chapters.Add(CreateChapterRulesAndSearchTerms(chapter5Lines, 5, Localization.PHBChapter5Title, "equipment")); var chapter6Lines = lines.Skip(chapter6StartIndex).Take(chapter7StartIndex - chapter6StartIndex) .CleanListOfStrings().ToList(); if (Localization.Language == Language.en) { chapter6Lines[2] = chapter6Lines[2].Insert(0, "T"); } chapters.Add(CreateChapterRulesAndSearchTerms(chapter6Lines, 6, Localization.PHBChapter6Title, "customization")); var chapter7Lines = lines.Skip(chapter7StartIndex).Take(chapter8StartIndex - chapter7StartIndex) .CleanListOfStrings().ToList(); if (Localization.Language == Language.en) { chapter7Lines[2] = chapter7Lines[2].Insert(0, "S"); } chapters.Add(CreateChapterRulesAndSearchTerms(chapter7Lines, 7, Localization.PHBChapter7Title, "abilityScores")); var chapter8Lines = lines.Skip(chapter8StartIndex).Take(chapter9StartIndex - chapter8StartIndex) .CleanListOfStrings().ToList(); if (Localization.Language == Language.en) { chapter8Lines[2] = chapter8Lines[2].Insert(0, "D"); } chapters.Add(CreateChapterRulesAndSearchTerms(chapter8Lines, 8, Localization.PHBChapter8Title, "adventuring")); var chapter9Lines = lines.Skip(chapter9StartIndex).Take(chapter10StartIndex - chapter9StartIndex) .CleanListOfStrings().ToList(); if (Localization.Language == Language.en) { chapter9Lines[2] = chapter9Lines[2].Insert(0, "T"); } chapters.Add(CreateChapterRulesAndSearchTerms(chapter9Lines, 9, Localization.PHBChapter9Title, "combat")); var chapter10Lines = lines.Skip(chapter10StartIndex).Take(chapter11StartIndex - chapter10StartIndex) .CleanListOfStrings().ToList(); if (Localization.Language == Language.en) { chapter10Lines[2] = chapter10Lines[2].Insert(0, "M"); } chapters.Add(CreateChapterRulesAndSearchTerms(chapter10Lines, 10, Localization.PHBChapter10Title, "casting")); var appendixALines = lines.Skip(appendixAStartIndex).Take(appendixBStartIndex - appendixAStartIndex) .CleanListOfStrings().ToList(); if (Localization.Language == Language.en) { appendixALines[2] = appendixALines[2].Insert(0, "C"); } chapters.Add(CreateChapterRulesAndSearchTerms(appendixALines, 13, Localization.PHBAppendixATitle, "conditions")); var appendixBLines = lines.Skip(appendixBStartIndex).Take(changelogStartIndex - appendixBStartIndex).CleanListOfStrings().ToList(); if (Localization.Language == Language.en) { appendixBLines[2] = appendixBLines[2].Insert(0, "H"); } chapters.Add(CreateChapterRulesAndSearchTerms(appendixBLines, 14, Localization.PHBAppendixBTitle, "variantRules")); var changelogLines = lines.Skip(changelogStartIndex).CleanListOfStrings().ToList(); chapters.Add(CreateChapterRulesAndSearchTerms(changelogLines, 99, Localization.PHBChangelogTitle)); var phbSections = new List <(string name, GlobalSearchTermType globalSearchTermType, string pathOverride)> { (Localization.PlayersHandbook, GlobalSearchTermType.Book, "/rules/phb"), (Localization.PlayersHandbookChangelog, GlobalSearchTermType.Changelog, "/rules/phb/changelog") }; foreach (var phbSection in phbSections) { var searchTerm = _globalSearchTermRepository.CreateSearchTerm(phbSection.name, phbSection.globalSearchTermType, ContentType.Core, phbSection.pathOverride); _globalSearchTermRepository.SearchTerms.Add(searchTerm); } return(Task.FromResult(chapters)); }
public override Task <List <ChapterRules> > FindBlocks(List <string> lines) { var chapters = new List <ChapterRules>(); var chapter0StartIndex = lines.FindIndex(f => f == Localization.WHChapter0StartLine); var chapter1StartIndex = lines.FindIndex(f => f == Localization.WHChapter1StartLine); var chapter2StartIndex = lines.FindIndex(f => f == Localization.WHChapter2StartLine); var chapter3StartIndex = lines.FindIndex(f => f == Localization.WHChapter3StartLine); var chapter4StartIndex = lines.FindIndex(f => f == Localization.WHChapter4StartLine); var chapter5StartIndex = lines.FindIndex(f => f == Localization.WHChapter5StartLine); var chapter6StartIndex = lines.FindIndex(f => f == Localization.WHChapter6StartLine); var chapter7StartIndex = lines.FindIndex(f => f == Localization.WHChapter7StartLine); var chapter8StartIndex = lines.FindIndex(f => f == Localization.WHChapter8StartLine); var appendixAStartIndex = lines.FindIndex(f => f == Localization.WHAppendixAStartLine); var changelogStartIndex = lines.FindIndex(f => f == Localization.WHChangelogStartLine); var chapter0Lines = lines.Skip(chapter0StartIndex).Take(chapter1StartIndex - chapter0StartIndex) .CleanListOfStrings().ToList(); if (Localization.Language == Language.en) { chapter0Lines[2] = chapter0Lines[2].Insert(0, "T"); } chapters.Add(CreateWretchedHivesChapterRules(chapter0Lines, 1, Localization.WHChapter0Title, "introduction")); var chapter1Lines = lines.Skip(chapter1StartIndex).Take(chapter2StartIndex - chapter1StartIndex) .CleanListOfStrings().ToList(); if (Localization.Language == Language.en) { chapter1Lines[2] = chapter1Lines[2].Insert(0, "M"); } chapters.Add(CreateWretchedHivesChapterRules(chapter1Lines, 1, Localization.WHChapter1Title, "stepByStep")); var chapter2Lines = lines.Skip(chapter2StartIndex).Take(chapter3StartIndex - chapter2StartIndex) .CleanListOfStrings().ToList(); if (Localization.Language == Language.en) { chapter2Lines[2] = chapter2Lines[2].Insert(0, "A"); } chapters.Add(CreateWretchedHivesChapterRules(chapter2Lines, 2, Localization.WHChapter2Title, "downtime")); var chapter3Lines = lines.Skip(chapter3StartIndex).Take(chapter5StartIndex - chapter3StartIndex) .CleanListOfStrings().ToList(); if (Localization.Language == Language.en) { chapter3Lines[2] = chapter3Lines[2].Insert(0, "A"); } chapters.Add(CreateWretchedHivesChapterRules(chapter3Lines, 3, Localization.WHChapter3Title, "factionsAndMembership")); var chapter4Lines = lines.Skip(chapter4StartIndex).Take(chapter5StartIndex - chapter4StartIndex) .CleanListOfStrings().ToList(); if (Localization.Language == Language.en) { chapter4Lines[2] = chapter4Lines[2].Insert(0, "S"); } chapters.Add(CreateWretchedHivesChapterRules(chapter4Lines, 4, Localization.WHChapter4Title, "abilityScores")); var chapter5Lines = lines.Skip(chapter5StartIndex).Take(chapter6StartIndex - chapter5StartIndex) .CleanListOfStrings().ToList(); if (Localization.Language == Language.en) { chapter5Lines[2] = chapter5Lines[2].Insert(0, "T"); } chapters.Add(CreateWretchedHivesChapterRules(chapter5Lines, 5, Localization.WHChapter5Title, "equipment")); var chapter6Lines = lines.Skip(chapter6StartIndex).Take(chapter7StartIndex - chapter6StartIndex) .CleanListOfStrings().ToList(); if (Localization.Language == Language.en) { chapter6Lines[2] = chapter6Lines[2].Insert(0, "T"); } chapters.Add(CreateWretchedHivesChapterRules(chapter6Lines, 6, Localization.WHChapter6Title, "customizationOptions")); var chapter7Lines = lines.Skip(chapter7StartIndex).Take(chapter8StartIndex - chapter7StartIndex) .CleanListOfStrings().ToList(); if (Localization.Language == Language.en) { chapter7Lines[2] = chapter7Lines[2].Insert(0, "T"); } chapters.Add(CreateWretchedHivesChapterRules(chapter7Lines, 7, Localization.WHChapter7Title, "enhancedItems")); var chapter8Lines = lines.Skip(chapter8StartIndex).Take(appendixAStartIndex - chapter8StartIndex) .CleanListOfStrings().ToList(); if (Localization.Language == Language.en) { chapter8Lines[2] = chapter8Lines[2].Insert(0, "T"); } chapters.Add(CreateWretchedHivesChapterRules(chapter8Lines, 8, Localization.WHChapter8Title, "toolProficiencies")); var changelogLines = lines.Skip(changelogStartIndex).CleanListOfStrings().ToList(); chapters.Add(CreateWretchedHivesChapterRules(changelogLines, 99, Localization.WHChangelogTitle)); var whSections = new List <(string name, GlobalSearchTermType globalSearchTermType, string pathOverride)> { (Localization.WretchedHives, GlobalSearchTermType.Book, "/rules/wh"), (Localization.WretchedHivesChangelog, GlobalSearchTermType.Changelog, "/rules/wh/changelog") }; foreach (var whSection in whSections) { var searchTerm = _globalSearchTermRepository.CreateSearchTerm(whSection.name, whSection.globalSearchTermType, ContentType.Core, whSection.pathOverride); _globalSearchTermRepository.SearchTerms.Add(searchTerm); } return(Task.FromResult(chapters)); }
public async Task Parse() { try { var equipment = await _playerHandbookEquipmentProcessor.Process(_phbFilesNames .Where(p => p.Equals("PHB.phb_05.txt")).ToList(), _localization); foreach (var equipment1 in equipment) { equipment1.ContentSourceEnum = ContentSource.PHB; switch (equipment1.EquipmentCategoryEnum) { case EquipmentCategory.Unknown: case EquipmentCategory.Ammunition: case EquipmentCategory.Explosive: case EquipmentCategory.Storage: case EquipmentCategory.AdventurePack: case EquipmentCategory.Communications: case EquipmentCategory.DataRecordingAndStorage: case EquipmentCategory.LifeSupport: case EquipmentCategory.Medical: case EquipmentCategory.WeaponOrArmorAccessory: case EquipmentCategory.Tool: case EquipmentCategory.Mount: case EquipmentCategory.Vehicle: case EquipmentCategory.TradeGood: case EquipmentCategory.Utility: case EquipmentCategory.GamingSet: case EquipmentCategory.MusicalInstrument: case EquipmentCategory.Droid: case EquipmentCategory.Clothing: case EquipmentCategory.Kit: var equipmentSearchTerm = _globalSearchTermRepository.CreateSearchTerm(equipment1.Name, GlobalSearchTermType.AdventuringGear, ContentType.Core, $"/loot/adventuringGear/?search={equipment1.Name}"); _globalSearchTermRepository.SearchTerms.Add(equipmentSearchTerm); break; case EquipmentCategory.Weapon: var weaponSearchTerm = _globalSearchTermRepository.CreateSearchTerm(equipment1.Name, GlobalSearchTermType.Weapon, ContentType.Core, $"/loot/weapons/?search={equipment1.Name}"); _globalSearchTermRepository.SearchTerms.Add(weaponSearchTerm); break; case EquipmentCategory.Armor: var searchTermType = GlobalSearchTermType.Armor; if (equipment1.ArmorClassificationEnum == ArmorClassification.Shield) { searchTermType = GlobalSearchTermType.Shield; } var armorSearchTerm = _globalSearchTermRepository.CreateSearchTerm(equipment1.Name, searchTermType, ContentType.Core, $"/loot/armor/?search={equipment1.Name}"); _globalSearchTermRepository.SearchTerms.Add(armorSearchTerm); break; default: throw new ArgumentOutOfRangeException(); } } await _tableStorage.AddBatchAsync <Equipment>($"equipment{_localization.Language}", equipment, new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace }); } catch (StorageException) { Console.WriteLine("Failed to upload PHB equipment."); } try { var backgrounds = await _playerHandbookBackgroundsProcessor.Process(_phbFilesNames.Where(p => p.Equals("PHB.phb_04.txt")) .ToList(), _localization); foreach (var background in backgrounds) { background.ContentSourceEnum = ContentSource.PHB; var backgroundSearchTerm = _globalSearchTermRepository.CreateSearchTerm(background.Name, GlobalSearchTermType.Background, ContentType.Core, $"/characters/backgrounds/{background.Name}"); _globalSearchTermRepository.SearchTerms.Add(backgroundSearchTerm); } await _tableStorage.AddBatchAsync <Background>($"backgrounds{_localization.Language}", backgrounds, new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace }); } catch (StorageException) { Console.WriteLine("Failed to upload PHB backgrounds."); } try { var speciesImageUrlsLus = await _tableStorage.GetAllAsync <SpeciesImageUrlLU>("speciesImageUrlsLU"); var playerHandbookSpeciesProcessor = new PlayerHandbookSpeciesProcessor(speciesImageUrlsLus.ToList()); var species = await playerHandbookSpeciesProcessor.Process(_phbFilesNames.Where(p => p.Equals("PHB.phb_02.txt")) .ToList(), _localization); foreach (var specie in species) { specie.ContentSourceEnum = ContentSource.PHB; var specieSearchTerm = _globalSearchTermRepository.CreateSearchTerm(specie.Name, GlobalSearchTermType.Species, ContentType.Core, $"/characters/species/{specie.Name}"); _globalSearchTermRepository.SearchTerms.Add(specieSearchTerm); } await _tableStorage.AddBatchAsync <Species>($"species{_localization.Language}", species, new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace }); } catch (StorageException) { Console.WriteLine("Failed to upload PHB species."); } try { var featureLevels = (await _tableStorage.GetAllAsync <FeatureDataLU>("featureLevelLU")).ToList(); var classImageLus = await _tableStorage.GetAllAsync <ClassImageLU>("classImageLU"); var casterRatioLus = await _tableStorage.GetAllAsync <CasterRatioLU>("casterRatioLU"); var multiclassProficiencyLus = await _tableStorage.GetAllAsync <MulticlassProficiencyLU>("multiclassProficiencyLU"); var playerHandbookClassProcessor = new PlayerHandbookClassProcessor(classImageLus.ToList(), casterRatioLus.ToList(), multiclassProficiencyLus.ToList()); var classes = await playerHandbookClassProcessor.Process(_phbFilesNames.Where(p => p.Equals("PHB.phb_03.txt")) .ToList(), _localization); foreach (var swClass in classes) { swClass.ContentSourceEnum = ContentSource.PHB; var classSearchTerm = _globalSearchTermRepository.CreateSearchTerm(swClass.Name, GlobalSearchTermType.Class, ContentType.Core, $"/characters/classes/{swClass.Name}"); _globalSearchTermRepository.SearchTerms.Add(classSearchTerm); } await _tableStorage.AddBatchAsync <Class>($"classes{_localization.Language}", classes, new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace }); try { var archetypes = classes.SelectMany(s => s.Archetypes).ToList(); foreach (var archetype in archetypes) { archetype.ContentSourceEnum = ContentSource.PHB; var archetypeSearchTerm = _globalSearchTermRepository.CreateSearchTerm(archetype.Name, GlobalSearchTermType.Archetype, ContentType.Core, $"/characters/archetypes/{archetype.Name}"); _globalSearchTermRepository.SearchTerms.Add(archetypeSearchTerm); } try { var archetypeFeatures = archetypes.SelectMany(f => f.Features).ToList(); foreach (var archetypeFeature in archetypeFeatures) { var featureLevel = featureLevels.SingleOrDefault(f => f.FeatureRowKey == archetypeFeature.RowKey); if (featureLevel != null) { archetypeFeature.Level = featureLevel.Level; } } await _tableStorage.AddBatchAsync <Feature>($"features{_localization.Language}", archetypeFeatures, new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace }); } catch (StorageException se) { Console.WriteLine($"Failed to upload PHB archetype features: {se}"); } var dupes = archetypes .GroupBy(i => i.RowKey) .Where(g => g.Count() > 1) .Select(g => g.Key); await _tableStorage.AddBatchAsync <Archetype>($"archetypes{_localization.Language}", archetypes, new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace }); } catch (StorageException se) { Console.WriteLine($"Failed to upload PHB archetypes: {se}"); } try { var classFeatures = classes.SelectMany(f => f.Features).ToList(); foreach (var classFeature in classFeatures) { var featureLevel = featureLevels.SingleOrDefault(f => f.FeatureRowKey == classFeature.RowKey); if (featureLevel != null) { classFeature.Level = featureLevel.Level; } } await _tableStorage.AddBatchAsync <Feature>($"features{_localization.Language}", classFeatures, new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace }); } catch (StorageException se) { Console.WriteLine($"Failed to upload PHB class features: {se}"); } } catch (StorageException) { Console.WriteLine("Failed to upload PHB classes."); } try { var playerHandbookPowersProcessor = new PlayerHandbookPowersProcessor(_localization); var powers = await playerHandbookPowersProcessor.Process(_phbFilesNames.Where(p => p.Equals("PHB.phb_11.txt") || p.Equals("PHB.phb_12.txt")) .ToList(), _localization); foreach (var power in powers) { power.ContentSourceEnum = ContentSource.PHB; switch (power.PowerTypeEnum) { case PowerType.None: break; case PowerType.Force: var forcePowerSearchTerm = _globalSearchTermRepository.CreateSearchTerm(power.Name, GlobalSearchTermType.ForcePower, ContentType.Core, $"/characters/forcePowers/?search={power.Name}"); _globalSearchTermRepository.SearchTerms.Add(forcePowerSearchTerm); break; case PowerType.Tech: var techPowerSearchTerm = _globalSearchTermRepository.CreateSearchTerm(power.Name, GlobalSearchTermType.TechPower, ContentType.Core, $"/characters/techPowers/?search={power.Name}"); _globalSearchTermRepository.SearchTerms.Add(techPowerSearchTerm); break; default: throw new ArgumentOutOfRangeException(); } } await _tableStorage.AddBatchAsync <Power>($"powers{_localization.Language}", powers, new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace }); } catch (StorageException) { Console.WriteLine("Failed to upload PHB powers."); } try { var feats = await _playerHandbookFeatProcessor.Process(_phbFilesNames.Where(p => p.Equals("PHB.phb_06.txt")) .ToList(), _localization); foreach (var feat in feats) { feat.ContentSourceEnum = ContentSource.PHB; var featSearchTerm = _globalSearchTermRepository.CreateSearchTerm(feat.Name, GlobalSearchTermType.Feat, ContentType.Core, $"/characters/feats/?search={feat.Name}"); _globalSearchTermRepository.SearchTerms.Add(featSearchTerm); } await _tableStorage.AddBatchAsync <Feat>($"feats{_localization.Language}", feats, new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace }); } catch (StorageException) { Console.WriteLine("Failed to upload PHB feats."); } try { var rules = await _playerHandbookChapterRulesProcessor.Process(_phbFilesNames, _localization); await _cloudBlobContainer.CreateIfNotExistsAsync(BlobContainerPublicAccessType.Off, null, null); foreach (var chapterRules in rules) { var json = JsonConvert.SerializeObject(chapterRules); var blob = _cloudBlobContainer.GetBlockBlobReference($"{chapterRules.ChapterName}.json"); await blob.UploadTextAsync(json); } } catch (StorageException) { Console.WriteLine("Failed to upload PHB rules."); } try { var weaponProperties = await _weaponPropertyProcessor.Process(_phbFilesNames.Where(p => p.Equals("PHB.phb_05.txt")).ToList(), _localization); var specialProperty = weaponProperties.SingleOrDefault(w => w.Name == "Special"); if (specialProperty != null) { specialProperty.Content = "#### Special\r\nA weapon with the special property has unusual rules governing its use, explained in the weapon's description."; } await _tableStorage.AddBatchAsync <WeaponProperty>($"weaponProperties{_localization.Language}", weaponProperties, new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace }); } catch (StorageException) { Console.WriteLine("Failed to upload PHB weapon properties."); } try { var armorProperties = await _armorPropertyProcessor.Process(_phbFilesNames.Where(p => p.Equals("PHB.phb_05.txt")).ToList(), _localization); await _tableStorage.AddBatchAsync <ArmorProperty>($"armorProperties{_localization.Language}", armorProperties, new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace }); } catch (StorageException) { Console.WriteLine("Failed to upload PHB weapon properties."); } foreach (var referenceName in SectionNames.ReferenceNames) { var referenceSearchTerm = _globalSearchTermRepository.CreateSearchTerm(referenceName.name, referenceName.globalSearchTermType, ContentType.Core, referenceName.pathOverride); _globalSearchTermRepository.SearchTerms.Add(referenceSearchTerm); } foreach (var variantRuleName in SectionNames.VariantRuleNames) { var variantRuleSearchTerm = _globalSearchTermRepository.CreateSearchTerm(variantRuleName.name, variantRuleName.globalSearchTermType, ContentType.Core, variantRuleName.pathOverride); _globalSearchTermRepository.SearchTerms.Add(variantRuleSearchTerm); } }
public async Task Parse() { try { var rules = await _wretchedHivesChapterRulesProcessor.Process(_whFilesName, _localization); await _cloudBlobContainer.CreateIfNotExistsAsync(BlobContainerPublicAccessType.Off, null, null); foreach (var chapterRules in rules) { var json = JsonConvert.SerializeObject(chapterRules); var blob = _cloudBlobContainer.GetBlockBlobReference($"{chapterRules.ChapterName}.json"); await blob.UploadTextAsync(json); } } catch (StorageException) { Console.WriteLine("Failed to upload WH rules."); } try { var enhancedItemProcessor = new EnhancedItemProcessor(_localization); var enhancedItems = await enhancedItemProcessor.Process(_whFilesName.Where(f => f.Equals("WH.wh_aa.txt")).ToList(), _localization); foreach (var enhancedItem in enhancedItems) { enhancedItem.ContentSourceEnum = ContentSource.WH; var enhancedItemSearchTerm = _globalSearchTermRepository.CreateSearchTerm(enhancedItem.Name, GlobalSearchTermType.EnhancedItem, ContentType.Core, $"/loot/enhancedItems?search={enhancedItem.Name}"); _globalSearchTermRepository.SearchTerms.Add(enhancedItemSearchTerm); } await _tableStorage.AddBatchAsync <EnhancedItem>($"enhancedItems{_localization.Language}", enhancedItems, new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace }); } catch (StorageException) { Console.WriteLine("Failed to upload WH enhanced items."); } try { var equipment = await _wretchedHivesEquipmentProcessor.Process(new List <string> { "WH.wh_05.txt" }, _localization); foreach (var equipment1 in equipment) { equipment1.ContentSourceEnum = ContentSource.WH; switch (equipment1.EquipmentCategoryEnum) { case EquipmentCategory.Unknown: case EquipmentCategory.Ammunition: case EquipmentCategory.Explosive: case EquipmentCategory.Storage: case EquipmentCategory.AdventurePack: case EquipmentCategory.Communications: case EquipmentCategory.DataRecordingAndStorage: case EquipmentCategory.LifeSupport: case EquipmentCategory.Medical: case EquipmentCategory.WeaponOrArmorAccessory: case EquipmentCategory.Tool: case EquipmentCategory.Mount: case EquipmentCategory.Vehicle: case EquipmentCategory.TradeGood: case EquipmentCategory.Utility: case EquipmentCategory.GamingSet: case EquipmentCategory.MusicalInstrument: case EquipmentCategory.Droid: case EquipmentCategory.Clothing: case EquipmentCategory.Kit: var equipmentSearchTerm = _globalSearchTermRepository.CreateSearchTerm(equipment1.Name, GlobalSearchTermType.AdventuringGear, ContentType.Core, $"/loot/adventuringGear/?search={equipment1.Name}"); _globalSearchTermRepository.SearchTerms.Add(equipmentSearchTerm); break; case EquipmentCategory.Weapon: var weaponSearchTerm = _globalSearchTermRepository.CreateSearchTerm(equipment1.Name, GlobalSearchTermType.Weapon, ContentType.Core, $"/loot/weapons/?search={equipment1.Name}"); _globalSearchTermRepository.SearchTerms.Add(weaponSearchTerm); break; case EquipmentCategory.Armor: var searchTermType = GlobalSearchTermType.Armor; if (equipment1.ArmorClassificationEnum == ArmorClassification.Shield) { searchTermType = GlobalSearchTermType.Shield; } var armorSearchTerm = _globalSearchTermRepository.CreateSearchTerm(equipment1.Name, searchTermType, ContentType.Core, $"/loot/armor/?search={equipment1.Name}"); _globalSearchTermRepository.SearchTerms.Add(armorSearchTerm); break; default: throw new ArgumentOutOfRangeException(); } } var dupes = equipment .GroupBy(i => i.RowKey) .Where(g => g.Count() > 1) .Select(g => g.Key); await _tableStorage.AddBatchAsync <Equipment>($"equipment{_localization.Language}", equipment, new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace }); } catch (StorageException e) { Console.WriteLine("Failed to upload WH equipment."); } try { var weaponProperties = await _weaponPropertyProcessor.Process(new List <string> { "WH.wh_05.txt" }, _localization); await _tableStorage.AddBatchAsync <WeaponProperty>($"weaponProperties{_localization.Language}", weaponProperties, new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace }); } catch (StorageException) { Console.WriteLine("Failed to upload WH weapon properties."); } try { var armorProperties = await _armorPropertyProcessor.Process(new List <string> { "WH.wh_05.txt" }, _localization); await _tableStorage.AddBatchAsync <ArmorProperty>($"armorProperties{_localization.Language}", armorProperties, new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace }); } catch (StorageException) { Console.WriteLine("Failed to upload WH weapon properties."); } try { var playerHandbookFeatProcessor = new PlayerHandbookFeatProcessor(_localization); var feats = await playerHandbookFeatProcessor.Process(new List <string> { "WH.wh_06.txt" }, _localization); foreach (var feat in feats) { feat.ContentSourceEnum = ContentSource.WH; var featSearchTerm = _globalSearchTermRepository.CreateSearchTerm(feat.Name, GlobalSearchTermType.Feat, ContentType.Core, $"/characters/feats/?search={feat.Name}"); _globalSearchTermRepository.SearchTerms.Add(featSearchTerm); } await _tableStorage.AddBatchAsync <Feat>($"feats{_localization.Language}", feats, new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace }); } catch (StorageException) { Console.WriteLine("Failed to upload PHB feats."); } }
public async Task Parse(List <ReferenceTable> referenceTables = null) { try { var rules = await _starshipChapterRulesProcessor.Process(_sotgFilesName, _localization); if (referenceTables != null) { foreach (var chapterRule in rules) { foreach (var referenceTable in referenceTables) { chapterRule.ContentMarkdown = Regex.Replace(chapterRule.ContentMarkdown, $@"(?<!#\s*){referenceTable.Name}", $"[{referenceTable.Name}](#{Uri.EscapeUriString(referenceTable.Name)})", RegexOptions.IgnoreCase); } } } await _blobContainerClient.CreateIfNotExistsAsync(); foreach (var chapterRules in rules) { var json = JsonConvert.SerializeObject(chapterRules); var blobClient = _blobContainerClient.GetBlobClient($"{chapterRules.ChapterName}.json"); var content = Encoding.UTF8.GetBytes(json); using (var ms = new MemoryStream(content)) { await blobClient.UploadAsync(ms, true); } } } catch (StorageException) { Console.WriteLine("Failed to upload SOTG rules."); } try { var deployments = await _starshipDeploymentProcessor.Process(_sotgFilesName.Where(f => f.Equals("SOTG.sotg_02.txt")).ToList(), _localization); foreach (var deployment in deployments) { deployment.ContentSourceEnum = ContentSource.SotG; var deploymentSearchTerm = _globalSearchTermRepository.CreateSearchTerm(deployment.Name, GlobalSearchTermType.Deployment, ContentType.Core, $"/starships/deployments/{deployment.Name}"); _globalSearchTermRepository.SearchTerms.Add(deploymentSearchTerm); } if (referenceTables != null) { foreach (var deployment in deployments) { foreach (var referenceTable in referenceTables) { if (deployment.Features != null) { foreach (var deploymentFeature in deployment.Features) { if (deploymentFeature.Content != null) { deploymentFeature.Content = Regex.Replace(deploymentFeature.Content, $@"(?<!#\s*){referenceTable.Name}", $"[{referenceTable.Name}](#{Uri.EscapeUriString(referenceTable.Name)})", RegexOptions.IgnoreCase); } } } } } } await _tableStorage.AddBatchAsync <StarshipDeployment>($"starshipDeployments{_localization.Language}", deployments, new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace }); } catch (StorageException) { Console.WriteLine("Failed to upload SOTG deployments."); } try { var equipment = await _starshipEquipmentProcessor.Process(_sotgFilesName.Where(f => f.Equals("SOTG.sotg_05.txt")).ToList(), _localization); if (referenceTables != null) { foreach (var starshipEquipment in equipment) { if (starshipEquipment.Description != null) { foreach (var referenceTable in referenceTables) { starshipEquipment.Description = Regex.Replace(starshipEquipment.Description, $@"(?<!#\s*){referenceTable.Name}", $"[{referenceTable.Name}](#{Uri.EscapeUriString(referenceTable.Name)})", RegexOptions.IgnoreCase); } } } } var dupes = equipment .GroupBy(i => i.RowKey) .Where(g => g.Count() > 1) .Select(g => g.Key); foreach (var starshipEquipment in equipment) { starshipEquipment.ContentSourceEnum = ContentSource.SotG; switch (starshipEquipment.TypeEnum) { case StarshipEquipmentType.Armor: case StarshipEquipmentType.Shield: case StarshipEquipmentType.Ammunition: case StarshipEquipmentType.Hyperdrive: case StarshipEquipmentType.Navcomputer: case StarshipEquipmentType.PowerCoupling: case StarshipEquipmentType.Reactor: var equipmentSearchTerm = _globalSearchTermRepository.CreateSearchTerm(starshipEquipment.Name, GlobalSearchTermType.StarshipEquipment, ContentType.Core, $"/starships/equipment?search={starshipEquipment.Name}"); _globalSearchTermRepository.SearchTerms.Add(equipmentSearchTerm); break; case StarshipEquipmentType.Weapon: var weaponSearchTerm = _globalSearchTermRepository.CreateSearchTerm(starshipEquipment.Name, GlobalSearchTermType.StarshipWeapon, ContentType.Core, $"/starships/weapons?search={starshipEquipment.Name}"); _globalSearchTermRepository.SearchTerms.Add(weaponSearchTerm); break; default: throw new ArgumentOutOfRangeException(); } } await _tableStorage.AddBatchAsync <StarshipEquipment>($"starshipEquipment{_localization.Language}", equipment, new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace }); } catch (StorageException e) { Console.WriteLine("Failed to upload SOTG equipment."); } try { var modifications = await _starshipModificationProcessor.Process(_sotgFilesName.Where(f => f.Equals("SOTG.sotg_04.txt")).ToList(), _localization); if (referenceTables != null) { foreach (var modification in modifications) { if (modification.Content != null) { foreach (var referenceTable in referenceTables) { modification.Content = Regex.Replace(modification.Content, $@"(?<!#\s*){referenceTable.Name}", $"[{referenceTable.Name}](#{Uri.EscapeUriString(referenceTable.Name)})", RegexOptions.IgnoreCase); } } } } foreach (var modification in modifications) { modification.ContentSourceEnum = ContentSource.SotG; var modificationSearchTerm = _globalSearchTermRepository.CreateSearchTerm(modification.Name, GlobalSearchTermType.StarshipModification, ContentType.Core, $"/starships/modifications?search={modification.Name}"); _globalSearchTermRepository.SearchTerms.Add(modificationSearchTerm); } await _tableStorage.AddBatchAsync <StarshipModification>($"starshipModifications{_localization.Language}", modifications, new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace }); } catch (StorageException e) { Console.WriteLine("Failed to upload SOTG modifications."); } try { var sizes = await _starshipSizeProcessor.Process(_sotgFilesName.Where(f => f.Equals("SOTG.sotg_03.txt")).ToList(), _localization); foreach (var size in sizes) { size.ContentSourceEnum = ContentSource.SotG; var sizeSearchTerm = _globalSearchTermRepository.CreateSearchTerm(size.Name, GlobalSearchTermType.StarshipSize, ContentType.Core, $"/rules/sotg/starshipSizes/{size.Name}"); _globalSearchTermRepository.SearchTerms.Add(sizeSearchTerm); } await _tableStorage.AddBatchAsync <StarshipBaseSize>($"starshipBaseSizes{_localization.Language}", sizes, new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace }); } catch (StorageException) { Console.WriteLine("Failed to upload SOTG sizes."); } try { var ventures = await _starshipVentureProcessor.Process(_sotgFilesName.Where(f => f.Equals("SOTG.sotg_06.txt")).ToList(), _localization); foreach (var venture in ventures) { venture.ContentSourceEnum = ContentSource.SotG; var sizeSearchTerm = _globalSearchTermRepository.CreateSearchTerm(venture.Name, GlobalSearchTermType.Venture, ContentType.Core, $"/starships/ventures?search={venture.Name}"); _globalSearchTermRepository.SearchTerms.Add(sizeSearchTerm); } await _tableStorage.AddBatchAsync <StarshipVenture>($"starshipVentures{_localization.Language}", ventures, new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace }); } catch (StorageException) { Console.WriteLine("Failed to upload SOTG ventures."); } }
public override Task <List <ChapterRules> > FindBlocks(List <string> lines) { var chapters = new List <ChapterRules>(); var chapter0StartIndex = lines.FindIndex(f => f == Localization.SOTGChapter0StartLine); var chapter1StartIndex = lines.FindIndex(f => f == Localization.SOTGChapter1StartLine); var chapter2StartIndex = lines.FindIndex(f => f == Localization.SOTGChapter2StartLine); var chapter3StartIndex = lines.FindIndex(f => f == Localization.SOTGChapter3StartLine); var chapter4StartIndex = lines.FindIndex(f => f == Localization.SOTGChapter4StartLine); var chapter5StartIndex = lines.FindIndex(f => f == Localization.SOTGChapter5StartLine); var chapter6StartIndex = lines.FindIndex(f => f == Localization.SOTGChapter6StartLine); var chapter7StartIndex = lines.FindIndex(f => f == Localization.SOTGChapter7StartLine); var chapter8StartIndex = lines.FindIndex(f => f == Localization.SOTGChapter8StartLine); var chapter9StartIndex = lines.FindIndex(f => f == Localization.SOTGChapter9StartLine); var chapter10StartIndex = lines.FindIndex(f => f == Localization.SOTGChapter10StartLine); var appendixAStartIndex = lines.FindIndex(f => f == Localization.SOTGAppendixAStartLine); var changelogStartIndex = lines.FindIndex(f => f == Localization.SOTGChangelogStartLine); var introLines = lines.Skip(chapter0StartIndex).Take(chapter1StartIndex - chapter0StartIndex) .CleanListOfStrings().ToList(); if (Localization.Language == Language.en) { introLines[2] = introLines[2].Insert(0, "T"); } chapters.Add(CreateStarshipChapterRulesAndSearchTerms(introLines, 0, Localization.SOTGChapter0Title)); var chapter1Lines = lines.Skip(chapter1StartIndex).Take(chapter2StartIndex - chapter1StartIndex) .CleanListOfStrings().ToList(); if (Localization.Language == Language.en) { chapter1Lines[2] = chapter1Lines[2].Insert(0, "Y"); } chapters.Add(CreateStarshipChapterRulesAndSearchTerms(chapter1Lines, 1, Localization.SOTGChapter1Title, "stepByStep")); var chapter2EndIndex = lines.FindIndex(chapter2StartIndex, f => f == Localization.SOTGDeploymentsStartLine); var chapter2Lines = lines.Skip(chapter2StartIndex).Take(chapter2EndIndex - chapter2StartIndex) .CleanListOfStrings().ToList(); if (Localization.Language == Language.en) { chapter2Lines[2] = chapter2Lines[2].Insert(0, "A"); } chapters.Add(CreateStarshipChapterRulesAndSearchTerms(chapter2Lines, 2, Localization.SOTGChapter2Title, "deployments")); var chapter3EndIndex = lines.FindIndex(chapter3StartIndex, f => f == Localization.SOTGShipSizeStartLine); var chapter3Lines = lines.Skip(chapter3StartIndex).Take(chapter3EndIndex - chapter3StartIndex) .CleanListOfStrings().ToList(); var variantStart = lines.FindIndex(chapter3StartIndex, f => f == Localization.SOTGVariantSpaceStations); var variantLines = lines.Skip(variantStart).Take(chapter4StartIndex - variantStart).CleanListOfStrings().ToList(); chapter3Lines.AddRange(variantLines); if (Localization.Language == Language.en) { chapter3Lines[2] = chapter3Lines[2].Insert(0, "C"); } chapters.Add(CreateStarshipChapterRulesAndSearchTerms(chapter3Lines, 3, Localization.SOTGChapter3Title, "starshipSizes")); var chapter4EndIndex = lines.FindIndex(chapter4StartIndex, f => f == Localization.SOTGModificationsStart); var chapter4Lines = lines.Skip(chapter4StartIndex).Take(chapter4EndIndex - chapter4StartIndex) .CleanListOfStrings().ToList(); if (Localization.Language == Language.en) { chapter4Lines[2] = chapter4Lines[2].Insert(0, "A"); } chapters.Add(CreateStarshipChapterRulesAndSearchTerms(chapter4Lines, 4, Localization.SOTGChapter4Title, "modifications")); var chapter5Lines = lines.Skip(chapter5StartIndex).Take(chapter6StartIndex - chapter5StartIndex) .CleanListOfStrings().ToList(); if (Localization.Language == Language.en) { chapter5Lines[2] = chapter5Lines[2].Insert(0, "T"); } chapters.Add(CreateStarshipChapterRulesAndSearchTerms(chapter5Lines, 5, Localization.SOTGChapter5Title, "equipment")); var chapter6Lines = lines.Skip(chapter6StartIndex).Take(chapter7StartIndex - chapter6StartIndex) .CleanListOfStrings().ToList(); if (Localization.Language == Language.en) { chapter6Lines[2] = chapter6Lines[2].Insert(0, "T"); } chapters.Add(CreateStarshipChapterRulesAndSearchTerms(chapter6Lines, 6, Localization.SOTGChapter6Title, "customization")); var chapter7Lines = lines.Skip(chapter7StartIndex).Take(chapter8StartIndex - chapter7StartIndex) .CleanListOfStrings().ToList(); if (Localization.Language == Language.en) { chapter7Lines[2] = chapter7Lines[2].Insert(0, "S"); } chapters.Add(CreateStarshipChapterRulesAndSearchTerms(chapter7Lines, 7, Localization.SOTGChapter7Title, "abilityScores")); var chapter8Lines = lines.Skip(chapter8StartIndex).Take(chapter9StartIndex - chapter8StartIndex) .CleanListOfStrings().ToList(); if (Localization.Language == Language.en) { chapter8Lines[2] = chapter8Lines[2].Insert(0, "D"); } chapters.Add(CreateStarshipChapterRulesAndSearchTerms(chapter8Lines, 8, Localization.SOTGChapter8Title, "adventuring")); var chapter9Lines = lines.Skip(chapter9StartIndex).Take(chapter10StartIndex - chapter9StartIndex).CleanListOfStrings().ToList(); if (Localization.Language == Language.en) { chapter9Lines[2] = chapter9Lines[2].Insert(0, "A"); } chapters.Add(CreateStarshipChapterRulesAndSearchTerms(chapter9Lines, 9, Localization.SOTGChapter9Title, "combat")); var chapter10Lines = lines.Skip(chapter10StartIndex).Take(appendixAStartIndex - chapter10StartIndex).CleanListOfStrings().ToList(); if (Localization.Language == Language.en) { chapter10Lines[2] = chapter10Lines[2].Insert(0, "C"); } chapters.Add(CreateStarshipChapterRulesAndSearchTerms(chapter10Lines, 10, Localization.SOTGChapter10Title, "generatingEncounters")); var appendixALines = lines.Skip(appendixAStartIndex).Take(changelogStartIndex - appendixAStartIndex).CleanListOfStrings().ToList(); if (Localization.Language == Language.en) { appendixALines[2] = appendixALines[2].Insert(0, "C"); } chapters.Add(CreateStarshipChapterRulesAndSearchTerms(appendixALines, 11, Localization.SOTGAppendixATitle, "conditions")); var changelogLines = lines.Skip(changelogStartIndex).CleanListOfStrings().ToList(); chapters.Add(CreateStarshipChapterRulesAndSearchTerms(changelogLines, 99, Localization.SOTGChangelogTitle)); var sotgSections = new List <(string name, GlobalSearchTermType globalSearchTermType, string pathOverride)> { (Localization.StarshipsOfTheGalaxy, GlobalSearchTermType.Book, "/rules/sotg"), (Localization.StarshipsOfTheGalaxyChangelog, GlobalSearchTermType.Changelog, "/rules/sotg/changelog") }; foreach (var sotgSection in sotgSections) { var searchTerm = _globalSearchTermRepository.CreateSearchTerm(sotgSection.name, sotgSection.globalSearchTermType, ContentType.Core, sotgSection.pathOverride); _globalSearchTermRepository.SearchTerms.Add(searchTerm); } return(Task.FromResult(chapters)); }