mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-23 04:23:12 +00:00
slick switch expression
Might be a target for future refactoring if Format(int) is changed in the future...
This commit is contained in:
parent
5260c5214e
commit
2f9e05972f
1 changed files with 9 additions and 16 deletions
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue