/// <summary>
        /// Updates the localized gamestrings to the selected <see cref="Localization"/>.
        /// </summary>
        /// <param name="rewardPortrait">The data to be updated.</param>
        /// <param name="gameStringDocument">Instance of a <see cref="GameStringDocument"/>.</param>
        /// <exception cref="ArgumentNullException"><paramref name="gameStringDocument"/> is null.</exception>
        public static void UpdateGameStrings(this RewardPortrait rewardPortrait, GameStringDocument gameStringDocument)
        {
            if (gameStringDocument is null)
            {
                throw new ArgumentNullException(nameof(gameStringDocument));
            }

            gameStringDocument.UpdateGameStrings(rewardPortrait);
        }
Esempio n. 2
0
        /// <summary>
        /// Updates the localized gamestrings to the selected <see cref="Localization"/>.
        /// </summary>
        /// <param name="typeDescription">The data to be updated.</param>
        /// <param name="gameStringDocument">Instance of a <see cref="GameStringDocument"/>.</param>
        /// <exception cref="ArgumentNullException"><paramref name="gameStringDocument"/> is null.</exception>
        public static void UpdateGameStrings(this TypeDescription typeDescription, GameStringDocument gameStringDocument)
        {
            if (gameStringDocument is null)
            {
                throw new ArgumentNullException(nameof(gameStringDocument));
            }

            gameStringDocument.UpdateGameStrings(typeDescription);
        }
Esempio n. 3
0
        /// <summary>
        /// Updates the localized gamestrings to the selected <see cref="Localization"/>.
        /// </summary>
        /// <param name="unit">The data to be updated.</param>
        /// <param name="gameStringDocument">Instance of a <see cref="GameStringDocument"/>.</param>
        /// <exception cref="ArgumentNullException"><paramref name="gameStringDocument"/> is null.</exception>
        public static void UpdateGameStrings(this Unit unit, GameStringDocument gameStringDocument)
        {
            if (gameStringDocument is null)
            {
                throw new ArgumentNullException(nameof(gameStringDocument));
            }

            gameStringDocument.UpdateGameStrings(unit);
        }
Esempio n. 4
0
        /// <summary>
        /// Updates the localized gamestrings to the selected <see cref="Localization"/>.
        /// </summary>
        /// <param name="hero">The data to be updated.</param>
        /// <param name="gameStringDocument">Instance of a <see cref="GameStringDocument"/>.</param>
        /// <exception cref="ArgumentNullException"><paramref name="gameStringDocument"/> is null.</exception>
        public static void UpdateGameStrings(this Hero hero, GameStringDocument gameStringDocument)
        {
            if (gameStringDocument is null)
            {
                throw new ArgumentNullException(nameof(gameStringDocument));
            }

            gameStringDocument.UpdateGameStrings(hero);
        }
Esempio n. 5
0
        /// <summary>
        /// Updates the localized gamestrings to the selected <see cref="Localization"/>.
        /// </summary>
        /// <param name="banner">The data to be updated.</param>
        /// <param name="gameStringDocument">Instance of a <see cref="GameStringDocument"/>.</param>
        /// <exception cref="ArgumentNullException"><paramref name="gameStringDocument"/> is null.</exception>
        public static void UpdateGameStrings(this Banner banner, GameStringDocument gameStringDocument)
        {
            if (gameStringDocument is null)
            {
                throw new ArgumentNullException(nameof(gameStringDocument));
            }

            gameStringDocument.UpdateGameStrings(banner);
        }
        /// <summary>
        /// Updates the localized gamestrings to the selected <see cref="Localization"/>.
        /// </summary>
        /// <param name="lootChest">The data to be updated.</param>
        /// <param name="gameStringDocument">Instance of a <see cref="GameStringDocument"/>.</param>
        /// <exception cref="ArgumentNullException"><paramref name="gameStringDocument"/> is null.</exception>
        public static void UpdateGameStrings(this LootChest lootChest, GameStringDocument gameStringDocument)
        {
            if (gameStringDocument is null)
            {
                throw new ArgumentNullException(nameof(gameStringDocument));
            }

            gameStringDocument.UpdateGameStrings(lootChest);
        }
Esempio n. 7
0
        /// <summary>
        /// Updates the localized gamestrings to the selected <see cref="Localization"/>.
        /// </summary>
        /// <param name="ability">The data to be updated.</param>
        /// <param name="gameStringDocument">Instance of a <see cref="GameStringDocument"/>.</param>
        /// <exception cref="ArgumentNullException"><paramref name="gameStringDocument"/> is null.</exception>
        public static void UpdateGameStrings(this Ability ability, GameStringDocument gameStringDocument)
        {
            if (gameStringDocument is null)
            {
                throw new ArgumentNullException(nameof(gameStringDocument));
            }

            gameStringDocument.UpdateGameStrings(ability);
        }
