Esempio n. 1
0
        private async Task GenerateItemSetByChampion(ChampionViewModel champion, LoLMode mode, CancellationToken cancelToken)
        {
            // Create a unique instance of BuildSource to be thread safe
            // I'm afraid of having corruption with a shared "Document" property if I use a single shared instance
            IBuildSource buildSource = (T)Activator.CreateInstance(typeof(T));
            await buildSource.InitAsync(champion.Name, mode);

            if (!buildSource.IsValidContent())
            {
                throw new InvalidOperationException("Invalid content");
            }

            LoLItemSetViewModel itemSetViewModel = ItemSetUtil.CreateItemSetPerChampion(buildSource, champion, mode, Configuration.ShowSkillsOrder);

            if (itemSetViewModel == null)
            {
                throw new InvalidOperationException("LoLItemSetViewModel is null");
            }

            // Create Item set JSON file into LoL directory
            string itemSetDir = LoLPathUtil.CreateItemSetDirectory(Configuration.LoLDirectory, champion.Name);

            string itemSetFileName     = ItemSetUtil.GetFormattedItemSetFileName(buildSource, mode, Configuration.ApplicationPrefixName);
            string itemSetAbsolutePath = Path.Combine(itemSetDir, itemSetFileName);

            await FileUtil.CreateJsonFileAsync(itemSetAbsolutePath, itemSetViewModel, cancelToken);
        }
Esempio n. 2
0
 /// <summary>
 /// Either returns champion position if LoLMode = classic (SR),
 /// Else, the mode itself (ex. "ARAM")
 /// </summary>
 /// <param name="source"></param>
 /// <param name="mode"></param>
 /// <returns></returns>
 public static string FormatChampionInfoByMode(IBuildSource source, LoLMode mode)
 {
     return(mode switch
     {
         LoLMode.Classic => EnumUtil.ToString <ChampionPosition>(source.GetChampionPosition()),
         LoLMode.ARAM => "ARAM",
         _ => throw new NotSupportedException()
     });
Esempio n. 3
0
        /// <summary>
        /// Returns formatted Item set file name with JSON extension
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        public static string GetFormattedItemSetFileName(IBuildSource source, LoLMode mode, string appPrefix)
        {
            string sourceName    = source.GetSourceName();
            string sourceVersion = source.GetVersion();
            // Either show champion position as info, or LoL mode if not classic
            string championInfo = LoLModeUtil.FormatChampionInfoByMode(source, mode);

            return($"{appPrefix}_{sourceName}v{sourceVersion}_{championInfo}.json");
        }
Esempio n. 4
0
 public ContentManager(ILog log, IBuildOptions buildOptions, IContentSaver contentSaver, IBuildSource buildSource)
 {
     Log               = log;
     _buildOptions     = buildOptions;
     _processorContext = new ContentProcessorContext();
     _processorContext.ContentManager = this;
     _contentSaver           = contentSaver;
     _materialFactoryManager = new MaterialFactoryManager();
     _buildSource            = buildSource;
 }
Esempio n. 5
0
        private static LoLItemSetBlockViewModel CreateBootBlockItems(IBuildSource source)
        {
            List <int> itemIds = source.GetBootItemIds();

            return(new LoLItemSetBlockViewModel
            {
                Type = "Boots",
                Items = ConvertItemIdsToBlockItem(itemIds)
            });
        }
Esempio n. 6
0
        private static LoLItemSetBlockViewModel CreateExtraBlockItems(IBuildSource source)
        {
            List <int> itemIds = source.GetExtraItemIds();

            return(new LoLItemSetBlockViewModel
            {
                Type = "Extra/Situational Items",
                Items = ConvertItemIdsToBlockItem(itemIds)
            });
        }
Esempio n. 7
0
        private static string GetPageTitle(IBuildSource source, LoLMode mode, ChampionViewModel champion)
        {
            string sourceName    = source.GetSourceName();
            string championName  = champion.Name;
            string championInfo  = LoLModeUtil.FormatChampionInfoByMode(source, mode);
            string sourceVersion = source.GetVersion();

            // Example for classic mode: OPGG - Annie Middle - v11.07
            // Example for ARAM mode: OPGG - Annie ARAM - v11.07
            return($"{sourceName} - {championName} {championInfo} - v{sourceVersion}");
        }
Esempio n. 8
0
 public static LoLItemSetViewModel CreateItemSetPerChampion(IBuildSource source, ChampionViewModel champion, LoLMode mode, bool showSkillsOrder)
 {
     return(new LoLItemSetViewModel()
     {
         Title = GetPageTitle(source, mode, champion),
         Map = LoLModeUtil.GetMapNameByMode(mode),
         AssociatedChampions = new List <int> {
             champion.Id
         },
         Blocks = CreateBlockItems(source, showSkillsOrder)
     });
 }
Esempio n. 9
0
        private static LoLItemSetBlockViewModel CreateStarterBlockItems(IBuildSource source, bool showSkillsOrder)
        {
            string title = "Starter Items";

            if (showSkillsOrder)
            {
                // Append skill orders to title
                title += $" - {source.GetFormattedSkills()}";
            }

            List <int> itemIds = source.GetStarterItemIds();

            return(new LoLItemSetBlockViewModel
            {
                Type = title,
                Items = ConvertItemIdsToBlockItem(itemIds)
            });
        }
Esempio n. 10
0
        private static List <LoLItemSetBlockViewModel> CreateBlockItems(IBuildSource source, bool showSkillsOrder)
        {
            var blockItems = new List <LoLItemSetBlockViewModel>
            {
                CreateStarterBlockItems(source, showSkillsOrder),
                CreateCoreBlockItems(source),
            };

            // Handle special cases: Boots and Extra items
            if (source.HasBootsCategory())
            {
                blockItems.Add(CreateBootBlockItems(source));
            }
            if (source.HasExtraCategory())
            {
                blockItems.Add(CreateExtraBlockItems(source));
            }

            return(blockItems);
        }