コード例 #1
0
        /// <summary>
        /// Updates the <paramref name="heroSkin"/>'s localized gamestrings to the currently selected <see cref="Localization"/>.
        /// </summary>
        /// <param name="heroSkin">The data to be updated.</param>
        /// <exception cref="ArgumentNullException"><paramref name="heroSkin"/> is <see langword="null"/>.</exception>
        public void UpdateGameStrings(HeroSkin heroSkin)
        {
            if (heroSkin is null)
            {
                throw new ArgumentNullException(nameof(heroSkin));
            }

            JsonElement element = JsonGameStringDocument.RootElement;

            if (element.TryGetProperty("gamestrings", out JsonElement gameStringElement))
            {
                if (gameStringElement.TryGetProperty("heroskin", out JsonElement keyValue))
                {
                    if (TryGetValueFromJsonElement(keyValue, "name", heroSkin.Id, out JsonElement nameElement))
                    {
                        heroSkin.Name = nameElement.GetString();
                    }
                    if (TryGetValueFromJsonElement(keyValue, "searchtext", heroSkin.Id, out JsonElement searchTextElement))
                    {
                        heroSkin.SearchText = searchTextElement.GetString();
                    }
                    if (TryGetValueFromJsonElement(keyValue, "sortname", heroSkin.Id, out JsonElement sortNameElement))
                    {
                        heroSkin.SortName = sortNameElement.GetString();
                    }
                    if (TryGetValueFromJsonElement(keyValue, "infotext", heroSkin.Id, out JsonElement infoTextElement))
                    {
                        heroSkin.InfoText = SetTooltipDescription(infoTextElement.GetString());
                    }
                }
            }
        }
コード例 #2
0
 protected void AddLocalizedGameString(HeroSkin heroSkin)
 {
     GameStringWriter.AddHeroSkinName(heroSkin.Id, heroSkin.Name);
     GameStringWriter.AddHeroSkinSortName(heroSkin.Id, heroSkin.SortName);
     GameStringWriter.AddHeroSkinInfo(heroSkin.Id, GetTooltip(heroSkin.Description, FileOutputOptions.DescriptionType));
     GameStringWriter.AddHeroSkinSearchText(heroSkin.Id, heroSkin.SearchText);
 }
コード例 #3
0
        private void Parse()
        {
            HeroSkinParser heroSkinParser = new HeroSkinParser(XmlDataService);

            AbathurCommonSkin    = heroSkinParser.Parse("AbathurBone");
            AbathurMechaVar1Skin = heroSkinParser.Parse("AbathurMechaVar1");
        }
コード例 #4
0
        public void UpdateGameStringsThrowArgumentNullException()
        {
            HeroSkin heroSkin = new HeroSkin
            {
                Id = "AbathurBaseVar3",
            };

            Assert.ThrowsException <ArgumentNullException>(() => heroSkin.UpdateGameStrings(null !));
        }
コード例 #5
0
        /// <summary>
        /// Updates the localized gamestrings to the selected <see cref="Localization"/>.
        /// </summary>
        /// <param name="heroSkin">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 HeroSkin heroSkin, GameStringDocument gameStringDocument)
        {
            if (gameStringDocument is null)
            {
                throw new ArgumentNullException(nameof(gameStringDocument));
            }

            gameStringDocument.UpdateGameStrings(heroSkin);
        }
コード例 #6
0
    public void UpdateGameStringHeroSkinTest()
    {
        using HeroSkinDataDocument dataDocument = _heroesDataDirectory.HeroSkinData(new HeroesDataVersion(2, 47, 3, 76124), true, Localization.KOKR);
        HeroSkin data = dataDocument.GetHeroSkinById("AbathurBaseVar3");

        Assert.AreEqual("칼디르 아바투르", data.Name);

        _heroesDataDirectory.UpdateGameString(data, new HeroesDataVersion(2, 48, 4, 77407), Localization.ENUS);
        Assert.AreEqual("heroskinName", data.Name);
    }
コード例 #7
0
    /// <summary>
    /// Updates the gamestrings of <paramref name="heroSkin"/>.
    /// </summary>
    /// <param name="heroSkin">The data who's gamestrings will be updated.</param>
    /// <param name="version">The version directory to load the gamestrings from.</param>
    /// <param name="localization">The <see cref="Localization"/> of the gamestrings.</param>
    /// <exception cref="ArgumentNullException"><paramref name="heroSkin"/> is null.</exception>
    /// <exception cref="ArgumentNullException"><paramref name="version"/> is null.</exception>
    public void UpdateGameString(HeroSkin heroSkin, HeroesDataVersion version, Localization localization)
    {
        ArgumentNullException.ThrowIfNull(heroSkin, nameof(heroSkin));
        ArgumentNullException.ThrowIfNull(version, nameof(version));

        (_, string gameStringPath) = GetDataAndGameStringPaths(version, true, localization, _heroSkinFileTemplateName, false, true);

        using GameStringDocument gameStringDocument = GameStringDocument.Parse(gameStringPath);

        heroSkin.UpdateGameStrings(gameStringDocument);
    }