Esempio n. 8
0
        /// <summary>
        /// Updates the localized gamestrings to the selected <see cref="Localization"/>.
        /// </summary>
        /// <param name="emoticon">The data to be updated.</param>
        /// <param name="gameStringDocument">Instance of a <see cref="GameStringDocument"/>.</param>
        /// <exception cref="ArgumentNullException"><paramref name="gameStringDocument"/> is null.</exception>
        public static void UpdateGameStrings(this Emoticon emoticon, GameStringDocument gameStringDocument)
        {
            if (gameStringDocument is null)
            {
                throw new ArgumentNullException(nameof(gameStringDocument));
            }

            gameStringDocument.UpdateGameStrings(emoticon);
        }
        /// <summary>
        /// Updates the localized gamestrings to the selected <see cref="Localization"/>.
        /// </summary>
        /// <param name="matchAward">The data to be updated.</param>
        /// <param name="gameStringDocument">Instance of a <see cref="GameStringDocument"/>.</param>
        /// <exception cref="ArgumentNullException"><paramref name="gameStringDocument"/> is null.</exception>
        public static void UpdateGameStrings(this MatchAward matchAward, GameStringDocument gameStringDocument)
        {
            if (gameStringDocument is null)
            {
                throw new ArgumentNullException(nameof(gameStringDocument));
            }

            gameStringDocument.UpdateGameStrings(matchAward);
        }
Esempio n. 10
0
        /// <summary>
        /// Updates the localized gamestrings to the selected <see cref="Localization"/>.
        /// </summary>
        /// <param name="voiceLine">The data to be updated.</param>
        /// <param name="gameStringDocument">Instance of a <see cref="GameStringDocument"/>.</param>
        /// <exception cref="ArgumentNullException"><paramref name="gameStringDocument"/> is null.</exception>
        public static void UpdateGameStrings(this VoiceLine voiceLine, GameStringDocument gameStringDocument)
        {
            if (gameStringDocument is null)
            {
                throw new ArgumentNullException(nameof(gameStringDocument));
            }

            gameStringDocument.UpdateGameStrings(voiceLine);
        }
        /// <summary>
        /// Updates the localized gamestrings to the selected <see cref="Localization"/>.
        /// </summary>
        /// <param name="portraitPack">The data to be updated.</param>
        /// <param name="gameStringDocument">Instance of a <see cref="GameStringDocument"/>.</param>
        /// <exception cref="ArgumentNullException"><paramref name="gameStringDocument"/> is null.</exception>
        public static void UpdateGameStrings(this PortraitPack portraitPack, GameStringDocument gameStringDocument)
        {
            if (gameStringDocument is null)
            {
                throw new ArgumentNullException(nameof(gameStringDocument));
            }

            gameStringDocument.UpdateGameStrings(portraitPack);
        }
Esempio n. 12
0
        private Banner GetBannerData(string bannerId, JsonElement bannerElement)
        {
            Banner banner = new Banner()
            {
                Id = bannerId,
            };

            if (bannerElement.TryGetProperty("name", out JsonElement name))
            {
                banner.Name = name.GetString();
            }

            if (bannerElement.TryGetProperty("hyperlinkId", out JsonElement hyperlinkId))
            {
                banner.HyperlinkId = hyperlinkId.GetString();
            }

            if (bannerElement.TryGetProperty("attributeId", out JsonElement attributeId))
            {
                banner.AttributeId = attributeId.GetString();
            }

            if (bannerElement.TryGetProperty("rarity", out JsonElement rarityElement) && Enum.TryParse(rarityElement.GetString(), out Rarity rarity))
            {
                banner.Rarity = rarity;
            }

            if (bannerElement.TryGetProperty("category", out JsonElement category))
            {
                banner.CollectionCategory = category.GetString();
            }

            if (bannerElement.TryGetProperty("releaseDate", out JsonElement releaseDateElement) && DateTime.TryParse(releaseDateElement.GetString(), out DateTime releaseDate))
            {
                banner.ReleaseDate = releaseDate;
            }

            if (bannerElement.TryGetProperty("sortName", out JsonElement sortName))
            {
                banner.SortName = sortName.GetString();
            }

            if (bannerElement.TryGetProperty("description", out JsonElement description))
            {
                banner.Description = SetTooltipDescription(description.GetString(), Localization);
            }

            GameStringDocument?.UpdateGameStrings(banner);

            return(banner);
        }
        private VoiceLine GetVoiceLineData(string voiceLineId, JsonElement voiceLineElement)
        {
            VoiceLine voiceLine = new VoiceLine()
            {
                Id = voiceLineId,
            };

            if (voiceLineElement.TryGetProperty("name", out JsonElement name))
            {
                voiceLine.Name = name.GetString();
            }

            if (voiceLineElement.TryGetProperty("hyperlinkId", out JsonElement hyperlinkId))
            {
                voiceLine.HyperlinkId = hyperlinkId.GetString();
            }

            if (voiceLineElement.TryGetProperty("attributeId", out JsonElement attributeId))
            {
                voiceLine.AttributeId = attributeId.GetString();
            }

            if (voiceLineElement.TryGetProperty("rarity", out JsonElement rarityElement) && Enum.TryParse(rarityElement.GetString(), out Rarity rarity))
            {
                voiceLine.Rarity = rarity;
            }

            if (voiceLineElement.TryGetProperty("releaseDate", out JsonElement releaseDateElement) && DateTime.TryParse(releaseDateElement.GetString(), out DateTime releaseDate))
            {
                voiceLine.ReleaseDate = releaseDate;
            }

            if (voiceLineElement.TryGetProperty("sortName", out JsonElement sortName))
            {
                voiceLine.SortName = sortName.GetString();
            }

            if (voiceLineElement.TryGetProperty("description", out JsonElement description))
            {
                voiceLine.Description = SetTooltipDescription(description.GetString(), Localization);
            }

            if (voiceLineElement.TryGetProperty("image", out JsonElement image))
            {
                voiceLine.ImageFileName = image.GetString();
            }

            GameStringDocument?.UpdateGameStrings(voiceLine);

            return(voiceLine);
        }
