@@ -170,6 +170,47 @@ static std::vector<cv::Mat> redCubePotential() {
170
170
}
171
171
172
172
173
+ static std::vector<cv::Mat> blackFlame () {
174
+ int plus = 103 ;
175
+ int left = 600 + 2 ;
176
+ int right = 730 ;
177
+ int top = 367 + plus;
178
+ int bottom = 534 + plus;
179
+
180
+ // Define the region of interest
181
+ std::vector<int > region{ left, top, right, bottom };
182
+ ScreenshotCapture& capture = ScreenshotCapture::Instance ();
183
+ cv::Mat flame = capture.capture (region);
184
+
185
+ int ma = 5 ;
186
+ int interval = 9 ;
187
+
188
+ // Extracting lines
189
+ cv::Mat line1 = flame (cv::Rect (0 , 0 , flame.cols , interval));
190
+ cv::Mat line2 = flame (cv::Rect (0 , interval + ma, flame.cols , interval));
191
+ cv::Mat line3 = flame (cv::Rect (0 , interval * 2 + 2 * ma, flame.cols , interval));
192
+ cv::Mat line4 = flame (cv::Rect (0 , interval * 3 + ma * 3 , flame.cols , interval));
193
+ cv::Mat line5 = flame (cv::Rect (0 , interval * 4 + ma * 4 , flame.cols , interval));
194
+ cv::Mat line6 = flame (cv::Rect (0 , interval * 5 + ma * 5 , flame.cols , interval));
195
+
196
+ return std::vector<cv::Mat>{line1, line2, line3, line4, line5, line6};
197
+ }
198
+
199
+
200
+ // rebirth flame
201
+ std::unordered_map<std::string, std::pair<std::string, int >> flameImageHub = {
202
+ {" boss" , {" flame/boss.png" , 30 }},
203
+ {" att" , {" flame/att.png" , 30 }},
204
+ {" matt" , {" flame/matt.png" , 30 }},
205
+ {" dex" , {" flame/dex.png" , 30 }},
206
+ {" str" , {" flame/str.png" , 30 }},
207
+ {" int" , {" flame/int.png" , 30 }},
208
+ {" luk" , {" flame/luk.png" , 30 }},
209
+ {" all" , {" flame/all.png" , 50 }},
210
+ {" hp" , {" flame/hp.png" , 50 }},
211
+ {" dmg" , {" flame/dmg.png" , 50 }}
212
+ };
213
+
173
214
174
215
std::unordered_map<std::string, std::pair<std::string, int >> imageHub = {
175
216
{" boss" , {" potential/boss.png" , 30 }},
@@ -191,8 +232,13 @@ std::unordered_map<std::string, std::pair<std::string, int>> imageHub = {
191
232
192
233
std::unordered_map<std::string, cv::Mat> LoadedHub;
193
234
194
- static void load_hub () {
195
- for (const auto & pair : imageHub) {
235
+
236
+ static void load_hub (bool flame) {
237
+ std::unordered_map<std::string, std::pair<std::string, int >>& images = imageHub;
238
+ if (flame) {
239
+ images = flameImageHub;
240
+ }
241
+ for (const auto & pair : images) {
196
242
const std::string& key = pair.first ;
197
243
const std::string& path = pair.second .first ;
198
244
int width = pair.second .second ;
@@ -254,6 +300,69 @@ static void rollBlueCude() {
254
300
msleep (2000 );
255
301
}
256
302
303
+ static void rollBlackRebirthFlame () {
304
+ leftclick (683 , 633 );
305
+ msleep (200 );
306
+ pressEnter ();
307
+ msleep (200 );
308
+ pressEnter ();
309
+ msleep (200 );
310
+ pressEnter ();
311
+ msleep (2000 );
312
+ }
313
+
314
+ static void matchFlame (int times, const std::vector<Rule>& groups) {
315
+ for (int i = 0 ; i < times; ++i) {
316
+ // got new lines
317
+ std::vector<cv::Mat> lines = blackFlame ();
318
+ std::vector<std::string> texts;
319
+
320
+ // Convert images to texts
321
+ for (const auto & line : lines) {
322
+ texts.push_back (img2text (line));
323
+ }
324
+
325
+ // Filter out "unknown" texts
326
+ texts.erase (std::remove (texts.begin (), texts.end (), " unknown" ), texts.end ());
327
+
328
+ // merge the texts;
329
+ std::string str;
330
+ for (auto & text : texts) {
331
+ str += text;
332
+ str += " \t " ;
333
+ }
334
+
335
+ printf (" [%d/%d]: %s\n " , i + 1 , times, str.c_str ());
336
+
337
+
338
+ // Iterate through each group
339
+ for (const auto & group : groups) {
340
+ int hit = group.hit ;
341
+ const std::vector<std::string>& keys = group.key ;
342
+ int count = 0 ;
343
+
344
+ for (const std::string& text : texts) {
345
+ if (std::find (keys.begin (), keys.end (), text) != keys.end ()) {
346
+ count++;
347
+ }
348
+ }
349
+
350
+ if (count >= hit) {
351
+ std::cout << " match! " ;
352
+ for (const auto & key : keys) {
353
+ std::cout << key << " " ;
354
+ }
355
+ std::cout << std::endl;
356
+ return ;
357
+ }
358
+ }
359
+
360
+ // Call reset function
361
+ rollBlackRebirthFlame ();
362
+ }
363
+
364
+ }
365
+
257
366
258
367
static void match (int times, const std::vector<Rule>& groups, bool is_red = false ) {
259
368
auto potential = is_red ? redCubePotential : blueCubePotential;
@@ -304,6 +413,7 @@ static void match(int times, const std::vector<Rule>& groups, bool is_red = fals
304
413
void helpinfo () {
305
414
printf (" Usage: \n " );
306
415
printf (" coffeestory [red/blue] [times] [target] \n " );
416
+ printf (" coffeestory flame [times] [target] \n " );
307
417
}
308
418
309
419
@@ -313,30 +423,46 @@ int main(int argc, char* argv[]) {
313
423
return 0 ;
314
424
}
315
425
reset_maple ();
316
- // Load the image hub
317
- load_hub ();
318
-
319
426
std::string kind = argv[1 ];
427
+
428
+ bool flame = false ;
320
429
bool is_red = false ;
321
430
if (kind == " red" ) {
322
431
is_red = true ;
432
+ load_hub (false );
323
433
}
324
434
else if (kind == " blue" ) {
325
435
is_red = false ;
436
+ load_hub (false );
437
+ }
438
+ else if (kind == " flame" ) {
439
+ flame = true ;
440
+ load_hub (true );
326
441
}
327
442
else {
328
443
helpinfo ();
329
444
return 0 ;
330
445
}
446
+
447
+ // Load the image hub
331
448
int times = std::stoi (argv[2 ]);
332
449
std::string target = argv[3 ];
333
- if (auto p = Rules.find (target); p != Rules.end ()) {
334
- match (times, p->second , is_red);
450
+ if (!flame) {
451
+ if (auto p = Rules.find (target); p != Rules.end ()) {
452
+ match (times, p->second , is_red);
453
+ }
454
+ else {
455
+ std::cout << " target not found! " << target << std::endl;
456
+ }
335
457
}
336
458
else {
337
- std::cout << " target not found! " << target << std::endl;
459
+ if (auto p = FlameRules.find (target); p != FlameRules.end ()) {
460
+ matchFlame (times, p->second );
461
+ }
462
+ else {
463
+ std::cout << " target not found! " << target << std::endl;
464
+ }
338
465
}
339
466
340
467
return 0 ;
341
468
}
342
-
0 commit comments