slick switch expression

Might be a target for future refactoring if Format(int) is changed in the future...
This commit is contained in:
Kurt 2022-04-09 12:25:19 -07:00
parent 5260c5214e
commit 2f9e05972f

View file

@ -8,24 +8,17 @@ namespace PKHeX.Core.Searching
/// </summary>
public static class SearchUtil
{
public static bool SatisfiesFilterFormat(PKM pk, int format, SearchComparison formatOperand)
// Future: Might need to clamp down further for generations that cannot exist in the current format.
public static bool SatisfiesFilterFormat(PKM pk, int format, SearchComparison formatOperand) => formatOperand switch
{
switch (formatOperand)
{
case SearchComparison.GreaterThanEquals when pk.Format < format:
case SearchComparison.Equals when pk.Format != format:
case SearchComparison.LessThanEquals when pk.Format > format:
return false;
}
SearchComparison.GreaterThanEquals when pk.Format < format => false,
SearchComparison.Equals when pk.Format != format => false,
SearchComparison.LessThanEquals when pk.Format > format => false,
// Might need to clamp down further for generations that cannot exist in the current format.
return format switch
{
<= 2 => pk.Format <= 2, // 1-2
<= 6 => pk.Format >= 3, // 3-6
_ => true,
};
}
_ when format <= 2 => pk.Format <= 2, // 1-2
_ when format <= 6 => pk.Format >= 3, // 3-6
_ => true,
};
public static bool SatisfiesFilterGeneration(PKM pk, int generation) => generation switch
{