Sanity check nature for Criteria parameter

This commit is contained in:
Kurt 2021-02-01 10:45:53 -08:00
parent afbf1d997b
commit 8a2d115df3
2 changed files with 12 additions and 1 deletions

View file

@ -33,4 +33,15 @@
Random = 25,
}
public static class NatureUtil
{
public static Nature GetNature(int value) => value switch
{
< 0 or >= (int)Nature.Random => Nature.Random,
_ => (Nature)value
};
public static bool IsFixed(this Nature value) => value is >= 0 and < Nature.Random;
}
}

View file

@ -58,7 +58,7 @@
IV_SPD = s.IVs[5],
HPType = s.HiddenPowerType,
Nature = (Nature)s.Nature,
Nature = NatureUtil.GetNature(s.Nature),
Shiny = s.Shiny ? Shiny.Always : Shiny.Never,
};
}