public static EggSource6[] Validate(int generation, int species, int form, GameVersion version, ReadOnlySpan <int> moves, out bool valid) { var count = moves.IndexOf(0); if (count == 0) { valid = false; // empty moveset return(Array.Empty <EggSource6>()); } if (count == -1) { count = moves.Length; } var learn = GameData.GetLearnsets(version); var table = GameData.GetPersonal(version); var index = table.GetFormIndex(species, form); var learnset = learn[index]; var egg = MoveEgg.GetEggMoves(generation, species, form, version); var actual = new EggSource6[count]; Span <byte> possible = stackalloc byte[count]; var value = new BreedInfo <EggSource6>(actual, possible, learnset, moves, level); if (species is (int)Species.Pichu && moves[count - 1] is (int)Move.VoltTackle) { actual[--count] = VoltTackle; } if (count == 0) { valid = VerifyBaseMoves(value); } else { bool inherit = Breeding.GetCanInheritMoves(species); MarkMovesForOrigin(value, egg, count, inherit); valid = RecurseMovesForOrigin(value, count - 1); } if (!valid) { CleanResult(actual, possible); } return(value.Actual); }
private static bool RecurseMovesForOrigin(BreedInfo <EggSource6> info, int start, EggSource6 type = Max - 1) { int i = start; do { var unpeel = type - 1; if (unpeel != 0 && RecurseMovesForOrigin(info, i, unpeel)) { return(true); } var permit = info.Possible[i]; if ((permit & (1 << (int)type)) == 0) { return(false); } info.Actual[i] = type; } while (--i >= 0); return(VerifyBaseMoves(info)); }