@@ -91,32 +91,39 @@ PrizeCornerReset::PrizeCornerReset()
9191void PrizeCornerReset::obtain_prize (SingleSwitchProgramEnvironment& env, ProControllerContext& context){
9292 PrizeCornerReset_Descriptor::Stats& stats = env.current_stats <PrizeCornerReset_Descriptor::Stats>();
9393
94- env.log (" Talking to booth." );
95- pbf_press_button (context, BUTTON_A, 320ms, 640ms);
96-
97- PrizeSelectWatcher prize_dialog (COLOR_RED);
94+ for (int attempts = 0 ;; attempts++){
95+ PrizeSelectWatcher prize_dialog (COLOR_RED);
96+
97+ // Only 1 line to press through in english, not sure about other languages?
98+ int ret = run_until<ProControllerContext>(
99+ env.console , context,
100+ [&](ProControllerContext& context){
101+ env.log (" Talking to booth." );
102+ pbf_press_button (context, BUTTON_A, 320ms, 640ms);
103+ pbf_press_button (context, BUTTON_B, 320ms, 1680ms);
104+ pbf_press_button (context, BUTTON_B, 320ms, 1680ms);
105+ pbf_press_button (context, BUTTON_B, 320ms, 1680ms);
106+ },
107+ { prize_dialog }
108+ );
109+ context.wait_for_all_requests ();
110+ if (ret == 0 ){
111+ break ;
112+ }
98113
99- // Only 1 line to press through in english, not sure about other languages?
100- int ret = run_until<ProControllerContext>(
101- env.console , context,
102- [](ProControllerContext& context){
103- for (int i = 0 ; i < 5 ; i++){
104- pbf_press_button (context, BUTTON_B, 320ms, 320ms);
105- pbf_wait (context, 600ms); // Don't go too fast, have to let the box pop up
106- context.wait_for_all_requests ();
107- }
108- },
109- { prize_dialog }
110- );
111- context.wait_for_all_requests ();
112- if (ret < 0 ){
113114 stats.errors ++;
114115 env.update_stats ();
115- OperationFailedException::fire (
116- ErrorReport::SEND_ERROR_REPORT,
117- " obtain_prize(): Unable to find prize menu." ,
118- env.console
119- );
116+ if (attempts >= 5 ){
117+ OperationFailedException::fire (
118+ ErrorReport::SEND_ERROR_REPORT,
119+ " obtain_prize(): Unable to open prize menu after 5 attempts." ,
120+ env.console
121+ );
122+ }
123+
124+ env.log (" Unable to find prize menu... Retrying..." , COLOR_RED);
125+
126+ pbf_mash_button (context, BUTTON_B, 5000ms);
120127 }
121128
122129 // Select prize slot
0 commit comments