diff --git a/PkmnLib.Dataloader/AbilityDataLoader.cs b/PkmnLib.Dataloader/AbilityDataLoader.cs index c444f44..7fecc39 100644 --- a/PkmnLib.Dataloader/AbilityDataLoader.cs +++ b/PkmnLib.Dataloader/AbilityDataLoader.cs @@ -12,9 +12,8 @@ namespace PkmnLib.Dataloader; public static class AbilityDataLoader { - public static AbilityLibrary LoadAbilities(Stream stream) + private static Dictionary LoadAbilitiesData(Stream stream) { - var library = new AbilityLibrary(); var obj = JsonSerializer.Deserialize(stream); if (obj == null) throw new InvalidDataException("Ability data is empty."); @@ -28,13 +27,34 @@ public static class AbilityDataLoader }); if (objects == null) throw new InvalidDataException("Ability data is empty."); + return objects; + } + + public static AbilityLibrary LoadAbilities(Stream[] streams) + { + var library = new AbilityLibrary(); + var objects = streams.SelectMany(LoadAbilitiesData); + if (objects == null) + throw new InvalidDataException("Ability data is empty."); + var abilities = objects.Select(x => DeserializeAbility(x.Key, x.Value)); + foreach (var a in abilities) + library.Add(a); + return library; + } + + public static AbilityLibrary LoadAbilities(Stream stream) + { + var library = new AbilityLibrary(); + var objects = LoadAbilitiesData(stream); + if (objects == null) + throw new InvalidDataException("Ability data is empty."); var abilities = objects.Select(x => DeserializeAbility(x.Key, x.Value)); foreach (var a in abilities) library.Add(a); return library; } - + private static AbilityImpl DeserializeAbility(string name, SerializedAbility serialized) { var effect = serialized.Effect;