Esempio n. 14
0
    private TypeDescription GetTypeDescriptionData(string typeDescriptionId, JsonElement typeDescriptionElement)
    {
        TypeDescription typeDescription = new()
        {
            Id = typeDescriptionId,
        };

        if (typeDescriptionElement.TryGetProperty("name", out JsonElement name))
        {
            typeDescription.Name = name.GetString();
        }

        if (typeDescriptionElement.TryGetProperty("hyperlinkId", out JsonElement hyperlinkId))
        {
            typeDescription.HyperlinkId = hyperlinkId.GetString();
        }

        if (typeDescriptionElement.TryGetProperty("iconSlot", out JsonElement iconSlot))
        {
            typeDescription.IconSlot = iconSlot.GetInt32();
        }

        if (typeDescriptionElement.TryGetProperty("textureSheet", out JsonElement textureSheetElement))
        {
            if (textureSheetElement.TryGetProperty("image", out JsonElement image))
            {
                typeDescription.TextureSheet.Image = image.GetString();
            }

            if (textureSheetElement.TryGetProperty("columns", out JsonElement columns))
            {
                typeDescription.TextureSheet.Columns = columns.GetInt32();
            }

            if (textureSheetElement.TryGetProperty("rows", out JsonElement rows))
            {
                typeDescription.TextureSheet.Rows = rows.GetInt32();
            }
        }

        if (typeDescriptionElement.TryGetProperty("image", out JsonElement imageFileName))
        {
            typeDescription.ImageFileName = imageFileName.GetString();
        }

        GameStringDocument?.UpdateGameStrings(typeDescription);

        return(typeDescription);
    }
Esempio n. 15
0
    private PortraitPack GetPortraitPackData(string portraitPackId, JsonElement portraitPackElement)
    {
        PortraitPack portraitPack = new()
        {
            Id = portraitPackId,
        };

        if (portraitPackElement.TryGetProperty("name", out JsonElement name))
        {
            portraitPack.Name = name.GetString();
        }

        if (portraitPackElement.TryGetProperty("hyperlinkId", out JsonElement hyperlinkId))
        {
            portraitPack.HyperlinkId = hyperlinkId.GetString();
        }

        if (portraitPackElement.TryGetProperty("rarity", out JsonElement rarityElement) && Enum.TryParse(rarityElement.GetString(), out Rarity rarity))
        {
            portraitPack.Rarity = rarity;
        }

        if (portraitPackElement.TryGetProperty("event", out JsonElement eventElement))
        {
            portraitPack.EventName = eventElement.GetString();
        }

        if (portraitPackElement.TryGetProperty("sortName", out JsonElement sortName))
        {
            portraitPack.SortName = sortName.GetString();
        }

        if (portraitPackElement.TryGetProperty("rewardPortraitIds", out JsonElement rewardPortraitIdsElements))
        {
            foreach (JsonElement rewardPortraitIdElement in rewardPortraitIdsElements.EnumerateArray())
            {
                string?rewardPortraitValue = rewardPortraitIdElement.GetString();
                if (rewardPortraitValue is not null)
                {
                    portraitPack.RewardPortraitIds.Add(rewardPortraitValue);
                }
            }
        }

        GameStringDocument?.UpdateGameStrings(portraitPack);

        return(portraitPack);
    }
Esempio n. 16
0
    public void UpdateGameStringsTest()
    {
        Unit unit = new()
        {
            CUnitId = "AbathurEvolvedMonstrosity",
            Id      = "AbathurEvolvedMonstrosity",
        };

        using GameStringDocument gameStringDocument = GameStringDocument.Parse(LoadEnusLocalizedStringData());
        gameStringDocument.UpdateGameStrings(unit);

        Assert.ThrowsException <ArgumentNullException>(() => gameStringDocument.UpdateGameStrings(unit: null !));

        Assert.AreEqual("A long description", unit.Description !.RawDescription);
        Assert.AreEqual("Shield", unit.Shield.ShieldType);
    }
