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

Filter Strings for Deck Editor search #3582

Merged
merged 31 commits into from
Mar 1, 2019

Conversation

basicer
Copy link
Member

@basicer basicer commented Feb 18, 2019

Related Issues

Short roundup of the initial problem

Searching cards in the deck editor is hard.

What will change with this Pull Request?

  • Entering a string in the search box with [:=<>] in it will try to parse the query in the MagicCards.info syntax.

Screenshots

image

@basicer basicer force-pushed the string-filter branch 2 times, most recently from 3d3b7c2 to 8b8ced8 Compare February 18, 2019 11:50
@tooomm
Copy link
Member

tooomm commented Feb 18, 2019

MagicCards.info syntax

You mean scryfall syntax since they took over mci? https://scryfall.com/docs/syntax

If it's the old mci syntax and that's any different, I wouldn't use that since the site no longer exists and people can't check the syntax or new users are not used to it at all.


In general a very nice new feature though! 👍

@ZeldaZach
Copy link
Member

My question is: Why doesn't this auto-create the filters in the filter section once they're typed up? Would make a bit more sense as why would we have two types of filtering operations?

@basicer
Copy link
Member Author

basicer commented Feb 18, 2019

I tried generating the filter tree in v0, but it turned out the filter tree wasn't expressive enough to capture the kinds of queries you can write.

@basicer
Copy link
Member Author

basicer commented Feb 18, 2019

MagicCards.info syntax

You mean scryfall syntax since they took over mci? https://scryfall.com/docs/syntax

If it's the old mci syntax and that's any different, I wouldn't use that since the site no longer exists and people can't check the syntax or new users are not used to it at all.

In general a very nice new feature though! 👍

What I really mean is http://magidex.com syntax : )

@ebbit1q
Copy link
Member

ebbit1q commented Feb 19, 2019

Scryfall syntax is almost exactly the same: https://scryfall.com/docs/syntax
Exception is the + and operation on sets (+ is or on Scryfall instead)
Also Scryfall is more expansive, with more details going as far as what character is represented on the art of the card.

@basicer
Copy link
Member Author

basicer commented Feb 19, 2019

The joke is I made magidex.com before scryfall ;)

