diff --git a/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs b/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs index e654f0539..93fda87d2 100644 --- a/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs +++ b/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs @@ -715,7 +715,7 @@ void IsHMSource(IList flags, ICollection source) } } - private static bool IsDefogWhirl(int move) => move == 250 || move == 432; + private static bool IsDefogWhirl(int move) => move is (int)Move.Defog or (int)Move.Whirlpool; private static bool IsCheckInvalid(CheckResult? chk) => !(chk?.Valid ?? false); private static bool IsCheckValid(CheckResult? chk) => chk?.Valid ?? false; diff --git a/PKHeX.Core/Legality/Moves/MoveTechnicalMachine.cs b/PKHeX.Core/Legality/Moves/MoveTechnicalMachine.cs index d0e550825..5aeebbc22 100644 --- a/PKHeX.Core/Legality/Moves/MoveTechnicalMachine.cs +++ b/PKHeX.Core/Legality/Moves/MoveTechnicalMachine.cs @@ -124,29 +124,28 @@ private static GameVersion GetIsMachine4HMTransfer(int species, int move, int fo private static GameVersion GetIsMachine4HM(int species, int move, int form) { + var dp = Legal.HM_DPPt; + for (var i = 0; i < dp.Length; i++) { - int i = 0; - foreach (var m in Legal.HM_DPPt) - { - if (m == move) - { - if (PersonalTable.Pt.GetFormEntry(species, form).TMHM[i + 92]) - return GameVersion.DPPt; - break; - } - i++; - } - foreach (var m in Legal.HM_HGSS) - { - if (m == move) - { - if (PersonalTable.HGSS.GetFormEntry(species, form).TMHM[i + 92]) - return GameVersion.HGSS; - break; - } - i++; - } + var m = dp[i]; + if (m != move) + continue; + if (PersonalTable.Pt.GetFormEntry(species, form).TMHM[i + 92]) + return GameVersion.DPPt; + break; } + + var hgss = Legal.HM_HGSS; + for (var i = 0; i < hgss.Length; i++) + { + var m = hgss[i]; + if (m != move) + continue; + if (PersonalTable.HGSS.GetFormEntry(species, form).TMHM[i + 92]) + return GameVersion.HGSS; + break; + } + return Legal.NONE; } diff --git a/PKHeX.Core/Legality/Tables/Tables4.cs b/PKHeX.Core/Legality/Tables/Tables4.cs index 90724bb78..3ff2bde0f 100644 --- a/PKHeX.Core/Legality/Tables/Tables4.cs +++ b/PKHeX.Core/Legality/Tables/Tables4.cs @@ -148,8 +148,29 @@ public static partial class Legal // Defog (DPPt) excluded since it's actually useful -- prefer to fake transfer from HGSS instead of DPPt. }; - internal static readonly HashSet HM_DPPt = new(HM_4_RemovePokeTransfer) {(int)Move.Defog}; - internal static readonly HashSet HM_HGSS = new(HM_4_RemovePokeTransfer) {(int)Move.Whirlpool}; + internal static readonly int[] HM_DPPt = + { + (int)Move.Cut, + (int)Move.Fly, + (int)Move.Surf, + (int)Move.Strength, + (int)Move.Defog, + (int)Move.RockSmash, + (int)Move.Waterfall, + (int)Move.RockClimb, + }; + + internal static readonly int[] HM_HGSS = + { + (int)Move.Cut, + (int)Move.Fly, + (int)Move.Surf, + (int)Move.Strength, + (int)Move.Whirlpool, + (int)Move.RockSmash, + (int)Move.Waterfall, + (int)Move.RockClimb, + }; internal static readonly byte[] MovePP_DP = { @@ -272,7 +293,7 @@ internal static int[] RemoveMovesHM45(int[] moves) /// /// Current moves /// Preferred move ban list - private static HashSet GetFavorableHMBanlist(int[] moves) + private static ICollection GetFavorableHMBanlist(int[] moves) { // if has defog, return ban list with whirlpool return moves.Contains(432) ? HM_HGSS : HM_DPPt;