Filter Strings for Deck Editor search (#3582)

* Add MagicCards.info like fitler parser.

* Use FilterString whenever one of [:=<>] is in the edit box.

* Opts

* Opt

* - Capture errors
- Allow querying any property by full name

* clang format

* Update cockatrice/src/filter_string.cpp

Co-Authored-By: basicer <basicer@basicer.com>

* - Some refactoring for clarity
- More filters
- Add filter help

* Clangify

* Add icon

* Fix test name

* Remove stay debug

* - Add Rarity filter
- Make " trigger filter string mode

* You have to pass both filter types

* clangify

* - Allow filtering by legality
- Import legality into card.xml

* Add format filter to filtertree

* More color search options

* RIP extended

* More fixes

* Fix c:m

* set syntax help parent

* Fix warning

* add additional explanations to syntax help

* Allow multiple ands/ors to be chained

* Cleanup and refactor

Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>

* Move utility into guards

Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>

* I heard you like refactors so I put a refactor inside your refactor (#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
This commit is contained in:
Rob Blanckaert 2019-03-01 11:30:32 -08:00 committed by Zach H
parent 4427ad1451
commit eb60fec8e2
24 changed files with 780 additions and 122 deletions

View file

@ -253,6 +253,11 @@ bool FilterItem::acceptCmc(const CardInfoPtr info) const
}
}
bool FilterItem::acceptFormat(const CardInfoPtr info) const
{
return info->getProperty(QString("format-%1").arg(term.toLower())) == "legal";
}
bool FilterItem::acceptLoyalty(const CardInfoPtr info) const
{
if (info->getLoyalty().isEmpty()) {
@ -400,6 +405,8 @@ bool FilterItem::acceptCardAttr(const CardInfoPtr info, CardFilter::Attr attr) c
return acceptPowerToughness(info, attr);
case CardFilter::AttrLoyalty:
return acceptLoyalty(info);
case CardFilter::AttrFormat:
return acceptFormat(info);
default:
return true; /* ignore this attribute */
}
@ -439,16 +446,6 @@ FilterItemList *FilterTree::attrTypeList(CardFilter::Attr attr, CardFilter::Type
return attrLogicMap(attr)->typeList(type);
}
int FilterTree::findTermIndex(CardFilter::Attr attr, CardFilter::Type type, const QString &term)
{
return attrTypeList(attr, type)->termIndex(term);
}
int FilterTree::findTermIndex(const CardFilter *f)
{
return findTermIndex(f->attr(), f->type(), f->term());
}
FilterTreeNode *FilterTree::termNode(CardFilter::Attr attr, CardFilter::Type type, const QString &term)
{
return attrTypeList(attr, type)->termNode(term);
@ -459,11 +456,6 @@ FilterTreeNode *FilterTree::termNode(const CardFilter *f)
return termNode(f->attr(), f->type(), f->term());
}
FilterTreeNode *FilterTree::attrTypeNode(CardFilter::Attr attr, CardFilter::Type type)
{
return attrTypeList(attr, type);
}
bool FilterTree::testAttr(const CardInfoPtr info, const LogicMap *lm) const
{
const FilterItemList *fil;