From 6b410dd65cb2c43e615b7329cc3c44c1caa6d98b Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Mon, 14 Mar 2016 23:46:18 -0700 Subject: [PATCH] Add basic form moveset checking Also added Pikachu/Rotom form moves --- Legality/Core.cs | 59 +++++++++++++++++++++++++++++++--------------- Legality/Tables.cs | 2 ++ 2 files changed, 42 insertions(+), 19 deletions(-) diff --git a/Legality/Core.cs b/Legality/Core.cs index 612678cd6..b0450d3b5 100644 --- a/Legality/Core.cs +++ b/Legality/Core.cs @@ -43,26 +43,43 @@ internal static bool getDexNavValid(PK6 pk6) internal static IEnumerable getValidMoves(PK6 pk6) { List r = new List {0}; - - r.AddRange(getLVLMoves(pk6.Species, pk6.CurrentLevel)); - r.AddRange(getTutorMoves(pk6.Species)); - r.AddRange(getMachineMoves(pk6.Species)); + int species = pk6.Species; + if (species == 386 || species == 492) // Deoxys & Shaymin + { + int formcount = PersonalAO[species].FormeCount; + for (int i = 0; i < formcount; i++) + { + // Check all Forms + r.AddRange(getLVLMoves(species, pk6.CurrentLevel, i)); + r.AddRange(getTutorMoves(species, i)); + r.AddRange(getMachineMoves(species, i)); + } + return r.Distinct().ToArray(); + } + r.AddRange(getLVLMoves(species, pk6.CurrentLevel, pk6.AltForm)); + r.AddRange(getTutorMoves(species, pk6.AltForm)); + r.AddRange(getMachineMoves(species, pk6.AltForm)); IEnumerable vs = getValidPreEvolutions(pk6); foreach (DexLevel evo in vs) { - r.AddRange(getLVLMoves(evo.Species, evo.Level)); - r.AddRange(getTutorMoves(evo.Species)); - r.AddRange(getMachineMoves(evo.Species)); + r.AddRange(getLVLMoves(evo.Species, evo.Level, pk6.AltForm)); + r.AddRange(getTutorMoves(evo.Species, pk6.AltForm)); + r.AddRange(getMachineMoves(evo.Species, pk6.AltForm)); } + if (species == 479) // Rotom + r.Add(RotomMoves[pk6.AltForm]); + if (species == 25) // Pikachu + r.Add(PikachuMoves[pk6.AltForm]); + return r.Distinct().ToArray(); } internal static IEnumerable getValidRelearn(PK6 pk6, int skipOption) { List r = new List { 0 }; int species = getBaseSpecies(pk6, skipOption); - r.AddRange(getLVLMoves(species, 1)); - r.AddRange(getEggMoves(species)); - r.AddRange(getLVLMoves(species, 100)); + r.AddRange(getLVLMoves(species, 1, pk6.AltForm)); + r.AddRange(getEggMoves(species, pk6.Species == 678 ? pk6.AltForm : 0)); + r.AddRange(getLVLMoves(species, 100, pk6.AltForm)); return r.Distinct(); } internal static int[] getLinkMoves(PK6 pk6) @@ -170,9 +187,11 @@ private static int getBaseSpecies(PK6 pk6, int skipOption) default: return evos.Length <= 0 ? pk6.Species : evos.Last().Species; } } - private static IEnumerable getLVLMoves(int species, int lvl) + private static IEnumerable getLVLMoves(int species, int lvl, int formnum) { - return LevelUpXY[species].getMoves(lvl).Concat(LevelUpAO[species].getMoves(lvl)); + int ind_XY = PersonalXY[species].FormeIndex(species, formnum); + int ind_AO = PersonalAO[species].FormeIndex(species, formnum); + return LevelUpXY[ind_XY].getMoves(lvl).Concat(LevelUpAO[ind_AO].getMoves(lvl)); } private static IEnumerable getEncounterSlots(PK6 pk6) { @@ -261,13 +280,15 @@ private static IEnumerable getStatic(PK6 pk6, IEnumerable dl = getValidPreEvolutions(pk6); return table.Where(e => dl.Any(d => d.Species == e.Species)); } - private static IEnumerable getEggMoves(int species) + private static IEnumerable getEggMoves(int species, int formnum) { - return EggMoveAO[species].Moves.Concat(EggMoveXY[species].Moves); + int ind_XY = PersonalXY[species].FormeIndex(species, formnum); + int ind_AO = PersonalAO[species].FormeIndex(species, formnum); + return EggMoveAO[ind_AO].Moves.Concat(EggMoveXY[ind_XY].Moves); } - private static IEnumerable getTutorMoves(int species) + private static IEnumerable getTutorMoves(int species, int formnum) { - PersonalInfo pkAO = PersonalAO[species]; + PersonalInfo pkAO = PersonalAO[PersonalAO[species].FormeIndex(species, formnum)]; // Type Tutor List moves = TypeTutor.Where((t, i) => pkAO.Tutors[i]).ToList(); @@ -280,10 +301,10 @@ private static IEnumerable getTutorMoves(int species) return moves; } - private static IEnumerable getMachineMoves(int species) + private static IEnumerable getMachineMoves(int species, int formnum) { - PersonalInfo pkXY = PersonalXY[species]; - PersonalInfo pkAO = PersonalAO[species]; + PersonalInfo pkXY = PersonalXY[PersonalXY[species].FormeIndex(species, formnum)]; + PersonalInfo pkAO = PersonalAO[PersonalAO[species].FormeIndex(species, formnum)]; List moves = new List(); moves.AddRange(TMHM_XY.Where((t, i) => pkXY.TMHM[i])); moves.AddRange(TMHM_AO.Where((t, i) => pkAO.TMHM[i])); diff --git a/Legality/Tables.cs b/Legality/Tables.cs index 61378925e..262e783e3 100644 --- a/Legality/Tables.cs +++ b/Legality/Tables.cs @@ -407,5 +407,7 @@ public static partial class Legal 082, 303, 597, 205, 227, 375, 600, 437, 530, 707, 098, 224, 400, 515, 008, 130, 195, 419, 061, 184, 657 }; + internal static readonly int[] RotomMoves = { 0, 315, 056, 059, 403, 437 }; + internal static readonly int[] PikachuMoves = { 0, 309, 556, 577, 604, 560 }; } }