Flag invalid forms on sav compatibility check

closes #1615
This commit is contained in:
Kurt 2017-11-16 14:30:18 -08:00
parent 8958646ae6
commit 025b8da52c
3 changed files with 22 additions and 17 deletions

View file

@ -1857,9 +1857,9 @@ namespace PKHeX.Core
if (count <= 1 && pkm.AltForm == 0)
return; // no forms to check
if (pkm.AltForm >= count && !IsValidOutOfBoundsForme(pkm.Species, pkm.AltForm, Info.Generation))
if (pkm.AltForm >= count && !FormConverter.IsValidOutOfBoundsForme(pkm.Species, pkm.AltForm, Info.Generation))
{
AddLine(Severity.Invalid, string.Format(V304, count, pkm.AltForm), CheckIdentifier.Form);
AddLine(Severity.Invalid, string.Format(V304, count-1, pkm.AltForm), CheckIdentifier.Form);
return;
}
@ -2029,20 +2029,6 @@ namespace PKHeX.Core
AddLine(Severity.Valid, V318, CheckIdentifier.Form);
}
private static bool IsValidOutOfBoundsForme(int species, int form, int generation)
{
switch (species)
{
case 201: // Unown
return form < (generation == 2 ? 26 : 28); // A-Z : A-Z?!
case 414: // Wormadam base form is kept
return form < 3;
case 664: case 665: // Vivillon Pre-evolutions
return form < 18;
default:
return false;
}
}
private void VerifyMiscG1()
{
if (pkm.IsEgg)

View file

@ -61,7 +61,22 @@ namespace PKHeX.Core
return form -2;
return form - 1;
}
public static bool IsValidOutOfBoundsForme(int species, int form, int generation)
{
switch (species)
{
case 201: // Unown
return form < (generation == 2 ? 26 : 28); // A-Z : A-Z?!
case 414: // Wormadam base form is kept
return form < 3;
case 664:
case 665: // Vivillon Pre-evolutions
return form < 18;
default:
return false;
}
}
private static string[] GetFormsGen1(int species, IReadOnlyList<string> types, IReadOnlyList<string> forms, int generation)
{
switch (species)

View file

@ -165,6 +165,10 @@ namespace PKHeX.WinForms
errata.Add($"Game can't hold item: {GameInfo.Strings.itemlist[held]}");
}
int count = SAV.Personal[pkm.Species].FormeCount;
if (pkm.AltForm >= SAV.Personal[pkm.Species].FormeCount && !FormConverter.IsValidOutOfBoundsForme(pkm.Species, pkm.AltForm, pkm.GenNumber))
errata.Add(string.Format(LegalityCheckStrings.V304, count-1, pkm.AltForm));
if (pkm.Species > GameInfo.Strings.specieslist.Length)
errata.Add($"Species Index beyond range: {pkm.Species}");
else if (SAV.MaxSpeciesID < pkm.Species)