From 501e82f712bb63742f16a60cde81df99e7f2968d Mon Sep 17 00:00:00 2001 From: Vafthrudnir Date: Wed, 7 Feb 2018 17:37:10 +0100 Subject: [PATCH] Split card handling added to cmc filter (#3090) --- cockatrice/src/filtertree.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/cockatrice/src/filtertree.cpp b/cockatrice/src/filtertree.cpp index ffae7100..50e40709 100644 --- a/cockatrice/src/filtertree.cpp +++ b/cockatrice/src/filtertree.cpp @@ -231,7 +231,22 @@ bool FilterItem::acceptManaCost(const CardInfoPtr info) const bool FilterItem::acceptCmc(const CardInfoPtr info) const { - return relationCheck(info->getCmc().toInt()); + bool convertSuccess; + int cmcInt = info->getCmc().toInt(&convertSuccess); + // if conversion failed, check for the "//" separator used in split cards + if (!convertSuccess) { + int cmcSum = 0; + for (const QString &cmc : info->getCmc().split("//")) { + cmcInt = cmc.toInt(); + cmcSum += cmcInt; + if (relationCheck(cmcInt)) { + return true; + } + } + return relationCheck(cmcSum); + } else { + return relationCheck(cmcInt); + } } bool FilterItem::acceptLoyalty(const CardInfoPtr info) const