Esempio n. 17
0
    public void UpdateGameStringsTest()
    {
        Announcer announcer = new()
        {
            Id = "AbathurA",
        };

        using GameStringDocument gameStringDocument = GameStringDocument.Parse(LoadEnusLocalizedStringData());
        gameStringDocument.UpdateGameStrings(announcer);

        Assert.ThrowsException <ArgumentNullException>(() => gameStringDocument.UpdateGameStrings(announcer: null !));

        Assert.AreEqual("Abathur Announcer", announcer.Name);
        Assert.AreEqual("asdf", announcer.Description?.RawDescription);
        Assert.AreEqual("asdfsn", announcer.SortName);
    }
        private LootChest GetLootChestData(string lootChestId, JsonElement lootChestElement)
        {
            LootChest lootChest = new LootChest()
            {
                Id = lootChestId,
            };

            if (lootChestElement.TryGetProperty("name", out JsonElement name))
            {
                lootChest.Name = name.GetString();
            }

            if (lootChestElement.TryGetProperty("hyperlinkId", out JsonElement hyperlinkId))
            {
                lootChest.HyperlinkId = hyperlinkId.GetString();
            }

            if (lootChestElement.TryGetProperty("rarity", out JsonElement rarityElement) && Enum.TryParse(rarityElement.GetString(), out Rarity rarity))
            {
                lootChest.Rarity = rarity;
            }

            if (lootChestElement.TryGetProperty("maxRerolls", out JsonElement maxRerolls))
            {
                lootChest.MaxRerolls = maxRerolls.GetInt32();
            }

            if (lootChestElement.TryGetProperty("typeDescription", out JsonElement typeDescription))
            {
                lootChest.TypeDescription = typeDescription.GetString();
            }

            if (lootChestElement.TryGetProperty("event", out JsonElement eventName))
            {
                lootChest.EventName = eventName.GetString();
            }

            if (lootChestElement.TryGetProperty("description", out JsonElement description))
            {
                lootChest.Description = SetTooltipDescription(description.GetString(), Localization);
            }

            GameStringDocument?.UpdateGameStrings(lootChest);

            return(lootChest);
        }
Esempio n. 19
0
        private MatchAward GetMatchAwardData(string matchAwardId, JsonElement matchAwardElement)
        {
            MatchAward matchAward = new MatchAward()
            {
                Id = matchAwardId,
            };

            if (matchAwardElement.TryGetProperty("name", out JsonElement name))
            {
                matchAward.Name = name.GetString();
            }

            if (matchAwardElement.TryGetProperty("gameLink", out JsonElement gameLink))
            {
                matchAward.HyperlinkId = gameLink.GetString();
            }

            if (matchAwardElement.TryGetProperty("tag", out JsonElement tag))
            {
                matchAward.Tag = tag.GetString();
            }

            if (matchAwardElement.TryGetProperty("mvpScreenIcon", out JsonElement mvpScreenIcon))
            {
                matchAward.MVPScreenImageFileName = mvpScreenIcon.GetString();
            }

            if (matchAwardElement.TryGetProperty("scoreScreenIcon", out JsonElement scoreScreenIcon))
            {
                matchAward.ScoreScreenImageFileName = scoreScreenIcon.GetString();
            }

            if (matchAwardElement.TryGetProperty("description", out JsonElement description))
            {
                matchAward.Description = SetTooltipDescription(description.GetString(), Localization);
            }

            GameStringDocument?.UpdateGameStrings(matchAward);

            return(matchAward);
        }
Esempio n. 20
0
    private Boost GetBoostData(string boostId, JsonElement boostElement)
    {
        Boost boost = new()
        {
            Id = boostId,
        };

        if (boostElement.TryGetProperty("name", out JsonElement name))
        {
            boost.Name = name.GetString();
        }

        if (boostElement.TryGetProperty("hyperlinkId", out JsonElement hyperlinkId))
        {
            boost.HyperlinkId = hyperlinkId.GetString();
        }

        if (boostElement.TryGetProperty("sortName", out JsonElement sortName))
        {
            boost.SortName = sortName.GetString();
        }

        if (boostElement.TryGetProperty("event", out JsonElement eventName))
        {
            boost.EventName = eventName.GetString();
        }

        if (boostElement.TryGetProperty("releaseDate", out JsonElement releaseDateElement) && DateTime.TryParse(releaseDateElement.GetString(), out DateTime releaseDate))
        {
            boost.ReleaseDate = releaseDate;
        }

        GameStringDocument?.UpdateGameStrings(boost);

        return(boost);
    }
