Issue? Multiple Filters uses OR, not AND

Perhaps you've found on a bug on the site or want to request a new feature to Khy'eras? Or maybe there's a continuity error in the lore? For any problems or comments, let us know here!
Post Reply
User avatar
Izzy
Writer
Posts: 5
Joined: January 7th, 2021, 12:56 pm
Location: Denmark
Has thanked: 1 time
Been thanked: 1 time

Issue? Multiple Filters uses OR, not AND

Post by Izzy »

Type: Technical

Details: When filtering either Character Listing or Achievements and using multiple filters (i.e. Race AND Class), the results returned will return anything that matches at least one filter.

I think this is fine when within a single option i.e. they select Fae, Human- so return anyone that matches either of them. The problem is when I'm filtering a class as well, like... Sorcerer. I'm usually thinking: show me Faes and Humans that are Sorcerers. Not: show me all Faes and Humans (regardless of class), all Sorcerers (regardless of race). Or a more common example, I imagine, is looking for active characters that are also the same race.

I rooted around in the code to see if I could debug this issue and think I understand why it happens?
Currently, when filtering, you check the search-filters vs the card's data-filters, and then score the card based on how many filters it matches. If it has 0 matches, it'll be hidden... is my understanding? It's hard to comprehend the minified code LOL.
My first thought was to then just check the number of filters and have the score to display = number of filters... So "race=human&class=cleric" there are two filters, so the score would have to be 2 or else it's hidden.
But that becomes a problem when you have multiple Race filters for example. "race=human&race=fae"... a Human would match 1, Fae would match 1, and a half Human-Fae would match 2. But we would like to show all those cases!
So what now? Perhaps it would be possible to have the card filters use arrays for same filter types, so instead of race=Fae and race=Human, it would be race=[Fae, Human], and you check if race has either option, rewarding only 1 point regardless if it has one or both. You would then be able to check if the matched score matches the number of filters.
Search-filters and card's data-filters would have to be managed similarly to keep the scores consistent.

I coded a very shoddy example of what I mean, which you can see in this JSFiddle.
User avatar
Memoria
Administrator
* { display: coffee; }
Posts: 238
Joined: April 21st, 2018, 9:21 pm
Location: Colorado
Has thanked: 31 times
Been thanked: 62 times
Contact:

Re: Issue? Multiple Filters uses OR, not AND

Post by Memoria »

I'll look into seeing if I can do something like this. I was aware it sorted by "or" rather than "and" when I built the code. It was easier implementation at the time and adding the filters was somewhat spur of the moment / "for fun" thing.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest