Mana cost filtering for split cards (#3098)

This commit is contained in:
Vafthrudnir 2018-02-08 20:15:42 +01:00 committed by Zach H
parent 2206328406
commit 51eeac0541

View file

@ -219,14 +219,21 @@ bool FilterItem::acceptSet(const CardInfoPtr info) const
bool FilterItem::acceptManaCost(const CardInfoPtr info) const bool FilterItem::acceptManaCost(const CardInfoPtr info) const
{ {
QString partialCost = term.toUpper(); QString partialCost = term.toUpper();
QString fullManaCost = info->getManaCost();
// Sort the mana costs so they can be easily compared // Sort the mana cost so it will be easy to find
std::sort(partialCost.begin(), partialCost.end()); std::sort(partialCost.begin(), partialCost.end());
// Try to seperate the mana cost in case it's a split card
// if it's not a split card the loop will run only once
for (QString fullManaCost : info->getManaCost().split("//")) {
std::sort(fullManaCost.begin(), fullManaCost.end()); std::sort(fullManaCost.begin(), fullManaCost.end());
// If the partial is found in the full, return true // If the partial is found in the full, return true
return (fullManaCost.indexOf(partialCost) > -1); if (fullManaCost.contains(partialCost)) {
return true;
}
}
return false;
} }
bool FilterItem::acceptCmc(const CardInfoPtr info) const bool FilterItem::acceptCmc(const CardInfoPtr info) const