@@ -228,6 +228,9 @@ std::vector<BBQuests> process_quest_list(
228228 uint8_t & eggs_hatched
229229){
230230 std::vector<BBQuests> quests_to_do;
231+ bool rerolled = false ;
232+ std::vector<std::unique_ptr<BBQuestTableRow>> exclusions_table = BBQ_OPTIONS.QUEST_EXCLUSIONS .copy_snapshot ();
233+ int questpos = 0 ;
231234
232235 stream.log (" Processing quests." );
233236 // Put all do-able quests into a different list
@@ -267,6 +270,7 @@ std::vector<BBQuests> process_quest_list(
267270 pbf_wait (context, 100 );
268271 context.wait_for_all_requests ();
269272
273+ rerolled = true ;
270274 press_Bs_to_back_to_overworld (info, stream, context);
271275
272276 break ;
@@ -284,24 +288,96 @@ std::vector<BBQuests> process_quest_list(
284288 );
285289 break ;
286290 }
287- }else {
288- // TODO
291+ }
292+ else {
293+ bool quest_in_table = false ;
294+ for (const std::unique_ptr<BBQuestTableRow>& row : exclusions_table){
295+ if (n == row->quest ) {
296+ stream.log (" Quest found in exclusions table." );
297+ quest_in_table = true ;
298+
299+ WhiteButtonWatcher rp2 (COLOR_BLUE, WhiteButton::ButtonB, {0.484 , 0.117 , 0.022 , 0.037 });
300+ int result2;
301+ switch (row->action ) {
302+ case BBQAction::run:
303+ stream.log (" Run selected. Adding quest to list." );
304+ quests_to_do.push_back (n);
305+ break ;
306+ case BBQAction::reroll:
307+ stream.log (" Reroll selected. Rerolling quest. New quest will be run in the next batch of quests." );
308+ result2 = run_until<ProControllerContext>(
309+ stream, context,
310+ [&](ProControllerContext& context){
311+ for (int i = 0 ; i < 6 ; i++){
312+ pbf_press_dpad (context, DPAD_RIGHT, 50 , 20 );
313+ pbf_wait (context, 200 );
314+ context.wait_for_all_requests ();
315+ }
316+ },
317+ {{ rp2 }}
318+ );
319+ if (result2 == 0 ){
320+ stream.log (" Found quest panel." );
321+ }
322+ context.wait_for_all_requests ();
323+
324+ // Move cursor down to quest
325+ for (int i = 0 ; i < questpos; i++) {
326+ pbf_press_dpad (context, DPAD_DOWN, 20 , 20 );
327+ pbf_wait (context, 100 );
328+ context.wait_for_all_requests ();
329+ }
330+
331+ // Reroll
332+ pbf_press_button (context, BUTTON_A, 20 , 50 );
333+ pbf_press_button (context, BUTTON_A, 20 , 50 );
334+ pbf_wait (context, 100 );
335+ context.wait_for_all_requests ();
289336
337+ // Prevent error and allows program to reread the rerolled quests
338+ rerolled = true ;
290339
291- stream.log (" Quest possible" );
292- quests_to_do.push_back (n);
340+ press_Bs_to_back_to_overworld (info, stream, context);
341+ break ;
342+ case BBQAction::skip:
343+ stream.log (" Skip selected. Skipping quest." );
344+ break ;
345+ }
346+ }
347+ }
348+ if (!quest_in_table){
349+ stream.log (" Quest not in exclusions table. Adding to list." );
350+ quests_to_do.push_back (n);
351+ }
293352 }
294353 }
354+ questpos++;
295355 }
296356
297357 // Check that quests_to_do is not empty (after completing all quests on the list, be sure to erase it.
298358 // Lag might be a problem in multi - look into making slots like menu-left navigation
299- if (quests_to_do.size () == 0 ){
359+ if (!rerolled && quests_to_do.size () == 0 ){
300360 stream.log (" No possible quests! Rerolling all quests." );
301361
302- // Open quest panel - see above
303- // Reroll all.
362+ // Open quest panel and reroll all quests.
304363 // This does not handle out of BP.
364+ WhiteButtonWatcher panel (COLOR_BLUE, WhiteButton::ButtonB, {0.484 , 0.117 , 0.022 , 0.037 });
365+ int result = run_until<ProControllerContext>(
366+ stream, context,
367+ [&](ProControllerContext& context){
368+ for (int i = 0 ; i < 6 ; i++){
369+ pbf_press_dpad (context, DPAD_RIGHT, 50 , 20 );
370+ pbf_wait (context, 200 );
371+ context.wait_for_all_requests ();
372+ }
373+ },
374+ {{ panel }}
375+ );
376+ if (result == 0 ){
377+ stream.log (" Found quest panel." );
378+ }
379+ context.wait_for_all_requests ();
380+
305381 for (int i = 0 ; i < quest_list.size (); i++){
306382 pbf_press_button (context, BUTTON_A, 20 , 50 );
307383 pbf_press_button (context, BUTTON_A, 20 , 50 ); // Yes.
@@ -312,16 +388,17 @@ std::vector<BBQuests> process_quest_list(
312388 context.wait_for_all_requests ();
313389 }
314390 // Close quest panel - mash b
391+ press_Bs_to_back_to_overworld (info, stream, context);
315392 }
316-
317- if (quests_to_do.size () == 0 ){
393+ /*
394+ if (!rerolled && quests_to_do.size() == 0){
318395 OperationFailedException::fire(
319396 ErrorReport::SEND_ERROR_REPORT,
320397 "No possible quests! Check language selection.",
321398 stream
322399 );
323400 }
324-
401+ */
325402 return quests_to_do;
326403}
327404
0 commit comments