Extract minimum trainer information requirements

If one wanted to extend ConvertToPKM to other IEncounterables, this
would be the provided obj containing the receiver's info

allows pkm gen without a savefile, which is nice?
This commit is contained in:
Kurt 2018-03-28 15:55:19 -07:00
parent 78616e1ad5
commit a0eb658ef2
8 changed files with 30 additions and 9 deletions

View file

@ -0,0 +1,21 @@
namespace PKHeX.Core
{
/// <summary>
/// Minimal Trainer Information necessary for generating a <see cref="PKM"/>.
/// </summary>
public interface ITrainerInfo
{
string OT { get; }
ushort TID { get; }
ushort SID { get; }
int Gender { get; }
int Game { get; }
int Language { get; }
int Country { get; }
int SubRegion { get; }
int ConsoleRegion { get; }
int Generation { get; }
}
}

View file

@ -80,7 +80,7 @@ namespace PKHeX.Core
public string Extension => GetType().Name.ToLower();
public string FileName => $"{CardHeader}.{Extension}";
public byte[] Data { get; set; }
public abstract PKM ConvertToPKM(SaveFile SAV);
public abstract PKM ConvertToPKM(ITrainerInfo sav);
public abstract int Format { get; }
/// <summary>

View file

@ -149,7 +149,7 @@ namespace PKHeX.Core
public override bool IsItem { get => CardType == 2; set { if (value) CardType = 2; } }
public bool IsPower { get => CardType == 3; set { if (value) CardType = 3; } }
public override PKM ConvertToPKM(SaveFile SAV)
public override PKM ConvertToPKM(ITrainerInfo SAV)
{
if (!IsPokémon)
return null;

View file

@ -112,7 +112,7 @@ namespace PKHeX.Core
return true;
}
public override PKM ConvertToPKM(SaveFile SAV)
public override PKM ConvertToPKM(ITrainerInfo SAV)
{
return Gift.ConvertToPKM(SAV);
}
@ -233,7 +233,7 @@ namespace PKHeX.Core
public override int Location { get => PK.Met_Location; set => PK.Met_Location = value; }
public override int EggLocation { get => PK.Egg_Location; set => PK.Egg_Location = value; }
public override PKM ConvertToPKM(SaveFile SAV)
public override PKM ConvertToPKM(ITrainerInfo SAV)
{
if (!IsPokémon)
return null;

View file

@ -60,9 +60,8 @@ namespace PKHeX.Core
set => _metLevel = value;
}
public override PKM ConvertToPKM(SaveFile SAV)
public override PKM ConvertToPKM(ITrainerInfo SAV)
{
var pi = SAV.Personal.GetFormeEntry(Species, 0);
PK3 pk = new PK3
{
Species = Species,
@ -82,6 +81,7 @@ namespace PKHeX.Core
FatefulEncounter = Fateful,
};
var pi = pk.PersonalInfo;
if (Version == 0)
{

View file

@ -278,7 +278,7 @@ namespace PKHeX.Core
}
}
public override PKM ConvertToPKM(SaveFile SAV)
public override PKM ConvertToPKM(ITrainerInfo SAV)
{
if (!IsPokémon)
return null;

View file

@ -302,7 +302,7 @@ namespace PKHeX.Core
}
}
public override PKM ConvertToPKM(SaveFile SAV)
public override PKM ConvertToPKM(ITrainerInfo SAV)
{
if (!IsPokémon)
return null;

View file

@ -8,7 +8,7 @@ namespace PKHeX.Core
/// <summary>
/// Base Class for Save Files
/// </summary>
public abstract class SaveFile
public abstract class SaveFile : ITrainerInfo
{
public static bool SetUpdateDex { protected get; set; } = true;
public static bool SetUpdatePKM { protected get; set; } = true;