Esempio n. 21
0
    private EmoticonPack GetEmoticonPackData(string emoticonPackId, JsonElement emoticonPackElement)
    {
        EmoticonPack emoticonPack = new()
        {
            Id = emoticonPackId,
        };

        if (emoticonPackElement.TryGetProperty("name", out JsonElement expression))
        {
            emoticonPack.Name = expression.GetString();
        }

        if (emoticonPackElement.TryGetProperty("hyperlinkId", out JsonElement hyperlinkId))
        {
            emoticonPack.HyperlinkId = hyperlinkId.GetString();
        }

        if (emoticonPackElement.TryGetProperty("rarity", out JsonElement rarityElement) && Enum.TryParse(rarityElement.GetString(), out Rarity rarity))
        {
            emoticonPack.Rarity = rarity;
        }

        if (emoticonPackElement.TryGetProperty("category", out JsonElement category))
        {
            emoticonPack.CollectionCategory = category.GetString();
        }

        if (emoticonPackElement.TryGetProperty("event", out JsonElement eventElement))
        {
            emoticonPack.EventName = eventElement.GetString();
        }

        if (emoticonPackElement.TryGetProperty("releaseDate", out JsonElement releaseDateElement) && DateTime.TryParse(releaseDateElement.GetString(), out DateTime releaseDate))
        {
            emoticonPack.ReleaseDate = releaseDate;
        }

        if (emoticonPackElement.TryGetProperty("sortName", out JsonElement sortName))
        {
            emoticonPack.SortName = sortName.GetString();
        }

        if (emoticonPackElement.TryGetProperty("description", out JsonElement description))
        {
            emoticonPack.Description = SetTooltipDescription(description.GetString(), Localization);
        }

        if (emoticonPackElement.TryGetProperty("emoticons", out JsonElement emoticons))
        {
            foreach (JsonElement emoticon in emoticons.EnumerateArray())
            {
                string?emoticonValue = emoticon.GetString();
                if (emoticonValue is not null)
                {
                    emoticonPack.EmoticonIds.Add(emoticonValue);
                }
            }
        }

        GameStringDocument?.UpdateGameStrings(emoticonPack);

        return(emoticonPack);
    }
    private Emoticon GetEmoticonData(string emoticonId, JsonElement emoticonElement)
    {
        Emoticon emoticon = new()
        {
            Id = emoticonId,
        };

        if (emoticonElement.TryGetProperty("expression", out JsonElement expression))
        {
            emoticon.Name = expression.GetString();
        }

        if (emoticonElement.TryGetProperty("hyperlinkId", out JsonElement hyperlinkId))
        {
            emoticon.HyperlinkId = hyperlinkId.GetString();
        }

        if (emoticonElement.TryGetProperty("caseSensitive", out JsonElement caseSensitive))
        {
            emoticon.IsAliasCaseSensitive = caseSensitive.GetBoolean();
        }

        if (emoticonElement.TryGetProperty("isHidden", out JsonElement isHidden))
        {
            emoticon.IsHidden = isHidden.GetBoolean();
        }

        if (emoticonElement.TryGetProperty("searchText", out JsonElement searchText))
        {
            string?searchTextValue = searchText.GetString();
            if (!string.IsNullOrEmpty(searchTextValue))
            {
                string[] values = searchTextValue.Split(' ', StringSplitOptions.RemoveEmptyEntries);
                foreach (string value in values)
                {
                    emoticon.SearchTexts.Add(value);
                }
            }
        }

        if (emoticonElement.TryGetProperty("description", out JsonElement description))
        {
            emoticon.Description = SetTooltipDescription(description.GetString(), Localization);
        }

        if (emoticonElement.TryGetProperty("descriptionLocked", out JsonElement descriptionLocked))
        {
            emoticon.DescriptionLocked = SetTooltipDescription(descriptionLocked.GetString(), Localization);
        }

        if (emoticonElement.TryGetProperty("localizedAliases", out JsonElement localizedAliasesElement))
        {
            foreach (JsonElement localizedAlias in localizedAliasesElement.EnumerateArray())
            {
                string?localizedAliasValue = localizedAlias.GetString();
                if (localizedAliasValue is not null)
                {
                    emoticon.LocalizedAliases.Add(localizedAliasValue);
                }
            }
        }

        if (emoticonElement.TryGetProperty("aliases", out JsonElement aliasesElement))
        {
            foreach (JsonElement alias in aliasesElement.EnumerateArray())
            {
                string?aliasValue = alias.GetString();
                if (aliasValue is not null)
                {
                    emoticon.UniversalAliases.Add(aliasValue);
                }
            }
        }

        if (emoticonElement.TryGetProperty("heroId", out JsonElement heroId))
        {
            emoticon.HeroId = heroId.GetString();
        }

        if (emoticonElement.TryGetProperty("heroSkinId", out JsonElement heroSkinId))
        {
            emoticon.HeroSkinId = heroSkinId.GetString();
        }

        if (emoticonElement.TryGetProperty("image", out JsonElement image))
        {
            emoticon.Image.FileName = image.GetString();
        }

        if (emoticonElement.TryGetProperty("animation", out JsonElement animationElement))
        {
            if (animationElement.TryGetProperty("texture", out JsonElement texture))
            {
                emoticon.TextureSheet.Image = texture.GetString();
            }

            if (animationElement.TryGetProperty("frames", out JsonElement frames))
            {
                emoticon.Image.Count = frames.GetInt32();
            }

            if (animationElement.TryGetProperty("duration", out JsonElement duration))
            {
                emoticon.Image.DurationPerFrame = duration.GetInt32();
            }

            if (animationElement.TryGetProperty("width", out JsonElement width))
            {
                emoticon.Image.Width = width.GetInt32();
            }

            if (animationElement.TryGetProperty("columns", out JsonElement columns))
            {
                emoticon.TextureSheet.Columns = columns.GetInt32();
            }

            if (animationElement.TryGetProperty("rows", out JsonElement rows))
            {
                emoticon.TextureSheet.Rows = rows.GetInt32();
            }
        }

        GameStringDocument?.UpdateGameStrings(emoticon);

        return(emoticon);
    }
    /// <summary>
    /// Updates the localized gamestrings to the selected <see cref="Localization"/>.
    /// </summary>
    /// <param name="emoticonPack">The data to be updated.</param>
    /// <param name="gameStringDocument">Instance of a <see cref="GameStringDocument"/>.</param>
    /// <exception cref="ArgumentNullException"><paramref name="gameStringDocument"/> is null.</exception>
    public static void UpdateGameStrings(this EmoticonPack emoticonPack, GameStringDocument gameStringDocument)
    {
        ArgumentNullException.ThrowIfNull(gameStringDocument, nameof(gameStringDocument));

        gameStringDocument.UpdateGameStrings(emoticonPack);
    }
    private Spray GetSprayData(string sprayId, JsonElement sprayElement)
    {
        Spray spray = new()
        {
            Id = sprayId,
        };

        if (sprayElement.TryGetProperty("name", out JsonElement name))
        {
            spray.Name = name.GetString();
        }

        if (sprayElement.TryGetProperty("hyperlinkId", out JsonElement hyperlinkId))
        {
            spray.HyperlinkId = hyperlinkId.GetString();
        }

        if (sprayElement.TryGetProperty("attributeId", out JsonElement attributeId))
        {
            spray.AttributeId = attributeId.GetString();
        }

        if (sprayElement.TryGetProperty("rarity", out JsonElement rarityElement) && Enum.TryParse(rarityElement.GetString(), out Rarity rarity))
        {
            spray.Rarity = rarity;
        }

        if (sprayElement.TryGetProperty("category", out JsonElement category))
        {
            spray.CollectionCategory = category.GetString();
        }

        if (sprayElement.TryGetProperty("event", out JsonElement eventElement))
        {
            spray.EventName = eventElement.GetString();
        }

        if (sprayElement.TryGetProperty("releaseDate", out JsonElement releaseDateElement) && DateTime.TryParse(releaseDateElement.GetString(), out DateTime releaseDate))
        {
            spray.ReleaseDate = releaseDate;
        }

        if (sprayElement.TryGetProperty("sortName", out JsonElement sortName))
        {
            spray.SortName = sortName.GetString();
        }

        if (sprayElement.TryGetProperty("searchText", out JsonElement searchText))
        {
            spray.SearchText = searchText.GetString();
        }

        if (sprayElement.TryGetProperty("description", out JsonElement description))
        {
            spray.Description = SetTooltipDescription(description.GetString(), Localization);
        }

        if (sprayElement.TryGetProperty("image", out JsonElement image))
        {
            spray.ImageFileName = image.GetString();
        }

        if (sprayElement.TryGetProperty("animation", out JsonElement animationElement))
        {
            if (animationElement.TryGetProperty("texture", out JsonElement texture))
            {
                spray.TextureSheet.Image = texture.GetString();
            }

            if (animationElement.TryGetProperty("frames", out JsonElement frames))
            {
                spray.AnimationCount = frames.GetInt32();
            }

            if (animationElement.TryGetProperty("duration", out JsonElement duration))
            {
                spray.AnimationDuration = duration.GetInt32();
            }
        }

        GameStringDocument?.UpdateGameStrings(spray);

        return(spray);
    }
    /// <summary>
    /// Updates the localized gamestrings to the selected <see cref="Localization"/>.
    /// </summary>
    /// <param name="rewardPortrait">The data to be updated.</param>
    /// <param name="gameStringDocument">Instance of a <see cref="GameStringDocument"/>.</param>
    /// <exception cref="ArgumentNullException"><paramref name="gameStringDocument"/> is null.</exception>
    public static void UpdateGameStrings(this RewardPortrait rewardPortrait, GameStringDocument gameStringDocument)
    {
        ArgumentNullException.ThrowIfNull(gameStringDocument, nameof(gameStringDocument));

        gameStringDocument.UpdateGameStrings(rewardPortrait);
    }
