Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

#include "Common/Cpp/PrettyPrint.h"
#include "CommonFramework/ErrorReports/ErrorReports.h"
#include "CommonFramework/Exceptions/OperationFailedException.h"
#include "CommonFramework/Exceptions/UnexpectedBattleException.h"
#include "CommonFramework/Notifications/ProgramNotifications.h"
Expand Down Expand Up @@ -463,7 +464,12 @@ void config_option(ProControllerContext& context, int change_option_value){
pbf_press_dpad(context, DPAD_DOWN, 104ms, 160ms);
}

void swap_starter_moves(SingleSwitchProgramEnvironment& env, ProControllerContext& context, Language language){
void swap_starter_moves(
SingleSwitchProgramEnvironment& env,
ProControllerContext& context,
Language language,
EventNotificationOption& notif_error_recoverable)
{
const ProgramInfo& info = env.program_info();
VideoStream& stream = env.console;

Expand Down Expand Up @@ -497,12 +503,18 @@ void swap_starter_moves(SingleSwitchProgramEnvironment& env, ProControllerContex
stream.log("Current top move: " + top_move);
if (top_move != "ember" && top_move != "leafage" && top_move != "water-gun"){
stream.log("Unable to confirm that the moves actually swapped.");
OperationFailedException exception(
ErrorReport::SEND_ERROR_REPORT,
"swap_starter_moves: Unable to confirm that the moves actually swapped.\n" + language_warning(language),
stream

auto snapshot = stream.video().snapshot().frame;
std::string message = "swap_starter_moves: Unable to confirm that the moves actually swapped.\n" + language_warning(language);
send_program_recoverable_error_notification(env, notif_error_recoverable, message, *snapshot);
report_error(
&env.logger(),
env.program_info(),
"Recoverable: OperationFailedExceptionWithScreenshot",
{{"Message:", message}},
*snapshot,
&stream.history()
);
exception.send_recoverable_notification(env);
}

}
Expand Down Expand Up @@ -1416,6 +1428,7 @@ void checkpoint_reattempt_loop(
SingleSwitchProgramEnvironment& env,
ProControllerContext& context,
EventNotificationOption& notif_status_update,
EventNotificationOption& notif_error_recoverable,
AutoStoryStats& stats,
const std::string& checkpoint_text,
std::function<void(size_t attempt_number)>&& action,
Expand Down Expand Up @@ -1443,12 +1456,17 @@ void checkpoint_reattempt_loop(
break;
}catch (OperationFailedException& e){
if (i == 10){ // send an error report for debugging if 10 failed attempts for a given checkpoint.
OperationFailedException exception(
ErrorReport::SEND_ERROR_REPORT,
"10 failed attempts. " + checkpoint_text,
env.console
auto snapshot = env.console.video().snapshot().frame;
std::string message = "10 failed attempts. " + checkpoint_text;
send_program_recoverable_error_notification(env, notif_error_recoverable, message, *snapshot);
report_error(
&env.logger(),
env.program_info(),
"Recoverable: OperationFailedExceptionWithScreenshot",
{{"Message:", message}},
*snapshot,
&env.console.history()
);
exception.send_recoverable_notification(env);
}

if (i > max_attempts){
Expand All @@ -1475,6 +1493,7 @@ void checkpoint_reattempt_loop_tutorial(
SingleSwitchProgramEnvironment& env,
ProControllerContext& context,
EventNotificationOption& notif_status_update,
EventNotificationOption& notif_error_recoverable,
AutoStoryStats& stats,
const std::string& checkpoint_text,
std::function<void(size_t attempt_number)>&& action
Expand All @@ -1497,12 +1516,17 @@ void checkpoint_reattempt_loop_tutorial(
break;
}catch (OperationFailedException& e){
if (i == 10){ // send an error report for debugging if 10 failed attempts for a given checkpoint.
OperationFailedException exception(
ErrorReport::SEND_ERROR_REPORT,
"10 failed attempts. " + checkpoint_text,
env.console
auto snapshot = env.console.video().snapshot().frame;
std::string message = "10 failed attempts. " + checkpoint_text;
send_program_recoverable_error_notification(env, notif_error_recoverable, message, *snapshot);
report_error(
&env.logger(),
env.program_info(),
"Recoverable: OperationFailedExceptionWithScreenshot",
{{"Message:", message}},
*snapshot,
&env.console.history()
);
exception.send_recoverable_notification(env);
}

if (i > max_attempts){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ struct AutoStoryOptions{
Language language;
StarterChoice starter_choice;
EventNotificationOption& notif_status_update;
EventNotificationOption& notif_error_recoverable;
};

class AutoStory_Segment {
Expand Down Expand Up @@ -183,7 +184,12 @@ void overworld_navigation(const ProgramInfo& info, VideoStream& stream, ProContr
void config_option(ProControllerContext& context, int change_option_value);

// enter menu and swap the first and third moves for your starter
void swap_starter_moves(SingleSwitchProgramEnvironment& env, ProControllerContext& context, Language language);
void swap_starter_moves(
SingleSwitchProgramEnvironment& env,
ProControllerContext& context,
Language language,
EventNotificationOption& notif_error_recoverable
);

// confirm the moves for the Lead pokemon: Moonblast, Mystical Fire, Psychic, Misty Terrain
// start and end in the overworld
Expand Down Expand Up @@ -379,6 +385,7 @@ void checkpoint_reattempt_loop(
SingleSwitchProgramEnvironment& env,
ProControllerContext& context,
EventNotificationOption& notif_status_update,
EventNotificationOption& notif_error_recoverable,
AutoStoryStats& stats,
const std::string& checkpoint_text,
std::function<void(size_t attempt_number)>&& action,
Expand All @@ -389,6 +396,7 @@ void checkpoint_reattempt_loop_tutorial(
SingleSwitchProgramEnvironment& env,
ProControllerContext& context,
EventNotificationOption& notif_status_update,
EventNotificationOption& notif_error_recoverable,
AutoStoryStats& stats,
const std::string& checkpoint_text,
std::function<void(size_t attempt_number)>&& action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,33 +71,34 @@ std::string AutoStory_Checkpoint_01::name() const{ return "001 - " + AutoStory_S
std::string AutoStory_Checkpoint_01::start_text() const{ return "Done cutscene. Stood up from chair. Walked to left side of room.";}
std::string AutoStory_Checkpoint_01::end_text() const{ return "Standing in room. Updated settings";}
void AutoStory_Checkpoint_01::run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const{
checkpoint_01(env, context, options.notif_status_update, stats, checkpoint_text(), options.language);
checkpoint_01(env, context, options.notif_status_update, options.notif_error_recoverable, stats, checkpoint_text(), options.language);
}

std::string AutoStory_Checkpoint_02::name() const{ return "002 - " + AutoStory_Segment_01().name(); }
std::string AutoStory_Checkpoint_02::start_text() const{ return AutoStory_Checkpoint_01().end_text();}
std::string AutoStory_Checkpoint_02::end_text() const{ return "Standing in front of the 'power of science' NPC. Cleared map tutorial.";}
void AutoStory_Checkpoint_02::run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const{
checkpoint_02(env, context, options.notif_status_update, stats, checkpoint_text());
checkpoint_02(env, context, options.notif_status_update, options.notif_error_recoverable, stats, checkpoint_text());
}

std::string AutoStory_Checkpoint_03::name() const{ return "003 - " + AutoStory_Segment_01().name(); }
std::string AutoStory_Checkpoint_03::start_text() const{ return AutoStory_Checkpoint_02().end_text();}
std::string AutoStory_Checkpoint_03::end_text() const{ return "Received starter Pokemon. Changed move order. Cleared autoheal tutorial.";}
void AutoStory_Checkpoint_03::run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const{
checkpoint_03(env, context, options.notif_status_update, stats, checkpoint_text(), options.language, options.starter_choice);
checkpoint_03(env, context, options.notif_status_update, options.notif_error_recoverable, stats, checkpoint_text(), options.language, options.starter_choice);
}


void checkpoint_01(
SingleSwitchProgramEnvironment& env,
ProControllerContext& context,
EventNotificationOption& notif_status_update,
EventNotificationOption& notif_error_recoverable,
AutoStoryStats& stats,
const std::string& checkpoint_text,
Language language
){
checkpoint_reattempt_loop_tutorial(env, context, notif_status_update, stats, checkpoint_text,
checkpoint_reattempt_loop_tutorial(env, context, notif_status_update, notif_error_recoverable, stats, checkpoint_text,
[&](size_t attempt_number){

context.wait_for_all_requests();
Expand All @@ -114,10 +115,11 @@ void checkpoint_02(
SingleSwitchProgramEnvironment& env,
ProControllerContext& context,
EventNotificationOption& notif_status_update,
EventNotificationOption& notif_error_recoverable,
AutoStoryStats& stats,
const std::string& checkpoint_text
){
checkpoint_reattempt_loop_tutorial(env, context, notif_status_update, stats, checkpoint_text,
checkpoint_reattempt_loop_tutorial(env, context, notif_status_update, notif_error_recoverable, stats, checkpoint_text,
[&](size_t attempt_number){

context.wait_for_all_requests();
Expand Down Expand Up @@ -189,12 +191,13 @@ void checkpoint_03(
SingleSwitchProgramEnvironment& env,
ProControllerContext& context,
EventNotificationOption& notif_status_update,
EventNotificationOption& notif_error_recoverable,
AutoStoryStats& stats,
const std::string& checkpoint_text,
Language language,
StarterChoice starter_choice
){
checkpoint_reattempt_loop(env, context, notif_status_update, stats, checkpoint_text,
checkpoint_reattempt_loop(env, context, notif_status_update, notif_error_recoverable, stats, checkpoint_text,
[&](size_t attempt_number){

context.wait_for_all_requests();
Expand Down Expand Up @@ -260,7 +263,7 @@ void checkpoint_03(
clear_tutorial(env.console, context);

env.console.log("Change move order.");
swap_starter_moves(env, context, language);
swap_starter_moves(env, context, language, notif_error_recoverable);
press_Bs_to_back_to_overworld(env.program_info(), env.console, context);

}, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ void checkpoint_01(
SingleSwitchProgramEnvironment& env,
ProControllerContext& context,
EventNotificationOption& notif_status_update,
EventNotificationOption& notif_error_recoverable,
AutoStoryStats& stats,
const std::string& checkpoint_text,
Language language
Expand All @@ -68,6 +69,7 @@ void checkpoint_02(
SingleSwitchProgramEnvironment& env,
ProControllerContext& context,
EventNotificationOption& notif_status_update,
EventNotificationOption& notif_error_recoverable,
AutoStoryStats& stats,
const std::string& checkpoint_text
);
Expand All @@ -78,6 +80,7 @@ void checkpoint_03(
SingleSwitchProgramEnvironment& env,
ProControllerContext& context,
EventNotificationOption& notif_status_update,
EventNotificationOption& notif_error_recoverable,
AutoStoryStats& stats,
const std::string& checkpoint_text,
Language language,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,19 @@ std::string AutoStory_Checkpoint_04::name() const{ return "004 - " + AutoStory_S
std::string AutoStory_Checkpoint_04::start_text() const{ return "Received starter Pokemon. Changed move order. Cleared autoheal tutorial.";}
std::string AutoStory_Checkpoint_04::end_text() const{ return "Battled Nemona on the beach.";}
void AutoStory_Checkpoint_04::run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const{
checkpoint_04(env, context, options.notif_status_update, stats, checkpoint_text());
checkpoint_04(env, context, options.notif_status_update, options.notif_error_recoverable, stats, checkpoint_text());
}


void checkpoint_04(
SingleSwitchProgramEnvironment& env,
ProControllerContext& context,
EventNotificationOption& notif_status_update,
EventNotificationOption& notif_error_recoverable,
AutoStoryStats& stats,
const std::string& checkpoint_text
){
checkpoint_reattempt_loop(env, context, notif_status_update, stats, checkpoint_text,
checkpoint_reattempt_loop(env, context, notif_status_update, notif_error_recoverable, stats, checkpoint_text,
[&](size_t attempt_number){
context.wait_for_all_requests();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ void checkpoint_04(
SingleSwitchProgramEnvironment& env,
ProControllerContext& context,
EventNotificationOption& notif_status_update,
EventNotificationOption& notif_error_recoverable,
AutoStoryStats& stats,
const std::string& checkpoint_text
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,31 +61,32 @@ std::string AutoStory_Checkpoint_05::name() const{ return "005 - " + AutoStory_S
std::string AutoStory_Checkpoint_05::start_text() const{ return "Battled Nemona on the beach.";}
std::string AutoStory_Checkpoint_05::end_text() const{ return "Met mom at gate. Received mom's sandwich.";}
void AutoStory_Checkpoint_05::run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const{
checkpoint_05(env, context, options.notif_status_update, stats, checkpoint_text());
checkpoint_05(env, context, options.notif_status_update, options.notif_error_recoverable, stats, checkpoint_text());
}

std::string AutoStory_Checkpoint_06::name() const{ return "006 - " + AutoStory_Segment_03().name(); }
std::string AutoStory_Checkpoint_06::start_text() const{ return AutoStory_Checkpoint_05().end_text();}
std::string AutoStory_Checkpoint_06::end_text() const{ return "Cleared catch tutorial.";}
void AutoStory_Checkpoint_06::run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const{
checkpoint_06(env, context, options.notif_status_update, stats, checkpoint_text());
checkpoint_06(env, context, options.notif_status_update, options.notif_error_recoverable, stats, checkpoint_text());
}

std::string AutoStory_Checkpoint_07::name() const{ return "007 - " + AutoStory_Segment_03().name(); }
std::string AutoStory_Checkpoint_07::start_text() const{ return AutoStory_Checkpoint_06().end_text();}
std::string AutoStory_Checkpoint_07::end_text() const{ return "Moved to cliff. Heard mystery cry. Standing in front of Nemona near the cliff.";}
void AutoStory_Checkpoint_07::run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const{
checkpoint_07(env, context, options.notif_status_update, stats, checkpoint_text());
checkpoint_07(env, context, options.notif_status_update, options.notif_error_recoverable, stats, checkpoint_text());
}

void checkpoint_05(
SingleSwitchProgramEnvironment& env,
ProControllerContext& context,
EventNotificationOption& notif_status_update,
EventNotificationOption& notif_error_recoverable,
AutoStoryStats& stats,
const std::string& checkpoint_text
){
checkpoint_reattempt_loop(env, context, notif_status_update, stats, checkpoint_text,
checkpoint_reattempt_loop(env, context, notif_status_update, notif_error_recoverable, stats, checkpoint_text,
[&](size_t attempt_number){
context.wait_for_all_requests();

Expand All @@ -107,10 +108,11 @@ void checkpoint_06(
SingleSwitchProgramEnvironment& env,
ProControllerContext& context,
EventNotificationOption& notif_status_update,
EventNotificationOption& notif_error_recoverable,
AutoStoryStats& stats,
const std::string& checkpoint_text
){
checkpoint_reattempt_loop(env, context, notif_status_update, stats, checkpoint_text,
checkpoint_reattempt_loop(env, context, notif_status_update, notif_error_recoverable, stats, checkpoint_text,
[&](size_t attempt_number){

context.wait_for_all_requests();
Expand Down Expand Up @@ -146,10 +148,11 @@ void checkpoint_07(
SingleSwitchProgramEnvironment& env,
ProControllerContext& context,
EventNotificationOption& notif_status_update,
EventNotificationOption& notif_error_recoverable,
AutoStoryStats& stats,
const std::string& checkpoint_text
){
checkpoint_reattempt_loop(env, context, notif_status_update, stats, checkpoint_text,
checkpoint_reattempt_loop(env, context, notif_status_update, notif_error_recoverable, stats, checkpoint_text,
[&](size_t attempt_number){

context.wait_for_all_requests();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ void checkpoint_05(
SingleSwitchProgramEnvironment& env,
ProControllerContext& context,
EventNotificationOption& notif_status_update,
EventNotificationOption& notif_error_recoverable,
AutoStoryStats& stats,
const std::string& checkpoint_text
);
Expand All @@ -66,6 +67,7 @@ void checkpoint_06(
SingleSwitchProgramEnvironment& env,
ProControllerContext& context,
EventNotificationOption& notif_status_update,
EventNotificationOption& notif_error_recoverable,
AutoStoryStats& stats,
const std::string& checkpoint_text
);
Expand All @@ -76,6 +78,7 @@ void checkpoint_07(
SingleSwitchProgramEnvironment& env,
ProControllerContext& context,
EventNotificationOption& notif_status_update,
EventNotificationOption& notif_error_recoverable,
AutoStoryStats& stats,
const std::string& checkpoint_text
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ std::string AutoStory_Checkpoint_08::name() const{ return "008 - " + AutoStory_S
std::string AutoStory_Checkpoint_08::start_text() const{ return "Moved to cliff. Heard mystery cry. Standing in front of Nemona near the cliff.";}
std::string AutoStory_Checkpoint_08::end_text() const{ return "Rescued Koraidon/Miraidon and escaped from the Houndoom Cave. Standing next to Koraidon/Miraidon just outside the cave exit.";}
void AutoStory_Checkpoint_08::run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const{
checkpoint_08(env, context, options.notif_status_update, stats, checkpoint_text());
checkpoint_08(env, context, options.notif_status_update, options.notif_error_recoverable, stats, checkpoint_text());
}


Expand All @@ -74,10 +74,11 @@ void checkpoint_08(
SingleSwitchProgramEnvironment& env,
ProControllerContext& context,
EventNotificationOption& notif_status_update,
EventNotificationOption& notif_error_recoverable,
AutoStoryStats& stats,
const std::string& checkpoint_text
){
checkpoint_reattempt_loop(env, context, notif_status_update, stats, checkpoint_text,
checkpoint_reattempt_loop(env, context, notif_status_update, notif_error_recoverable, stats, checkpoint_text,
[&](size_t attempt_number){

context.wait_for_all_requests();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ void checkpoint_08(
SingleSwitchProgramEnvironment& env,
ProControllerContext& context,
EventNotificationOption& notif_status_update,
EventNotificationOption& notif_error_recoverable,
AutoStoryStats& stats,
const std::string& checkpoint_text
);
Expand Down
Loading
Loading