diff --git a/PKHeX.Core/Legality/LearnSource/Group/LearnGroup3.cs b/PKHeX.Core/Legality/LearnSource/Group/LearnGroup3.cs index af822a2db..a7d5c0b68 100644 --- a/PKHeX.Core/Legality/LearnSource/Group/LearnGroup3.cs +++ b/PKHeX.Core/Legality/LearnSource/Group/LearnGroup3.cs @@ -152,22 +152,36 @@ private static void CheckNX(Span result, ReadOnlySpan curren var lg = LearnSource3LG.Instance; var lp = lg[species]; + var isFireRed = pk.Version == GameVersion.FR; + ILearnSource primaryLS = isFireRed ? fr : lg; + ILearnSource secondaryLS = !isFireRed ? fr : lg; + var primaryPI = isFireRed ? fp : lp; + var secondaryPI = !isFireRed ? fp : lp; + var primaryEnv = isFireRed ? LearnEnvironment.FR : LearnEnvironment.LG; + for (int i = result.Length - 1; i >= 0; i--) { if (result[i].Valid) continue; - // Level Up moves are different for each game, but TM/HM is shared (use Emerald). + // Level Up moves are different for each game, but TM/HM is shared. var move = current[i]; - var chk = fr.GetCanLearn(pk, fp, evo, move, types & (MoveSourceType.LevelUp | MoveSourceType.AllTutors)); + var chk = primaryLS.GetCanLearn(pk, primaryPI, evo, move, types); if (chk != default) { result[i] = new(chk, (byte)stage, Context); continue; } - chk = lg.GetCanLearn(pk, lp, evo, move, types & MoveSourceType.LevelUp); // Tutors same as FR + chk = secondaryLS.GetCanLearn(pk, secondaryPI, evo, move, types & MoveSourceType.LevelUp); // Tutors same as FR if (chk != default) + { result[i] = new(chk, (byte)stage, Context); + continue; + } + + // Tutors are indexes 0-14, same as Emerald. + if (LearnSource3E.GetIsTutorFRLG(evo.Species, move)) + result[i] = new(new(LearnMethod.Tutor, primaryEnv)); } } @@ -196,6 +210,10 @@ private static void GetAllMoves(Span result, PKM pk, EvoCriteria evo, Move { LearnSource3FR.Instance.GetAllMoves(result, pk, evo, types); LearnSource3LG.Instance.GetAllMoves(result, pk, evo, types & (MoveSourceType.LevelUp)); + + // Tutors are indexes 0-14, same as Emerald. + if (types.HasFlag(MoveSourceType.EnhancedTutor)) + LearnSource3E.GetAllTutorMovesFRLG(result, evo.Species); return; } LearnSource3E.Instance.GetAllMoves(result, pk, evo, types); diff --git a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource3E.cs b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource3E.cs index bf4c3d7ed..81bf020c7 100644 --- a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource3E.cs +++ b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource3E.cs @@ -144,10 +144,33 @@ public void GetAllMoves(Span result, PKM pk, EvoCriteria evo, MoveSourceTy } } + // TODO RSE VC: Remove these. + internal static bool GetIsTutorFRLG(ushort species, ushort move) + { + var info = Personal[species]; + var index = Tutor_E.IndexOf(move); + if ((uint)index >= 15) + return false; + return info.TypeTutors[index]; + } + + internal static void GetAllTutorMovesFRLG(Span result, ushort species) + { + var pi = Personal[species]; + var flags = pi.TypeTutors; + var moves = Tutor_E; + for (int i = 0; i < 15; i++) + { + if (flags[i]) + result[moves[i]] = true; + } + } + private static ReadOnlySpan Tutor_E => [ - 005, 014, 025, 034, 038, 068, 069, 102, 118, 135, - 138, 086, 153, 157, 164, 223, 205, 244, 173, 196, - 203, 189, 008, 207, 214, 129, 111, 009, 007, 210, + // Introduced in FR/LG + 005, 014, 025, 034, 038, 068, 069, 102, 118, 135, 138, 086, 153, 157, 164, + // Introduced in Emerald + 223, 205, 244, 173, 196, 203, 189, 008, 207, 214, 129, 111, 009, 007, 210, ]; }