コード例 #8
0
        public void UpdateGameStringsTest()
        {
            using GameStringDocument gameStringDocument = GameStringDocument.Parse(LoadEnusLocalizedStringData());

            HeroSkin heroSkin = new HeroSkin
            {
                Id = "AbathurBaseVar3",
            };

            heroSkin.UpdateGameStrings(gameStringDocument);

            Assert.AreEqual("Abathur, the Evolution Master of Kerrigan's Swarm, works ceaselessly to improve the zerg from the genetic level up. His hate for chaos and imperfection almost rivals his hatred of pronouns.", heroSkin.InfoText !.RawDescription);
        }
コード例 #9
0
        protected override JProperty MainElement(HeroSkin heroSkin)
        {
            if (FileOutputOptions.IsLocalizedText)
            {
                AddLocalizedGameString(heroSkin);
            }

            JObject heroSkinObject = new JObject();

            if (!string.IsNullOrEmpty(heroSkin.Name) && !FileOutputOptions.IsLocalizedText)
            {
                heroSkinObject.Add("name", heroSkin.Name);
            }

            heroSkinObject.Add("hyperlinkId", heroSkin.HyperlinkId);
            heroSkinObject.Add("attributeId", heroSkin.AttributeId);
            heroSkinObject.Add("rarity", heroSkin.Rarity.ToString());

            if (heroSkin.ReleaseDate.HasValue)
            {
                heroSkinObject.Add("releaseDate", heroSkin.ReleaseDate.Value.ToString("yyyy-MM-dd"));
            }

            if (!string.IsNullOrEmpty(heroSkin.SortName) && !FileOutputOptions.IsLocalizedText)
            {
                heroSkinObject.Add("sortName", heroSkin.SortName);
            }

            if (!string.IsNullOrEmpty(heroSkin.SearchText) && !FileOutputOptions.IsLocalizedText)
            {
                heroSkinObject.Add("searchText", heroSkin.SearchText);
            }

            if (!string.IsNullOrEmpty(heroSkin.Description?.RawDescription) && !FileOutputOptions.IsLocalizedText)
            {
                heroSkinObject.Add("description", GetTooltip(heroSkin.Description, FileOutputOptions.DescriptionType));
            }

            if (heroSkin.Features.Any())
            {
                heroSkinObject.Add(new JProperty("features", heroSkin.Features));
            }

            return(new JProperty(heroSkin.Id, heroSkinObject));
        }
コード例 #10
0
        protected override XElement MainElement(HeroSkin heroSkin)
        {
            if (FileOutputOptions.IsLocalizedText)
            {
                AddLocalizedGameString(heroSkin);
            }

            return(new XElement(
                       XmlConvert.EncodeName(heroSkin.Id),
                       string.IsNullOrEmpty(heroSkin.Name) || FileOutputOptions.IsLocalizedText ? null : new XAttribute("name", heroSkin.Name),
                       new XAttribute("hyperlinkId", heroSkin.HyperlinkId),
                       new XAttribute("attributeId", heroSkin.AttributeId),
                       new XAttribute("rarity", heroSkin.AttributeId),
                       heroSkin.ReleaseDate.HasValue ? new XAttribute("releaseDate", heroSkin.ReleaseDate.Value.ToString("yyyy-MM-dd")) : null,
                       string.IsNullOrEmpty(heroSkin.SortName) || FileOutputOptions.IsLocalizedText ? null : new XElement("SortName", heroSkin.SortName),
                       string.IsNullOrEmpty(heroSkin.SearchText) || FileOutputOptions.IsLocalizedText ? null : new XElement("SearchText", heroSkin.SearchText),
                       string.IsNullOrEmpty(heroSkin.Description?.RawDescription) || FileOutputOptions.IsLocalizedText ? null : new XElement("Description", GetTooltip(heroSkin.Description, FileOutputOptions.DescriptionType)),
                       heroSkin.Features.Any() ? new XElement("Features", heroSkin.Features.Select(f => new XElement("Feature", f))) : null));
        }
