Pass form when form doesn't match encounter

This is still a horrible hack, needs to be done similar to encounter slots

handle the galar NFE formchange cases
This commit is contained in:
Kurt 2020-04-23 20:53:57 -07:00
parent 8a54e8c7b9
commit 913d2773bf
9 changed files with 14 additions and 11 deletions

View file

@ -448,7 +448,7 @@ namespace PKHeX.Core
}; };
} }
private static bool IsEvolvedFormChange(PKM pkm) private static bool IsEvolvedFormChange(PKM pkm, int expected)
{ {
if (pkm.IsEgg) if (pkm.IsEgg)
return false; return false;
@ -461,6 +461,8 @@ namespace PKHeX.Core
return pkm.AltForm == 1; return pkm.AltForm == 1;
if (GalarForm0Evolutions.TryGetValue(pkm.Species, out var orig)) if (GalarForm0Evolutions.TryGetValue(pkm.Species, out var orig))
return pkm.AltForm != orig; // bad compare? return pkm.AltForm != orig; // bad compare?
if ((int) Species.Darmanitan == pkm.Species)
return pkm.AltForm == (expected == 1 ? 2 : 0);
if ((int) Species.Toxtricity == pkm.Species) if ((int) Species.Toxtricity == pkm.Species)
return pkm.AltForm == EvolutionMethod.GetAmpLowKeyResult(pkm.Nature); return pkm.AltForm == EvolutionMethod.GetAmpLowKeyResult(pkm.Nature);
if ((int) Species.Alcremie == pkm.Species) if ((int) Species.Alcremie == pkm.Species)
@ -554,11 +556,12 @@ namespace PKHeX.Core
/// <summary>Checks if the form may be different than the original encounter detail.</summary> /// <summary>Checks if the form may be different than the original encounter detail.</summary>
/// <param name="pkm">Pokémon</param> /// <param name="pkm">Pokémon</param>
/// <param name="species">Original species</param> /// <param name="species">Original species</param>
internal static bool IsFormChangeable(PKM pkm, int species) /// <param name="form">Original form</param>
internal static bool IsFormChangeable(PKM pkm, int species, int form)
{ {
if (FormChange.Contains(species)) if (FormChange.Contains(species))
return true; return true;
if (species != pkm.Species && IsEvolvedFormChange(pkm)) if (species != pkm.Species && IsEvolvedFormChange(pkm, form))
return true; return true;
if (species == (int)Species.Zygarde && pkm.InhabitedGeneration(7) && pkm.AltForm > 1) if (species == (int)Species.Zygarde && pkm.InhabitedGeneration(7) && pkm.AltForm > 1)
return true; return true;

View file

@ -302,7 +302,7 @@ namespace PKHeX.Core
var expectForm = pkm.Format == 7 ? Form : FormConverter.GetTotemBaseForm(Species, Form); var expectForm = pkm.Format == 7 ? Form : FormConverter.GetTotemBaseForm(Species, Form);
return expectForm == pkm.AltForm; return expectForm == pkm.AltForm;
} }
if (Form != pkm.AltForm && !Legal.IsFormChangeable(pkm, Species)) if (Form != pkm.AltForm && !Legal.IsFormChangeable(pkm, Species, Form))
return false; return false;
return true; return true;
} }

View file

@ -247,7 +247,7 @@ namespace PKHeX.Core
if (CurrentLevel != -1 && CurrentLevel > pkm.CurrentLevel) if (CurrentLevel != -1 && CurrentLevel > pkm.CurrentLevel)
return false; return false;
if (Form != pkm.AltForm && !Legal.IsFormChangeable(pkm, Species)) if (Form != pkm.AltForm && !Legal.IsFormChangeable(pkm, Species, Form))
return false; return false;
if (OTGender != -1 && OTGender != pkm.OT_Gender) if (OTGender != -1 && OTGender != pkm.OT_Gender)
return false; return false;

View file

@ -161,7 +161,7 @@ namespace PKHeX.Core
return false; return false;
} }
if (wc.AltForm != pkm.AltForm && !Legal.IsFormChangeable(pkm, Species)) if (wc.AltForm != pkm.AltForm && !Legal.IsFormChangeable(pkm, Species, wc.AltForm))
return false; return false;
if (wc.Ball != pkm.Ball) return false; if (wc.Ball != pkm.Ball) return false;

View file

@ -369,7 +369,7 @@ namespace PKHeX.Core
return false; return false;
} }
if (Form != pkm.AltForm && !Legal.IsFormChangeable(pkm, Species)) if (Form != pkm.AltForm && !Legal.IsFormChangeable(pkm, Species, Form))
return false; return false;
if (Level != pkm.Met_Level) return false; if (Level != pkm.Met_Level) return false;

View file

@ -474,7 +474,7 @@ namespace PKHeX.Core
if (EncryptionConstant != 0 && EncryptionConstant != pkm.EncryptionConstant) return false; if (EncryptionConstant != 0 && EncryptionConstant != pkm.EncryptionConstant) return false;
} }
if (Form != pkm.AltForm && !Legal.IsFormChangeable(pkm, Species)) if (Form != pkm.AltForm && !Legal.IsFormChangeable(pkm, Species, Form))
return false; return false;
if (IsEgg) if (IsEgg)

View file

@ -478,7 +478,7 @@ namespace PKHeX.Core
if (EncryptionConstant != 0 && EncryptionConstant != pkm.EncryptionConstant) return false; if (EncryptionConstant != 0 && EncryptionConstant != pkm.EncryptionConstant) return false;
if (Language != 0 && Language != pkm.Language) return false; if (Language != 0 && Language != pkm.Language) return false;
} }
if (Form != pkm.AltForm && !Legal.IsFormChangeable(pkm, Species)) if (Form != pkm.AltForm && !Legal.IsFormChangeable(pkm, Species, Form))
return false; return false;
if (IsEgg) if (IsEgg)

View file

@ -509,7 +509,7 @@ namespace PKHeX.Core
if (Language != 0 && Language != pkm.Language) return false; if (Language != 0 && Language != pkm.Language) return false;
} }
if (Form != pkm.AltForm && !Legal.IsFormChangeable(pkm, Species)) if (Form != pkm.AltForm && !Legal.IsFormChangeable(pkm, Species, Form))
{ {
if (Species == (int)Core.Species.Rockruff && Form == 1 && pkm.Species == 745 && pkm.AltForm == 2) if (Species == (int)Core.Species.Rockruff && Form == 1 && pkm.Species == 745 && pkm.AltForm == 2)
{ {

View file

@ -519,7 +519,7 @@ namespace PKHeX.Core
} }
} }
if (Form != pkm.AltForm && !Legal.IsFormChangeable(pkm, Species)) if (Form != pkm.AltForm && !Legal.IsFormChangeable(pkm, Species, Form))
return false; return false;
if (IsEgg) if (IsEgg)