mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-09-07 23:08:47 -05:00
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:
21
PKHeX.Core/Legality/Structures/ITrainerInfo.cs
Normal file
21
PKHeX.Core/Legality/Structures/ITrainerInfo.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
@@ -80,7 +80,7 @@ public static MysteryGift GetMysteryGift(byte[] data)
|
||||
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>
|
||||
|
||||
@@ -149,7 +149,7 @@ public override int CardID
|
||||
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;
|
||||
|
||||
@@ -112,7 +112,7 @@ public bool GiftEquals(PGT pgt)
|
||||
return true;
|
||||
}
|
||||
|
||||
public override PKM ConvertToPKM(SaveFile SAV)
|
||||
public override PKM ConvertToPKM(ITrainerInfo SAV)
|
||||
{
|
||||
return Gift.ConvertToPKM(SAV);
|
||||
}
|
||||
@@ -233,7 +233,7 @@ private void EncryptPK()
|
||||
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;
|
||||
|
||||
@@ -60,9 +60,8 @@ public int Met_Level
|
||||
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 @@ public override PKM ConvertToPKM(SaveFile SAV)
|
||||
|
||||
FatefulEncounter = Fateful,
|
||||
};
|
||||
var pi = pk.PersonalInfo;
|
||||
|
||||
if (Version == 0)
|
||||
{
|
||||
|
||||
@@ -278,7 +278,7 @@ public override int[] RelearnMoves
|
||||
}
|
||||
}
|
||||
|
||||
public override PKM ConvertToPKM(SaveFile SAV)
|
||||
public override PKM ConvertToPKM(ITrainerInfo SAV)
|
||||
{
|
||||
if (!IsPokémon)
|
||||
return null;
|
||||
|
||||
@@ -302,7 +302,7 @@ public override int[] RelearnMoves
|
||||
}
|
||||
}
|
||||
|
||||
public override PKM ConvertToPKM(SaveFile SAV)
|
||||
public override PKM ConvertToPKM(ITrainerInfo SAV)
|
||||
{
|
||||
if (!IsPokémon)
|
||||
return null;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user