/// <summary> /// Updates the <paramref name="matchAward"/>'s localized gamestrings to the currently selected <see cref="Localization"/>. /// </summary> /// <param name="matchAward">The data to be updated.</param> /// <exception cref="ArgumentNullException"><paramref name="matchAward"/> is <see langword="null"/>.</exception> public void UpdateGameStrings(MatchAward matchAward) { if (matchAward is null) { throw new ArgumentNullException(nameof(matchAward)); } JsonElement element = JsonGameStringDocument.RootElement; if (element.TryGetProperty("gamestrings", out JsonElement gameStringElement)) { if (gameStringElement.TryGetProperty("award", out JsonElement keyValue)) { if (TryGetValueFromJsonElement(keyValue, "name", matchAward.Id, out JsonElement nameElement)) { matchAward.Name = nameElement.GetString(); } if (TryGetValueFromJsonElement(keyValue, "description", matchAward.Id, out JsonElement descriptionElement)) { matchAward.Description = SetTooltipDescription(descriptionElement.GetString()); } } } }
private void Parse() { MatchAwardParser matchAwardParser = new MatchAwardParser(XmlDataService, _matchAwardOverrideLoader); InterruptedCageUnlocks = matchAwardParser.Parse("EndOfMatchAwardMostInterruptedCageUnlocksBoolean", "alteracpass.stormmod"); MostAltarDamage = matchAwardParser.Parse("EndOfMatchAwardMostAltarDamageDone", "towersofdoom.stormmod"); }
protected override JProperty MainElement(MatchAward matchAward) { if (FileOutputOptions.IsLocalizedText) { AddLocalizedGameString(matchAward); } JObject matchAwardObject = new JObject(); if (!string.IsNullOrEmpty(matchAward.Name) && !FileOutputOptions.IsLocalizedText) { matchAwardObject.Add("name", matchAward.Name); } matchAwardObject.Add("gameLink", matchAward.HyperlinkId); matchAwardObject.Add("tag", matchAward.Tag); matchAwardObject.Add("mvpScreenIcon", Path.ChangeExtension(matchAward.MVPScreenImageFileName?.ToLower(), StaticImageExtension)); matchAwardObject.Add("scoreScreenIcon", Path.ChangeExtension(matchAward.ScoreScreenImageFileName?.ToLower(), StaticImageExtension)); if (!FileOutputOptions.IsLocalizedText) { matchAwardObject.Add("description", GetTooltip(matchAward.Description, FileOutputOptions.DescriptionType)); } return(new JProperty(matchAward.Id, matchAwardObject)); }
public void UpdateGameStringsThrowArgumentNullException() { MatchAward matchAward = new MatchAward { Id = "ClutchHealer", }; Assert.ThrowsException <ArgumentNullException>(() => matchAward.UpdateGameStrings(null !)); }
protected void AddLocalizedGameString(MatchAward matchAward) { GameStringWriter.AddMatchAwardName(matchAward.Id, matchAward.Name); if (matchAward.Description != null) { GameStringWriter.AddMatchAwardDescription(matchAward.Id, GetTooltip(matchAward.Description, FileOutputOptions.DescriptionType)); } }
/// <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); }
public void UpdateGameStringMatchAwardTest() { using MatchAwardDataDocument dataDocument = _heroesDataDirectory.MatchAwardData(new HeroesDataVersion(2, 47, 3, 76124), true, Localization.KOKR); MatchAward data = dataDocument.GetMatchAwardById("HatTrick"); Assert.AreEqual("기선 제압자", data.Name); _heroesDataDirectory.UpdateGameString(data, new HeroesDataVersion(2, 48, 4, 77407), Localization.ENUS); Assert.AreEqual("awardName", data.Name); }
private static void BasicClutchHealerAsserts(MatchAward matchAward) { Assert.AreEqual("ClutchHealer", matchAward.Id); Assert.AreEqual("Clutch Healer", matchAward.Name); Assert.AreEqual("EndOfMatchAwardClutchHealerBoolean", matchAward.HyperlinkId); Assert.AreEqual("AwCH", matchAward.Tag); Assert.AreEqual("storm_ui_mvp_clutchhealer_%color%.png", matchAward.MVPScreenImageFileName); Assert.AreEqual("storm_ui_scorescreen_mvp_clutchhealer_%team%.png", matchAward.ScoreScreenImageFileName); Assert.AreEqual("Many Heals That Saved a Dying Ally", matchAward.Description?.RawDescription); }
/// <summary> /// Updates the gamestrings of <paramref name="matchAward"/>. /// </summary> /// <param name="matchAward">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="matchAward"/> is null.</exception> /// <exception cref="ArgumentNullException"><paramref name="version"/> is null.</exception> public void UpdateGameString(MatchAward matchAward, HeroesDataVersion version, Localization localization) { ArgumentNullException.ThrowIfNull(matchAward, nameof(matchAward)); ArgumentNullException.ThrowIfNull(version, nameof(version)); (_, string gameStringPath) = GetDataAndGameStringPaths(version, true, localization, _matchAwardFileTemplateName, false, true); using GameStringDocument gameStringDocument = GameStringDocument.Parse(gameStringPath); matchAward.UpdateGameStrings(gameStringDocument); }
public void UpdateGameStringsTest() { using GameStringDocument gameStringDocument = GameStringDocument.Parse(LoadEnusLocalizedStringData()); MatchAward matchAward = new MatchAward { Id = "ClutchHealer", }; matchAward.UpdateGameStrings(gameStringDocument); Assert.AreEqual("Many Heals That Saved a Dying Ally", matchAward.Description !.RawDescription); }
protected override XElement MainElement(MatchAward matchAward) { if (FileOutputOptions.IsLocalizedText) { AddLocalizedGameString(matchAward); } return(new XElement( matchAward.Id, string.IsNullOrEmpty(matchAward.Name) || FileOutputOptions.IsLocalizedText ? null : new XAttribute("name", matchAward.Name), string.IsNullOrEmpty(matchAward.HyperlinkId) ? null : new XAttribute("gameLink", matchAward.HyperlinkId), new XAttribute("tag", matchAward.Tag), new XElement("MVPScreenIcon", Path.ChangeExtension(matchAward.MVPScreenImageFileName?.ToLower(), StaticImageExtension)), new XElement("ScoreScreenIcon", Path.ChangeExtension(matchAward.ScoreScreenImageFileName?.ToLower(), StaticImageExtension)), FileOutputOptions.IsLocalizedText ? null : new XElement("Description", GetTooltip(matchAward.Description, FileOutputOptions.DescriptionType)))); }
private void SetMVPAward(string awardType) { ScoreScreenAwardColor teamColor; if (Player.Team == 0) { teamColor = ScoreScreenAwardColor.Blue; } else { teamColor = ScoreScreenAwardColor.Red; } MatchAward matchAward = HeroesIcons.MatchAwards(Build).MatchAward(awardType); MvpAward = matchAward.MatchAwardScoreScreenImage(teamColor); MvpAwardDescription = $"{matchAward.Name}{Environment.NewLine}{matchAward.Description}"; }
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); }
/// <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); }