From 5d9c0f006a5d8e3a24f7f4313eebf6063ed297db Mon Sep 17 00:00:00 2001 From: javierhimura Date: Mon, 20 Mar 2017 19:10:50 +0100 Subject: [PATCH] Simplify gen 4 tm and hm --- PKHeX/Legality/Core.cs | 17 +++++++++++++++-- PKHeX/Legality/Tables4.cs | 18 +++++------------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/PKHeX/Legality/Core.cs b/PKHeX/Legality/Core.cs index cf29f41e1..fc0dae25f 100644 --- a/PKHeX/Legality/Core.cs +++ b/PKHeX/Legality/Core.cs @@ -2079,9 +2079,22 @@ private static IEnumerable getMoves(PKM pkm, int species, int lvl, int form if (Machine) { var pi_hgss = PersonalTable.HGSS[index]; - r.AddRange(TMHM_HGSS.Where((t, m) => pi_hgss.TMHM[m])); var pi_dppt = PersonalTable.Pt[index]; - r.AddRange(TMHM_DPPt.Where((t, m) => pi_dppt.TMHM[m])); + r.AddRange(TM_4.Where((t, m) => pi_hgss.TMHM[m])); + if (pkm.Format > 4) + { + // The combination of both these moves is illegal, it should be checked that the pokemon only learn one + // except if it can learn any of these moves in gen 5 or later + if (pi_hgss.TMHM[96]) + r.Add(250); // Whirlpool + if (pi_dppt.TMHM[96]) + r.Add(432); // Defog + } + else + { + r.AddRange(HM_DPPt.Where((t, m) => pi_dppt.TMHM[m + 92])); + r.AddRange(HM_HGSS.Where((t, m) => pi_hgss.TMHM[m + 92])); + } } if (moveTutor) r.AddRange(getTutorMoves(pkm, species, form, specialTutors, Generation)); diff --git a/PKHeX/Legality/Tables4.cs b/PKHeX/Legality/Tables4.cs index 730d236d9..69bebaa57 100644 --- a/PKHeX/Legality/Tables4.cs +++ b/PKHeX/Legality/Tables4.cs @@ -106,7 +106,7 @@ public static partial class Legal internal static readonly ushort[] HeldItems_HGSS = new ushort[1].Concat(Pouch_Items_HGSS).Concat(Pouch_Mail_HGSS).Concat(Pouch_Medicine_HGSS).Concat(Pouch_Berries_HGSS).Concat(Pouch_Ball_Pt).Concat(Pouch_TMHM_HGSS.Take(Pouch_TMHM_HGSS.Length - 8)).ToArray(); #endregion - internal static readonly int[] TMHM_HGSS = + internal static readonly int[] TM_4 = { 264, 337, 352, 347, 046, 092, 258, 339, 331, 237, 241, 269, 058, 059, 063, 113, 182, 240, 202, 219, @@ -118,23 +118,15 @@ public static partial class Legal 444, 419, 086, 360, 014, 446, 244, 445, 399, 157, 404, 214, 363, 398, 138, 447, 207, 365, 369, 164, 430, 433, + }; + internal static readonly int[] HM_HGSS = + { 015, 019, 057, 070, 250, 249, 127, 431 // Defog(DPPt) & Whirlpool(HGSS) }; - internal static readonly int[] TMHM_DPPt = + internal static readonly int[] HM_DPPt = { - 264, 337, 352, 347, 046, 092, 258, 339, 331, 237, - 241, 269, 058, 059, 063, 113, 182, 240, 202, 219, - 218, 076, 231, 085, 087, 089, 216, 091, 094, 247, - 280, 104, 115, 351, 053, 188, 201, 126, 317, 332, - 259, 263, 290, 156, 213, 168, 211, 285, 289, 315, - 355, 411, 412, 206, 362, 374, 451, 203, 406, 409, - 261, 318, 373, 153, 421, 371, 278, 416, 397, 148, - 444, 419, 086, 360, 014, 446, 244, 445, 399, 157, - 404, 214, 363, 398, 138, 447, 207, 365, 369, 164, - 430, 433, - 015, 019, 057, 070, 432, 249, 127, 431 // Defog(DPPt) & Whirlpool(HGSS) };