private static void ParseAndUpdateDamageToArmourMatrix(string gameConstantsFilePath) { Debug.Assert(gameConstantsFilePath != null, nameof(gameConstantsFilePath) + " != null"); Debug.Assert(File.Exists(gameConstantsFilePath), nameof(gameConstantsFilePath) + " must exist"); XDocument gameConstantsFile = XDocument.Load(gameConstantsFilePath); Debug.Assert(gameConstantsFile.Root != null, "gameConstantsFile.Root != null"); foreach (XElement xElement in gameConstantsFile.Root.Elements()) { if (!xElement.Name.ToString().Equals(Tags.DAMAGE_TO_ARMOR_MOD, StringComparison.InvariantCultureIgnoreCase)) { continue; } DamageToArmour dta = DamageToArmourUtility.ParseFromString(xElement.Value); DamageToArmour dtaToUpdate = DamageToArmourUtility.Get(dta.Damage, dta.Armour); Debug.Assert(dtaToUpdate != null, nameof(dtaToUpdate) + " != null"); dtaToUpdate.DamageToArmourFactor = dta.DamageToArmourFactor; } }
private static void SaveToGameConstantsFilePrepare([NotNull] string gameConstantsFilePath) { DamageUtility.CleanDamageDeclaration(gameConstantsFilePath); ArmourUtility.CleanArmourDeclaration(gameConstantsFilePath); DamageToArmourUtility.CleanDamageToArmourDeclaration(gameConstantsFilePath); }
private static void SaveToGameConstantsFileInternal([NotNull] string gameConstantsFilePath) { XmlUtility.ReplaceValueForTag(gameConstantsFilePath, Tags.DAMAGE_TYPES, DamageUtility.GetAllAsString()); XmlUtility.ReplaceValueForTag(gameConstantsFilePath, Tags.ARMOR_TYPES, ArmourUtility.GetAllAsString()); XmlUtility.InsertElement(gameConstantsFilePath, DamageToArmourUtility.ParseDamageToArmourMatrixAsXElement(), Tags.ARMOR_TYPES); }