diff --git a/PKHeX.Core/Legality/Moves/MoveTutor.cs b/PKHeX.Core/Legality/Moves/MoveTutor.cs index 6a45f461c..0aba61846 100644 --- a/PKHeX.Core/Legality/Moves/MoveTutor.cs +++ b/PKHeX.Core/Legality/Moves/MoveTutor.cs @@ -100,19 +100,21 @@ private static GameVersion GetIsTutor4(int species, int form, int move) private static GameVersion GetIsTutor5(PKM pkm, int species, int form, bool specialTutors, int move) { var pi = PersonalTable.B2W2.GetFormeEntry(species, form); - for (int i = 0; i < TypeTutor6.Length; i++) + var arr = TypeTutor6; + for (int i = 0; i < arr.Length; i++) { - if (TypeTutor6[i] == move && pi.TypeTutors[i]) + if (arr[i] == move && pi.TypeTutors[i]) return GameVersion.Gen5; } if (specialTutors && pkm.HasVisitedB2W2()) { - for (int i = 0; i < Tutors_B2W2.Length; i++) + var tutors = Tutors_B2W2; + for (int i = 0; i < tutors.Length; i++) { - for (int j = 0; j < Tutors_B2W2[i].Length; j++) + for (int j = 0; j < tutors[i].Length; j++) { - if (Tutors_B2W2[i][j] == move && pi.SpecialTutors[i][j]) + if (tutors[i][j] == move && pi.SpecialTutors[i][j]) return GameVersion.B2W2; } } @@ -124,19 +126,21 @@ private static GameVersion GetIsTutor5(PKM pkm, int species, int form, bool spec private static GameVersion GetIsTutor6(PKM pkm, int species, int form, bool specialTutors, int move) { var pi = PersonalTable.AO.GetFormeEntry(species, form); - for (int i = 0; i < TypeTutor6.Length; i++) + var arr = TypeTutor6; + for (int i = 0; i < arr.Length; i++) { - if (TypeTutor6[i] == move && pi.TypeTutors[i]) + if (arr[i] == move && pi.TypeTutors[i]) return GameVersion.Gen6; } if (specialTutors && pkm.HasVisitedORAS()) { - for (int i = 0; i < Tutors_AO.Length; i++) + var tutors = Tutors_AO; + for (int i = 0; i < tutors.Length; i++) { - for (int j = 0; j < Tutors_AO[i].Length; j++) + for (int j = 0; j < tutors[i].Length; j++) { - if (Tutors_AO[i][j] == move && pi.SpecialTutors[i][j]) + if (tutors[i][j] == move && pi.SpecialTutors[i][j]) return GameVersion.ORAS; } } @@ -148,17 +152,19 @@ private static GameVersion GetIsTutor6(PKM pkm, int species, int form, bool spec private static GameVersion GetIsTutor7(PKM pkm, int species, int form, bool specialTutors, int move) { var pi = PersonalTable.USUM.GetFormeEntry(species, form); - for (int i = 0; i < TypeTutor6.Length; i++) + var arr = TypeTutor6; + for (int i = 0; i < arr.Length; i++) { - if (TypeTutor6[i] == move && pi.TypeTutors[i]) + if (arr[i] == move && pi.TypeTutors[i]) return GameVersion.Gen7; } if (specialTutors && pkm.HasVisitedUSUM()) { - for (int i = 0; i < Tutors_USUM.Length; i++) + var tutors = Tutors_USUM; + for (int i = 0; i < tutors.Length; i++) { - if (Tutors_USUM[i] == move && pi.SpecialTutors[0][i]) + if (tutors[i] == move && pi.SpecialTutors[0][i]) return GameVersion.USUM; } } @@ -168,6 +174,14 @@ private static GameVersion GetIsTutor7(PKM pkm, int species, int form, bool spec private static GameVersion GetIsTutor8(PKM pkm, int species, int form, bool specialTutors, int move) { + var pi = (PersonalInfoSWSH)PersonalTable.SWSH.GetFormeEntry(species, form); + var arr = TypeTutor8; + for (int i = 0; i < arr.Length; i++) + { + if (arr[i] == move && pi.TypeTutors[i]) + return GameVersion.Gen8; + } + return NONE; } @@ -249,11 +263,15 @@ private static void AddMovesTutor7(List moves, int species, int form, PKM p var pi = PersonalTable.USUM.GetFormeEntry(species, form); moves.AddRange(TypeTutor6.Where((_, i) => pi.TypeTutors[i])); if (specialTutors && pkm.HasVisitedUSUM()) - moves.AddRange(GetTutors(PersonalTable.USUM.GetFormeEntry(species, form), Tutors_USUM)); + moves.AddRange(GetTutors(pi, Tutors_USUM)); } private static void AddMovesTutor8(List moves, int species, int form, PKM pkm, bool specialTutors) { + var pi = (PersonalInfoSWSH)PersonalTable.SWSH.GetFormeEntry(species, form); + if (!pi.IsPresentInGame) + return; + moves.AddRange(TypeTutor8.Where((_, i) => pi.TypeTutors[i])); } private static IEnumerable GetTutors(PersonalInfo pi, params int[][] tutors) diff --git a/PKHeX.Core/Legality/Tables/Tables6.cs b/PKHeX.Core/Legality/Tables/Tables6.cs index d362f0329..137c4a470 100644 --- a/PKHeX.Core/Legality/Tables/Tables6.cs +++ b/PKHeX.Core/Legality/Tables/Tables6.cs @@ -214,7 +214,13 @@ public static partial class Legal 15, 19, 57, 70, 127, }; - internal static readonly int[] TypeTutor6 = {520, 519, 518, 338, 307, 308, 434, 620}; + internal static readonly int[] TypeTutor6 = + { + 520, 519, 518, // Pledge + 338, 307, 308, // Elemental Beam + 434, // Draco Meteor + 620, // Dragon Ascent + }; internal static readonly int[][] Tutors_AO = { diff --git a/PKHeX.Core/Legality/Tables/Tables8.cs b/PKHeX.Core/Legality/Tables/Tables8.cs index af1e0a284..82d7a153f 100644 --- a/PKHeX.Core/Legality/Tables/Tables8.cs +++ b/PKHeX.Core/Legality/Tables/Tables8.cs @@ -404,5 +404,13 @@ public static partial class Legal 710, 711, 715, 716, 718, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756, }; + + internal static readonly int[] TypeTutor8 = + { + 520, 519, 518, // Pledge + 338, 307, 308, // Elemental Beam + 434, // Draco Meteor + 796, // Steel Beam + }; } } diff --git a/PKHeX.Core/PersonalInfo/PersonalInfoSWSH.cs b/PKHeX.Core/PersonalInfo/PersonalInfoSWSH.cs index 817f98109..58fd14a49 100644 --- a/PKHeX.Core/PersonalInfo/PersonalInfoSWSH.cs +++ b/PKHeX.Core/PersonalInfo/PersonalInfoSWSH.cs @@ -17,7 +17,12 @@ public PersonalInfoSWSH(byte[] data) : base(data) TMHM[i] = FlagUtil.GetFlag(Data, 0x28 + (i >> 3), i); TMHM[i + 100] = FlagUtil.GetFlag(Data, 0x3C + (i >> 3), i); } - TypeTutors = Array.Empty(); + + // 0x38-0x3B type tutors, but only 8 bits are valid flags. + var typeTutors = new bool[8]; + for (int i = 0; i < typeTutors.Length; i++) + typeTutors[i] = FlagUtil.GetFlag(Data, 0x38, i); + TypeTutors = typeTutors; } public override byte[] Write() @@ -27,6 +32,8 @@ public override byte[] Write() FlagUtil.SetFlag(Data, 0x28 + (i >> 3), i, TMHM[i]); FlagUtil.SetFlag(Data, 0x3C + (i >> 3), i, TMHM[i + 100]); } + for (int i = 0; i < TypeTutors.Length; i++) + FlagUtil.SetFlag(Data, 0x38, i, TypeTutors[i]); return Data; }