From 17efe8c003a5c79d8b5348b1bbdc2c6c069c5a78 Mon Sep 17 00:00:00 2001 From: ebbit1q Date: Tue, 17 Mar 2020 01:56:30 +0100 Subject: [PATCH] add pauper to the list of checked formats in search (#3901) * add pauper to the list of checked formats without a short form l:p remains reserved for pioneer * throw out weird hardcoded formats this will at least still work whenever a format gets added the shorthands are still kept --- cockatrice/src/filter_string.cpp | 36 ++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/cockatrice/src/filter_string.cpp b/cockatrice/src/filter_string.cpp index dbe6aadc..bcd6565b 100644 --- a/cockatrice/src/filter_string.cpp +++ b/cockatrice/src/filter_string.cpp @@ -28,7 +28,7 @@ ToughnessQuery <- [Tt] 'ou' 'ghness'? ws? NumericExpression RarityQuery <- [rR] ':' RegexString FormatQuery <- 'f' ':' Format / Legality ':' Format -Format <- [Mm] 'odern'? / [Ss] 'tandard'? / [Vv] 'intage'? / [Ll] 'egacy'? / [Cc] 'ommander'? / [Pp] 'ioneer'? +Format <- [a-zA-Z] [a-z]* Legality <- [Ll] 'egal'? / [Bb] 'anned'? / [Rr] 'estricted' @@ -138,21 +138,25 @@ static void setupParserRules() }; search["Format"] = [](const peg::SemanticValues &sv) -> QString { - switch (tolower(sv.str()[0])) { - case 'm': - return "modern"; - case 's': - return "standard"; - case 'v': - return "vintage"; - case 'l': - return "legacy"; - case 'c': - return "commander"; - case 'p': - return "pioneer"; - default: - return ""; + if (sv.length() == 1) { + switch (tolower(sv.str()[0])) { + case 'm': + return "modern"; + case 's': + return "standard"; + case 'v': + return "vintage"; + case 'l': + return "legacy"; + case 'c': + return "commander"; + case 'p': + return "pioneer"; + default: + return ""; + } + } else { + return QString::fromStdString(sv.str()).toLower(); } }; search["StringValue"] = [](const peg::SemanticValues &sv) -> StringMatcher {