Move data and data loading to plugin libraries.
continuous-integration/drone/push Build is passing

This commit is contained in:
Deukhoofd committed 2025-05-16 13:01:23 +02:00
1 parent b6ff51c9df
commit 810cdbb15a
46 files changed
+108405 -155

No files matched your search

@@ -0,0 +1,22 @@
using System.Text.Json;
using PkmnLib.Static;
using PkmnLib.Static.Libraries;
namespace PkmnLib.Dynamic.Libraries.DataLoaders;
public static class GrowthRateDataLoader
{
public static GrowthRateLibrary LoadGrowthRates(Stream stream, Action<List<IGrowthRate>>? action = null)
{
var objects = JsonSerializer.Deserialize<Dictionary<string, uint[]>>(stream, JsonOptions.DefaultOptions)!;
var growthRates = objects.Select(x => new LookupGrowthRate(x.Key, x.Value)).Cast<IGrowthRate>().ToList();
action?.Invoke(growthRates);
var library = new GrowthRateLibrary();
foreach (var growthRate in growthRates)
{
library.Add(growthRate);
}
return library;
}
}