using System; using System.Collections.Generic; using System.Linq; namespace PKHeX.Core { /// /// Logic for generating a large amount of data. /// public static class BulkGenerator { public static List GetLivingDex(this SaveFile sav) { var speciesToGenerate = Enumerable.Range(1, sav.MaxSpeciesID); return GetLivingDex(sav, speciesToGenerate); } private static List GetLivingDex(SaveFile sav, IEnumerable speciesToGenerate) { return sav.GetLivingDex(speciesToGenerate, sav.BlankPKM); } public static List GetLivingDex(this ITrainerInfo tr, IEnumerable speciesToGenerate, PKM blank) { var result = new List(); var destType = blank.GetType(); foreach (var s in speciesToGenerate) { var pk = blank.Clone(); pk.Species = s; pk.Gender = pk.GetSaneGender(); var pi = pk.PersonalInfo; for (int f = 0; f < pi.FormeCount; f++) { var entry = tr.GetLivingEntry(pk, s, f, destType); if (entry == null) continue; result.Add(entry); } } return result; } public static PKM? GetLivingEntry(this ITrainerInfo tr, PKM template, int species, int form, Type destType) { template.Species = species; template.AltForm = form; template.Gender = template.GetSaneGender(); var f = EncounterMovesetGenerator.GeneratePKMs(template, tr).FirstOrDefault(); if (f == null) return null; var result = PKMConverter.ConvertToType(f, destType, out _); if (result == null) return null; result.CurrentLevel = 100; result.Species = species; result.AltForm = form; result.Heal(); return result; } } }