mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-27 06:20:25 +00:00
Add pk6/pk7 differentiation
Moves a lot of const values from SAV to Legal for reuse. Closes #754
This commit is contained in:
parent
c93a4bf217
commit
c401781526
15 changed files with 111 additions and 46 deletions
|
@ -5,8 +5,10 @@ namespace PKHeX.Core
|
|||
public static partial class Legal
|
||||
{
|
||||
internal const int MaxSpeciesID_1 = 151;
|
||||
|
||||
// PKHeX Valid Array Storage
|
||||
internal const int MaxMoveID_1 = 165;
|
||||
internal const int MaxItemID_1 = 255;
|
||||
internal const int MaxAbilityID_1 = 0;
|
||||
|
||||
internal static readonly ushort[] Pouch_Items_RBY = Enumerable.Range(0, 7) // 0-6
|
||||
.Concat(Enumerable.Range(10, 11)) // 10-20
|
||||
.Concat(Enumerable.Range(29, 15)) // 29-43
|
||||
|
|
|
@ -5,8 +5,10 @@ namespace PKHeX.Core
|
|||
public static partial class Legal
|
||||
{
|
||||
internal const int MaxSpeciesID_2 = 251;
|
||||
|
||||
// PKHeX Valid Array Storage
|
||||
internal const int MaxMoveID_2 = 251;
|
||||
internal const int MaxItemID_2 = 255;
|
||||
internal const int MaxAbilityID_2 = 0;
|
||||
|
||||
internal static readonly ushort[] Pouch_Items_GSC = {
|
||||
3, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 46, 47, 48, 49, 51, 52, 53, 57, 60, 62, 63, 64, 65, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 91, 92, 93, 94, 95, 96, 97, 98, 99, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 117, 118, 119, 121, 122, 123, 124, 125, 126, 131, 132, 138, 139, 140, 143, 144, 146, 150, 151, 152, 156, 158, 163, 168, 169, 170, 172, 173, 174, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189
|
||||
};
|
||||
|
|
|
@ -5,8 +5,11 @@ namespace PKHeX.Core
|
|||
public static partial class Legal
|
||||
{
|
||||
internal const int MaxSpeciesID_3 = 386;
|
||||
|
||||
// PKHeX Valid Array Storage
|
||||
internal const int MaxMoveID_3 = 354;
|
||||
internal const int MaxItemID_3 = 374;
|
||||
internal const int MaxAbilityID_3 = 77;
|
||||
internal const int MaxBallID_3 = 0xC;
|
||||
|
||||
#region RS
|
||||
internal static readonly ushort[] Pouch_Items_RS = {
|
||||
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 63, 64, 65, 66, 67, 68, 69, 70, 71, 73, 74, 75, 76, 77, 78, 79, 80, 81, 83, 84, 85, 86, 93, 94, 95, 96, 97, 98, 103, 104, 106, 107, 108, 109, 110, 111, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 254, 255, 256, 257, 258
|
||||
|
|
|
@ -5,8 +5,12 @@ namespace PKHeX.Core
|
|||
public static partial class Legal
|
||||
{
|
||||
internal const int MaxSpeciesID_4 = 493;
|
||||
|
||||
// PKHeX Valid Array Storage
|
||||
internal const int MaxMoveID_4 = 467;
|
||||
internal const int MaxItemID_4_DP = 464;
|
||||
internal const int MaxItemID_4_Pt = 467;
|
||||
internal const int MaxItemID_4_HGSS = 536;
|
||||
internal const int MaxAbilityID_4 = 123;
|
||||
internal const int MaxBallID_4 = 0x18;
|
||||
|
||||
internal static readonly int[] Met_HGSS_0 =
|
||||
{
|
||||
|
|
|
@ -5,8 +5,12 @@ namespace PKHeX.Core
|
|||
public static partial class Legal
|
||||
{
|
||||
internal const int MaxSpeciesID_5 = 649;
|
||||
|
||||
// PKHeX Valid Array Storage
|
||||
internal const int MaxMoveID_5 = 559;
|
||||
internal const int MaxItemID_5_BW = 632;
|
||||
internal const int MaxItemID_5_B2W2 = 638;
|
||||
internal const int MaxAbilityID_5 = 164;
|
||||
internal const int MaxBallID_5 = 0x19;
|
||||
internal const int MaxGameID_5 = 23; // B2
|
||||
|
||||
internal static readonly int[] Met_BW2c = { 0, 60002, 30003 };
|
||||
|
||||
|
|
|
@ -5,8 +5,14 @@ namespace PKHeX.Core
|
|||
public static partial class Legal
|
||||
{
|
||||
internal const int MaxSpeciesID_6 = 721;
|
||||
|
||||
// PKHeX Valid Array Storage
|
||||
internal const int MaxMoveID_6_XY = 617;
|
||||
internal const int MaxMoveID_6_AO = 621;
|
||||
internal const int MaxItemID_6_XY = 717;
|
||||
internal const int MaxItemID_6_AO = 775;
|
||||
internal const int MaxAbilityID_6_XY = 188;
|
||||
internal const int MaxAbilityID_6_AO = 191;
|
||||
internal const int MaxBallID_6 = 0x19;
|
||||
internal const int MaxGameID_6 = 27; // OR
|
||||
|
||||
#region Met Locations
|
||||
internal static readonly int[] Met_XYc = {0, 60002, 30002,};
|
||||
|
|
|
@ -5,7 +5,11 @@ namespace PKHeX.Core
|
|||
public static partial class Legal
|
||||
{
|
||||
internal const int MaxSpeciesID_7 = 802;
|
||||
// PKHeX Valid Array Storage
|
||||
internal const int MaxMoveID_7 = 720;
|
||||
internal const int MaxItemID_7 = 920;
|
||||
internal const int MaxAbilityID_7 = 232;
|
||||
internal const int MaxBallID_7 = 0x1A; // 26
|
||||
internal const int MaxGameID_7 = 38; // Yellow VC
|
||||
|
||||
#region Met Locations
|
||||
|
||||
|
|
|
@ -109,14 +109,54 @@ namespace PKHeX.Core
|
|||
case 5:
|
||||
return new PK5(data, ident);
|
||||
case 6:
|
||||
PKM pkx = new PK6(data, ident);
|
||||
if (pkx.SM || pkx.VC || pkx.Horohoro)
|
||||
pkx = new PK7(data, ident);
|
||||
return pkx;
|
||||
var pkx = new PK6(data, ident);
|
||||
return checkPKMFormat7(pkx);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the input PK6 file is really a PK7, if so, updates the object.
|
||||
/// </summary>
|
||||
/// <param name="pk">PKM to check</param>
|
||||
/// <returns>Updated PKM if actually PK7</returns>
|
||||
private static PKM checkPKMFormat7(PK6 pk) => checkPK6is7(pk) ? new PK7(pk.Data, pk.Identifier) : (PKM)pk;
|
||||
/// <summary>
|
||||
/// Checks if the input PK6 file is really a PK7.
|
||||
/// </summary>
|
||||
/// <param name="pk">PKM to check</param>
|
||||
/// <returns>Boolean is a PK7</returns>
|
||||
private static bool checkPK6is7(PK6 pk)
|
||||
{
|
||||
if (pk.Version > Legal.MaxGameID_6)
|
||||
return true;
|
||||
if (pk.Geo1_Country != 0)
|
||||
return false;
|
||||
|
||||
int lvl = pk.CurrentLevel;
|
||||
if (lvl < 100 && pk.EncounterType != 0)
|
||||
return false;
|
||||
if (pk.EncounterType > 24)
|
||||
return true;
|
||||
|
||||
if (pk.Enjoyment != 0 || pk.Fullness != 0)
|
||||
return false;
|
||||
|
||||
// Check Ranges
|
||||
if (pk.Species > Legal.MaxSpeciesID_6)
|
||||
return true;
|
||||
if (pk.Moves.Any(move => move > Legal.MaxMoveID_6_AO))
|
||||
return true;
|
||||
if (pk.RelearnMoves.Any(move => move > Legal.MaxMoveID_6_AO))
|
||||
return true;
|
||||
if (pk.Ability > Legal.MaxAbilityID_6_AO)
|
||||
return true;
|
||||
if (pk.HeldItem > Legal.MaxItemID_6_AO)
|
||||
return true;
|
||||
|
||||
return false; // 6
|
||||
}
|
||||
|
||||
public static PKM convertToFormat(PKM pk, Type PKMType, out string comment)
|
||||
{
|
||||
|
|
|
@ -168,10 +168,10 @@ namespace PKHeX.Core
|
|||
public override PKM BlankPKM => new PK1(null, null, Japanese);
|
||||
public override Type PKMType => typeof(PK1);
|
||||
|
||||
public override int MaxMoveID => 165;
|
||||
public override int MaxMoveID => Legal.MaxMoveID_1;
|
||||
public override int MaxSpeciesID => Legal.MaxSpeciesID_1;
|
||||
public override int MaxAbilityID => 0;
|
||||
public override int MaxItemID => 255;
|
||||
public override int MaxAbilityID => Legal.MaxAbilityID_1;
|
||||
public override int MaxItemID => Legal.MaxItemID_1;
|
||||
public override int MaxBallID => 0;
|
||||
public override int MaxGameID => 99; // What do I set this to...?
|
||||
public override int MaxMoney => 999999;
|
||||
|
|
|
@ -219,10 +219,10 @@ namespace PKHeX.Core
|
|||
private int SIZE_BOX => BoxSlotCount*SIZE_STORED;
|
||||
private int SIZE_STOREDBOX => PokemonList2.GetDataLength(Japanese ? PokemonList2.CapacityType.StoredJP : PokemonList2.CapacityType.Stored, Japanese);
|
||||
|
||||
public override int MaxMoveID => 251;
|
||||
public override int MaxMoveID => Legal.MaxMoveID_2;
|
||||
public override int MaxSpeciesID => Legal.MaxSpeciesID_2;
|
||||
public override int MaxAbilityID => 0;
|
||||
public override int MaxItemID => 255;
|
||||
public override int MaxAbilityID => Legal.MaxAbilityID_2;
|
||||
public override int MaxItemID => Legal.MaxItemID_2;
|
||||
public override int MaxBallID => 0;
|
||||
public override int MaxGameID => 99; // What do I set this to...?
|
||||
public override int MaxMoney => 999999;
|
||||
|
|
|
@ -166,11 +166,11 @@ namespace PKHeX.Core
|
|||
public override PKM BlankPKM => new PK3();
|
||||
public override Type PKMType => typeof(PK3);
|
||||
|
||||
public override int MaxMoveID => 354;
|
||||
public override int MaxMoveID => Legal.MaxMoveID_3;
|
||||
public override int MaxSpeciesID => Legal.MaxSpeciesID_3;
|
||||
public override int MaxAbilityID => 77;
|
||||
public override int MaxItemID => 374;
|
||||
public override int MaxBallID => 0xC;
|
||||
public override int MaxAbilityID => Legal.MaxAbilityID_3;
|
||||
public override int MaxItemID => Legal.MaxItemID_3;
|
||||
public override int MaxBallID => Legal.MaxBallID_3;
|
||||
public override int MaxGameID => 5;
|
||||
|
||||
public override int BoxCount => 14;
|
||||
|
|
|
@ -56,11 +56,11 @@ namespace PKHeX.Core
|
|||
public override int NickLength => 10;
|
||||
public override int MaxMoney => 999999;
|
||||
|
||||
public override int MaxMoveID => 467;
|
||||
public override int MaxMoveID => Legal.MaxMoveID_4;
|
||||
public override int MaxSpeciesID => Legal.MaxSpeciesID_4;
|
||||
public override int MaxItemID => Version == GameVersion.HGSS ? 536 : Version == GameVersion.Pt ? 467 : 464;
|
||||
public override int MaxAbilityID => 123;
|
||||
public override int MaxBallID => 0x18;
|
||||
public override int MaxItemID => Version == GameVersion.HGSS ? Legal.MaxItemID_4_HGSS : Version == GameVersion.Pt ? Legal.MaxItemID_4_Pt : Legal.MaxItemID_4_DP;
|
||||
public override int MaxAbilityID => Legal.MaxAbilityID_4;
|
||||
public override int MaxBallID => Legal.MaxBallID_4;
|
||||
public override int MaxGameID => 15; // Colo/XD
|
||||
|
||||
// Checksums
|
||||
|
|
|
@ -108,12 +108,12 @@ namespace PKHeX.Core
|
|||
protected override int EventConstMax => 0x35E/2;
|
||||
protected override int GiftCountMax => 12;
|
||||
|
||||
public override int MaxMoveID => 559;
|
||||
public override int MaxMoveID => Legal.MaxMoveID_5;
|
||||
public override int MaxSpeciesID => Legal.MaxSpeciesID_5;
|
||||
public override int MaxItemID => Version == GameVersion.BW ? 632 : 638;
|
||||
public override int MaxAbilityID => 164;
|
||||
public override int MaxBallID => 0x19;
|
||||
public override int MaxGameID => 23; // B2
|
||||
public override int MaxItemID => Version == GameVersion.BW ? Legal.MaxItemID_5_BW : Legal.MaxItemID_5_B2W2;
|
||||
public override int MaxAbilityID => Legal.MaxAbilityID_5;
|
||||
public override int MaxBallID => Legal.MaxBallID_5;
|
||||
public override int MaxGameID => Legal.MaxGameID_5; // B2
|
||||
|
||||
// Blocks & Offsets
|
||||
private BlockInfo[] Blocks;
|
||||
|
|
|
@ -44,12 +44,12 @@ namespace PKHeX.Core
|
|||
public override int OTLength => 12;
|
||||
public override int NickLength => 12;
|
||||
|
||||
public override int MaxMoveID => XY ? 617 : 621;
|
||||
public override int MaxMoveID => XY ? Legal.MaxMoveID_6_XY : Legal.MaxMoveID_6_AO;
|
||||
public override int MaxSpeciesID => Legal.MaxSpeciesID_6;
|
||||
public override int MaxItemID => XY ? 717 : 775;
|
||||
public override int MaxAbilityID => XY ? 188 : 191;
|
||||
public override int MaxBallID => 0x19;
|
||||
public override int MaxGameID => 27; // OR
|
||||
public override int MaxItemID => XY ? Legal.MaxItemID_6_XY : Legal.MaxItemID_6_AO;
|
||||
public override int MaxAbilityID => XY ? Legal.MaxAbilityID_6_XY : Legal.MaxAbilityID_6_AO;
|
||||
public override int MaxBallID => Legal.MaxBallID_6;
|
||||
public override int MaxGameID => Legal.MaxGameID_6; // OR
|
||||
|
||||
// Feature Overrides
|
||||
public override bool HasGeolocation => true;
|
||||
|
|
|
@ -80,12 +80,12 @@ namespace PKHeX.Core
|
|||
public override int OTLength => 12;
|
||||
public override int NickLength => 12;
|
||||
|
||||
public override int MaxMoveID => 720;
|
||||
public override int MaxMoveID => Legal.MaxMoveID_7;
|
||||
public override int MaxSpeciesID => Legal.MaxSpeciesID_7;
|
||||
public override int MaxItemID => 920;
|
||||
public override int MaxAbilityID => 232;
|
||||
public override int MaxBallID => 0x1A; // 26
|
||||
public override int MaxGameID => 38; // Yellow VC
|
||||
public override int MaxItemID => Legal.MaxItemID_7;
|
||||
public override int MaxAbilityID => Legal.MaxAbilityID_7;
|
||||
public override int MaxBallID => Legal.MaxBallID_7; // 26
|
||||
public override int MaxGameID => Legal.MaxGameID_7;
|
||||
|
||||
public int QRSaveData;
|
||||
|
||||
|
|
Loading…
Reference in a new issue