2020-03-20 20:33:15 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2019-10-26 19:58:55 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Logic for generating a large amount of <see cref="PKM"/> data.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static class BulkGenerator
|
|
|
|
|
{
|
2020-03-20 20:33:15 +00:00
|
|
|
|
public static List<PKM> GetLivingDex(this SaveFile sav)
|
2019-10-26 19:58:55 +00:00
|
|
|
|
{
|
2020-01-26 06:54:25 +00:00
|
|
|
|
var speciesToGenerate = Enumerable.Range(1, sav.MaxSpeciesID);
|
2020-03-20 20:33:15 +00:00
|
|
|
|
return GetLivingDex(sav, speciesToGenerate);
|
2020-01-26 06:54:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-20 20:33:15 +00:00
|
|
|
|
private static List<PKM> GetLivingDex(SaveFile sav, IEnumerable<int> speciesToGenerate)
|
|
|
|
|
{
|
|
|
|
|
return sav.GetLivingDex(speciesToGenerate, sav.BlankPKM);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static List<PKM> GetLivingDex(this ITrainerInfo tr, IEnumerable<int> speciesToGenerate, PKM blank)
|
2020-01-26 06:54:25 +00:00
|
|
|
|
{
|
|
|
|
|
var result = new List<PKM>();
|
|
|
|
|
var destType = blank.GetType();
|
|
|
|
|
foreach (var s in speciesToGenerate)
|
2019-10-26 19:58:55 +00:00
|
|
|
|
{
|
2020-01-26 06:54:25 +00:00
|
|
|
|
var pk = blank.Clone();
|
|
|
|
|
pk.Species = s;
|
2019-10-26 19:58:55 +00:00
|
|
|
|
pk.Gender = pk.GetSaneGender();
|
|
|
|
|
|
2020-01-26 06:54:25 +00:00
|
|
|
|
var pi = pk.PersonalInfo;
|
2020-12-11 04:42:30 +00:00
|
|
|
|
for (int f = 0; f < pi.FormCount; f++)
|
2020-01-26 06:54:25 +00:00
|
|
|
|
{
|
2020-03-20 20:33:15 +00:00
|
|
|
|
var entry = tr.GetLivingEntry(pk, s, f, destType);
|
|
|
|
|
if (entry == null)
|
2020-01-26 06:54:25 +00:00
|
|
|
|
continue;
|
2020-03-20 20:33:15 +00:00
|
|
|
|
result.Add(entry);
|
2020-01-26 06:54:25 +00:00
|
|
|
|
}
|
2019-10-26 19:58:55 +00:00
|
|
|
|
}
|
2020-01-26 06:54:25 +00:00
|
|
|
|
|
|
|
|
|
return result;
|
2019-10-26 19:58:55 +00:00
|
|
|
|
}
|
2020-03-20 20:33:15 +00:00
|
|
|
|
|
|
|
|
|
public static PKM? GetLivingEntry(this ITrainerInfo tr, PKM template, int species, int form, Type destType)
|
|
|
|
|
{
|
|
|
|
|
template.Species = species;
|
2020-12-11 04:42:30 +00:00
|
|
|
|
template.Form = form;
|
2020-03-20 20:33:15 +00:00
|
|
|
|
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.Species = species;
|
2020-12-11 04:42:30 +00:00
|
|
|
|
result.Form = form;
|
2022-03-06 02:13:31 +00:00
|
|
|
|
result.CurrentLevel = 100;
|
2020-03-20 20:33:15 +00:00
|
|
|
|
|
|
|
|
|
result.Heal();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2019-10-26 19:58:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|