@@ -556,52 +556,47 @@ void config_option(ProControllerContext& context, int change_option_value){
556556 pbf_press_dpad (context, DPAD_DOWN, 15 , 20 );
557557}
558558
559- void swap_starter_moves (const ProgramInfo& info, VideoStream& stream, ProControllerContext& context, Language language){
560- WallClock start = current_time ();
561- while (true ){
562- if (current_time () - start > std::chrono::minutes (3 )){
563- OperationFailedException::fire (
564- ErrorReport::SEND_ERROR_REPORT,
565- " swap_starter_moves(): Failed to swap the starter moves after 3 minutes." ,
566- stream
567- );
568- }
569- // start in the overworld
570- press_Bs_to_back_to_overworld (info, stream, context);
559+ void swap_starter_moves (SingleSwitchProgramEnvironment& env, ProControllerContext& context, Language language){
560+ const ProgramInfo& info = env.program_info ();
561+ VideoStream& stream = env.console ;
571562
572- // open menu, select your starter
573- enter_menu_from_overworld (info, stream, context, 0 , MenuSide::LEFT );
563+ // start in the overworld
564+ press_Bs_to_back_to_overworld (info, stream, context);
574565
575- // enter Pokemon summary screen
576- pbf_press_button (context, BUTTON_A, 20 , 5 * TICKS_PER_SECOND);
577- pbf_press_dpad (context, DPAD_RIGHT, 15 , 1 * TICKS_PER_SECOND);
578- pbf_press_button (context, BUTTON_Y, 20 , 40 );
566+ // open menu, select your starter
567+ enter_menu_from_overworld (info, stream, context, 0 , MenuSide::LEFT);
579568
580- // select move 1
581- pbf_press_button (context, BUTTON_A, 20 , 40 );
582- pbf_press_dpad (context, DPAD_DOWN, 15 , 40 );
583- pbf_press_dpad (context, DPAD_DOWN, 15 , 40 );
584- // extra button presses to avoid drops
585- pbf_press_dpad (context, DPAD_DOWN, 15 , 40 );
586- pbf_press_dpad (context, DPAD_DOWN, 15 , 40 );
569+ // enter Pokemon summary screen
570+ pbf_press_button (context, BUTTON_A, 20 , 5 * TICKS_PER_SECOND);
571+ pbf_press_dpad (context, DPAD_RIGHT, 15 , 1 * TICKS_PER_SECOND);
572+ pbf_press_button (context, BUTTON_Y, 20 , 40 );
587573
588- // select move 3. swap move 1 and move 3.
589- pbf_press_button (context, BUTTON_A, 20 , 40 );
574+ // select move 1
575+ pbf_press_button (context, BUTTON_A, 20 , 40 );
576+ pbf_press_dpad (context, DPAD_DOWN, 15 , 40 );
577+ pbf_press_dpad (context, DPAD_DOWN, 15 , 40 );
578+ // extra button presses to avoid drops
579+ pbf_press_dpad (context, DPAD_DOWN, 15 , 40 );
580+ pbf_press_dpad (context, DPAD_DOWN, 15 , 40 );
590581
591- // confirm that Ember/Leafage/Water Gun is in slot 1
592- context.wait_for_all_requests ();
593- VideoSnapshot screen = stream.video ().snapshot ();
594- PokemonMovesReader reader (language);
595- std::string top_move = reader.read_move (stream.logger (), screen, 0 );
596- stream.log (" Current top move: " + top_move);
597- if (top_move != " ember" && top_move != " leafage" && top_move != " water-gun" ){
598- stream.log (" Failed to swap moves. Re-try." );
599- continue ;
600- }
582+ // select move 3. swap move 1 and move 3.
583+ pbf_press_button (context, BUTTON_A, 20 , 40 );
601584
602-
603- break ;
604- }
585+ // confirm that Ember/Leafage/Water Gun is in slot 1
586+ context.wait_for_all_requests ();
587+ VideoSnapshot screen = stream.video ().snapshot ();
588+ PokemonMovesReader reader (language);
589+ std::string top_move = reader.read_move (stream.logger (), screen, 0 );
590+ stream.log (" Current top move: " + top_move);
591+ if (top_move != " ember" && top_move != " leafage" && top_move != " water-gun" ){
592+ stream.log (" Failed to swap moves." );
593+ OperationFailedException exception (
594+ ErrorReport::SEND_ERROR_REPORT,
595+ " swap_starter_moves: Failed to swap moves.\n " + language_warning (language),
596+ stream
597+ );
598+ exception.send_recoverable_notification (env);
599+ }
605600
606601}
607602
0 commit comments