Skip to content

Commit 975adc5

Browse files
committed
Added more example functions. Added instance modifiers to filter class.
1 parent 661a6dd commit 975adc5

File tree

2 files changed

+191
-0
lines changed

2 files changed

+191
-0
lines changed

src/filters.cpp

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ long searchWithFilter(Instance inst, Filter &filter) {
1515
std:fill(amountFoundList.begin(), amountFoundList.end(), 0);
1616

1717
for (int ante = 1; ante <= filter.maxAnte; ante++) {
18+
//TODO: Check instance modifiers here, maybe?
1819
for (int i = 0; i < filter.searchList.size(); i++) {
1920
if (ante > filter.searchList[i].maxAnte) { continue; }
2021
amountFoundList[i] += searchWithObject(inst, filter.searchList[i], ante);
@@ -39,6 +40,18 @@ long searchWithObject(Instance inst, SearchObject searchObject, int ante){
3940
switch (searchObject.searchType) {
4041
case SearchableType::Joker:
4142
return searchForJoker(inst, searchObject, ante);
43+
case SearchableType::Tarot:
44+
return searchForTarot(inst, searchObject, ante);
45+
case SearchableType::Planet:
46+
return searchForPlanet(inst, searchObject, ante);
47+
case SearchableType::Spectral:
48+
return searchForSpectral(inst, searchObject, ante);
49+
case SearchableType::Card:
50+
return searchForCard(inst, searchObject, ante);
51+
case SearchableType::Tag:
52+
return searchForTag(inst, searchObject, ante);
53+
case SearchableType::Voucher:
54+
return searchForVoucher(inst, searchObject, ante);
4255
default:
4356
return 0;
4457
}
@@ -76,4 +89,162 @@ long searchForJoker(Instance inst, SearchObject searchObject, int ante) {
7689
}
7790

7891
return amount_found;
92+
}
93+
94+
long searchForTarot(Instance inst, SearchObject searchObject, int ante) {
95+
int amount_found = 0;
96+
int max_packs = 4;
97+
if (ante > 1) max_packs = 6;
98+
int max_store_items = 10;
99+
if (ante > 1) max_store_items = 50;
100+
101+
//Check packs
102+
for (int p = 1; p <= max_packs; p++) {
103+
Pack pack = packInfo(inst.nextPack(ante));
104+
if (pack.type == Item::Arcana_Pack ||
105+
pack.type == Item::Jumbo_Arcana_Pack ||
106+
pack.type == Item::Mega_Arcana_Pack) {
107+
auto packContents = inst.nextArcanaPack(pack.size, 1);
108+
for (int x = 0; x < pack.size; x++) {
109+
if (packContents[x] == searchObject.item) {
110+
amount_found++;
111+
}
112+
}
113+
}
114+
continue;
115+
}
116+
117+
//Check shop
118+
for (int s = 1; s <= max_store_items; s++) {
119+
ShopItem shop_item = inst.nextShopItem(ante);
120+
if (shop_item.item == searchObject.item) {
121+
amount_found++;
122+
}
123+
}
124+
125+
return amount_found;
126+
}
127+
128+
long searchForPlanet(Instance inst, SearchObject searchObject, int ante) {
129+
int amount_found = 0;
130+
int max_packs = 4;
131+
if (ante > 1) max_packs = 6;
132+
int max_store_items = 10;
133+
if (ante > 1) max_store_items = 50;
134+
135+
//Check packs
136+
for (int p = 1; p <= max_packs; p++) {
137+
Pack pack = packInfo(inst.nextPack(ante));
138+
if (pack.type == Item::Celestial_Pack ||
139+
pack.type == Item::Jumbo_Celestial_Pack ||
140+
pack.type == Item::Mega_Celestial_Pack) {
141+
auto packContents = inst.nextArcanaPack(pack.size, 1);
142+
for (int x = 0; x < pack.size; x++) {
143+
if (packContents[x] == searchObject.item) {
144+
amount_found++;
145+
}
146+
}
147+
}
148+
continue;
149+
}
150+
151+
//Check shop
152+
for (int s = 1; s <= max_store_items; s++) {
153+
ShopItem shop_item = inst.nextShopItem(ante);
154+
if (shop_item.item == searchObject.item) {
155+
amount_found++;
156+
}
157+
}
158+
159+
return amount_found;
160+
}
161+
162+
long searchForSpectral(Instance inst, SearchObject searchObject, int ante) {
163+
int amount_found = 0;
164+
int max_packs = 4;
165+
if (ante > 1) max_packs = 6;
166+
int max_store_items = 10;
167+
if (ante > 1) max_store_items = 50;
168+
169+
//Check packs
170+
for (int p = 1; p <= max_packs; p++) {
171+
Pack pack = packInfo(inst.nextPack(ante));
172+
if (pack.type == Item::Spectral_Pack ||
173+
pack.type == Item::Jumbo_Spectral_Pack ||
174+
pack.type == Item::Mega_Spectral_Pack) {
175+
auto packContents = inst.nextArcanaPack(pack.size, 1);
176+
for (int x = 0; x < pack.size; x++) {
177+
if (packContents[x] == searchObject.item) {
178+
amount_found++;
179+
}
180+
}
181+
}
182+
continue;
183+
}
184+
185+
//Check shop TODO: Setup instance
186+
/*for (int s = 1; s <= max_store_items; s++) {
187+
ShopItem shop_item = inst.nextShopItem(ante);
188+
if (shop_item.item == searchObject.item) {
189+
amount_found++;
190+
}
191+
}*/
192+
193+
return amount_found;
194+
}
195+
196+
long searchForCard(Instance inst, SearchObject searchObject, int ante) {
197+
int amount_found = 0;
198+
int max_packs = 4;
199+
if (ante > 1) max_packs = 6;
200+
int max_store_items = 10;
201+
if (ante > 1) max_store_items = 50;
202+
203+
//Check packs
204+
for (int p = 1; p <= max_packs; p++) {
205+
Pack pack = packInfo(inst.nextPack(ante));
206+
if (pack.type == Item::Standard_Pack ||
207+
pack.type == Item::Jumbo_Standard_Pack ||
208+
pack.type == Item::Mega_Standard_Pack) {
209+
auto packContents = inst.nextArcanaPack(pack.size, 1);
210+
for (int x = 0; x < pack.size; x++) {
211+
if (packContents[x] == searchObject.item) {
212+
amount_found++;
213+
}
214+
}
215+
}
216+
continue;
217+
}
218+
219+
//Check shop TODO: Setup instance
220+
/*for (int s = 1; s <= max_store_items; s++) {
221+
ShopItem shop_item = inst.nextShopItem(ante);
222+
if (shop_item.item == searchObject.item) {
223+
amount_found++;
224+
}
225+
}*/
226+
227+
return amount_found;
228+
}
229+
230+
231+
long seachForTag(Instance inst, SearchObject searchObject, int ante) {
232+
int amount_found = 0;
233+
234+
for(int i = 1; i <=2; i++) {
235+
if(inst.nextTag(ante) == searchObject.item) {
236+
amount_found++;
237+
}
238+
}
239+
240+
return amount_found;
241+
}
242+
243+
//TODO: Setup instance prior to calling this
244+
// May want to seperate ante 1 loop for examples like perkeo_observatory
245+
long searchForVoucher(Instance inst, SearchObject searchObject, int ante) {
246+
if(inst.nextVoucher(ante) == searchObject.item) {
247+
return 1;
248+
}
249+
return 0;
79250
}

src/filters.hpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ struct SearchObject {
3636
int amount;
3737
};
3838

39+
struct InstanceModifier {
40+
Item modifier;
41+
int startAnte;
42+
int maxAnte;
43+
};
44+
3945
//Possible optimizations for bigger searchList
4046
//Generating all the items before searching
4147
class Filter {
@@ -45,13 +51,27 @@ class Filter {
4551
int maxAnte = 1;
4652

4753
std::vector<SearchObject> searchList;
54+
std::vector<InstanceModifier> instanceModList;
4855

4956
void parseJSON(std::string input);
5057
long generateObjects(Instance inst);
5158
};
5259

5360
long searchWithFilter(Instance inst, Filter &filter);
5461
long searchWithObject(Instance inst, SearchObject searchObject, int ante);
62+
63+
//Appear in shop & packs
64+
//TODO: Possibly combine some of these functions (They use similar code)
5565
long searchForJoker(Instance inst, SearchObject searchObject, int ante);
66+
long searchForTarot(Instance inst, SearchObject searchObject, int ante);
67+
long searchForPlanet(Instance inst, SearchObject searchObject, int ante);
68+
69+
//Appear in packs (mostly)
70+
long searchForSpectral(Instance inst, SearchObject searchObject, int ante);
71+
long searchForCard(Instance inst, SearchObject searchObject, int ante);
72+
73+
//Appears on ante
74+
long searchForTag(Instance inst, SearchObject searchObject, int ante);
75+
long searchForVoucher(Instance inst, SearchObject searchObject, int ante);
5676

5777
#endif

0 commit comments

Comments
 (0)