PkmnLib.NET/PkmnLib.Dataloader/CommonDataLoaderHelper.cs

21 lines
686 B
C#
Raw Normal View History

2025-01-10 10:11:50 +00:00
using System.Collections.Generic;
using System.Linq;
using PkmnLib.Dataloader.Models;
using PkmnLib.Static.Moves;
using PkmnLib.Static.Utils;
namespace PkmnLib.Dataloader;
internal static class CommonDataLoaderHelper
{
internal static ISecondaryEffect? ParseEffect(this SerializedMoveEffect? effect)
{
if (effect == null)
return null;
var name = effect.Name;
2025-03-08 13:39:50 +00:00
var chance = effect.Chance ?? -1;
2025-01-10 10:11:50 +00:00
var parameters = effect.Parameters?.ToDictionary(x => (StringKey)x.Key, x => x.Value.ToParameter()) ??
new Dictionary<StringKey, object?>();
return new SecondaryEffectImpl(chance, name, parameters);
}
}