auto op = sv[0].get<QString>();
return [=](int s) {
if (op == ">")
return s > arg;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember in the past for a school problem I was able to convert the op string to a real op without switches... maybe I'm mistaken?

@basicer basicer force-pushed the string-filter branch 3 times, most recently from b81f9d3 to 46154f3 Compare February 20, 2019 20:42
Copy link
Member

@ZeldaZach ZeldaZach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine to me. More of an Easter egg than anything, but has no detriment to the program so I'm fine having it.


std::once_flag init;

FilterString::FilterString(const QString &expr)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would really like some comments in here

@basicer
Copy link
Member Author

basicer commented Feb 21, 2019

Seems fine to me. More of an Easter egg than anything, but has no detriment to the program so I'm fine having it.

Should I add a tip of the day?

@ZeldaZach
Copy link
Member

Good idea, forgot about that 😅

@ebbit1q
Copy link
Member

ebbit1q commented Feb 21, 2019

hold on, do we now have two separate filter methods? we already have a entire separate filter widget and all.

@ctrlaltca
Copy link
Contributor

I agree, having two different ways to do the same thing (filtering cards in the deck editor), both of them not exactly clear to use and not well documented is not really good from an user perspective.
To be honest, this implementation looks far better than the existing one; it would be nice to merge them into a single one or even drop the older, as long as we implement a visual way to discover the possible syntax that can be user in the new filter.

@basicer
Copy link
Member Author

basicer commented Feb 21, 2019

Could add something like this to the search text widget that gives syntax help.

image

@ebbit1q
Copy link
Member

ebbit1q commented Feb 21, 2019

I don't like the old filter system either. this would solve multiple issues with it. Documenting it well is a must.

@ctrlaltca
Copy link
Contributor

That would be great. Also, a history of the last used search queries, so that a recent search pattern can be reused easily. That would totally surpass the old filters capabilities and make it obsolete.

Copy link
Member

@ebbit1q ebbit1q left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parser isn't activated if a search only contains quotes"".
This means the search for "Birds of Paradise" has no results, but the search "Birds of Paradise" t:bird does what you'd expect.

This search overrules the filter widget, so setting a filter there for something like cmc = 5 and searching t:angel will still give angels of all mana costs.
If the old system is still there it should at least be told somewhere that they don't combine.

The clickable link for c:(l,c) in the syntax help has an added brace to the right, clicking it results in c:(l%2Cc being inserted in the search bar with no results. Other links with ,)+ in them don't work either.
Inserting c:(l,c) doesn't actually work either. Other searches with (),+ in them don't work either.

The format filters f: and banned: don't actually work, unsurprisingly as this data isn't stored in xmls afaik. They should be removed from the syntax help.

The filter for rarity r: doesn't work even though mentioned in the syntax help.

Searching for o:{T} doesn't work, o:"{T}" does work, this should be changed in the syntax help.

Searching for c:wu doesn't work, nor does any combined letter combination, single letters as c:w work fine.

Searching for c!w doesn't work, nor does the ! syntax in any combination.

Copy link
Member

@ebbit1q ebbit1q left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There still are a few things in the syntax guide that don't work as expected:

  • while c:m does work c:mw or c:wm ignores m and filters exactly like c:w
  • c!uw actually only tests if a card is both
  • c!uwm gives no results at all
  • c= doesn't work at all and gets mojibaked when clicked as well, just like ! used to
  • , doesn't work, instead some form of or keyword might be better
  • e:lea+leb doesn't work and clicking it inserts e:al,be instead, same for e:lea,leb -e:lea+leb
    ** just replace e:lea+leb with e:lea e:leb

also:

  • e: doesn't work for sets with a number in them like 6ed or cn2
  • the keyword for toughness sorting isn't mentioned in the syntax help even though it's easily assumed to be tou
  • c!c doesn't work, in theory it should give the same results as c:c
  • closing the cockatrice main window should close the syntax help window as well

@basicer
Copy link
Member Author

basicer commented Feb 27, 2019

  • f: and banned: aren't implemented, it's best to remove them from the syntax help for now

They should be, update your card database?

@ebbit1q
Copy link
Member

ebbit1q commented Feb 27, 2019

My bad, they work fine.

@@ -700,7 +704,11 @@ void TabDeckEditor::updateCardInfoRight(const QModelIndex &current, const QModel

void TabDeckEditor::updateSearch(const QString &search)
{
databaseDisplayModel->setCardName(search);
if (search.contains(QRegularExpression("[:<>=\"!]"))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be a tad more efficient to store the regex instead? afaik qt does some optimization for them.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, having a const QRegex is better

@ebbit1q
Copy link
Member

ebbit1q commented Feb 27, 2019

--- a/cockatrice/resources/help/search.md
+++ b/cockatrice/resources/help/search.md
@@ -23,7 +23,7 @@
 <dd>[c!w](#c!w) <small>(Cards that are only white)</small></dd>
 <dd>[c!wu](#c!wu) <small>(Cards that are only white or blue, or both)</small></dd>
 <dd>[c!wum](#c!wum) <small>(Cards that are only white and blue, and multicolored)</small></dd>
-<dd>[c=wubrg](#c%3Dwubrg) <small>(Cards that are all five colors)</small></dd>
+<dd>[c=wubrg](#c=wubrg) <small>(Cards that are all five colors)</small></dd>
 <dd>[c:m](#c:m) <small>(Any multicolored card)</small></dd>
 
 <dt><u>Pow</u>er, <u>Tou</u>ghness, <u>C</u>onverted <u>M</u>ana <u>C</u>ost:</dt>
@@ -41,7 +41,7 @@
 <dd>[e:lea](#e:lea)</dd>
 <dd>[e:lea,leb](#e:lea,leb) <small>(Cards that appear in Alpha or Beta)</small></dd>
 
-<dd>[e:lea+leb](#e:al,be) <small>(Cards that appear in Alpha and Beta)</small></dd>
-<dd>[e:lea,leb -e:lea+leb](#e:al,be -e:al,be) <small>(Cards that appear in Alpha or Beta but not in both editions)</small></dd>
+<dd>[e:lea+leb](#e:lea+leb) <small>(Cards that appear in Alpha and Beta)</small></dd>
+<dd>[e:lea,leb -e:lea+leb](#e:lea,leb -e:lea+leb) <small>(Cards that appear in Alpha or Beta but not in both editions)</small></dd>

Copy link
Member

@ebbit1q ebbit1q left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c:m now doesn't work at all anymore. c:uwm now does work though.

@ebbit1q
Copy link
Member

ebbit1q commented Feb 28, 2019

Can you link the syntax help window so that it closes when you close the main window?

@ebbit1q
Copy link
Member

ebbit1q commented Feb 28, 2019

considering this will add legality to oracle, linking #3406

Copy link
Member

@ebbit1q ebbit1q left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're currently unable to chain multiple ors, that is the search for gruul or azorius or simic doesn't work. Note that this search does work if you use grouping: (gruul or azorius) or simic.

Copy link
Member

@ebbit1q ebbit1q left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

certified grade A ebbit-proof

Copy link
Member

@ZeldaZach ZeldaZach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still need to do one more pass through

ZeldaZach and others added 4 commits March 1, 2019 05:56
Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>
Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>
…ockatrice#3594)

* I heard you like refactors so I put a refactor inside your refactor

so you can refactor while you refactor

* clangify

* Update tab_deck_editor.h
Copy link
Member

@ZeldaZach ZeldaZach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great change. Will launch a beta!

@ZeldaZach ZeldaZach merged commit eb60fec into Cockatrice:master Mar 1, 2019
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

Successfully merging this pull request may close these issues.

None yet

5 participants