From c23cc8121291dbcbb3e56489b2b964a66db5ba74 Mon Sep 17 00:00:00 2001 From: Kurt Date: Tue, 19 Sep 2017 21:35:30 -0700 Subject: [PATCH] More usum prep I think egg hatch location checking is wrong for traded eggs (see gen3 vs future games, origin game shouldn't change but could hatch ORAS egg on XY at XY location?) --- PKHeX.Core/Game/GameInfo.cs | 6 ++++- PKHeX.Core/Legality/Checks.cs | 27 ++++++++++--------- .../Encounters/EncounterSuggestion.cs | 2 ++ .../Legality/Encounters/EncounterVerifier.cs | 2 ++ .../Legality/Structures/EvolutionTree.cs | 2 +- PKHeX.Core/Legality/Tables7.cs | 3 +++ PKHeX.Core/PKM/PKM.cs | 1 + PKHeX.Core/Saves/SaveUtil.cs | 4 ++- 8 files changed, 31 insertions(+), 16 deletions(-) diff --git a/PKHeX.Core/Game/GameInfo.cs b/PKHeX.Core/Game/GameInfo.cs index bff8301e3..d61f3f34e 100644 --- a/PKHeX.Core/Game/GameInfo.cs +++ b/PKHeX.Core/Game/GameInfo.cs @@ -456,13 +456,17 @@ public static List GetLocationList(GameVersion Version, int SaveForma case GameVersion.SN: case GameVersion.MN: + return MetGen7.Take(3).Concat(MetGen7.Skip(3).OrderByDescending(loc => loc.Value < 200)).ToList(); // Outer Cape + + case GameVersion.US: + case GameVersion.UM: case GameVersion.GO: case GameVersion.RD: case GameVersion.BU: case GameVersion.GN: case GameVersion.YW: - return MetGen7.Take(3).Concat(MetGen7.Skip(3).OrderByDescending(loc => loc.Value < 200)).ToList(); // Secret Base + return MetGen7.Take(3).Concat(MetGen7.Skip(3).OrderByDescending(loc => loc.Value < 200)).ToList(); // Outer Cape } // Currently on a future game, return corresponding list for generation diff --git a/PKHeX.Core/Legality/Checks.cs b/PKHeX.Core/Legality/Checks.cs index 555785b58..92d4ce190 100644 --- a/PKHeX.Core/Legality/Checks.cs +++ b/PKHeX.Core/Legality/Checks.cs @@ -302,6 +302,12 @@ private void VerifyNicknameTrade() AddLine(Severity.Valid, V194, CheckIdentifier.Nickname); return; } + else if (pkm.USUM) + { + // TODO + AddLine(Severity.Valid, V194, CheckIdentifier.Nickname); + return; + } else if (pkm.Format <= 2 || pkm.VC) { var et = (EncounterOriginalGB ?? EncounterMatch) as EncounterTrade; @@ -2173,13 +2179,8 @@ private bool VerifyNsPKMOTValid() if (pkm.TID != 00002 || pkm.SID != 00000) return false; - switch (pkm.Language) - { - case 1: // jp - return pkm.OT_Name == "N"; - default: - return pkm.OT_Name == "N"; - } + var OT = pkm.Language == 1 ? "N" : "N"; + return OT == pkm.OT_Name; } private void VerifyVersionEvolution() { @@ -2187,20 +2188,22 @@ private void VerifyVersionEvolution() return; // No point using the evolution tree. Just handle certain species. + bool Sun() => pkm.Version == (int)GameVersion.SN || pkm.Version == (int)GameVersion.US; + bool Moon() => pkm.Version == (int)GameVersion.MN || pkm.Version == (int)GameVersion.UM; switch (pkm.Species) { case 745: // Lycanroc if (!pkm.WasEgg) break; - if (pkm.AltForm == 0 && pkm.Version == 31 // Moon - || pkm.AltForm == 1 && pkm.Version == 30) // Sun + if (pkm.AltForm == 0 && Moon() + || pkm.AltForm == 1 && Sun()) if (pkm.IsUntraded) AddLine(Severity.Invalid, V328, CheckIdentifier.Evolution); break; case 791: // Solgaleo - if (pkm.Version == 31 && pkm.IsUntraded) + if (Moon() && pkm.IsUntraded) { if (EncounterMatch is MysteryGift g && g.Species == pkm.Species) // Gifted via Mystery Gift break; @@ -2208,7 +2211,7 @@ private void VerifyVersionEvolution() } break; case 792: // Lunala - if (pkm.Version == 30 && pkm.IsUntraded) + if (Sun() && pkm.IsUntraded) { if (EncounterMatch is MysteryGift g && g.Species == pkm.Species) // Gifted via Mystery Gift break; @@ -2217,8 +2220,6 @@ private void VerifyVersionEvolution() break; } } - #region VerifyMoves - #endregion public static string[] MoveStrings { internal get; set; } = Util.GetMovesList("en"); public static string[] SpeciesStrings { internal get; set; } = Util.GetSpeciesList("en"); internal static IEnumerable getMoveNames(IEnumerable moves) => moves.Select(m => m >= MoveStrings.Length ? V190 : MoveStrings[m]); diff --git a/PKHeX.Core/Legality/Encounters/EncounterSuggestion.cs b/PKHeX.Core/Legality/Encounters/EncounterSuggestion.cs index 1c16f9ee6..c1cb99223 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSuggestion.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSuggestion.cs @@ -106,6 +106,8 @@ public static int GetSuggestedEggMetLocation(PKM pkm) case GameVersion.SN: case GameVersion.MN: + case GameVersion.US: + case GameVersion.UM: return 50; // Route 4 } return -1; diff --git a/PKHeX.Core/Legality/Encounters/EncounterVerifier.cs b/PKHeX.Core/Legality/Encounters/EncounterVerifier.cs index 745ce60fa..6292aa822 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterVerifier.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterVerifier.cs @@ -218,6 +218,8 @@ private static CheckResult VerifyEncounterEgg7(PKM pkm) { if (pkm.SM) return VerifyEncounterEggLevelLoc(pkm, 1, Legal.ValidMet_SM); + if (pkm.USUM) + return VerifyEncounterEggLevelLoc(pkm, 1, Legal.ValidMet_USUM); // no other games return new CheckResult(Severity.Invalid, V51, CheckIdentifier.Encounter); diff --git a/PKHeX.Core/Legality/Structures/EvolutionTree.cs b/PKHeX.Core/Legality/Structures/EvolutionTree.cs index 0d77999e7..20d69144e 100644 --- a/PKHeX.Core/Legality/Structures/EvolutionTree.cs +++ b/PKHeX.Core/Legality/Structures/EvolutionTree.cs @@ -515,7 +515,7 @@ public class EvolutionMethod internal static readonly int[] TradeMethods = {5, 6, 7}; private static readonly IReadOnlyCollection NoBanlist = new GameVersion[0]; - internal static readonly IReadOnlyCollection BanSM = new[] {GameVersion.SN, GameVersion.MN}; + internal static readonly IReadOnlyCollection BanSM = new[] {GameVersion.SN, GameVersion.MN, GameVersion.US, GameVersion.UM}; internal IReadOnlyCollection Banlist = NoBanlist; public bool Valid(PKM pkm, int lvl, bool skipChecks) diff --git a/PKHeX.Core/Legality/Tables7.cs b/PKHeX.Core/Legality/Tables7.cs index 8349c9096..b6eb45d97 100644 --- a/PKHeX.Core/Legality/Tables7.cs +++ b/PKHeX.Core/Legality/Tables7.cs @@ -316,6 +316,9 @@ public static partial class Legal 30016 // Poké Pelago }; + internal static readonly int[] ValidMet_USUM = + { + }; private static readonly int[] TMHM_SM = { diff --git a/PKHeX.Core/PKM/PKM.cs b/PKHeX.Core/PKM/PKM.cs index e37c90a20..263bda352 100644 --- a/PKHeX.Core/PKM/PKM.cs +++ b/PKHeX.Core/PKM/PKM.cs @@ -297,6 +297,7 @@ private byte[] Write() public bool XY => Version == (int)GameVersion.X || Version == (int)GameVersion.Y; public bool AO => Version == (int)GameVersion.AS || Version == (int)GameVersion.OR; public bool SM => Version == (int)GameVersion.SN || Version == (int)GameVersion.MN; + public bool USUM => Version == (int)GameVersion.US || Version == (int)GameVersion.UM; protected bool PtHGSS => Pt || HGSS; public bool VC => VC1 || VC2; public bool Gen7 => Version >= 30 && Version <= 33; diff --git a/PKHeX.Core/Saves/SaveUtil.cs b/PKHeX.Core/Saves/SaveUtil.cs index 7c73e9023..994a34a28 100644 --- a/PKHeX.Core/Saves/SaveUtil.cs +++ b/PKHeX.Core/Saves/SaveUtil.cs @@ -10,7 +10,7 @@ public static class SaveUtil { public const int BEEF = 0x42454546; - public const int SIZE_G7USUM = -1; + public const int SIZE_G7USUM = 999_999_999; public const int SIZE_G7SM = 0x6BE00; public const int SIZE_G6XY = 0x65600; public const int SIZE_G6ORAS = 0x76000; @@ -545,6 +545,8 @@ private static SaveFile GetBlankSAV(GameVersion Game) case GameVersion.SN: case GameVersion.MN: case GameVersion.SM: return new SAV7(new byte[SIZE_G7SM]); + case GameVersion.US: case GameVersion.UM: case GameVersion.USUM: + return new SAV7(new byte[SIZE_G7USUM]); default: return null;