diff --git a/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs b/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs index 0c52f7d22..d378b77aa 100644 --- a/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs +++ b/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs @@ -173,12 +173,13 @@ private static CheckMoveResult[] ParseMovesGenGB(PKM pkm, IReadOnlyList cur { var res = new CheckMoveResult[4]; var enc = info.EncounterMatch; + var level = pkm.HasOriginalMetLocation ? pkm.Met_Level : enc.LevelMin; var InitialMoves = Array.Empty(); var SpecialMoves = GetSpecialMoves(enc); var games = enc.Generation == 1 ? GBRestrictions.GetGen1Versions(enc) : GBRestrictions.GetGen2Versions(enc, pkm.Korean); foreach (var ver in games) { - var VerInitialMoves = MoveLevelUp.GetEncounterMoves(enc.Species, 0, enc.LevelMin, ver); + var VerInitialMoves = MoveLevelUp.GetEncounterMoves(enc.Species, 0, level, ver); if (VerInitialMoves.Intersect(InitialMoves).Count() == VerInitialMoves.Length) return res; @@ -727,24 +728,24 @@ private static void VerifyNoEmptyDuplicates(IReadOnlyList moves, CheckMoveR } } - private static void FlagDuplicateMovesAfterIndex(IReadOnlyList moves, CheckMoveResult[] res, int i, int move) + private static void FlagDuplicateMovesAfterIndex(IReadOnlyList moves, CheckMoveResult[] res, int index, int move) { - for (int j = i + 1; j < 4; j++) + for (int i = index + 1; i < 4; i++) { - if (moves[j] != move) + if (moves[i] != move) continue; - res[i] = new CheckMoveResult(res[i], Invalid, LMoveSourceDuplicate); + res[index] = new CheckMoveResult(res[index], Invalid, LMoveSourceDuplicate); return; } } - private static void FlagEmptySlotsBeforeIndex(IReadOnlyList moves, CheckMoveResult[] res, int i) + private static void FlagEmptySlotsBeforeIndex(IReadOnlyList moves, CheckMoveResult[] res, int index) { - for (int k = i - 1; k >= 0; k--) + for (int i = index - 1; i >= 0; i--) { - if (moves[k] != 0) + if (moves[i] != 0) return; - res[k] = new CheckMoveResult(res[k], Invalid, LMoveSourceEmpty); + res[i] = new CheckMoveResult(res[i], Invalid, LMoveSourceEmpty); } } diff --git a/PKHeX.Core/Legality/Verifiers/MemoryPermissions.cs b/PKHeX.Core/Legality/Verifiers/MemoryPermissions.cs index eeaa1cf4e..d3a208dae 100644 --- a/PKHeX.Core/Legality/Verifiers/MemoryPermissions.cs +++ b/PKHeX.Core/Legality/Verifiers/MemoryPermissions.cs @@ -96,6 +96,11 @@ private static bool CanBuyItem8(int item, GameVersion version) public static bool GetCanLearnMachineMove(PKM pkm, int move, int generation, GameVersion version = GameVersion.Any) { var evos = EvolutionChain.GetValidPreEvolutions(pkm); + return GetCanLearnMachineMove(pkm, evos, move, generation, version); + } + + public static bool GetCanLearnMachineMove(PKM pkm, IReadOnlyList evos, int move, int generation, GameVersion version = GameVersion.Any) + { return MoveList.GetValidMoves(pkm, version, evos, generation, types: MoveSourceType.AllMachines).Contains(move); } diff --git a/PKHeX.Core/Legality/Verifiers/MemoryVerifier.cs b/PKHeX.Core/Legality/Verifiers/MemoryVerifier.cs index ab9085b34..9f7919188 100644 --- a/PKHeX.Core/Legality/Verifiers/MemoryVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/MemoryVerifier.cs @@ -27,14 +27,14 @@ private CheckResult VerifyCommonMemory(PKM pkm, int handler, int gen, LegalInfo if (matchingMoveMemory != -1) { // Gen8 has no HMs, so this memory can never exist. - if (gen != 6 || (pkm.Species != (int)Species.Smeargle && !GetCanLearnMachineMove(pkm, Memories.MoveSpecificMemories[1][matchingMoveMemory], 6))) + if (gen != 6 || (pkm.Species != (int)Species.Smeargle && !GetCanLearnMachineMove(pkm, info.EvoChainsAllGens[gen], Memories.MoveSpecificMemories[1][matchingMoveMemory], 6))) return GetInvalid(string.Format(LMemoryArgBadMove, memory.Handler)); } switch (memory.MemoryID) { // {0} saw {2} carrying {1} on its back. {4} that {3}. - case 21 when gen != 6 || !GetCanLearnMachineMove(new PK6 {Species = memory.Variable, EXP = Experience.GetEXP(100, PersonalTable.XY.GetFormIndex(memory.Variable, 0))}, 19, 6): + case 21 when gen != 6 || !GetCanLearnMachineMove(new PK6 {Species = memory.Variable, EXP = Experience.GetEXP(100, PersonalTable.XY.GetFormIndex(memory.Variable, 0))}, (int)Move.Fly, 6): return GetInvalid(string.Format(LMemoryArgBadMove, memory.Handler)); case 16 or 48 when !CanKnowMove(pkm, memory, gen, info, memory.MemoryID == 16):