Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SAM.Game filter not working correctly? #446

Open
bbfox0703 opened this issue Nov 21, 2024 · 0 comments
Open

SAM.Game filter not working correctly? #446

bbfox0703 opened this issue Nov 21, 2024 · 0 comments

Comments

@bbfox0703
Copy link

Original Code in Manager.cs

if (textSearch != null)
{
    if (def.Name.IndexOf(textSearch, StringComparison.OrdinalIgnoreCase) < 0 ||
        def.Description.IndexOf(textSearch, StringComparison.OrdinalIgnoreCase) < 0)
    {
        continue;
    }
}

Issue

  • The current logic skips the entry if either Name or Description does not match the search term.
  • This makes it impossible to filter achievements based solely on Description.

Proposed Solution

The logic can be updated to:

  1. Use && instead of ||.
  2. Check if Description is either empty or does not match the search term.

Here’s the revised code:

if (textSearch != null)
{
    if (def.Name.IndexOf(textSearch, StringComparison.OrdinalIgnoreCase) < 0 &&
        (string.IsNullOrEmpty(def.Description) || def.Description.IndexOf(textSearch, StringComparison.OrdinalIgnoreCase) < 0))
    {
        continue;
    }
}

Explanation

  • The updated condition ensures the entry is skipped only if both conditions fail:
    1. The Name does not contain the search term.
    2. The Description is either empty or does not contain the search term.
  • This fix allows filtering by either Name or Description, ensuring the functionality is more flexible.

Improved Behavior

  • Original Code: If Name does not match, the entry is skipped regardless of whether Description matches or not.
  • Revised Code: If Name does not match, the Description is still checked. If it matches, the entry is not skipped.

This ensures that the filtering logic meets the requirement of "matching either condition to include the entry."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant