Move data and data loading to plugin libraries.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user