Extend core api

add copy/fetch new
This commit is contained in:
Kurt 2018-03-28 20:34:58 -07:00
parent 4cc31ea5e2
commit 314a92b67b
3 changed files with 27 additions and 0 deletions

View file

@ -7,4 +7,9 @@
{
int Generation { get; set; }
}
public static partial class Extensions
{
internal static PKM GetBlank(this IGeneration gen) => PKMConverter.GetBlank(gen.Generation);
}
}

View file

@ -18,4 +18,21 @@ namespace PKHeX.Core
int Generation { get; }
}
public static partial class Extensions
{
public static void ApplyToPKM(this ITrainerInfo info, PKM pk)
{
pk.OT_Name = info.OT;
pk.TID = info.TID;
pk.SID = info.SID;
pk.OT_Gender = info.Gender;
pk.Language = info.Language;
pk.Version = info.Game;
pk.Country = info.Country;
pk.Region = info.SubRegion;
pk.ConsoleRegion = info.ConsoleRegion;
}
}
}

View file

@ -458,5 +458,10 @@ namespace PKHeX.Core
var argCount = constructors.First().GetParameters().Length;
return (PKM)Activator.CreateInstance(t, new object[argCount]);
}
public static PKM GetBlank(int gen)
{
var type = Type.GetType($"PKHeX.Core.PK{gen}");
return GetBlank(type);
}
}
}