Enabled color extension if color is not available in version

This commit is contained in:
Sven Kribitz 2025-01-05 15:29:29 +01:00
parent 6ea0e7bc55
commit 1975ab4bd1
3 changed files with 17 additions and 3 deletions

View file

@ -36,7 +36,21 @@ namespace HRServer.Models
{ {
WriteIndented = true // Aktiviert die formatierte Ausgabe WriteIndented = true // Aktiviert die formatierte Ausgabe
}; };
// Create an example genetics set for color
HorseGenetics example = new HorseGenetics();
// Check any horse whether all colors are loaded
if (Horses.First().Value.Genetics.Colors.Count < example.Colors.Count)
{
// Add missing colors to all horses
foreach (var horse in Horses)
{
foreach (var color in example.Colors)
{
if (!horse.Value.Genetics.Colors.ContainsKey(color.Key))
horse.Value.Genetics.Colors[color.Key] = color.Value;
}
}
}
// JSON-Datei speichern // JSON-Datei speichern
var json = JsonSerializer.Serialize(Horses, options); var json = JsonSerializer.Serialize(Horses, options);
File.WriteAllText($"{HorseDataPath}.json", json); File.WriteAllText($"{HorseDataPath}.json", json);

View file

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("HRServer")] [assembly: System.Reflection.AssemblyCompanyAttribute("HRServer")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+dceb598b52dfe3fc24772a14d69d8799841f2ed6")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+6ea0e7bc553819083e5e54f233074238b58ccf0f")]
[assembly: System.Reflection.AssemblyProductAttribute("HRServer")] [assembly: System.Reflection.AssemblyProductAttribute("HRServer")]
[assembly: System.Reflection.AssemblyTitleAttribute("HRServer")] [assembly: System.Reflection.AssemblyTitleAttribute("HRServer")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View file

@ -1 +1 @@
67964aab995a10c5597615e52369d5f3249b51e0fd1252048dd4c11c7b480717 de2d1f7d22a7dee4b24f63858221c57025d9bf1747e68570e0f4fe7cc3ef3499