diff --git a/libcockatrice_filters/libcockatrice/filters/filter_tree.cpp b/libcockatrice_filters/libcockatrice/filters/filter_tree.cpp index b3cbf8926..817c7298d 100644 --- a/libcockatrice_filters/libcockatrice/filters/filter_tree.cpp +++ b/libcockatrice_filters/libcockatrice/filters/filter_tree.cpp @@ -359,10 +359,17 @@ bool FilterItem::acceptSubType(const CardInfoPtr &info) const return subType.contains(term, Qt::CaseInsensitive); } -static bool matchesColor(const QString &convertedColorTerm, const QString &colors) +/** + * @brief Return true when every letter of the given term appears in the given colors string. + * If the term is equal to "c", then only return true if the color string is empty. + * + * @param term The letters which should be included, or "c" + * @param colors The string to check for letters in + */ +static bool matchesColor(const QString &term, const QString &colors) { // Colorless card filter - if (convertedColorTerm == "c" && colors.length() < 1) { + if (term == "c" && colors.length() < 1) { return true; } @@ -371,13 +378,13 @@ static bool matchesColor(const QString &convertedColorTerm, const QString &color * then we should match all of them to the card's colors */ int match_count = 0; - for (const QChar &color : convertedColorTerm) { + for (const QChar &color : term) { if (colors.contains(color, Qt::CaseInsensitive)) { match_count++; } } - return match_count == convertedColorTerm.length(); + return match_count == term.length(); } bool FilterItem::acceptColor(const CardInfoPtr &info) const @@ -387,8 +394,6 @@ bool FilterItem::acceptColor(const CardInfoPtr &info) const bool FilterItem::acceptColorIdentity(const CardInfoPtr &info) const { - // if (info->getColorIdentity() == "") - // system(std::format("notify-send \"{}, {}\"", convertedColorTerm.toStdString(), info->getColorIdentity().toStdString()).c_str()); return matchesColor(convertedColorTerm, info->getColorIdentity()); }