Support multiple ability sources
This commit is contained in:
parent
1df35c1f50
commit
f86ef53d51
|
@ -12,9 +12,8 @@ namespace PkmnLib.Dataloader;
|
|||
|
||||
public static class AbilityDataLoader
|
||||
{
|
||||
public static AbilityLibrary LoadAbilities(Stream stream)
|
||||
private static Dictionary<string, SerializedAbility> LoadAbilitiesData(Stream stream)
|
||||
{
|
||||
var library = new AbilityLibrary();
|
||||
var obj = JsonSerializer.Deserialize<JsonObject>(stream);
|
||||
if (obj == null)
|
||||
throw new InvalidDataException("Ability data is empty.");
|
||||
|
@ -28,6 +27,27 @@ 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)
|
||||
|
|
Loading…
Reference in New Issue