diff --git a/Directory.Build.props b/Directory.Build.props index 8db53cbb..75fa77d9 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,8 +1,8 @@ - 13 + 14 enable - net9.0 + net10.0 en pkNX Project Pokémon diff --git a/README.md b/README.md index b27bd75b..8b133c78 100644 --- a/README.md +++ b/README.md @@ -43,9 +43,9 @@ pkNX also provides some utility to extract from supported container types, e.g. ## Building -pkNX is a Windows Forms application which requires [.NET 9.0](https://dotnet.microsoft.com/download/dotnet/9.0). +pkNX is a Windows Forms application which requires [.NET 10.0](https://dotnet.microsoft.com/download/dotnet/10.0). -The executable can be built with any compiler that supports C# 13. +The executable can be built with any compiler that supports C# 14. ## Dependencies diff --git a/pkNX.Structures/GameUtil.cs b/pkNX.Structures/GameUtil.cs index 27eed47e..c362bf62 100644 --- a/pkNX.Structures/GameUtil.cs +++ b/pkNX.Structures/GameUtil.cs @@ -7,25 +7,6 @@ namespace pkNX.Structures; /// public static class GameUtil { - /// - /// Gets a Version ID from the end of that Generation - /// - /// Generation ID - /// Version ID from requested generation. If none, return . - public static GameVersion GetVersion(int generation) => generation switch - { - 1 => RBY, - 2 => C, - 3 => E, - 4 => SS, - 5 => W2, - 6 => AS, - 7 => UM, - 8 => SH, - 9 => VL, - _ => Invalid, - }; - /// /// Gets the Generation the belongs to. /// @@ -40,113 +21,92 @@ public static int GetGeneration(this GameVersion game) if (Gen5.Contains(game)) return 5; if (Gen6.Contains(game)) return 6; if (Gen7.Contains(game)) return 7; - if (Gen8.Contains(game)) return 8; - if (Gen9.Contains(game)) return 9; + if (Gen7b.Contains(game)) return 7; + if (SWSH.Contains(game)) return 8; + if (game is PLA) return 8; + if (BDSP.Contains(game)) return 8; + if (SV.Contains(game)) return 9; + if (game is ZA) return 9; return -1; } /// - /// Gets the Generation the belongs to. + /// Checks if the version (or subset versions) is equivalent to . /// - /// Game to retrieve the generation for - /// Generation ID - public static int GetMaxSpeciesID(this GameVersion game) - { - if (Gen1.Contains(game)) return 151; - if (Gen2.Contains(game)) return 251; - if (Gen3.Contains(game)) return 384; - if (Gen4.Contains(game)) return 493; - if (Gen5.Contains(game)) return 649; - if (Gen6.Contains(game)) return Legal.MaxSpeciesID_6; - if (Gen7.Contains(game) || Gen7b.Contains(game)) - { - if (SM.Contains(game)) - return 802; - if (USUM.Contains(game)) - return 807; - return Legal.MaxSpeciesID_7_GG; - } - if (Gen8.Contains(game)) - { - if (SWSH.Contains(game)) - return Legal.MaxSpeciesID_8; - return Legal.MaxSpeciesID_8a; - } - - if (game is ZA) - return Legal.MaxSpeciesID_9a; - - if (Gen9.Contains(game)) - { - return Legal.MaxSpeciesID_9; - } - return -1; - } - - /// - /// Checks if the version (or subset versions) is equivalent to . - /// - /// Version (set) + /// Version (set) /// Individual version - public static bool Contains(this GameVersion g1, int g2) => g1.Contains((GameVersion)g2); - - /// - /// Checks if the version (or subset versions) is equivalent to . - /// - /// Version (set) - /// Individual version - public static bool Contains(this GameVersion g1, GameVersion g2) + public static bool Contains(this GameVersion version, GameVersion g2) { - if (g1 == g2 || g1 == Any) + if (version == g2 || version == Any) return true; - - return g1 switch - { - RB => g2 is RD or BU or GN, - RBY or Stadium => RB.Contains(g2) || g2 == YW, - Gen1 => RBY.Contains(g2) || g2 == Stadium, - - GS => g2 is GD or SV, - GSC or Stadium2 => GS.Contains(g2) || g2 == C, - Gen2 => GSC.Contains(g2) || g2 == Stadium2, - - RS => g2 is R or S, - RSE => RS.Contains(g2) || g2 == E, - FRLG => g2 is FR or LG, - COLO or XD => g2 == CXD, - CXD => g2 is COLO or XD, - RSBOX => RS.Contains(g2) || g2 == E || FRLG.Contains(g2), - Gen3 => RSE.Contains(g2) || FRLG.Contains(g2) || CXD.Contains(g2) || g2 == RSBOX, - - DP => g2 is D or P, - HGSS => g2 is HG or SS, - DPPt => DP.Contains(g2) || g2 == Pt, - BATREV => DP.Contains(g2) || g2 == Pt || HGSS.Contains(g2), - Gen4 => DPPt.Contains(g2) || HGSS.Contains(g2) || g2 == BATREV, - - BW => g2 is B or W, - B2W2 => g2 is B2 or W2, - Gen5 => BW.Contains(g2) || B2W2.Contains(g2), - - XY => g2 is X or Y, - ORAS => g2 is OR or AS, - - Gen6 => XY.Contains(g2) || ORAS.Contains(g2), - SM => g2 is SN or MN, - USUM => g2 is US or UM, - GG => g2 is GP or GE, - Gen7 => SM.Contains(g2) || USUM.Contains(g2), - Gen7b => GG.Contains(g2) || GO == g2, - - SWSH => g2 is SW or SH, - PLA => g2 is PLA, - Gen8 => SWSH.Contains(g2) || PLA.Contains(g2), - - SV => g2 is SL or VL, - ZA => g2 is ZA, - Gen9 => SV.Contains(g2) || ZA.Contains(g2), - - _ => false, - }; + if (version.IsValidSavedVersion()) + return false; + return version.ContainsFromLumped(g2); } + + /// + /// Most recent game ID utilized by official games. + /// + internal const GameVersion HighestGameID = RB - 1; + + /// + /// Indicates if the value is a value used by the games or is an aggregate indicator. + /// + public static bool IsValidSavedVersion(this GameVersion version) => version is > 0 and <= HighestGameID; + + /// + /// Checks if the version (or subset versions) is equivalent to . + /// + /// Version (set) + /// Individual version + public static bool ContainsFromLumped(this GameVersion g1, GameVersion version1) => g1 switch + { + RB => version1 is RD or BU or GN, + RBY => version1 is RD or BU or GN or YW or RB, + Stadium => version1 is RD or BU or GN or YW or RB or RBY, + StadiumJ => version1 is RD or BU or GN or YW or RB or RBY, + Gen1 => version1 is RD or BU or GN or YW or RB or RBY or Stadium, + + GS => version1 is GD or SI, + GSC => version1 is GD or SI or C or GS, + Stadium2 => version1 is GD or SI or C or GS or GSC, + Gen2 => version1 is GD or SI or C or GS or GSC or Stadium2, + + RS => version1 is R or S, + RSE => version1 is R or S or E or RS, + FRLG => version1 is FR or LG, + RSBOX => version1 is R or S or E or FR or LG, + Gen3 => version1 is R or S or E or FR or LG or CXD or RSBOX or RS or RSE or FRLG, + COLO => version1 is CXD, + XD => version1 is CXD, + + DP => version1 is D or P, + HGSS => version1 is HG or SS, + DPPt => version1 is D or P or Pt or DP, + Gen4 => version1 is D or P or Pt or HG or SS or BATREV or DP or HGSS or DPPt, + + BW => version1 is B or W, + B2W2 => version1 is B2 or W2, + Gen5 => version1 is B or W or B2 or W2 or BW or B2W2, + + XY => version1 is X or Y, + ORAS => version1 is OR or AS, + Gen6 => version1 is X or Y or OR or AS or XY or ORAS, + + SM => version1 is SN or MN, + USUM => version1 is US or UM, + Gen7 => version1 is SN or MN or US or UM or SM or USUM, + + GG => version1 is GP or GE, + Gen7b => version1 is GP or GE or GO or GG, + + SWSH => version1 is SW or SH, + BDSP => version1 is BD or SP, + Gen8 => version1 is SW or SH or BD or SP or SWSH or BDSP or PLA, + + SV => version1 is SL or VL, + Gen9 => version1 is SL or VL or SV or ZA, + + _ => false, + }; } diff --git a/pkNX.WinForms/pkNX.WinForms.csproj b/pkNX.WinForms/pkNX.WinForms.csproj index 7a1e2beb..690476b5 100644 --- a/pkNX.WinForms/pkNX.WinForms.csproj +++ b/pkNX.WinForms/pkNX.WinForms.csproj @@ -1,7 +1,7 @@ WinExe - net9.0-windows + net10.0-windows pkNX.WinForms en Project Pokémon