Add forme range check method to personalinfo

relocates logic to better location
This commit is contained in:
Kurt 2017-11-21 18:31:24 -08:00
parent b2b6df7808
commit f25b4fea9c
3 changed files with 10 additions and 4 deletions

View file

@ -1857,7 +1857,7 @@ namespace PKHeX.Core
if (count <= 1 && pkm.AltForm == 0)
return; // no forms to check
if (pkm.AltForm >= count && !FormConverter.IsValidOutOfBoundsForme(pkm.Species, pkm.AltForm, Info.Generation))
if (!PersonalInfo.IsFormeWithinRange(pkm.AltForm) && !FormConverter.IsValidOutOfBoundsForme(pkm.Species, pkm.AltForm, Info.Generation))
{
AddLine(Severity.Invalid, string.Format(V304, count-1, pkm.AltForm), CheckIdentifier.Form);
return;

View file

@ -117,5 +117,12 @@
}
public bool HasFormes => FormeCount > 1;
public int BST => HP + ATK + DEF + SPE + SPA + SPD;
public bool IsFormeWithinRange(int forme)
{
if (forme == 0)
return true;
return forme < FormeCount;
}
}
}

View file

@ -170,9 +170,8 @@ namespace PKHeX.WinForms
else if (SAV.MaxSpeciesID < pkm.Species)
errata.Add($"Game can't obtain species: {GameInfo.Strings.specieslist[pkm.Species]}");
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 (!SAV.Personal[pkm.Species].IsFormeWithinRange(pkm.AltForm) && !FormConverter.IsValidOutOfBoundsForme(pkm.Species, pkm.AltForm, pkm.GenNumber))
errata.Add(string.Format(LegalityCheckStrings.V304, Math.Max(0, SAV.Personal[pkm.Species].FormeCount - 1), pkm.AltForm));
if (pkm.Moves.Any(m => m > GameInfo.Strings.movelist.Length))
errata.Add($"Item Index beyond range: {string.Join(", ", pkm.Moves.Where(m => m > GameInfo.Strings.movelist.Length).Select(m => m.ToString()))}");