mirror of
https://github.com/kwsch/PKHeX
synced 2025-02-17 05:48:44 +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
|
namespace PKHeX.Core
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Mystery Gift Template File
|
||||||
|
/// </summary>
|
||||||
public abstract class MysteryGift : IEncounterable, IMoveset
|
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>
|
/// <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)
|
public static MysteryGift GetMysteryGift(byte[] data, string ext)
|
||||||
{
|
{
|
||||||
// Generation 7
|
if (ext == null)
|
||||||
if (data.Length == WC7.SizeFull && ext == ".wc7full")
|
return GetMysteryGift(data);
|
||||||
return new WC7(data);
|
|
||||||
if (data.Length == WC7.Size && ext == ".wc7")
|
|
||||||
return new WC7(data);
|
|
||||||
|
|
||||||
// Generation 6
|
switch (data.Length)
|
||||||
if (data.Length == WC6.SizeFull && ext == ".wc6full")
|
{
|
||||||
return new WC6(data);
|
case WC7.SizeFull when ext == ".wc7full":
|
||||||
if (data.Length == WC6.Size && ext == ".wc6")
|
case WC7.Size when ext == ".wc7":
|
||||||
return new WC6(data);
|
return new WC7(data);
|
||||||
|
case WC6.SizeFull when ext == ".wc6full":
|
||||||
|
case WC6.Size when ext == ".wc6":
|
||||||
|
return new WC6(data);
|
||||||
|
|
||||||
// Generation 5
|
case PGF.Size when ext == ".pgf":
|
||||||
if (data.Length == PGF.Size && ext == ".pgf")
|
return new PGF(data);
|
||||||
return new PGF(data);
|
case PGT.Size when ext == ".pgt":
|
||||||
|
return new PGT(data);
|
||||||
// Generation 4
|
case PCD.Size when ext == ".pcd":
|
||||||
if (data.Length == PGT.Size && ext == ".pgt")
|
return new PCD(data);
|
||||||
return new PGT(data);
|
}
|
||||||
if (data.Length == PCD.Size && ext == ".pcd")
|
|
||||||
return new PCD(data);
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -69,14 +70,11 @@ namespace PKHeX.Core
|
||||||
if (BitConverter.ToUInt32(data, 0x4C) / 10000 < 2000)
|
if (BitConverter.ToUInt32(data, 0x4C) / 10000 < 2000)
|
||||||
return new WC7(data);
|
return new WC7(data);
|
||||||
return new WC6(data);
|
return new WC6(data);
|
||||||
case PGF.Size:
|
|
||||||
return new PGF(data);
|
case PGF.Size: return new PGF(data);
|
||||||
case PGT.Size:
|
case PGT.Size: return new PGT(data);
|
||||||
return new PGT(data);
|
case PCD.Size: return new PCD(data);
|
||||||
case PCD.Size:
|
default: return null;
|
||||||
return new PCD(data);
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,9 @@ using System.Text;
|
||||||
|
|
||||||
namespace PKHeX.Core
|
namespace PKHeX.Core
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Generation 5 Mystery Gift Template File
|
||||||
|
/// </summary>
|
||||||
public sealed class PGF : MysteryGift, IRibbonSetEvent3, IRibbonSetEvent4
|
public sealed class PGF : MysteryGift, IRibbonSetEvent3, IRibbonSetEvent4
|
||||||
{
|
{
|
||||||
public const int Size = 0xCC;
|
public const int Size = 0xCC;
|
||||||
|
|
|
@ -3,11 +3,15 @@ using System.Linq;
|
||||||
|
|
||||||
namespace PKHeX.Core
|
namespace PKHeX.Core
|
||||||
{
|
{
|
||||||
/* Big thanks to Grovyle91's Pokémon Mystery Gift Editor, from which the structure was referenced.
|
/// <summary>
|
||||||
* http://projectpokemon.org/forums/member.php?829-Grovyle91
|
/// Generation 4 Mystery Gift Template File
|
||||||
* http://projectpokemon.org/forums/showthread.php?6524
|
/// </summary>
|
||||||
* See also: http://tccphreak.shiny-clique.net/debugger/pcdfiles.htm
|
/// <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 sealed class PCD : MysteryGift
|
||||||
{
|
{
|
||||||
public const int Size = 0x358; // 856
|
public const int Size = 0x358; // 856
|
||||||
|
@ -106,6 +110,10 @@ namespace PKHeX.Core
|
||||||
|
|
||||||
public bool CanBeReceivedBy(int pkmVersion) => (CardCompatibility >> pkmVersion & 1) == 1;
|
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 sealed class PGT : MysteryGift
|
||||||
{
|
{
|
||||||
public const int Size = 0x104; // 260
|
public const int Size = 0x104; // 260
|
||||||
|
|
|
@ -4,6 +4,9 @@ using System.Text;
|
||||||
|
|
||||||
namespace PKHeX.Core
|
namespace PKHeX.Core
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Generation 6 Mystery Gift Template File
|
||||||
|
/// </summary>
|
||||||
public sealed class WC6 : MysteryGift, IRibbonSetEvent3, IRibbonSetEvent4
|
public sealed class WC6 : MysteryGift, IRibbonSetEvent3, IRibbonSetEvent4
|
||||||
{
|
{
|
||||||
public const int Size = 0x108;
|
public const int Size = 0x108;
|
||||||
|
|
|
@ -4,6 +4,9 @@ using System.Text;
|
||||||
|
|
||||||
namespace PKHeX.Core
|
namespace PKHeX.Core
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Generation 7 Mystery Gift Template File
|
||||||
|
/// </summary>
|
||||||
public sealed class WC7 : MysteryGift, IRibbonSetEvent3, IRibbonSetEvent4
|
public sealed class WC7 : MysteryGift, IRibbonSetEvent3, IRibbonSetEvent4
|
||||||
{
|
{
|
||||||
public const int Size = 0x108;
|
public const int Size = 0x108;
|
||||||
|
|
Loading…
Add table
Reference in a new issue