Esempio n. 26
0
        private Unit GetUnitData(string unitId, JsonElement element, bool includeAbilities, bool includeSubAbilities)
        {
            Unit unit = new Unit
            {
                Id      = unitId,
                CUnitId = unitId,
            };

            int indexOfMapSplit = unit.Id.IndexOf('-', StringComparison.OrdinalIgnoreCase);

            if (indexOfMapSplit > 0)
            {
                unit.MapName = unit.Id.Substring(0, indexOfMapSplit);
            }

            if (element.TryGetProperty("hyperlinkId", out JsonElement hyperlinkId))
            {
                unit.HyperlinkId = hyperlinkId.GetString();
            }

            int index = unitId.IndexOf('-', StringComparison.InvariantCultureIgnoreCase);

            if (index > -1)
            {
                unit.MapName = unitId.Substring(0, index);
            }

            if (element.TryGetProperty("name", out JsonElement name))
            {
                unit.Name = name.GetString();
            }
            if (element.TryGetProperty("innerRadius", out JsonElement innerRadius))
            {
                unit.InnerRadius = innerRadius.GetDouble();
            }
            if (element.TryGetProperty("radius", out JsonElement radius))
            {
                unit.Radius = radius.GetDouble();
            }
            if (element.TryGetProperty("sight", out JsonElement sight))
            {
                unit.Sight = sight.GetDouble();
            }
            if (element.TryGetProperty("speed", out JsonElement speed))
            {
                unit.Speed = speed.GetDouble();
            }
            if (element.TryGetProperty("killXP", out JsonElement killXP))
            {
                unit.KillXP = killXP.GetInt32();
            }
            if (element.TryGetProperty("damageType", out JsonElement damageType))
            {
                unit.DamageType = damageType.GetString();
            }
            if (element.TryGetProperty("scalingLinkId", out JsonElement scalingLinkId))
            {
                unit.ScalingBehaviorLink = scalingLinkId.GetString();
            }

            if (element.TryGetProperty("description", out JsonElement description))
            {
                unit.Description = SetTooltipDescription(description.GetString(), Localization);
            }

            if (element.TryGetProperty("descriptors", out JsonElement descriptorElements))
            {
                foreach (JsonElement descriptorArrayElement in descriptorElements.EnumerateArray())
                {
                    string?descriptorValue = descriptorArrayElement.GetString();
                    if (descriptorValue is not null)
                    {
                        unit.HeroDescriptors.Add(descriptorValue);
                    }
                }
            }

            if (element.TryGetProperty("attributes", out JsonElement attributesElements))
            {
                foreach (JsonElement attributeArrayElement in attributesElements.EnumerateArray())
                {
                    string?attributeValue = attributeArrayElement.GetString();
                    if (attributeValue is not null)
                    {
                        unit.Attributes.Add(attributeValue);
                    }
                }
            }

            if (element.TryGetProperty("units", out JsonElement unitsElements))
            {
                foreach (JsonElement unitArrayElement in unitsElements.EnumerateArray())
                {
                    string?unitValue = unitArrayElement.GetString();
                    if (unitValue is not null)
                    {
                        unit.UnitIds.Add(unitValue);
                    }
                }
            }

            // portraits
            if (element.TryGetProperty("portraits", out JsonElement portraitsElement))
            {
                if (portraitsElement.TryGetProperty("targetInfo", out JsonElement portraitValue))
                {
                    unit.UnitPortrait.TargetInfoPanelFileName = portraitValue.GetString();
                }
                if (portraitsElement.TryGetProperty("minimap", out portraitValue))
                {
                    unit.UnitPortrait.MiniMapIconFileName = portraitValue.GetString();
                }
            }

            // life
            SetUnitLife(element, unit);

            // shield
            SetUnitShield(element, unit);

            // energy
            SetUnitEnergy(element, unit);

            // armor
            SetUnitArmor(element, unit);

            // weapons
            SetUnitWeapons(element, unit);

            // abilities
            if (includeAbilities && element.TryGetProperty("abilities", out JsonElement abilities))
            {
                AddAbilities(unit, abilities);
            }

            if (includeSubAbilities && element.TryGetProperty("subAbilities", out JsonElement subAbilities))
            {
                foreach (JsonElement subAbilityArrayElement in subAbilities.EnumerateArray())
                {
                    foreach (JsonProperty subAbilityProperty in subAbilityArrayElement.EnumerateObject())
                    {
                        string parentLink = subAbilityProperty.Name;

                        AddAbilities(unit, subAbilityProperty.Value, parentLink);
                    }
                }
            }

            GameStringDocument?.UpdateGameStrings(unit);

            return(unit);
        }
