mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-23 04:23:12 +00:00
Add xmldoc for mystery gift class names
refactor pattern checking to simpler representation, add null abort when extension is not provided.
This commit is contained in:
parent
60562fb44e
commit
a46e56c917
5 changed files with 47 additions and 32 deletions
|
@ -3,6 +3,9 @@ using System.Linq;
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Mystery Gift Template File
|
||||
/// </summary>
|
||||
public abstract class MysteryGift : IEncounterable, IMoveset
|
||||
{
|
||||
|
||||
|
@ -25,27 +28,25 @@ namespace PKHeX.Core
|
|||
/// <remarks>This overload differs from <see cref="GetMysteryGift(byte[])"/> by checking the <paramref name="data"/>/<paramref name="ext"/> combo for validity. If either is invalid, a null reference is returned.</remarks>
|
||||
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 @@ namespace PKHeX.Core
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,9 @@ using System.Text;
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Generation 5 Mystery Gift Template File
|
||||
/// </summary>
|
||||
public sealed class PGF : MysteryGift, IRibbonSetEvent3, IRibbonSetEvent4
|
||||
{
|
||||
public const int Size = 0xCC;
|
||||
|
|
|
@ -3,11 +3,15 @@ using System.Linq;
|
|||
|
||||
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
|
||||
*/
|
||||
/// <summary>
|
||||
/// Generation 4 Mystery Gift Template File
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 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
|
||||
/// </remarks>
|
||||
public sealed class PCD : MysteryGift
|
||||
{
|
||||
public const int Size = 0x358; // 856
|
||||
|
@ -106,6 +110,10 @@ namespace PKHeX.Core
|
|||
|
||||
public bool CanBeReceivedBy(int pkmVersion) => (CardCompatibility >> pkmVersion & 1) == 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generation 4 Mystery Gift Template File (Inner Gift Data, no card data)
|
||||
/// </summary>
|
||||
public sealed class PGT : MysteryGift
|
||||
{
|
||||
public const int Size = 0x104; // 260
|
||||
|
|
|
@ -4,6 +4,9 @@ using System.Text;
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Generation 6 Mystery Gift Template File
|
||||
/// </summary>
|
||||
public sealed class WC6 : MysteryGift, IRibbonSetEvent3, IRibbonSetEvent4
|
||||
{
|
||||
public const int Size = 0x108;
|
||||
|
|
|
@ -4,6 +4,9 @@ using System.Text;
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Generation 7 Mystery Gift Template File
|
||||
/// </summary>
|
||||
public sealed class WC7 : MysteryGift, IRibbonSetEvent3, IRibbonSetEvent4
|
||||
{
|
||||
public const int Size = 0x108;
|
||||
|
|
Loading…
Reference in a new issue