diff --git a/PKHeX.Core/MysteryGifts/MysteryGift.cs b/PKHeX.Core/MysteryGifts/MysteryGift.cs index 58d664397..5059ff377 100644 --- a/PKHeX.Core/MysteryGifts/MysteryGift.cs +++ b/PKHeX.Core/MysteryGifts/MysteryGift.cs @@ -3,6 +3,9 @@ namespace PKHeX.Core { + /// + /// Mystery Gift Template File + /// public abstract class MysteryGift : IEncounterable, IMoveset { @@ -25,27 +28,25 @@ public static bool IsMysteryGift(long len) /// This overload differs from by checking the / combo for validity. If either is invalid, a null reference is returned. public static MysteryGift GetMysteryGift(byte[] data, string ext) { - // Generation 7 - if (data.Length == WC7.SizeFull && ext == ".wc7full") - return new WC7(data); - if (data.Length == WC7.Size && ext == ".wc7") - return new WC7(data); + if (ext == null) + return GetMysteryGift(data); - // Generation 6 - if (data.Length == WC6.SizeFull && ext == ".wc6full") - return new WC6(data); - if (data.Length == WC6.Size && ext == ".wc6") - return new WC6(data); + switch (data.Length) + { + case WC7.SizeFull when ext == ".wc7full": + case WC7.Size when ext == ".wc7": + return new WC7(data); + case WC6.SizeFull when ext == ".wc6full": + case WC6.Size when ext == ".wc6": + return new WC6(data); - // Generation 5 - if (data.Length == PGF.Size && ext == ".pgf") - return new PGF(data); - - // Generation 4 - if (data.Length == PGT.Size && ext == ".pgt") - return new PGT(data); - if (data.Length == PCD.Size && ext == ".pcd") - return new PCD(data); + case PGF.Size when ext == ".pgf": + return new PGF(data); + case PGT.Size when ext == ".pgt": + return new PGT(data); + case PCD.Size when ext == ".pcd": + return new PCD(data); + } return null; } @@ -69,14 +70,11 @@ public static MysteryGift GetMysteryGift(byte[] data) if (BitConverter.ToUInt32(data, 0x4C) / 10000 < 2000) return new WC7(data); return new WC6(data); - case PGF.Size: - return new PGF(data); - case PGT.Size: - return new PGT(data); - case PCD.Size: - return new PCD(data); - default: - return null; + + case PGF.Size: return new PGF(data); + case PGT.Size: return new PGT(data); + case PCD.Size: return new PCD(data); + default: return null; } } diff --git a/PKHeX.Core/MysteryGifts/PGF.cs b/PKHeX.Core/MysteryGifts/PGF.cs index 4b26e8380..09f314796 100644 --- a/PKHeX.Core/MysteryGifts/PGF.cs +++ b/PKHeX.Core/MysteryGifts/PGF.cs @@ -3,6 +3,9 @@ namespace PKHeX.Core { + /// + /// Generation 5 Mystery Gift Template File + /// public sealed class PGF : MysteryGift, IRibbonSetEvent3, IRibbonSetEvent4 { public const int Size = 0xCC; diff --git a/PKHeX.Core/MysteryGifts/PGT.cs b/PKHeX.Core/MysteryGifts/PGT.cs index 7bd836923..49db2c1f2 100644 --- a/PKHeX.Core/MysteryGifts/PGT.cs +++ b/PKHeX.Core/MysteryGifts/PGT.cs @@ -3,11 +3,15 @@ namespace PKHeX.Core { - /* Big thanks to Grovyle91's Pokémon Mystery Gift Editor, from which the structure was referenced. - * http://projectpokemon.org/forums/member.php?829-Grovyle91 - * http://projectpokemon.org/forums/showthread.php?6524 - * See also: http://tccphreak.shiny-clique.net/debugger/pcdfiles.htm - */ + /// + /// Generation 4 Mystery Gift Template File + /// + /// + /// Big thanks to Grovyle91's Pokémon Mystery Gift Editor, from which the structure was referenced. + /// http://projectpokemon.org/forums/member.php?829-Grovyle91 + /// http://projectpokemon.org/forums/showthread.php?6524 + /// See also: http://tccphreak.shiny-clique.net/debugger/pcdfiles.htm + /// public sealed class PCD : MysteryGift { public const int Size = 0x358; // 856 @@ -106,6 +110,10 @@ public override PKM ConvertToPKM(SaveFile SAV) public bool CanBeReceivedBy(int pkmVersion) => (CardCompatibility >> pkmVersion & 1) == 1; } + + /// + /// Generation 4 Mystery Gift Template File (Inner Gift Data, no card data) + /// public sealed class PGT : MysteryGift { public const int Size = 0x104; // 260 diff --git a/PKHeX.Core/MysteryGifts/WC6.cs b/PKHeX.Core/MysteryGifts/WC6.cs index de74f6fe1..0eb5e50f9 100644 --- a/PKHeX.Core/MysteryGifts/WC6.cs +++ b/PKHeX.Core/MysteryGifts/WC6.cs @@ -4,6 +4,9 @@ namespace PKHeX.Core { + /// + /// Generation 6 Mystery Gift Template File + /// public sealed class WC6 : MysteryGift, IRibbonSetEvent3, IRibbonSetEvent4 { public const int Size = 0x108; diff --git a/PKHeX.Core/MysteryGifts/WC7.cs b/PKHeX.Core/MysteryGifts/WC7.cs index 71f0031e3..9c89afdc3 100644 --- a/PKHeX.Core/MysteryGifts/WC7.cs +++ b/PKHeX.Core/MysteryGifts/WC7.cs @@ -4,6 +4,9 @@ namespace PKHeX.Core { + /// + /// Generation 7 Mystery Gift Template File + /// public sealed class WC7 : MysteryGift, IRibbonSetEvent3, IRibbonSetEvent4 { public const int Size = 0x108;