From 589e9a15a6b1f23f1a094cec66542124e957884f Mon Sep 17 00:00:00 2001
From: RickyRister <42636155+RickyRister@users.noreply.github.com>
Date: Sun, 14 Dec 2025 15:14:19 -0800
Subject: [PATCH] [DeckFilterString] Add search query for format (#6414)
* [DeckFilterString] Rename file search expression
* [DeckFilterString] Add search query for format
---
cockatrice/resources/help/deck_search.md | 3 +++
cockatrice/src/filters/deck_filter_string.cpp | 11 ++++++++++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/cockatrice/resources/help/deck_search.md b/cockatrice/resources/help/deck_search.md
index 9ae7164e2..c42e41c42 100644
--- a/cockatrice/resources/help/deck_search.md
+++ b/cockatrice/resources/help/deck_search.md
@@ -24,6 +24,9 @@ searches are case insensitive.
[p:aggro](#p:aggro) (Any deck that has "aggro" somewhere in its relative path)
[p:edh/](#p:edh/) (Any deck with "edh/" in its relative path, A.K.A. decks in the "edh" folder)
+Format:
+[f:standard](#f:standard) (Any deck with format set to standard)
+
Deck Contents (Uses [card search expressions](#cardSearchSyntaxHelp)):
[[plains]] (Any deck that contains at least one card with "plains" in its name)
[[t:legendary]] (Any deck that contains at least one legendary)
diff --git a/cockatrice/src/filters/deck_filter_string.cpp b/cockatrice/src/filters/deck_filter_string.cpp
index 186ee0b90..ed1a24322 100644
--- a/cockatrice/src/filters/deck_filter_string.cpp
+++ b/cockatrice/src/filters/deck_filter_string.cpp
@@ -13,7 +13,7 @@ QueryPartList <- ComplexQueryPart ( ws ("AND" ws)? ComplexQueryPart)* ws*
ComplexQueryPart <- SomewhatComplexQueryPart ws "OR" ws ComplexQueryPart / SomewhatComplexQueryPart
SomewhatComplexQueryPart <- [(] QueryPartList [)] / QueryPart
-QueryPart <- NotQuery / DeckContentQuery / DeckNameQuery / FileNameQuery / PathQuery / GenericQuery
+QueryPart <- NotQuery / DeckContentQuery / DeckNameQuery / FileNameQuery / PathQuery / FormatQuery / GenericQuery
NotQuery <- ('NOT' ws/'-') SomewhatComplexQueryPart
@@ -24,6 +24,7 @@ CardFilterString <- (!']]'.)*
DeckNameQuery <- ([Dd] 'eck')? [Nn] 'ame'? [:] String
FileNameQuery <- [Ff] ([Nn] / 'ile' ([Nn] 'ame')?) [:] String
PathQuery <- [Pp] 'ath'? [:] String
+FormatQuery <- [Ff] 'ormat'? [:] String
GenericQuery <- String
@@ -157,6 +158,14 @@ static void setupParserRules()
};
};
+ search["FormatQuery"] = [](const peg::SemanticValues &sv) -> DeckFilter {
+ auto format = std::any_cast(sv[0]);
+ return [=](const DeckPreviewWidget *deck, const ExtraDeckSearchInfo &) {
+ auto gameFormat = deck->deckLoader->getDeckList()->getGameFormat();
+ return QString::compare(format, gameFormat, Qt::CaseInsensitive) == 0;
+ };
+ };
+
search["GenericQuery"] = [](const peg::SemanticValues &sv) -> DeckFilter {
auto name = std::any_cast(sv[0]);
return [=](const DeckPreviewWidget *deck, const ExtraDeckSearchInfo &) {