Esempio n. 27
0
    private Announcer GetAnnouncerData(string announcerId, JsonElement announcerElement)
    {
        Announcer announcer = new()
        {
            Id = announcerId,
        };

        if (announcerElement.TryGetProperty("name", out JsonElement name))
        {
            announcer.Name = name.GetString();
        }

        if (announcerElement.TryGetProperty("hyperlinkId", out JsonElement hyperlinkId))
        {
            announcer.HyperlinkId = hyperlinkId.GetString();
        }

        if (announcerElement.TryGetProperty("attributeId", out JsonElement attributeId))
        {
            announcer.AttributeId = attributeId.GetString();
        }

        if (announcerElement.TryGetProperty("rarity", out JsonElement rarityElement) && Enum.TryParse(rarityElement.GetString(), out Rarity rarity))
        {
            announcer.Rarity = rarity;
        }

        if (announcerElement.TryGetProperty("category", out JsonElement category))
        {
            announcer.CollectionCategory = category.GetString();
        }

        if (announcerElement.TryGetProperty("gender", out JsonElement gender))
        {
            announcer.Gender = gender.GetString();
        }

        if (announcerElement.TryGetProperty("heroId", out JsonElement heroId))
        {
            announcer.HeroId = heroId.GetString();
        }

        if (announcerElement.TryGetProperty("releaseDate", out JsonElement releaseDateElement) && DateTime.TryParse(releaseDateElement.GetString(), out DateTime releaseDate))
        {
            announcer.ReleaseDate = releaseDate;
        }

        if (announcerElement.TryGetProperty("sortName", out JsonElement sortName))
        {
            announcer.SortName = sortName.GetString();
        }

        if (announcerElement.TryGetProperty("description", out JsonElement description))
        {
            announcer.Description = SetTooltipDescription(description.GetString(), Localization);
        }

        if (announcerElement.TryGetProperty("image", out JsonElement image))
        {
            announcer.ImageFileName = image.GetString();
        }

        GameStringDocument?.UpdateGameStrings(announcer);

        return(announcer);
    }
    /// <summary>
    /// Updates the localized gamestrings to the selected <see cref="Localization"/>.
    /// </summary>
    /// <param name="matchAward">The data to be updated.</param>
    /// <param name="gameStringDocument">Instance of a <see cref="GameStringDocument"/>.</param>
    /// <exception cref="ArgumentNullException"><paramref name="gameStringDocument"/> is null.</exception>
    public static void UpdateGameStrings(this MatchAward matchAward, GameStringDocument gameStringDocument)
    {
        ArgumentNullException.ThrowIfNull(gameStringDocument, nameof(gameStringDocument));

        gameStringDocument.UpdateGameStrings(matchAward);
    }
    /// <summary>
    /// Updates the localized gamestrings to the selected <see cref="Localization"/>.
    /// </summary>
    /// <param name="mount">The data to be updated.</param>
    /// <param name="gameStringDocument">Instance of a <see cref="GameStringDocument"/>.</param>
    /// <exception cref="ArgumentNullException"><paramref name="gameStringDocument"/> is null.</exception>
    public static void UpdateGameStrings(this Mount mount, GameStringDocument gameStringDocument)
    {
        ArgumentNullException.ThrowIfNull(gameStringDocument, nameof(gameStringDocument));

        gameStringDocument.UpdateGameStrings(mount);
    }
