22 lines
737 B
C#
22 lines
737 B
C#
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;
|
|
}
|
|
} |