PkmnLib.NET/PkmnLib.Dataloader/GrowthRateDataLoader.cs

22 lines
608 B
C#

using System.Collections.Generic;
using System.IO;
using System.Text.Json;
using PkmnLib.Static;
using PkmnLib.Static.Libraries;
namespace PkmnLib.Dataloader;
public static class GrowthRateDataLoader
{
public static GrowthRateLibrary LoadGrowthRates(Stream stream)
{
var objects = JsonSerializer.Deserialize<Dictionary<string, uint[]>>(stream)!;
var library = new GrowthRateLibrary();
foreach (var (key, value) in objects)
{
var growthRate = new LookupGrowthRate(key, value);
library.Add(growthRate);
}
return library;
}
}