public static EggSource2[] Validate(int species, GameVersion version, ReadOnlySpan <int> moves, out bool valid) { var count = moves.IndexOf(0); if (count == 0) { valid = false; // empty moveset return(Array.Empty <EggSource2>()); } if (count == -1) { count = moves.Length; } var learn = GameData.GetLearnsets(version); var table = GameData.GetPersonal(version); var learnset = learn[species]; var pi = table[species]; var egg = (version == GameVersion.C ? Legal.EggMovesC : Legal.EggMovesGS)[species].Moves; var actual = new EggSource2[count]; Span <byte> possible = stackalloc byte[count]; var value = new BreedInfo <EggSource2>(actual, possible, learnset, moves, level); { bool inherit = Breeding.GetCanInheritMoves(species); MarkMovesForOrigin(value, egg, count, inherit, pi, version); valid = RecurseMovesForOrigin(value, count - 1); } if (!valid) { CleanResult(actual, possible); } return(actual); }
private static bool RecurseMovesForOrigin(BreedInfo <EggSource2> info, int start, EggSource2 type = Max) { int i = start; do { if (type != Base) { if (RecurseMovesForOrigin(info, i, Base)) { return(true); } } var flag = 1 << (int)Base; if (type != Base) { flag = ~flag; } var permit = info.Possible[i]; if ((permit & flag) == 0) { return(false); } info.Actual[i] = type == Base ? Base : GetFirstType(permit); } while (--i >= 0); return(VerifyBaseMoves(info)); }