-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNameFilter.cpp
More file actions
29 lines (26 loc) · 863 Bytes
/
NameFilter.cpp
File metadata and controls
29 lines (26 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "NameFilter.h"
NameFilter::NameFilter(QString pharse) : pharse(pharse)
{
pharse = pharse.toLower();
}
bool NameFilter::match(DivinationCard *card)
{
bool isNumber;
int pharseValue = pharse.toInt(&isNumber);
return pharse.isEmpty() || card->name.toLower().contains(pharse) || card->rewardRawName.toLower().contains(pharse) || card->reward.name.toLower().contains(pharse) ||
(isNumber && (card->amount == pharseValue || card->chaosValue == pharseValue ||
card->stackSize == pharseValue || card->reward.chaosValue == pharseValue ||
card->reward.amount == pharseValue));//if any field of card contains pharse or pharse is empty
}
void NameFilter::filter(QVector<std::shared_ptr<DivinationCard> > *cards)
{
for(int i = 0; i < cards->size(); ++i)
{
if(match(cards->at(i).get()))
{
continue;
}
cards->remove(i);
--i;
}
}