private void CreateChampionIndex(Progression progression, StringVersion gameVersion, string staticResourceRootDirectory)
        {
            progression.StartNextStep(LoLStaticResourceCacheResources.CreateChampionIndexProgressStepDescription);
            Champions.Clear();
            ChampionNameToIdIndex.Clear();

            var championCollectionFile     = Path.Combine(staticResourceRootDirectory, gameVersion.ToString(), "data", "en_US", "champion.json");
            var championCollectionFileText = File.ReadAllText(championCollectionFile);

            var championCollection   = JObject.Parse(championCollectionFileText);
            var numberOfChampions    = championCollection["data"] !.Children().Count();
            var currentChampionIndex = 0;

            foreach (var championJson in championCollection["data"] !.Children())
            {
                progression.CurrentStepProgress = currentChampionIndex++ / (double)numberOfChampions;

                var champion = ToChampion(championJson.First !, gameVersion, staticResourceRootDirectory);
                if (!Champions.TryAdd(champion.Id, champion))
                {
                    throw new Exception($"The champion id {champion.Id} has been defined multiple times!");
                }

                if (!ChampionNameToIdIndex.TryAdd(champion.Name, champion.Id))
                {
                    throw new Exception($"The champion name {champion.Name} has been defined multiple times!");
                }
            }
        }
コード例 #2
0
 internal IncrementContext(StringVersion currentVersion, DateTime buildStartDate, DateTime projectStartDate, string projectFilename)
 {
     this.CurrentVersion   = currentVersion;
     this.BuildStartDate   = buildStartDate;
     this.ProjectStartDate = projectStartDate;
     this.ProjectFilename  = projectFilename;
     this.NewVersion       = new StringVersion(currentVersion.Major, currentVersion.Minor, currentVersion.Build, currentVersion.Revision);
     this.Continue         = true;
 }
コード例 #3
0
 internal IncrementContext(StringVersion currentVersion, DateTime buildStartDate, DateTime projectStartDate, string projectFilename)
 {
     this.CurrentVersion = currentVersion;
     this.BuildStartDate = buildStartDate;
     this.ProjectStartDate = projectStartDate;
     this.ProjectFilename = projectFilename;
     this.NewVersion = new StringVersion(currentVersion.Major, currentVersion.Minor, currentVersion.Build, currentVersion.Revision);
     this.Continue = true;
 }
        private LoLStaticChampion ToChampion(JToken token, StringVersion gameVersion, string staticResourceRootDirectory)
        {
            var name          = token.Value <string>("name");
            var id            = token.Value <int>("key");
            var imageFileName = token.Value <JToken>("image").Value <string>("full");

            var smallTileImage = Path.Combine(staticResourceRootDirectory, gameVersion.ToString(), "img", "champion", imageFileName);
            var largeTileImage = Path.Combine(staticResourceRootDirectory, "img", "champion", "tiles", $"{Path.GetFileNameWithoutExtension(imageFileName)}_0.jpg");

            return(new LoLStaticChampion(id, name, smallTileImage, largeTileImage));
        }
        private LoLStaticItem ToItem(JProperty property, StringVersion gameVersion, string staticResourceRootDirectory)
        {
            var id    = int.Parse(property.Name);
            var token = property.First !;

            var name           = token.Value <string>("name");
            var imageFileName  = token.Value <JToken>("image") !.Value <string>("full");
            var smallTileImage = Path.Combine(staticResourceRootDirectory, gameVersion.ToString(), "img", "item", imageFileName);

            var gold        = token.Value <JToken>("gold");
            var totalCosts  = gold.Value <int>("total");
            var recipeCosts = gold.Value <int>("base");
            var sellWorth   = gold.Value <int>("sell");

            return(new LoLStaticItem(id, name, smallTileImage, totalCosts, recipeCosts, sellWorth));
        }
        private void CreateItemIndex(Progression progression, StringVersion gameVersion, string staticResourceRootDirectory)
        {
            progression.StartNextStep(LoLStaticResourceCacheResources.CreateItemIndexProgressStepDescription);
            Items.Clear();

            var itemCollectionFile     = Path.Combine(staticResourceRootDirectory, gameVersion.ToString(), "data", "en_US", "item.json");
            var itemCollectionFileText = File.ReadAllText(itemCollectionFile);

            var itemCollection   = JObject.Parse(itemCollectionFileText);
            var numberOfItems    = itemCollection["data"] !.Children().Count();
            var currentItemIndex = 0;

            foreach (var itemJson in itemCollection["data"] !.Children().Cast <JProperty>())
            {
                progression.CurrentStepProgress = currentItemIndex++ / (double)numberOfItems;

                var item = ToItem(itemJson, gameVersion, staticResourceRootDirectory);
                if (!Items.TryAdd(item.Id, item))
                {
                    throw new Exception($"The item id {item.Id} has been defined multiple times!");
                }
            }
        }
コード例 #7
0
        public void SetNewVersionComponentValue(VersionComponent component, string value)
        {
            switch (component)
            {
            case VersionComponent.Build:
                NewVersion = new StringVersion(NewVersion.Major, NewVersion.Minor, value, NewVersion.Revision);
                break;

            case VersionComponent.Major:
                NewVersion = new StringVersion(value, NewVersion.Minor, NewVersion.Build, NewVersion.Revision);
                break;

            case VersionComponent.Minor:
                NewVersion = new StringVersion(NewVersion.Major, value, NewVersion.Build, NewVersion.Revision);
                break;

            case VersionComponent.Revision:
                NewVersion = new StringVersion(NewVersion.Major, NewVersion.Minor, NewVersion.Build, value);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(component), component, null);
            }
        }
コード例 #8
0
        static ApplicationConstants()
        {
            var assemblyVersion = FileVersionInfo.GetVersionInfo("GoldDiff.exe").FileVersion;

            Version = StringVersion.TryParse(assemblyVersion, out var version) ? version ! : StringVersion.Zero;
        }