Esempio n. 30
0
    private RewardPortrait GetRewardPortraitData(string rewardPortraitId, JsonElement rewardPortraitElement)
    {
        RewardPortrait rewardPortrait = new()
        {
            Id = rewardPortraitId,
        };

        if (rewardPortraitElement.TryGetProperty("name", out JsonElement name))
        {
            rewardPortrait.Name = name.GetString();
        }

        if (rewardPortraitElement.TryGetProperty("hyperlinkId", out JsonElement hyperlinkId))
        {
            rewardPortrait.HyperlinkId = hyperlinkId.GetString();
        }

        if (rewardPortraitElement.TryGetProperty("rarity", out JsonElement rarityElement) && Enum.TryParse(rarityElement.GetString(), out Rarity rarity))
        {
            rewardPortrait.Rarity = rarity;
        }

        if (rewardPortraitElement.TryGetProperty("category", out JsonElement eventElement))
        {
            rewardPortrait.CollectionCategory = eventElement.GetString();
        }

        if (rewardPortraitElement.TryGetProperty("description", out JsonElement description))
        {
            rewardPortrait.Description = SetTooltipDescription(description.GetString(), Localization);
        }

        if (rewardPortraitElement.TryGetProperty("descriptionUnearned", out JsonElement descriptionUnearned))
        {
            rewardPortrait.DescriptionUnearned = SetTooltipDescription(descriptionUnearned.GetString(), Localization);
        }

        if (rewardPortraitElement.TryGetProperty("heroId", out JsonElement heroIdElement))
        {
            rewardPortrait.HeroId = heroIdElement.GetString();
        }

        if (rewardPortraitElement.TryGetProperty("portraitPackId", out JsonElement portraitPack))
        {
            rewardPortrait.PortraitPackId = portraitPack.GetString();
        }

        if (rewardPortraitElement.TryGetProperty("iconSlot", out JsonElement iconSlot))
        {
            rewardPortrait.IconSlot = iconSlot.GetInt32();
        }

        if (rewardPortraitElement.TryGetProperty("textureSheet", out JsonElement textureSheetElement))
        {
            if (textureSheetElement.TryGetProperty("image", out JsonElement image))
            {
                rewardPortrait.TextureSheet.Image = image.GetString();
            }

            if (textureSheetElement.TryGetProperty("columns", out JsonElement columns))
            {
                rewardPortrait.TextureSheet.Columns = columns.GetInt32();
            }

            if (textureSheetElement.TryGetProperty("rows", out JsonElement rows))
            {
                rewardPortrait.TextureSheet.Rows = rows.GetInt32();
            }
        }

        if (rewardPortraitElement.TryGetProperty("image", out JsonElement imageElement))
        {
            rewardPortrait.ImageFileName = imageElement.GetString();
        }

        GameStringDocument?.UpdateGameStrings(rewardPortrait);

        return(rewardPortrait);
    }