1+ #include " filters.hpp"
2+ #include " functions.hpp"
3+ #include < vector>
4+ #include < numeric>
5+
6+ void Filter::parseJSON (std::string input) {
7+ // Populate Lists with variables from the Json
8+ return ;
9+ }
10+
11+
12+ long searchWithFilter (Instance inst, Filter &filter) {
13+ std::vector<int > amountFoundList;
14+ amountFoundList.resize (filter.searchList .size ());
15+ std:fill (amountFoundList.begin (), amountFoundList.end (), 0 );
16+
17+ for (int ante = 1 ; ante <= filter.maxAnte ; ante++) {
18+ for (int i = 0 ; i < filter.searchList .size (); i++) {
19+ if (ante > filter.searchList [i].maxAnte ) { continue ; }
20+ amountFoundList[i] += searchWithObject (inst, filter.searchList [i], ante);
21+ }
22+ }
23+
24+ // Check if you have found all the items in a list
25+ int correct_amounts = 0 ;
26+ for (int i = 0 ; i < filter.searchList .size (); i++) {
27+ if (amountFoundList[i] >= filter.searchList [i].amount ) {
28+ correct_amounts++;
29+ }
30+ }
31+ if (correct_amounts == filter.searchList .size ()) {
32+ return 1 ;
33+ }
34+ return 0 ;
35+
36+ }
37+
38+ long searchWithObject (Instance inst, SearchObject searchObject, int ante){
39+ switch (searchObject.searchType ) {
40+ case SearchableType::Joker:
41+ return searchForJoker (inst, searchObject, ante);
42+ default :
43+ return 0 ;
44+ }
45+ }
46+
47+ long searchForJoker (Instance inst, SearchObject searchObject, int ante) {
48+ int amount_found = 0 ;
49+ int max_packs = 4 ;
50+ if (ante > 1 ) max_packs = 6 ;
51+ int max_store_items = 10 ;
52+ if (ante > 1 ) max_store_items = 50 ;
53+
54+ // Check packs
55+ for (int p = 1 ; p <= max_packs; p++) {
56+ Pack pack = packInfo (inst.nextPack (ante));
57+ if (pack.type == Item::Buffoon_Pack ||
58+ pack.type == Item::Jumbo_Buffoon_Pack ||
59+ pack.type == Item::Mega_Buffoon_Pack) {
60+ auto packContents = inst.nextArcanaPack (pack.size , 1 );
61+ for (int x = 0 ; x < pack.size ; x++) {
62+ if (packContents[x] == searchObject.item ) {
63+ amount_found++;
64+ }
65+ }
66+ }
67+ continue ;
68+ }
69+
70+ // Check shop
71+ for (int s = 1 ; s <= max_store_items; s++) {
72+ ShopItem shop_item = inst.nextShopItem (ante);
73+ if (shop_item.item == searchObject.item ) {
74+ amount_found++;
75+ }
76+ }
77+
78+ return amount_found;
79+ }
0 commit comments