From 2e4af1afc54bd7b19c12f52f4b82ff23b6daf69d Mon Sep 17 00:00:00 2001 From: Kurt Date: Sat, 24 Oct 2020 11:16:01 -0700 Subject: [PATCH] Update legality comparisons for Crown Tundra Co-Authored-By: Lusamine <30205550+Lusamine@users.noreply.github.com> Co-Authored-By: Matt <17801814+sora10pls@users.noreply.github.com> --- PKHeX.Core/Legality/Areas/EncounterArea8.cs | 10 ++-- .../EncounterStatic/EncounterStatic8.cs | 21 ++++++-- .../EncounterStatic/EncounterStatic8ND.cs | 2 +- PKHeX.Core/Legality/Moves/MoveTutor.cs | 13 +++-- PKHeX.Core/Legality/Tables/Tables8.cs | 50 ++++++++----------- PKHeX.Core/Legality/Verifiers/BallVerifier.cs | 19 +++---- 6 files changed, 65 insertions(+), 50 deletions(-) diff --git a/PKHeX.Core/Legality/Areas/EncounterArea8.cs b/PKHeX.Core/Legality/Areas/EncounterArea8.cs index dbbbb4f41..d86bb2bd2 100644 --- a/PKHeX.Core/Legality/Areas/EncounterArea8.cs +++ b/PKHeX.Core/Legality/Areas/EncounterArea8.cs @@ -31,7 +31,7 @@ public override IEnumerable GetMatchingSlots(PKM pkm, IReadOnlyLi { // wild area gets boosted up to level 60 post-game var met = pkm.Met_Level; - bool isBoosted = met == 60 && (IsWildArea8(Location) || IsWildArea8Armor(Location)); + bool isBoosted = met == 60 && IsBoostedArea60(Location); if (isBoosted) return GetBoostedMatches(chain); return GetUnboostedMatches(chain, met); @@ -78,8 +78,12 @@ private IEnumerable GetBoostedMatches(IReadOnlyList } } - public static bool IsWildArea8(int loc) => 122 <= loc && loc <= 154; // Rolling Fields -> Lake of Outrage - public static bool IsWildArea8Armor(int loc) => 164 <= loc && loc <= 194; // Fields of Honor -> Honeycalm Island + public static bool IsWildArea(int loc) => IsWildArea8(loc) || IsWildArea8Armor(loc) || IsWildArea8Crown(loc); + public static bool IsBoostedArea60(int loc) => IsWildArea(loc); + + private static bool IsWildArea8(int loc) => 122 <= loc && loc <= 154; // Rolling Fields -> Lake of Outrage + private static bool IsWildArea8Armor(int loc) => 164 <= loc && loc <= 194; // Fields of Honor -> Honeycalm Island + private static bool IsWildArea8Crown(int loc) => 204 <= loc && loc <= 234 && loc != 206; // Slippery Slope -> Dyna Tree Hill, skip Freezington // Location, and areas that it can feed encounters to. public static readonly IReadOnlyDictionary> ConnectingArea8 = new Dictionary> diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8.cs index 173991475..52b1f700d 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8.cs @@ -1,18 +1,31 @@ -namespace PKHeX.Core +using System; +using System.Collections.Generic; + +namespace PKHeX.Core { - public class EncounterStatic8 : EncounterStatic, IGigantamax + public class EncounterStatic8 : EncounterStatic, IDynamaxLevel, IGigantamax, IRelearn { public sealed override int Generation => 8; public bool CanGigantamax { get; set; } + public byte DynamaxLevel { get; set; } protected override bool IsMatchLevel(PKM pkm, DexLevel evo) { var met = pkm.Met_Level; if (met == Level) return true; - if (EncounterArea8.IsWildArea8(Location) || EncounterArea8.IsWildArea8Armor(Location)) + if (EncounterArea8.IsBoostedArea60(Location)) return met == 60; return false; } + + public override bool IsMatch(PKM pkm, DexLevel evo) + { + if (pkm is IDynamaxLevel d && d.DynamaxLevel < DynamaxLevel) + return false; + return base.IsMatch(pkm, evo); + } + + public IReadOnlyList Relearn { get; internal set; } = Array.Empty(); } -} \ No newline at end of file +} diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8ND.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8ND.cs index db4b39bec..62a66b247 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8ND.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8ND.cs @@ -17,7 +17,7 @@ public EncounterStatic8ND(byte lvl, byte dyna, byte flawless) protected override bool IsMatchLocation(PKM pkm) { var loc = pkm.Met_Location; - return loc == SharedNest || EncounterArea8.IsWildArea8(loc) || EncounterArea8.IsWildArea8Armor(loc); + return loc == SharedNest || EncounterArea8.IsWildArea(loc); } public override bool IsMatch(PKM pkm, DexLevel evo) diff --git a/PKHeX.Core/Legality/Moves/MoveTutor.cs b/PKHeX.Core/Legality/Moves/MoveTutor.cs index 9ad457ccf..0204f278f 100644 --- a/PKHeX.Core/Legality/Moves/MoveTutor.cs +++ b/PKHeX.Core/Legality/Moves/MoveTutor.cs @@ -328,16 +328,19 @@ internal static void AddSpecialFormChangeMoves(List r, PKM pkm, int Generat { switch (species) { - case (int)Species.Rotom when Generation >= 4: // rotom - r.Add(RotomMoves[pkm.AltForm]); + case (int)Species.Rotom when Generation >= 4: + var formMoves = RotomMoves; + var form = pkm.AltForm - 1; + if ((uint)form < formMoves.Length) + r.Add(RotomMoves[form]); break; - case (int)Species.Zygarde when Generation == 7: // zygarde + case (int)Species.Zygarde when Generation == 7: r.AddRange(ZygardeMoves); break; - case (int)Species.Necrozma when pkm.AltForm == 1: // Sun Necrozma + case (int)Species.Necrozma when pkm.AltForm == 1: // Sun r.Add(713); break; - case (int)Species.Necrozma when pkm.AltForm == 2: // Moon Necrozma + case (int)Species.Necrozma when pkm.AltForm == 2: // Moon r.Add(714); break; } diff --git a/PKHeX.Core/Legality/Tables/Tables8.cs b/PKHeX.Core/Legality/Tables/Tables8.cs index 758e09c53..3eaffd44f 100644 --- a/PKHeX.Core/Legality/Tables/Tables8.cs +++ b/PKHeX.Core/Legality/Tables/Tables8.cs @@ -24,10 +24,10 @@ public static partial class Legal internal const int MaxAbilityID_8_R1 = 260; // Unseen Fist // Rigel 2 (DLC 2: Crown Tundra) - internal const int MaxSpeciesID_8_R2 = 893; // todo - internal const int MaxMoveID_8_R2 = 818; // todo - internal const int MaxItemID_8_R2 = 1589; // todo - internal const int MaxAbilityID_8_R2 = 260; // todo + internal const int MaxSpeciesID_8_R2 = 898; // Calyrex + internal const int MaxMoveID_8_R2 = 826; // Eerie Spell + internal const int MaxItemID_8_R2 = 1607; // Reins of Unity + internal const int MaxAbilityID_8_R2 = 267; // As One internal const int MaxBallID_8 = 0x1A; // 26 Beast internal const int MaxGameID_8 = 45; @@ -55,7 +55,13 @@ public static partial class Legal 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, - 200, 202, + 200, 202, + + 204, 206, 208, + 210, 212, 214, 216, 218, + 220, 222, 224, 226, 228, + 230, 232, 234, 236, 238, + 240, 242, 244, 246, }; internal static readonly int[] Met_SWSH_3 = @@ -143,7 +149,7 @@ public static partial class Legal 1269, 1270, 1271, 1278, 1583, 1584, 1585, 1586, 1587, 1589, // DLC 2 - 1590, 1591, 1593, 1594, 1595, 1596, 1597, 1598, 1599, 1600, 1601, 1602, 1603, 1605 + 1590, 1591, 1593, 1594, 1595, 1596, 1597, 1598, 1599, 1600, 1601, 1602, 1603, 1605, 1607, }; internal static readonly ushort[] TM_SWSH = @@ -315,7 +321,13 @@ public static partial class Legal 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, - 200 + 200, + + 202, 204, 206, 208, 210, + 212, 214, 216, 218, 220, + 222, 224, 226, 228, 230, + 232, 234, 236, 238, 240, + 242, 244, 246, }; public static readonly int[] TMHM_SWSH = @@ -364,15 +376,15 @@ public static partial class Legal 01, 01, 01, 01, 01, 01, 01, 01, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 40, 15, 20, 30, 20, 15, 15, 20, 10, 15, 15, 10, 05, 10, 10, 20, 15, 10, 15, 15, 15, 05, 15, 20, 20, 01, 01, 01, 01, 01, 01, 01, 01, 01, 05, 05, 10, 10, 10, 20, 10, 10, 10, 05, 05, 20, 10, 10, 10, 01, 05, 15, 05, 01, 01, 01, 01, 01, 01, 10, 15, 15, 20, 20, 20, 20, 15, 15, 10, 10, 05, 20, 05, 10, 05, 15, 10, 10, 05, 15, 20, 10, 10, 15, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 05, 10, 15, 10, 15, 05, 05, 05, 10, 15, 40, 10, 10, 10, 15, 10, 10, 10, 10, 05, 05, 05, 10, 05, 20, 10, - 10, 05, 20, 20, 10, 10, 05, 05, 05, 40, 10, 20, 10, 10, 10, 10, 05, 05 + 10, 05, 20, 20, 10, 10, 05, 05, 05, 40, 10, 20, 10, 10, 10, 10, 05, 05, 15, 05, 10, 10, 10, 05, 05, 05, }; internal static readonly HashSet Ban_NoHidden8 = new HashSet(); // none as of DLC 1! internal static readonly HashSet Ban_NoHidden8Apricorn = new HashSet { - 029, // Nidoran - 032, // Nidoran + // 029, // Nidoran -- Used to not be encounterable in Gen7 with HA; Gen8 now can via Raids + // 032, // Nidoran -- Used to not be encounterable in Gen7 with HA; Gen8 now can via Raids 100, // Voltorb // 436, // Bronzor -- Used to not be encounterable in Gen7 with HA; Gen8 now can via Raids 669 + (3 << 11), // Flabébé-Blue @@ -381,15 +393,6 @@ public static partial class Legal #region Unreleased Items internal static readonly HashSet UnreleasedHeldItems_8 = new HashSet { - 112, // Griseous Orb - 116, // Douse Drive - 117, // Shock Drive - 118, // Burn Drive - 119, // Chill Drive - 135, // Adamant Orb - 136, // Lustrous Orb - 225, // Soul Dew - 298, // Flame Plate 299, // Splash Plate 300, // Zap Plate @@ -408,9 +411,6 @@ public static partial class Legal 313, // Iron Plate // 644, // Pixie Plate - 322, // Electirizer - 323, // Magmarizer - // 1279, // ★And458 (Jangmo-o) // 1280, // ★And15 (Larvitar) // 1281, // ★And337 (Corviknight) @@ -714,12 +714,6 @@ public static partial class Legal 016, // Cherish Ball 500, // Park Ball - - 208, // Enigma Berry - 209, // Micle Berry - 210, // Custap Berry - 211, // Jaboca Berry - 212, // Rowap Berry }; #endregion internal static readonly bool[] ReleasedHeldItems_8 = Enumerable.Range(0, MaxItemID_8+1).Select(i => HeldItems_SWSH.Contains((ushort)i) && !UnreleasedHeldItems_8.Contains(i)).ToArray(); diff --git a/PKHeX.Core/Legality/Verifiers/BallVerifier.cs b/PKHeX.Core/Legality/Verifiers/BallVerifier.cs index 2c9f352e0..4a28f0193 100644 --- a/PKHeX.Core/Legality/Verifiers/BallVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/BallVerifier.cs @@ -348,22 +348,23 @@ public static bool IsGalarCatchAndBreed(int species) { if ((int)Species.Grookey <= species && species <= (int)Species.Inteleon) // starter return false; + var pt = PersonalTable.SWSH; - var pi = ((PersonalInfoSWSH) pt.GetFormeEntry(species, 0)); + var pi = (PersonalInfoSWSH) pt.GetFormeEntry(species, 0); + bool galar = pi.PokeDexIndex != 0; if (galar) return true; + var armor = pi.ArmorDexIndex != 0; if (armor) - { - if (722 <= species && species <= 730) // G7 Starters - return false; - if ((int) Species.Porygon == species) - return false; - return true; - } + return species != (int)Species.Porygon; - return true; + var crown = pi.CrownDexIndex != 0; + if (crown) + return true; + + return false; } private CheckResult VerifyBallEquals(LegalityAnalysis data, int ball) => GetResult(ball == data.pkm.Ball);