Prevent setting of invalid dmax levels to set

Just an extra protection.
This commit is contained in:
Kurt 2022-08-03 17:50:11 -07:00
parent 50a64d8beb
commit ac17c7d4a3

View File

@ -209,7 +209,7 @@ private bool ParseEntry(string identifier, string value)
case "Nature": return (Nature = StringUtil.FindIndexIgnoreCase(Strings.natures, value)) >= 0;
case "EV" or "EVs": ParseLineEVs(value); return true;
case "IV" or "IVs": ParseLineIVs(value); return true;
case "Dynamax Level": return (DynamaxLevel = (byte)Util.ToInt32(value)) is (>= 0 and <= 10);
case "Dynamax Level": return ParseDynamax(value);
case "Level":
{
if (!int.TryParse(value.Trim(), out int val))
@ -229,6 +229,14 @@ private bool ParseEntry(string identifier, string value)
}
}
private bool ParseDynamax(string value)
{
var val = Util.ToInt32(value);
if ((uint)val > 10)
return false;
return (DynamaxLevel = (byte)val) is (>= 0 and <= 10);
}
/// <summary>
/// Gets the standard Text representation of the set details.
/// </summary>