mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-10-02 09:19:20 -05:00
Update form destination handling
espurr-F evolves to form-1 from form0, even tho the form arg is -1 (gen7 consideration) gen8 has 0/1 for the two evolutions, dictating the destination form
This commit is contained in:
@@ -10,12 +10,16 @@ public sealed class EvolutionMethod
|
||||
public int Method;
|
||||
public int Species;
|
||||
public int Argument;
|
||||
public int Form = -1;
|
||||
public int Form = AnyForm;
|
||||
public int Level;
|
||||
|
||||
public const int AnyForm = -1;
|
||||
|
||||
// Not stored in binary data
|
||||
public bool RequiresLevelUp; // tracks if this method requires a Level Up, lazily set
|
||||
|
||||
public int GetDestinationForm(int form) => Form == AnyForm ? form : Method == (int)LevelUpFormFemale1 ? 1 : Form;
|
||||
|
||||
/// <summary>
|
||||
/// Checks the <see cref="EvolutionMethod"/> for validity by comparing against the <see cref="PKM"/> data.
|
||||
/// </summary>
|
||||
|
||||
@@ -89,10 +89,40 @@ private EvolutionTree(IReadOnlyList<byte[]> data, GameVersion game, PersonalTabl
|
||||
Personal = personal;
|
||||
MaxSpeciesTree = maxSpeciesTree;
|
||||
Entries = GetEntries(data);
|
||||
var connections = CreateTree();
|
||||
|
||||
// Starting in Generation 7, forms have separate evolution data.
|
||||
int format = Game.GetGeneration();
|
||||
var oldStyle = format < 7;
|
||||
var connections = oldStyle ? CreateTreeOld() : CreateTree();
|
||||
|
||||
Lineage = connections.ToLookup(obj => obj.Key, obj => obj.Value);
|
||||
}
|
||||
|
||||
private IEnumerable<KeyValuePair<int, EvolutionLink>> CreateTreeOld()
|
||||
{
|
||||
for (int sSpecies = 1; sSpecies <= MaxSpeciesTree; sSpecies++)
|
||||
{
|
||||
var fc = Personal[sSpecies].FormeCount;
|
||||
for (int sForm = 0; sForm < fc; sForm++)
|
||||
{
|
||||
var index = sSpecies;
|
||||
var evos = Entries[index];
|
||||
foreach (var evo in evos)
|
||||
{
|
||||
var dSpecies = evo.Species;
|
||||
if (dSpecies == 0)
|
||||
continue;
|
||||
|
||||
var dForm = sForm;
|
||||
var key = GetLookupKey(dSpecies, dForm);
|
||||
|
||||
var link = new EvolutionLink(sSpecies, sForm, evo);
|
||||
yield return new KeyValuePair<int, EvolutionLink>(key, link);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<KeyValuePair<int, EvolutionLink>> CreateTree()
|
||||
{
|
||||
for (int sSpecies = 1; sSpecies <= MaxSpeciesTree; sSpecies++)
|
||||
@@ -107,7 +137,12 @@ private EvolutionTree(IReadOnlyList<byte[]> data, GameVersion game, PersonalTabl
|
||||
var dSpecies = evo.Species;
|
||||
if (dSpecies == 0)
|
||||
continue;
|
||||
var dForm = evo.Form < 0 ? sForm : evo.Form;
|
||||
|
||||
bool any = evo.Form == EvolutionMethod.AnyForm;
|
||||
if (!any && evo.Form != sForm)
|
||||
continue;
|
||||
|
||||
var dForm = evo.GetDestinationForm(sForm);
|
||||
var key = GetLookupKey(dSpecies, dForm);
|
||||
|
||||
var link = new EvolutionLink(sSpecies, sForm, evo);
|
||||
@@ -210,7 +245,7 @@ private IEnumerable<int> GetPreEvolutions(int species, int form)
|
||||
|
||||
private IEnumerable<int> GetEvolutions(int species, int form)
|
||||
{
|
||||
int index = Personal.GetFormeIndex(species, form);
|
||||
int index = GetLookupKey(species, form);
|
||||
var node = Lineage[index];
|
||||
foreach (var method in node)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user