コード例 #11
0
 private static void BasicAbathurBoneAsserts(HeroSkin heroSkin)
 {
     Assert.AreEqual("AbathurBone", heroSkin.Id);
     Assert.AreEqual("Bone Abathur", heroSkin.Name);
     Assert.AreEqual("BoneAbathur", heroSkin.HyperlinkId);
     Assert.AreEqual("Aba1", heroSkin.AttributeId);
     Assert.AreEqual(Rarity.Common, heroSkin.Rarity);
     Assert.AreEqual(new DateTime(2014, 3, 13), heroSkin.ReleaseDate);
     Assert.AreEqual("zxAbathurVar0", heroSkin.SortName);
     Assert.AreEqual("White Pink", heroSkin.SearchText);
     Assert.AreEqual("Abathur, the Evolution Master of Kerrigan's Swarm, works ceaselessly to improve the zerg from the genetic level up. His hate for chaos and imperfection almost rivals his hatred of pronouns.", heroSkin.InfoText?.RawDescription);
     Assert.IsTrue(heroSkin.Features.Contains("AlteredVO"));
     Assert.IsTrue(heroSkin.Features.Contains("ThemedAbilities"));
     Assert.IsTrue(heroSkin.Features.Contains("ThemedAnimations"));
     Assert.AreEqual(Franchise.Nexus, heroSkin.Franchise);
     Assert.IsTrue(heroSkin.VariationSkinIds.Contains("AbathurMechaVar1"));
     Assert.IsTrue(heroSkin.VariationSkinIds.Contains("AbathurMechaVar2"));
     Assert.IsTrue(heroSkin.VoiceLineIds.Contains("AbathurMecha_VoiceLine01"));
     Assert.IsTrue(heroSkin.VoiceLineIds.Contains("AbathurMecha_VoiceLine02"));
 }
コード例 #12
0
        private HeroSkin GetHeroSkinData(string heroSkinId, JsonElement heroSkinElement)
        {
            HeroSkin heroSkin = new HeroSkin()
            {
                Id = heroSkinId,
            };

            if (heroSkinElement.TryGetProperty("name", out JsonElement name))
                heroSkin.Name = name.GetString();

            if (heroSkinElement.TryGetProperty("hyperlinkId", out JsonElement hyperlinkId))
                heroSkin.HyperlinkId = hyperlinkId.GetString();

            if (heroSkinElement.TryGetProperty("attributeId", out JsonElement attributeId))
                heroSkin.AttributeId = attributeId.GetString();

            if (heroSkinElement.TryGetProperty("rarity", out JsonElement rarityElement) && Enum.TryParse(rarityElement.GetString(), out Rarity rarity))
                heroSkin.Rarity = rarity;

            if (heroSkinElement.TryGetProperty("releaseDate", out JsonElement releaseDateElement) && DateTime.TryParse(releaseDateElement.GetString(), out DateTime releaseDate))
                heroSkin.ReleaseDate = releaseDate;

            if (heroSkinElement.TryGetProperty("sortName", out JsonElement sortName))
                heroSkin.SortName = sortName.GetString();

            if (heroSkinElement.TryGetProperty("searchText", out JsonElement searchText))
                heroSkin.SearchText = searchText.GetString();

            if (heroSkinElement.TryGetProperty("infoText", out JsonElement infoText))
                heroSkin.InfoText = SetTooltipDescription(infoText.GetString(), Localization);

            if (heroSkinElement.TryGetProperty("features", out JsonElement featuresElement))
            {
                foreach (JsonElement featureElement in featuresElement.EnumerateArray())
                {
                    string? featureValue = featureElement.GetString();
                    if (featureValue is not null)
                        heroSkin.Features.Add(featureValue);
                }
            }

            if (heroSkinElement.TryGetProperty("franchise", out JsonElement franchiseElement) && Enum.TryParse(franchiseElement.GetString(), out Franchise franchise))
                heroSkin.Franchise = franchise;
            else
                heroSkin.Franchise = Franchise.Unknown;

            if (heroSkinElement.TryGetProperty("variationSkins", out JsonElement variationSkinsElement))
            {
                foreach (JsonElement variationSkin in variationSkinsElement.EnumerateArray())
                {
                    string? variationSkinValue = variationSkin.GetString();
                    if (variationSkinValue is not null)
                        heroSkin.VariationSkinIds.Add(variationSkinValue);
                }
            }

            if (heroSkinElement.TryGetProperty("voiceLines", out JsonElement variationVoiceLinesElement))
            {
                foreach (JsonElement variationVoiceLine in variationVoiceLinesElement.EnumerateArray())
                {
                    string? variationVoiceLineValue = variationVoiceLine.GetString();
                    if (variationVoiceLineValue is not null)
                        heroSkin.VoiceLineIds.Add(variationVoiceLineValue);
                }
            }

            GameStringDocument?.UpdateGameStrings(heroSkin);

            return heroSkin;
        }
コード例 #13
0
    /// <summary>
    /// Updates the localized gamestrings to the selected <see cref="Localization"/>.
    /// </summary>
    /// <param name="heroSkin">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 HeroSkin heroSkin, GameStringDocument gameStringDocument)
    {
        ArgumentNullException.ThrowIfNull(gameStringDocument, nameof(gameStringDocument));

        gameStringDocument.UpdateGameStrings(heroSkin);
    }