diff --git a/SerialPrograms/CMakeLists.txt b/SerialPrograms/CMakeLists.txt index d8e17800d3..065f29ffdb 100644 --- a/SerialPrograms/CMakeLists.txt +++ b/SerialPrograms/CMakeLists.txt @@ -1824,6 +1824,8 @@ file(GLOB MAIN_SOURCES Source/PokemonSV/Programs/Farming/PokemonSV_BlueberryCatchPhoto.h Source/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp Source/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.h + Source/PokemonSV/Programs/Farming/PokemonSV_ClaimMysteryGift.cpp + Source/PokemonSV/Programs/Farming/PokemonSV_ClaimMysteryGift.h Source/PokemonSV/Programs/Farming/PokemonSV_ESPTraining.cpp Source/PokemonSV/Programs/Farming/PokemonSV_ESPTraining.h Source/PokemonSV/Programs/Farming/PokemonSV_FlyingTrialFarmer.cpp diff --git a/SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramSwitch.cpp b/SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramSwitch.cpp index 394bae96d8..2bf080ce5e 100644 --- a/SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramSwitch.cpp +++ b/SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramSwitch.cpp @@ -138,6 +138,7 @@ #include "PokemonHome/Inference/PokemonHome_BallReader.h" #include "PokemonSwSh/MaxLair/Inference/PokemonSwSh_MaxLair_Detect_PathSide.h" #include "PokemonSwSh/MaxLair/Inference/PokemonSwSh_MaxLair_Detect_PathMap.h" +#include "NintendoSwitch/Inference/NintendoSwitch_SelectedSettingDetector.h" #include #include @@ -256,6 +257,36 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope& VideoOverlaySet overlays(overlay); + +#if 0 + bool switch2 = true; + ImageFloatBox key1_box; + ImageFloatBox other_setting1; + ImageFloatBox other_setting2; + + if (!switch2){ + key1_box = {0.037322, 0.451172, 0.009879, 0.113281}; + other_setting1 = {0.01, 0.451172, 0.009879, 0.113281}; + other_setting2 = {0.02, 0.451172, 0.009879, 0.113281}; + }else if (switch2){ + key1_box = {0.062706, 0.510763, 0.009901, 0.097847}; + other_setting1 = {0.02, 0.510763, 0.009901, 0.097847}; + other_setting2 = {0.04, 0.510763, 0.009901, 0.097847}; + } + + SelectedSettingWatcher key1_selected(key1_box, other_setting1, other_setting2, other_setting1); + int ret = wait_until( + console, context, + Milliseconds(5000), + {key1_selected} + ); + if (ret < 0){ // failed to detect Key 1 being highlighted. Reset game and re-try + console.log("claim_mystery_gift: Failed to detect the Mystery Gift window. Reset game and re-try.", COLOR_YELLOW); + reset_game(env.program_info(), console, context); + } + +#endif + #if 0 auto screenshot = feed.snapshot(); @@ -342,7 +373,7 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope& #endif -#if 1 +#if 0 auto screenshot = feed.snapshot(); PokemonHome::BallReader reader(console); @@ -607,7 +638,7 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope& // context->issue_gyro_rotate_x(&scope, duration, duration, 0s, 0x1000); // context->issue_nop(&scope, 60h); -#if 1 +#if 0 auto duration = 15ms; for (size_t c = 0; c < 65536; c += 1){ context->issue_gyro_accel_x(&scope, 0s, duration, 0s, (uint16_t)(688 + 0*c % 2)); @@ -655,7 +686,7 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope& #if 0 // ImageRGB32 image(IMAGE_PATH); auto image = feed.snapshot(); -#if 1 +#if 0 ImageRGB32 image(IMAGE_PATH); // auto image = feed.snapshot(); diff --git a/SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch_ConsoleTypeDetector.cpp b/SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch_ConsoleTypeDetector.cpp index 87a8398d3e..19a00bbce0 100644 --- a/SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch_ConsoleTypeDetector.cpp +++ b/SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch_ConsoleTypeDetector.cpp @@ -7,6 +7,9 @@ #include "CommonFramework/VideoPipeline/VideoOverlayScopes.h" #include "CommonFramework/ImageTools/ImageStats.h" #include "NintendoSwitch_ConsoleTypeDetector.h" +#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" +#include "NintendoSwitch/Programs/NintendoSwitch_GameEntry.h" +#include "CommonFramework/VideoPipeline/VideoFeed.h" //#include //using std::cout; @@ -83,6 +86,17 @@ void ConsoleTypeDetector_StartGameUserSelect::commit_to_cache(){ m_console.state().set_console_type(m_console, m_last); } +ConsoleType detect_console_type_from_in_game(ConsoleHandle& console, ProControllerContext& context){ + go_home(console, context); + + ConsoleTypeDetector_Home detector(console); + ConsoleType console_type = detector.detect_only(console.video().snapshot()); + detector.commit_to_cache(); + + resume_game_from_home(console, context); + + return console_type; +} diff --git a/SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch_ConsoleTypeDetector.h b/SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch_ConsoleTypeDetector.h index 47d34fc5e5..a6eaaf5d94 100644 --- a/SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch_ConsoleTypeDetector.h +++ b/SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch_ConsoleTypeDetector.h @@ -49,7 +49,7 @@ class ConsoleTypeDetector_StartGameUserSelect{ ConsoleType m_last; }; - +ConsoleType detect_console_type_from_in_game(ConsoleHandle& console, ProControllerContext& context); diff --git a/SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch_SelectedSettingDetector.cpp b/SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch_SelectedSettingDetector.cpp index 43c8c15e93..2d428dca1b 100644 --- a/SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch_SelectedSettingDetector.cpp +++ b/SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch_SelectedSettingDetector.cpp @@ -9,9 +9,9 @@ #include "NintendoSwitch_SelectedSettingDetector.h" // -//#include -//using std::cout; -//using std::endl; +// #include +// using std::cout; +// using std::endl; namespace PokemonAutomation{ namespace NintendoSwitch{ @@ -21,24 +21,26 @@ SelectedSettingWatcher::~SelectedSettingWatcher() = default; SelectedSettingWatcher::SelectedSettingWatcher( ImageFloatBox selected_box, ImageFloatBox not_selected_box1, - ImageFloatBox not_selected_box2 + ImageFloatBox not_selected_box2, + ImageFloatBox representative_background ) : VisualInferenceCallback("SelectedSettingWatcher") , m_selected_box(selected_box) , m_not_selected_box1(not_selected_box1) , m_not_selected_box2(not_selected_box2) + , m_representative_background(representative_background) {} void SelectedSettingWatcher::make_overlays(VideoOverlaySet& items) const{ items.add(COLOR_RED, m_selected_box); items.add(COLOR_BLUE, m_not_selected_box1); items.add(COLOR_BLUE, m_not_selected_box2); + items.add(COLOR_GREEN, m_representative_background); } -bool is_white_theme(const ImageViewRGB32& screen){ - ImageFloatBox window_top(0.60, 0.02, 0.35, 0.05); - ImageStats stats_window_top = image_stats(extract_box_reference(screen, window_top)); - bool white_theme = stats_window_top.average.sum() > 500; +bool SelectedSettingWatcher::is_white_theme(const ImageViewRGB32& screen){ + ImageStats stats_window_background = image_stats(extract_box_reference(screen, m_representative_background)); + bool white_theme = stats_window_background.average.sum() > 500; return white_theme; } diff --git a/SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch_SelectedSettingDetector.h b/SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch_SelectedSettingDetector.h index 5d3858ed84..ea07016a4c 100644 --- a/SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch_SelectedSettingDetector.h +++ b/SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch_SelectedSettingDetector.h @@ -20,16 +20,20 @@ class SelectedSettingWatcher : public VisualInferenceCallback{ SelectedSettingWatcher( ImageFloatBox selected_box, ImageFloatBox not_selected_box1, - ImageFloatBox not_selected_box2 + ImageFloatBox not_selected_box2, + ImageFloatBox representative_background = {0.60, 0.02, 0.35, 0.05} ); virtual ~SelectedSettingWatcher(); virtual void make_overlays(VideoOverlaySet& items) const override; + bool is_white_theme(const ImageViewRGB32& screen); + // return true if the area within the selected_box is highlighted, compared with the area within unselected_box // This compares the brightness of the selected_box with the unselected_box. // selected_box: the box where we expect the screen should be highlighted // not_selected_box 1 and 2: the boxes where we expect the screen should NOT be highlighted. These acts as the control, for comparison. + // representative_background: box around an area that would represent the background. for determining whether this is white or dark mode. // the average sum of selected_box should be greater than the absolute difference of average sum between unselected_box 1 and 2. virtual bool process_frame(const ImageViewRGB32& screen, WallClock timestamp) override; @@ -38,6 +42,7 @@ class SelectedSettingWatcher : public VisualInferenceCallback{ ImageFloatBox m_selected_box; ImageFloatBox m_not_selected_box1; ImageFloatBox m_not_selected_box2; + ImageFloatBox m_representative_background; }; diff --git a/SerialPrograms/Source/NintendoSwitch/Programs/FastCodeEntry/NintendoSwitch_KeyboardCodeEntry.cpp b/SerialPrograms/Source/NintendoSwitch/Programs/FastCodeEntry/NintendoSwitch_KeyboardCodeEntry.cpp index ed6430df72..d7a1209c48 100644 --- a/SerialPrograms/Source/NintendoSwitch/Programs/FastCodeEntry/NintendoSwitch_KeyboardCodeEntry.cpp +++ b/SerialPrograms/Source/NintendoSwitch/Programs/FastCodeEntry/NintendoSwitch_KeyboardCodeEntry.cpp @@ -10,6 +10,7 @@ #include "NintendoSwitch/NintendoSwitch_Settings.h" #include "NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h" #include "NintendoSwitch/Options/NintendoSwitch_CodeEntrySettingsOption.h" +#include "NintendoSwitch/Inference/NintendoSwitch_ConsoleTypeDetector.h" #include "NintendoSwitch_CodeEntryTools.h" #include "NintendoSwitch_KeyboardCodeEntry.h" @@ -285,6 +286,11 @@ void keyboard_enter_code( ConsoleType console_type = console.state().console_type(); + + if (console_type == ConsoleType::Unknown){ + console.log("Unknown Switch type. Try to detect."); + console_type = detect_console_type_from_in_game(console, context); + } bool switch2; if (is_switch1(console_type)){ switch2 = false; diff --git a/SerialPrograms/Source/PokemonSV/PokemonSV_Panels.cpp b/SerialPrograms/Source/PokemonSV/PokemonSV_Panels.cpp index 799eab550d..5f413783f9 100644 --- a/SerialPrograms/Source/PokemonSV/PokemonSV_Panels.cpp +++ b/SerialPrograms/Source/PokemonSV/PokemonSV_Panels.cpp @@ -53,6 +53,7 @@ #include "Programs/ShinyHunting/PokemonSV_ShinyHunt-Scatterbug.h" #include "Programs/AutoStory/PokemonSV_AutoStory.h" +#include "Programs/Farming/PokemonSV_ClaimMysteryGift.h" #include "Programs/Glitches/PokemonSV_WildItemFarmer.h" #include "Programs/Glitches/PokemonSV_RideCloner-1.0.1.h" @@ -146,6 +147,7 @@ std::vector PanelListFactory::make_panels() const{ ret.emplace_back("---- Public Betas ----"); ret.emplace_back(make_single_switch_program()); + ret.emplace_back(make_single_switch_program()); ret.emplace_back("---- Deprecated Programs ----"); ret.emplace_back(make_single_switch_program()); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp index 64b8418954..1a1d449fe7 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp @@ -164,8 +164,18 @@ std::unique_ptr AutoStory_Descriptor::make_stats() const{ AutoStory::~AutoStory(){ + STORY_SECTION.remove_listener(*this); STARTPOINT_TUTORIAL.remove_listener(*this); ENDPOINT_TUTORIAL.remove_listener(*this); + STARTPOINT_MAINSTORY.remove_listener(*this); + ENDPOINT_MAINSTORY.remove_listener(*this); + ENABLE_TEST_CHECKPOINTS.remove_listener(*this); + ENABLE_TEST_REALIGN.remove_listener(*this); + ENABLE_MISC_TEST.remove_listener(*this); + TEST_PBF_LEFT_JOYSTICK.remove_listener(*this); + TEST_PBF_LEFT_JOYSTICK2.remove_listener(*this); + TEST_CURRENT_DIRECTION.remove_listener(*this); + TEST_CHANGE_DIRECTION.remove_listener(*this); } AutoStory::AutoStory() @@ -557,66 +567,67 @@ void AutoStory::test_checkpoints( int start, int end, int loop, int start_loop, int end_loop ){ + AutoStoryStats& stats = env.current_stats(); EventNotificationOption& notif_status_update = NOTIFICATION_STATUS_UPDATE; Language language = LANGUAGE; StarterChoice starter_choice = STARTERCHOICE; std::vector> checkpoint_list; checkpoint_list.push_back([&](){checkpoint_00(env, context);}); - checkpoint_list.push_back([&](){checkpoint_01(env, context, notif_status_update, language);}); - checkpoint_list.push_back([&](){checkpoint_02(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_03(env, context, notif_status_update, language, starter_choice);}); - checkpoint_list.push_back([&](){checkpoint_04(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_05(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_06(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_07(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_08(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_09(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_10(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_11(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_12(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_13(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_14(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_15(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_16(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_17(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_18(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_19(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_20(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_21(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_22(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_23(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_24(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_25(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_26(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_27(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_28(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_29(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_30(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_31(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_32(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_33(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_34(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_35(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_36(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_37(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_38(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_39(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_40(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_41(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_42(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_43(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_44(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_45(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_46(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_47(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_48(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_49(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_50(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_51(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_52(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_53(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_54(env, context, notif_status_update);}); - checkpoint_list.push_back([&](){checkpoint_55(env, context, notif_status_update);}); + checkpoint_list.push_back([&](){checkpoint_01(env, context, notif_status_update, stats, language);}); + checkpoint_list.push_back([&](){checkpoint_02(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_03(env, context, notif_status_update, stats, language, starter_choice);}); + checkpoint_list.push_back([&](){checkpoint_04(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_05(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_06(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_07(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_08(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_09(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_10(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_11(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_12(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_13(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_14(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_15(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_16(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_17(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_18(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_19(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_20(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_21(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_22(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_23(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_24(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_25(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_26(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_27(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_28(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_29(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_30(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_31(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_32(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_33(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_34(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_35(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_36(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_37(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_38(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_39(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_40(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_41(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_42(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_43(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_44(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_45(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_46(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_47(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_48(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_49(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_50(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_51(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_52(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_53(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_54(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_55(env, context, notif_status_update, stats);}); for (int checkpoint = start; checkpoint <= end; checkpoint++){ @@ -718,12 +729,13 @@ void AutoStory::run_autostory(SingleSwitchProgramEnvironment& env, ProController NOTIFICATION_STATUS_UPDATE }; + AutoStoryStats& stats = env.current_stats(); if (get_start_segment_index() > get_end_segment_index()){ throw UserSetupError(env.logger(), "The start segment cannot be later than the end segment."); } - + for (size_t segment_index = get_start_segment_index(); segment_index <= get_end_segment_index(); segment_index++){ - ALL_AUTO_STORY_SEGMENT_LIST()[segment_index]->run_segment(env, context, options); + ALL_AUTO_STORY_SEGMENT_LIST()[segment_index]->run_segment(env, context, options, stats); } } @@ -787,7 +799,6 @@ void AutoStory::test_code(SingleSwitchProgramEnvironment& env, ProControllerCont void AutoStory::program(SingleSwitchProgramEnvironment& env, ProControllerContext& context){ assert_16_9_720p_min(env.logger(), env.console); - // AutoStoryStats& stats = env.current_stats(); // test code diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.h index 1d3be15268..6b9e1d46e6 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.h @@ -127,7 +127,7 @@ class AutoStory : public SingleSwitchProgramInstance, public ConfigOption::Liste FloatingPointOption DIR_RADIANS; }; - +const std::vector>& ALL_AUTO_STORY_SEGMENT_LIST(); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp index 1ff1783c28..21ba30670f 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp @@ -1009,8 +1009,7 @@ void get_on_or_off_ride(const ProgramInfo& info, VideoStream& stream, ProControl } } -void checkpoint_save(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update){ - AutoStoryStats& stats = env.current_stats(); +void checkpoint_save(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ save_game_from_overworld(env.program_info(), env.console, context); stats.m_checkpoint++; env.update_stats(); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h index d503efb7e1..ff4be97ce8 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h @@ -115,7 +115,8 @@ class AutoStory_Segment { virtual void run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options) const = 0; + AutoStoryOptions options, + AutoStoryStats& stats) const = 0; }; // spam A button to choose the first move for trainer battles @@ -289,7 +290,7 @@ void change_settings_prior_to_autostory( void change_settings(SingleSwitchProgramEnvironment& env, ProControllerContext& context, Language language, bool use_inference = true); -void checkpoint_save(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update); +void checkpoint_save(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); enum class ZoomChange{ ZOOM_IN, diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_00.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_00.cpp index f07edee59d..f0b95af620 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_00.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_00.cpp @@ -37,9 +37,9 @@ std::string AutoStory_Segment_00::end_text() const{ void AutoStory_Segment_00::run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const{ - // AutoStoryStats& stats = env.current_stats(); context.wait_for_all_requests(); env.console.log("Start Segment 00: Intro Cutscene", COLOR_ORANGE); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_00.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_00.h index e9abe3156c..a443226fc7 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_00.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_00.h @@ -21,7 +21,8 @@ class AutoStory_Segment_00 : public AutoStory_Segment{ virtual void run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const override; }; diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_01.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_01.cpp index 9616af0ffa..2f09044468 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_01.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_01.cpp @@ -49,18 +49,18 @@ std::string AutoStory_Segment_01::end_text() const{ void AutoStory_Segment_01::run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const{ - AutoStoryStats& stats = env.current_stats(); stats.m_segment++; env.update_stats(); context.wait_for_all_requests(); env.console.log("Start Segment 01: Pick Starter", COLOR_ORANGE); - checkpoint_01(env, context, options.notif_status_update, options.language); - checkpoint_02(env, context, options.notif_status_update); - checkpoint_03(env, context, options.notif_status_update, options.language, options.starter_choice); + checkpoint_01(env, context, options.notif_status_update, stats, options.language); + checkpoint_02(env, context, options.notif_status_update, stats); + checkpoint_03(env, context, options.notif_status_update, stats, options.language, options.starter_choice); context.wait_for_all_requests(); env.console.log("End Segment 01: Pick Starter", COLOR_GREEN); @@ -71,10 +71,10 @@ void AutoStory_Segment_01::run_segment( void checkpoint_01( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update, + EventNotificationOption& notif_status_update, + AutoStoryStats& stats, Language language ){ -AutoStoryStats& stats = env.current_stats(); bool first_attempt = true; while (true){ try{ @@ -108,9 +108,9 @@ AutoStoryStats& stats = env.current_stats(); void checkpoint_02( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); bool first_attempt = true; while (true){ try{ @@ -199,15 +199,15 @@ void checkpoint_03( SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, + AutoStoryStats& stats, Language language, StarterChoice starter_choice ){ - AutoStoryStats& stats = env.current_stats(); bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_01.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_01.h index 0a58727f29..420167cd35 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_01.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_01.h @@ -21,7 +21,8 @@ class AutoStory_Segment_01 : public AutoStory_Segment{ virtual void run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const override; }; @@ -31,6 +32,7 @@ void checkpoint_01( SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, + AutoStoryStats& stats, Language language ); @@ -39,7 +41,8 @@ void checkpoint_01( void checkpoint_02( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); // start: standing in front of power of science NPC. Cleared map tutorial. @@ -48,6 +51,7 @@ void checkpoint_03( SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, + AutoStoryStats& stats, Language language, StarterChoice starter_choice ); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_02.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_02.cpp index 13317ee8e0..a7129f01b6 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_02.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_02.cpp @@ -45,16 +45,15 @@ std::string AutoStory_Segment_02::end_text() const{ void AutoStory_Segment_02::run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const{ - AutoStoryStats& stats = env.current_stats(); - stats.m_segment++; env.update_stats(); context.wait_for_all_requests(); env.console.log("Start Segment 02: First Nemona Battle", COLOR_ORANGE); - checkpoint_04(env, context, options.notif_status_update); + checkpoint_04(env, context, options.notif_status_update, stats); context.wait_for_all_requests(); env.console.log("End Segment 02: First Nemona Battle", COLOR_GREEN); @@ -65,14 +64,14 @@ void AutoStory_Segment_02::run_segment( void checkpoint_04( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } context.wait_for_all_requests(); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_02.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_02.h index 0409ae8ca8..6f3055ca81 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_02.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_02.h @@ -21,7 +21,8 @@ class AutoStory_Segment_02 : public AutoStory_Segment{ virtual void run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const override; }; @@ -31,7 +32,8 @@ class AutoStory_Segment_02 : public AutoStory_Segment{ void checkpoint_04( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_03.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_03.cpp index ae1d73c099..309f2f8834 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_03.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_03.cpp @@ -41,17 +41,16 @@ std::string AutoStory_Segment_03::end_text() const{ return "End: Finished catch tutorial. Walked to the cliff and heard mystery cry."; } -void AutoStory_Segment_03::run_segment(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options) const{ - AutoStoryStats& stats = env.current_stats(); +void AutoStory_Segment_03::run_segment(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const{ stats.m_segment++; env.update_stats(); context.wait_for_all_requests(); env.console.log("Start Segment 03: Catch Tutorial", COLOR_ORANGE); - checkpoint_05(env, context, options.notif_status_update); - checkpoint_06(env, context, options.notif_status_update); - checkpoint_07(env, context, options.notif_status_update); + checkpoint_05(env, context, options.notif_status_update, stats); + checkpoint_06(env, context, options.notif_status_update, stats); + checkpoint_07(env, context, options.notif_status_update, stats); context.wait_for_all_requests(); env.console.log("End Segment 03: Catch Tutorial", COLOR_GREEN); @@ -62,14 +61,14 @@ void AutoStory_Segment_03::run_segment(SingleSwitchProgramEnvironment& env, ProC void checkpoint_05( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } context.wait_for_all_requests(); @@ -98,14 +97,14 @@ void checkpoint_05( void checkpoint_06( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } @@ -148,14 +147,14 @@ void checkpoint_06( void checkpoint_07( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_03.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_03.h index 949f113349..2d7614ecfe 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_03.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_03.h @@ -21,7 +21,8 @@ class AutoStory_Segment_03 : public AutoStory_Segment{ virtual void run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options) const override; + AutoStoryOptions options, + AutoStoryStats& stats) const override; }; @@ -30,7 +31,8 @@ class AutoStory_Segment_03 : public AutoStory_Segment{ void checkpoint_05( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); // start: Met mom at gate. Received mom's sandwich. @@ -38,7 +40,8 @@ void checkpoint_05( void checkpoint_06( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); // start: Cleared catch tutorial. @@ -46,7 +49,8 @@ void checkpoint_06( void checkpoint_07( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_04.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_04.cpp index 32cde6a1ce..bb4b7ce7b8 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_04.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_04.cpp @@ -45,16 +45,16 @@ std::string AutoStory_Segment_04::end_text() const{ void AutoStory_Segment_04::run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const{ - AutoStoryStats& stats = env.current_stats(); stats.m_segment++; env.update_stats(); context.wait_for_all_requests(); env.console.log("Start Segment 04: Rescue Legendary", COLOR_ORANGE); - checkpoint_08(env, context, options.notif_status_update); + checkpoint_08(env, context, options.notif_status_update, stats); context.wait_for_all_requests(); env.console.log("End Segment 04: Rescue Legendary", COLOR_GREEN); @@ -64,14 +64,14 @@ void AutoStory_Segment_04::run_segment( void checkpoint_08( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } context.wait_for_all_requests(); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_04.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_04.h index 1879b5cf2b..10e8bf968b 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_04.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_04.h @@ -21,7 +21,8 @@ class AutoStory_Segment_04 : public AutoStory_Segment{ virtual void run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const override; }; @@ -31,7 +32,8 @@ class AutoStory_Segment_04 : public AutoStory_Segment{ void checkpoint_08( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_05.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_05.cpp index 5b56380f66..928de33f01 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_05.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_05.cpp @@ -44,17 +44,17 @@ std::string AutoStory_Segment_05::end_text() const{ void AutoStory_Segment_05::run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const{ - AutoStoryStats& stats = env.current_stats(); stats.m_segment++; env.update_stats(); context.wait_for_all_requests(); env.console.log("Start Segment 05: First Arven Battle", COLOR_ORANGE); - checkpoint_09(env, context, options.notif_status_update); - checkpoint_10(env, context, options.notif_status_update); + checkpoint_09(env, context, options.notif_status_update, stats); + checkpoint_10(env, context, options.notif_status_update, stats); context.wait_for_all_requests(); env.console.log("End Segment 05: First Arven Battle", COLOR_GREEN); @@ -65,14 +65,14 @@ void AutoStory_Segment_05::run_segment( void checkpoint_09( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } context.wait_for_all_requests(); @@ -115,14 +115,14 @@ void checkpoint_09( void checkpoint_10( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } context.wait_for_all_requests(); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_05.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_05.h index 4e3e6103cf..8ab8553145 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_05.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_05.h @@ -21,7 +21,8 @@ class AutoStory_Segment_05 : public AutoStory_Segment{ virtual void run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const override; }; @@ -31,7 +32,8 @@ class AutoStory_Segment_05 : public AutoStory_Segment{ void checkpoint_09( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); // start: Battled Arven and received Legendary's Pokeball. @@ -39,7 +41,8 @@ void checkpoint_09( void checkpoint_10( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.cpp index 0add7006eb..9bb7aa3eba 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.cpp @@ -43,16 +43,16 @@ std::string AutoStory_Segment_06::end_text() const{ void AutoStory_Segment_06::run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const{ - AutoStoryStats& stats = env.current_stats(); stats.m_segment++; env.update_stats(); context.wait_for_all_requests(); env.console.log("Start Segment 06: Go to Los Platos", COLOR_ORANGE); - checkpoint_11(env, context, options.notif_status_update); + checkpoint_11(env, context, options.notif_status_update, stats); context.wait_for_all_requests(); env.console.log("End Segment 06: Go to Los Platos", COLOR_GREEN); @@ -64,14 +64,14 @@ void AutoStory_Segment_06::run_segment( void checkpoint_11( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.h index a608b5f770..ad6d1616fc 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.h @@ -21,7 +21,8 @@ class AutoStory_Segment_06 : public AutoStory_Segment{ virtual void run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const override; }; @@ -31,7 +32,8 @@ class AutoStory_Segment_06 : public AutoStory_Segment{ void checkpoint_11( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.cpp index cc6b2dc7bd..ffc9d7ea14 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.cpp @@ -43,26 +43,17 @@ std::string AutoStory_Segment_07::end_text() const{ void AutoStory_Segment_07::run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const{ - AutoStoryStats& stats = env.current_stats(); + stats.m_segment++; env.update_stats(); context.wait_for_all_requests(); env.console.log("Start Segment 07: Go to Mesagoza South", COLOR_ORANGE); - checkpoint_12(env, context, options.notif_status_update); - - // // Mystery Gift, delete later - // enter_menu_from_overworld(env.program_info(), env.console, context, 2); - // pbf_press_button(context, BUTTON_A, 20, 4 * TICKS_PER_SECOND); - // pbf_press_dpad(context, DPAD_UP, 20, 105); - // pbf_press_button(context, BUTTON_A, 20, 4 * TICKS_PER_SECOND); - // pbf_press_dpad(context, DPAD_DOWN, 20, 105); - // pbf_press_button(context, BUTTON_A, 20, 4 * TICKS_PER_SECOND); - // pbf_press_button(context, BUTTON_A, 20, 10 * TICKS_PER_SECOND); - // clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 10); + checkpoint_12(env, context, options.notif_status_update, stats); context.wait_for_all_requests(); env.console.log("End Segment 07: Go to Mesagoza South", COLOR_GREEN); @@ -72,17 +63,18 @@ void AutoStory_Segment_07::run_segment( void checkpoint_12( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ // reset rate: ~25%. 12 resets out of 52. // resets due to: getting attacked by wild pokemon, either from behind, // or when lead pokemon not strong enough to clear them with Let's go - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.h index a059221d8b..40c14fbd9c 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.h @@ -21,7 +21,8 @@ class AutoStory_Segment_07 : public AutoStory_Segment{ virtual void run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const override; }; @@ -31,7 +32,8 @@ class AutoStory_Segment_07 : public AutoStory_Segment{ void checkpoint_12( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_08.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_08.cpp index c8a7097800..ce0c098578 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_08.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_08.cpp @@ -41,18 +41,19 @@ std::string AutoStory_Segment_08::end_text() const{ void AutoStory_Segment_08::run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const{ - AutoStoryStats& stats = env.current_stats(); + stats.m_segment++; env.update_stats(); context.wait_for_all_requests(); env.console.log("Start Segment 08: Beat Team Star and arrive at School", COLOR_ORANGE); - checkpoint_13(env, context, options.notif_status_update); - checkpoint_14(env, context, options.notif_status_update); - checkpoint_15(env, context, options.notif_status_update); + checkpoint_13(env, context, options.notif_status_update, stats); + checkpoint_14(env, context, options.notif_status_update, stats); + checkpoint_15(env, context, options.notif_status_update, stats); context.wait_for_all_requests(); @@ -64,10 +65,11 @@ void AutoStory_Segment_08::run_segment( void checkpoint_13( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ // reset rate: 0%. 0 resets out of 70. - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ @@ -75,7 +77,7 @@ void checkpoint_13( [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } @@ -115,14 +117,15 @@ void checkpoint_13( void checkpoint_14( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } context.wait_for_all_requests(); @@ -173,14 +176,15 @@ void checkpoint_14( void checkpoint_15( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } context.wait_for_all_requests(); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_08.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_08.h index 7f9dbffae7..f48c66a0d5 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_08.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_08.h @@ -21,7 +21,8 @@ class AutoStory_Segment_08 : public AutoStory_Segment{ virtual void run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const override; }; @@ -30,7 +31,8 @@ class AutoStory_Segment_08 : public AutoStory_Segment{ void checkpoint_13( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); // start: Battled Nemona at Mesagoza gate. Entered Mesagoza. @@ -38,7 +40,8 @@ void checkpoint_13( void checkpoint_14( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); // start: Battled Team Star at school entrance. @@ -46,7 +49,8 @@ void checkpoint_14( void checkpoint_15( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_09.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_09.cpp index e7cf88c809..8c5eaed5ac 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_09.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_09.cpp @@ -41,20 +41,21 @@ std::string AutoStory_Segment_09::end_text() const{ void AutoStory_Segment_09::run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const{ - AutoStoryStats& stats = env.current_stats(); + stats.m_segment++; env.update_stats(); context.wait_for_all_requests(); env.console.log("Start Segment 09: Complete tutorial", COLOR_ORANGE); - checkpoint_16(env, context, options.notif_status_update); - checkpoint_17(env, context, options.notif_status_update); - checkpoint_18(env, context, options.notif_status_update); - checkpoint_19(env, context, options.notif_status_update); - checkpoint_20(env, context, options.notif_status_update); + checkpoint_16(env, context, options.notif_status_update, stats); + checkpoint_17(env, context, options.notif_status_update, stats); + checkpoint_18(env, context, options.notif_status_update, stats); + checkpoint_19(env, context, options.notif_status_update, stats); + checkpoint_20(env, context, options.notif_status_update, stats); context.wait_for_all_requests(); env.console.log("End Segment 09: Complete tutorial", COLOR_GREEN); @@ -67,14 +68,15 @@ void AutoStory_Segment_09::run_segment( void checkpoint_16( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } context.wait_for_all_requests(); @@ -120,14 +122,15 @@ void checkpoint_16( void checkpoint_17( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } context.wait_for_all_requests(); @@ -175,14 +178,15 @@ void checkpoint_17( void checkpoint_18( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } context.wait_for_all_requests(); @@ -221,14 +225,15 @@ void checkpoint_18( void checkpoint_19( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } context.wait_for_all_requests(); @@ -266,14 +271,15 @@ void checkpoint_19( void checkpoint_20( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } context.wait_for_all_requests(); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_09.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_09.h index f2f97eadac..5b9825908b 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_09.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_09.h @@ -21,7 +21,8 @@ class AutoStory_Segment_09 : public AutoStory_Segment{ virtual void run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const override; }; @@ -31,7 +32,8 @@ class AutoStory_Segment_09 : public AutoStory_Segment{ void checkpoint_16( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); // start: Talked to Arven. Received Titan questline (Path of Legends). @@ -39,7 +41,8 @@ void checkpoint_16( void checkpoint_17( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); // start: Talked to Cassiopeia. Saw Geeta. Talked to Nemona. Received Gym/Elite Four questline (Victory Road). Standing in staff room. @@ -47,7 +50,8 @@ void checkpoint_17( void checkpoint_18( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); // start: Talked to Clavell and the professor. @@ -55,7 +59,8 @@ void checkpoint_18( void checkpoint_19( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); // start: Talked to Nemona, visited dorm, time passed. @@ -63,7 +68,8 @@ void checkpoint_19( void checkpoint_20( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_10.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_10.cpp index fc6d5cbbff..daa31ad47f 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_10.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_10.cpp @@ -44,18 +44,19 @@ std::string AutoStory_Segment_10::end_text() const{ void AutoStory_Segment_10::run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const{ - AutoStoryStats& stats = env.current_stats(); + stats.m_segment++; env.update_stats(); context.wait_for_all_requests(); env.console.log("Start Segment " + name(), COLOR_ORANGE); - checkpoint_21(env, context, options.notif_status_update); - checkpoint_22(env, context, options.notif_status_update); - checkpoint_23(env, context, options.notif_status_update); + checkpoint_21(env, context, options.notif_status_update, stats); + checkpoint_22(env, context, options.notif_status_update, stats); + checkpoint_23(env, context, options.notif_status_update, stats); context.wait_for_all_requests(); env.console.log("End Segment " + name(), COLOR_GREEN); @@ -65,14 +66,15 @@ void AutoStory_Segment_10::run_segment( void checkpoint_21( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } fly_to_overlapping_flypoint(env.program_info(), env.console, context); @@ -131,14 +133,15 @@ void checkpoint_21( void checkpoint_22( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } context.wait_for_all_requests(); @@ -200,14 +203,15 @@ void checkpoint_22( void checkpoint_23( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } context.wait_for_all_requests(); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_10.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_10.h index e7026478e7..c47699f28e 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_10.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_10.h @@ -21,7 +21,8 @@ class AutoStory_Segment_10 : public AutoStory_Segment{ virtual void run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const override; }; @@ -31,7 +32,8 @@ class AutoStory_Segment_10 : public AutoStory_Segment{ void checkpoint_21( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); // start: At Mesagoza West gate flypoint @@ -39,7 +41,8 @@ void checkpoint_21( void checkpoint_22( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); // start: At South Province Area Two Pokecenter. @@ -47,7 +50,8 @@ void checkpoint_22( void checkpoint_23( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_11.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_11.cpp index badc0ae070..c461d66ef4 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_11.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_11.cpp @@ -51,19 +51,20 @@ std::string AutoStory_Segment_11::end_text() const{ void AutoStory_Segment_11::run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const{ - AutoStoryStats& stats = env.current_stats(); + stats.m_segment++; env.update_stats(); context.wait_for_all_requests(); env.console.log("Start Segment " + name(), COLOR_ORANGE); - checkpoint_24(env, context, options.notif_status_update); - checkpoint_25(env, context, options.notif_status_update); - checkpoint_26(env, context, options.notif_status_update); - checkpoint_27(env, context, options.notif_status_update); + checkpoint_24(env, context, options.notif_status_update, stats); + checkpoint_25(env, context, options.notif_status_update, stats); + checkpoint_26(env, context, options.notif_status_update, stats); + checkpoint_27(env, context, options.notif_status_update, stats); context.wait_for_all_requests(); env.console.log("End Segment " + name(), COLOR_GREEN); @@ -73,14 +74,15 @@ void AutoStory_Segment_11::run_segment( void checkpoint_24( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } context.wait_for_all_requests(); @@ -139,14 +141,15 @@ void checkpoint_24( void checkpoint_25( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } context.wait_for_all_requests(); @@ -227,14 +230,15 @@ void checkpoint_25( void checkpoint_26( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } context.wait_for_all_requests(); @@ -593,14 +597,15 @@ void checkpoint_26( void checkpoint_27( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } context.wait_for_all_requests(); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_11.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_11.h index 5b17aaf4f9..a5bfcbfe48 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_11.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_11.h @@ -21,7 +21,8 @@ class AutoStory_Segment_11 : public AutoStory_Segment{ virtual void run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const override; }; @@ -31,7 +32,8 @@ class AutoStory_Segment_11 : public AutoStory_Segment{ void checkpoint_24( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); // start: Spoke to Cortondo Gym reception. At Cortondo West Pokecenter. @@ -39,7 +41,8 @@ void checkpoint_24( void checkpoint_25( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); // start: Defeated the trainers at Olive Roll, but left Olive unmoved. Then backed out, standing in front of the Olive Roll NPC. @@ -47,7 +50,8 @@ void checkpoint_25( void checkpoint_26( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); // start: Completed Olive roll gym challenge. @@ -55,7 +59,8 @@ void checkpoint_26( void checkpoint_27( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_12.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_12.cpp index dea88783dc..ceee0a2964 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_12.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_12.cpp @@ -47,16 +47,17 @@ std::string AutoStory_Segment_12::end_text() const{ void AutoStory_Segment_12::run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const{ - AutoStoryStats& stats = env.current_stats(); + stats.m_segment++; env.update_stats(); context.wait_for_all_requests(); env.console.log("Start Segment " + name(), COLOR_ORANGE); - checkpoint_28(env, context, options.notif_status_update); + checkpoint_28(env, context, options.notif_status_update, stats); context.wait_for_all_requests(); env.console.log("End Segment " + name(), COLOR_GREEN); @@ -67,14 +68,15 @@ void AutoStory_Segment_12::run_segment( void checkpoint_28( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } context.wait_for_all_requests(); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_12.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_12.h index 0e7d277412..234c693674 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_12.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_12.h @@ -21,7 +21,8 @@ class AutoStory_Segment_12 : public AutoStory_Segment{ virtual void run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const override; }; @@ -30,7 +31,8 @@ class AutoStory_Segment_12 : public AutoStory_Segment{ void checkpoint_28( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_13.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_13.cpp index 38957b4660..b57cef2fd8 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_13.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_13.cpp @@ -42,16 +42,17 @@ std::string AutoStory_Segment_13::end_text() const{ void AutoStory_Segment_13::run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const{ - AutoStoryStats& stats = env.current_stats(); + stats.m_segment++; env.update_stats(); context.wait_for_all_requests(); env.console.log("Start Segment " + name(), COLOR_ORANGE); - checkpoint_29(env, context, options.notif_status_update); + checkpoint_29(env, context, options.notif_status_update, stats); context.wait_for_all_requests(); env.console.log("End Segment " + name(), COLOR_GREEN); @@ -62,14 +63,15 @@ void AutoStory_Segment_13::run_segment( void checkpoint_29( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } context.wait_for_all_requests(); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_13.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_13.h index ce4330a4b6..4a88253794 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_13.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_13.h @@ -21,7 +21,8 @@ class AutoStory_Segment_13 : public AutoStory_Segment{ virtual void run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const override; }; @@ -31,7 +32,8 @@ class AutoStory_Segment_13 : public AutoStory_Segment{ void checkpoint_29( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_14.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_14.cpp index 8d3042c18c..029e71b484 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_14.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_14.cpp @@ -43,17 +43,18 @@ std::string AutoStory_Segment_14::end_text() const{ void AutoStory_Segment_14::run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const{ - AutoStoryStats& stats = env.current_stats(); + stats.m_segment++; env.update_stats(); context.wait_for_all_requests(); env.console.log("Start Segment " + name(), COLOR_ORANGE); - checkpoint_30(env, context, options.notif_status_update); - checkpoint_31(env, context, options.notif_status_update); + checkpoint_30(env, context, options.notif_status_update, stats); + checkpoint_31(env, context, options.notif_status_update, stats); context.wait_for_all_requests(); env.console.log("End Segment " + name(), COLOR_GREEN); @@ -65,14 +66,15 @@ void AutoStory_Segment_14::run_segment( void checkpoint_30( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } context.wait_for_all_requests(); @@ -251,14 +253,15 @@ void checkpoint_30( void checkpoint_31( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } context.wait_for_all_requests(); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_14.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_14.h index d4c5128c8a..ffddf03134 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_14.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_14.h @@ -21,7 +21,8 @@ class AutoStory_Segment_14 : public AutoStory_Segment{ virtual void run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const override; }; @@ -31,7 +32,8 @@ class AutoStory_Segment_14 : public AutoStory_Segment{ void checkpoint_30( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); // start: Defeated Bombirdier @@ -39,7 +41,8 @@ void checkpoint_30( void checkpoint_31( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_15.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_15.cpp index 7758d86909..ee42908645 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_15.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_15.cpp @@ -46,18 +46,19 @@ std::string AutoStory_Segment_15::end_text() const{ void AutoStory_Segment_15::run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const{ - AutoStoryStats& stats = env.current_stats(); + stats.m_segment++; env.update_stats(); context.wait_for_all_requests(); env.console.log("Start Segment " + name(), COLOR_ORANGE); - checkpoint_32(env, context, options.notif_status_update); - checkpoint_33(env, context, options.notif_status_update); - checkpoint_34(env, context, options.notif_status_update); + checkpoint_32(env, context, options.notif_status_update, stats); + checkpoint_33(env, context, options.notif_status_update, stats); + checkpoint_34(env, context, options.notif_status_update, stats); context.wait_for_all_requests(); @@ -70,14 +71,15 @@ void AutoStory_Segment_15::run_segment( void checkpoint_32( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } context.wait_for_all_requests(); @@ -147,14 +149,15 @@ void checkpoint_32( void checkpoint_33( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } context.wait_for_all_requests(); @@ -274,14 +277,15 @@ void checkpoint_33( void checkpoint_34( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } context.wait_for_all_requests(); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_15.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_15.h index ae8b01571a..5c8cb7169d 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_15.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_15.h @@ -21,7 +21,8 @@ class AutoStory_Segment_15 : public AutoStory_Segment{ virtual void run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const override; }; @@ -32,7 +33,8 @@ class AutoStory_Segment_15 : public AutoStory_Segment{ void checkpoint_32( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); // start: Defeated Team star dark grunts at base entrance @@ -40,7 +42,8 @@ void checkpoint_32( void checkpoint_33( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); // start: Defeated Team Star (Dark) boss @@ -48,7 +51,8 @@ void checkpoint_33( void checkpoint_34( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_16.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_16.cpp index 2de8913d99..6c1788a2be 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_16.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_16.cpp @@ -43,17 +43,18 @@ std::string AutoStory_Segment_16::end_text() const{ void AutoStory_Segment_16::run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const{ - AutoStoryStats& stats = env.current_stats(); + stats.m_segment++; env.update_stats(); context.wait_for_all_requests(); env.console.log("Start Segment " + name(), COLOR_ORANGE); - checkpoint_35(env, context, options.notif_status_update); - checkpoint_36(env, context, options.notif_status_update); + checkpoint_35(env, context, options.notif_status_update, stats); + checkpoint_36(env, context, options.notif_status_update, stats); context.wait_for_all_requests(); env.console.log("End Segment " + name(), COLOR_GREEN); @@ -64,14 +65,15 @@ void AutoStory_Segment_16::run_segment( void checkpoint_35( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } context.wait_for_all_requests(); @@ -114,14 +116,15 @@ void checkpoint_35( void checkpoint_36( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } context.wait_for_all_requests(); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_16.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_16.h index a6d5ddcb8c..5226cd1167 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_16.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_16.h @@ -21,7 +21,8 @@ class AutoStory_Segment_16 : public AutoStory_Segment{ virtual void run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const override; }; @@ -31,7 +32,8 @@ class AutoStory_Segment_16 : public AutoStory_Segment{ void checkpoint_35( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); // start: At Cascarrafa Gym. Received Kofu's wallet. @@ -39,7 +41,8 @@ void checkpoint_35( void checkpoint_36( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_17.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_17.cpp index 46c4e80474..2451c5ab85 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_17.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_17.cpp @@ -43,17 +43,18 @@ std::string AutoStory_Segment_17::end_text() const{ void AutoStory_Segment_17::run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const{ - AutoStoryStats& stats = env.current_stats(); + stats.m_segment++; env.update_stats(); context.wait_for_all_requests(); env.console.log("Start Segment " + name(), COLOR_ORANGE); - checkpoint_37(env, context, options.notif_status_update); - checkpoint_38(env, context, options.notif_status_update); + checkpoint_37(env, context, options.notif_status_update, stats); + checkpoint_38(env, context, options.notif_status_update, stats); context.wait_for_all_requests(); env.console.log("End Segment " + name(), COLOR_GREEN); @@ -64,14 +65,15 @@ void AutoStory_Segment_17::run_segment( void checkpoint_37( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } context.wait_for_all_requests(); @@ -118,14 +120,15 @@ void checkpoint_37( void checkpoint_38( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } context.wait_for_all_requests(); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_17.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_17.h index 95db8b3f35..d83b331167 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_17.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_17.h @@ -21,7 +21,8 @@ class AutoStory_Segment_17 : public AutoStory_Segment{ virtual void run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const override; }; @@ -31,7 +32,8 @@ class AutoStory_Segment_17 : public AutoStory_Segment{ void checkpoint_37( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); // start: Won auction at Porto Marinada, passed Gym challenge. @@ -39,7 +41,8 @@ void checkpoint_37( void checkpoint_38( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_18.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_18.cpp index dedf074c67..955acb93b0 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_18.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_18.cpp @@ -44,17 +44,18 @@ std::string AutoStory_Segment_18::end_text() const{ void AutoStory_Segment_18::run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const{ - AutoStoryStats& stats = env.current_stats(); + stats.m_segment++; env.update_stats(); context.wait_for_all_requests(); env.console.log("Start Segment " + name(), COLOR_ORANGE); - checkpoint_39(env, context, options.notif_status_update); - checkpoint_40(env, context, options.notif_status_update); + checkpoint_39(env, context, options.notif_status_update, stats); + checkpoint_40(env, context, options.notif_status_update, stats); context.wait_for_all_requests(); env.console.log("End Segment " + name(), COLOR_GREEN); @@ -65,14 +66,15 @@ void AutoStory_Segment_18::run_segment( void checkpoint_39( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } context.wait_for_all_requests(); @@ -245,14 +247,15 @@ void checkpoint_39( void checkpoint_40( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } context.wait_for_all_requests(); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_18.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_18.h index e2660a7e4a..794f22846c 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_18.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_18.h @@ -21,7 +21,8 @@ class AutoStory_Segment_18 : public AutoStory_Segment{ virtual void run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const override; }; @@ -31,7 +32,8 @@ class AutoStory_Segment_18 : public AutoStory_Segment{ void checkpoint_39( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); // start: Defeated Great Tusk/Iron Treads. @@ -39,7 +41,8 @@ void checkpoint_39( void checkpoint_40( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_19.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_19.cpp index d530416ef5..a811b38a74 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_19.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_19.cpp @@ -43,17 +43,18 @@ std::string AutoStory_Segment_19::end_text() const{ void AutoStory_Segment_19::run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const{ - AutoStoryStats& stats = env.current_stats(); + stats.m_segment++; env.update_stats(); context.wait_for_all_requests(); env.console.log("Start Segment " + name(), COLOR_ORANGE); - checkpoint_41(env, context, options.notif_status_update); - checkpoint_42(env, context, options.notif_status_update); + checkpoint_41(env, context, options.notif_status_update, stats); + checkpoint_42(env, context, options.notif_status_update, stats); context.wait_for_all_requests(); env.console.log("End Segment " + name(), COLOR_GREEN); @@ -65,14 +66,15 @@ void AutoStory_Segment_19::run_segment( void checkpoint_41( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } context.wait_for_all_requests(); @@ -262,14 +264,15 @@ void checkpoint_41( void checkpoint_42( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; } context.wait_for_all_requests(); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_19.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_19.h index 49aa9afc03..fa87aa2ca7 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_19.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_19.h @@ -21,7 +21,8 @@ class AutoStory_Segment_19 : public AutoStory_Segment{ virtual void run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const override; }; @@ -31,7 +32,8 @@ class AutoStory_Segment_19 : public AutoStory_Segment{ void checkpoint_41( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); // start: Defeated Klawf. @@ -39,7 +41,8 @@ void checkpoint_41( void checkpoint_42( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_20.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_20.cpp index 6dd3642076..62126511a1 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_20.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_20.cpp @@ -45,18 +45,19 @@ std::string AutoStory_Segment_20::end_text() const{ void AutoStory_Segment_20::run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const{ - AutoStoryStats& stats = env.current_stats(); + stats.m_segment++; env.update_stats(); context.wait_for_all_requests(); env.console.log("Start Segment " + name(), COLOR_ORANGE); - checkpoint_43(env, context, options.notif_status_update); - checkpoint_44(env, context, options.notif_status_update); - checkpoint_45(env, context, options.notif_status_update); + checkpoint_43(env, context, options.notif_status_update, stats); + checkpoint_44(env, context, options.notif_status_update, stats); + checkpoint_45(env, context, options.notif_status_update, stats); context.wait_for_all_requests(); env.console.log("End Segment " + name(), COLOR_GREEN); @@ -67,14 +68,15 @@ void AutoStory_Segment_20::run_segment( void checkpoint_43( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; }else{ enter_menu_from_overworld(env.program_info(), env.console, context, -1); @@ -146,14 +148,15 @@ void checkpoint_43( void checkpoint_44( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; }else{ enter_menu_from_overworld(env.program_info(), env.console, context, -1); @@ -492,14 +495,15 @@ void checkpoint_44( void checkpoint_45( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; }else{ enter_menu_from_overworld(env.program_info(), env.console, context, -1); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_20.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_20.h index 9c43729401..a69e8cfc78 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_20.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_20.h @@ -21,7 +21,8 @@ class AutoStory_Segment_20 : public AutoStory_Segment{ virtual void run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options) const override; + AutoStoryOptions options, + AutoStoryStats& stats) const override; }; @@ -30,7 +31,8 @@ class AutoStory_Segment_20 : public AutoStory_Segment{ void checkpoint_43( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); // start: At Artazon Gym building. Battled Nemona. Received Sunflora gym challenge. @@ -38,7 +40,8 @@ void checkpoint_43( void checkpoint_44( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); // start: Finished Sunflora gym challenge. @@ -46,7 +49,8 @@ void checkpoint_44( void checkpoint_45( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_21.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_21.cpp index 372f866501..017f234061 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_21.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_21.cpp @@ -43,16 +43,17 @@ std::string AutoStory_Segment_21::end_text() const{ void AutoStory_Segment_21::run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const{ - AutoStoryStats& stats = env.current_stats(); + stats.m_segment++; env.update_stats(); context.wait_for_all_requests(); env.console.log("Start Segment " + name(), COLOR_ORANGE); - checkpoint_46(env, context, options.notif_status_update); + checkpoint_46(env, context, options.notif_status_update, stats); context.wait_for_all_requests(); env.console.log("End Segment " + name(), COLOR_GREEN); @@ -62,14 +63,15 @@ void AutoStory_Segment_21::run_segment( void checkpoint_46( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; }else{ enter_menu_from_overworld(env.program_info(), env.console, context, -1); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_21.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_21.h index 43ad7672a4..bddc755b55 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_21.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_21.h @@ -21,7 +21,8 @@ class AutoStory_Segment_21 : public AutoStory_Segment{ virtual void run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const override; }; @@ -30,7 +31,8 @@ class AutoStory_Segment_21 : public AutoStory_Segment{ void checkpoint_46( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.cpp index 22be82158a..994741c2c6 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.cpp @@ -45,18 +45,19 @@ std::string AutoStory_Segment_22::end_text() const{ void AutoStory_Segment_22::run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const{ - AutoStoryStats& stats = env.current_stats(); + stats.m_segment++; env.update_stats(); context.wait_for_all_requests(); env.console.log("Start Segment " + name(), COLOR_ORANGE); - checkpoint_47(env, context, options.notif_status_update); - checkpoint_48(env, context, options.notif_status_update); - checkpoint_49(env, context, options.notif_status_update); + checkpoint_47(env, context, options.notif_status_update, stats); + checkpoint_48(env, context, options.notif_status_update, stats); + checkpoint_49(env, context, options.notif_status_update, stats); context.wait_for_all_requests(); env.console.log("End Segment " + name(), COLOR_GREEN); @@ -67,14 +68,15 @@ void AutoStory_Segment_22::run_segment( void checkpoint_47( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; }else{ enter_menu_from_overworld(env.program_info(), env.console, context, -1); @@ -136,14 +138,15 @@ void checkpoint_47( void checkpoint_48( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; }else{ enter_menu_from_overworld(env.program_info(), env.console, context, -1); @@ -292,14 +295,15 @@ void checkpoint_48( void checkpoint_49( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; }else{ enter_menu_from_overworld(env.program_info(), env.console, context, -1); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.h index 9673fc1cf1..bc130904cf 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.h @@ -21,7 +21,8 @@ class AutoStory_Segment_22 : public AutoStory_Segment{ virtual void run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const override; }; @@ -31,7 +32,8 @@ class AutoStory_Segment_22 : public AutoStory_Segment{ void checkpoint_47( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); // start: At gate of Team Star (Fire) base. @@ -39,7 +41,8 @@ void checkpoint_47( void checkpoint_48( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); // start: Beat Team Star (Fire) @@ -47,7 +50,8 @@ void checkpoint_48( void checkpoint_49( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.cpp index 9fefaf9470..61564057d2 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.cpp @@ -42,16 +42,17 @@ std::string AutoStory_Segment_23::end_text() const{ void AutoStory_Segment_23::run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const{ - AutoStoryStats& stats = env.current_stats(); + stats.m_segment++; env.update_stats(); context.wait_for_all_requests(); env.console.log("Start Segment " + name(), COLOR_ORANGE); - // checkpoint_(env, context, options.notif_status_update); + // checkpoint_(env, context, options.notif_status_update, stats); context.wait_for_all_requests(); env.console.log("End Segment " + name(), COLOR_GREEN); @@ -62,14 +63,15 @@ void AutoStory_Segment_23::run_segment( void checkpoint_50( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - // checkpoint_save(env, context, notif_status_update); + // checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; }else{ enter_menu_from_overworld(env.program_info(), env.console, context, -1); @@ -98,14 +100,15 @@ void checkpoint_50( void checkpoint_51( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - // checkpoint_save(env, context, notif_status_update); + // checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; }else{ enter_menu_from_overworld(env.program_info(), env.console, context, -1); @@ -133,14 +136,15 @@ void checkpoint_51( void checkpoint_52( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - // checkpoint_save(env, context, notif_status_update); + // checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; }else{ enter_menu_from_overworld(env.program_info(), env.console, context, -1); @@ -168,14 +172,15 @@ void checkpoint_52( void checkpoint_53( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - // checkpoint_save(env, context, notif_status_update); + // checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; }else{ enter_menu_from_overworld(env.program_info(), env.console, context, -1); @@ -203,14 +208,15 @@ void checkpoint_53( void checkpoint_54( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - // checkpoint_save(env, context, notif_status_update); + // checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; }else{ enter_menu_from_overworld(env.program_info(), env.console, context, -1); @@ -238,14 +244,15 @@ void checkpoint_54( void checkpoint_55( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ){ - AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; while (true){ try{ if (first_attempt){ - // checkpoint_save(env, context, notif_status_update); + // checkpoint_save(env, context, notif_status_update, stats); first_attempt = false; }else{ enter_menu_from_overworld(env.program_info(), env.console, context, -1); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.h index b42a4e3626..c072731103 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.h @@ -21,7 +21,8 @@ class AutoStory_Segment_23 : public AutoStory_Segment{ virtual void run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const override; }; @@ -30,7 +31,8 @@ class AutoStory_Segment_23 : public AutoStory_Segment{ void checkpoint_50( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); // start: @@ -38,7 +40,8 @@ void checkpoint_50( void checkpoint_51( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); @@ -47,7 +50,8 @@ void checkpoint_51( void checkpoint_52( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); @@ -56,7 +60,8 @@ void checkpoint_52( void checkpoint_53( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); @@ -65,7 +70,8 @@ void checkpoint_53( void checkpoint_54( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); @@ -74,7 +80,8 @@ void checkpoint_54( void checkpoint_55( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - EventNotificationOption& notif_status_update + EventNotificationOption& notif_status_update, + AutoStoryStats& stats ); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_24.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_24.cpp index a22655b6e7..91b37de11e 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_24.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_24.cpp @@ -42,16 +42,17 @@ std::string AutoStory_Segment_24::end_text() const{ void AutoStory_Segment_24::run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const{ - AutoStoryStats& stats = env.current_stats(); + stats.m_segment++; env.update_stats(); context.wait_for_all_requests(); env.console.log("Start Segment " + name(), COLOR_ORANGE); - // checkpoint_(env, context, options.notif_status_update); + // checkpoint_(env, context, options.notif_status_update, stats); context.wait_for_all_requests(); env.console.log("End Segment " + name(), COLOR_GREEN); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_24.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_24.h index d3bca07ba5..54ff1408b2 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_24.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_24.h @@ -21,7 +21,8 @@ class AutoStory_Segment_24 : public AutoStory_Segment{ virtual void run_segment( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - AutoStoryOptions options + AutoStoryOptions options, + AutoStoryStats& stats ) const override; }; diff --git a/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_ClaimMysteryGift.cpp b/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_ClaimMysteryGift.cpp new file mode 100644 index 0000000000..4759a1a9ec --- /dev/null +++ b/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_ClaimMysteryGift.cpp @@ -0,0 +1,261 @@ +/* ClaimMysteryGift + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include "CommonTools/Async/InferenceRoutines.h" +#include "CommonFramework/Exceptions/OperationFailedException.h" +#include "CommonFramework/GlobalSettingsPanel.h" +#include "CommonFramework/Notifications/ProgramNotifications.h" +#include "CommonFramework/VideoPipeline/VideoFeed.h" +#include "CommonFramework/ProgramStats/StatsTracking.h" +#include "CommonTools/StartupChecks/VideoResolutionCheck.h" +#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" +#include "Pokemon/Pokemon_Strings.h" +#include "PokemonSwSh/Inference/PokemonSwSh_IvJudgeReader.h" +#include "NintendoSwitch/Inference/NintendoSwitch_SelectedSettingDetector.h" +#include "NintendoSwitch/Inference/NintendoSwitch_ConsoleTypeDetector.h" +#include "PokemonSV/Inference/PokemonSV_MainMenuDetector.h" +#include "PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.h" +#include "PokemonSV/Programs/PokemonSV_GameEntry.h" +#include "PokemonSV/Programs/PokemonSV_SaveGame.h" +#include "PokemonSV/Programs/PokemonSV_MenuNavigation.h" +#include "PokemonSV/Programs/PokemonSV_WorldNavigation.h" +#include "PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.h" +#include "PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h" +#include "PokemonSV_ClaimMysteryGift.h" + +#include +using std::cout; +using std::endl; +//#include +//#include + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonSV{ + +using namespace Pokemon; + + +ClaimMysteryGift_Descriptor::ClaimMysteryGift_Descriptor() + : SingleSwitchProgramDescriptor( + "PokemonSV:ClaimMysteryGift", + STRING_POKEMON + " SV", "Claim Mystery Gift", + "ComputerControl/blob/master/Wiki/Programs/PokemonSV/ClaimMysteryGift.md", + "Claim the Mystery Gift in SV.", + FeedbackType::VIDEO_AUDIO, + AllowCommandsWhenRunning::DISABLE_COMMANDS, + {SerialPABotBase::OLD_NINTENDO_SWITCH_DEFAULT_REQUIREMENTS} + ) +{} + +// std::unique_ptr ClaimMysteryGift_Descriptor::make_stats() const{ +// return std::unique_ptr(new ClaimMysteryGiftStats()); +// } + + + +ClaimMysteryGift::~ClaimMysteryGift(){ + STARTING_POINT.remove_listener(*this); +} + +ClaimMysteryGift::ClaimMysteryGift() + : LANGUAGE( + "Game Language:", + PokemonSwSh::IV_READER().languages(), + LockMode::UNLOCK_WHILE_RUNNING, + true + ) + , STARTING_POINT( + "Starting point:", + { + {StartingPoint::NEW_GAME, "new-game", "New Game"}, + {StartingPoint::DONE_TUTORIAL, "done-tutorial", "Done Tutorial"}, + }, + LockMode::LOCK_WHILE_RUNNING, + StartingPoint::NEW_GAME + ) + , MYSTERY_GIFT_NOTE{ + "Ensure you are logged into a Nintendo account.
" + "You can ignore the options for multiple switches below. This only works for 1 Switch.
" + "Refer to the documentation on github for more details." + } + , CODE( + "Link Code:
Mystery Gift code. (not case sensitive)
" + "(Box is big so it's easy to land your mouse on.)", + LockMode::UNLOCK_WHILE_RUNNING, + "0123", "0123", + true + ) + , GO_HOME_WHEN_DONE(true) + , NOTIFICATION_STATUS_UPDATE("Status Update", true, false, std::chrono::seconds(30)) + , NOTIFICATIONS({ + &NOTIFICATION_STATUS_UPDATE, + &NOTIFICATION_PROGRAM_FINISH, + &NOTIFICATION_ERROR_RECOVERABLE, + &NOTIFICATION_ERROR_FATAL, + }) +{ + + PA_ADD_OPTION(LANGUAGE); + PA_ADD_OPTION(STARTING_POINT); + PA_ADD_OPTION(MYSTERY_GIFT_NOTE); + PA_ADD_OPTION(CODE); + PA_ADD_OPTION(SETTINGS); + PA_ADD_OPTION(GO_HOME_WHEN_DONE); + PA_ADD_OPTION(NOTIFICATIONS); + + + ClaimMysteryGift::on_config_value_changed(this); + + STARTING_POINT.add_listener(*this); +} + +void ClaimMysteryGift::on_config_value_changed(void* object){ + + +} + +void ClaimMysteryGift::enter_mystery_gift_code(SingleSwitchProgramEnvironment& env, ProControllerContext& context){ + env.log("Enter mystery gift code."); + + std::string normalized_code; + bool force_keyboard_mode = true; + bool connect_controller_press = false; + normalize_code(normalized_code, CODE, force_keyboard_mode); + + const FastCodeEntrySettings& settings = SETTINGS; + enter_code( + env.console, context, + settings.keyboard_layout[env.console.index()], + normalized_code, force_keyboard_mode, + !settings.skip_plus, + connect_controller_press + ); + +} + +void ClaimMysteryGift::claim_mystery_gift(SingleSwitchProgramEnvironment& env, ProControllerContext& context, int menu_index){ + save_game_from_menu_or_overworld(env.program_info(), env.console, context, false); + + size_t max_attempts = 5; + for (size_t i = 0; i < max_attempts; i++){ + enter_menu_from_overworld(env.program_info(), env.console, context, menu_index); + pbf_press_button(context, BUTTON_A, 20, 4 * TICKS_PER_SECOND); + pbf_press_dpad(context, DPAD_UP, 20, 105); + pbf_press_button(context, BUTTON_A, 20, 4 * TICKS_PER_SECOND); + pbf_press_dpad(context, DPAD_DOWN, 20, 105); + pbf_press_button(context, BUTTON_A, 20, 4 * TICKS_PER_SECOND); + pbf_press_button(context, BUTTON_A, 20, 10 * TICKS_PER_SECOND); + try { + clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 10, {CallbackEnum::PROMPT_DIALOG}); + }catch(OperationFailedException&){ + env.console.log("claim_mystery_gift: Failed to detect the dialog that leads to the Mystery Gift window. Reset game and re-try.", COLOR_YELLOW); + reset_game(env.program_info(), env.console, context); + continue; + } + + context.wait_for_all_requests(); + context.wait_for(Milliseconds(300)); + // we expect to be within Mystery Gift window, with the keyboard visible and "1" being highlighted + + // check whether this is Switch 1 or 2. + ConsoleType console_type = env.console.state().console_type(); + if (console_type == ConsoleType::Unknown){ + env.console.log("Unknown Switch type. Try to detect."); + console_type = detect_console_type_from_in_game(env.console, context); + } + + ImageFloatBox key1_box; + ImageFloatBox other_setting1; + ImageFloatBox other_setting2; + ImageFloatBox background; + + if (is_switch1(console_type)){ + key1_box = {0.037322, 0.451172, 0.009879, 0.113281}; + other_setting1 = {0.01, 0.451172, 0.009879, 0.113281}; + other_setting2 = {0.02, 0.451172, 0.009879, 0.113281}; + background = {0.0, 0.451172, 0.009879, 0.113281}; + }else if (is_switch2(console_type)){ + key1_box = {0.062706, 0.510763, 0.009901, 0.097847}; + other_setting1 = {0.02, 0.510763, 0.009901, 0.097847}; + other_setting2 = {0.04, 0.510763, 0.009901, 0.097847}; + background = {0.0, 0.510763, 0.009901, 0.097847}; + }else{ + throw UserSetupError( + env.console, + "Please select a valid Switch console type." + ); + } + + SelectedSettingWatcher key1_selected(key1_box, other_setting1, other_setting2, background); + int ret = wait_until( + env.console, context, + Milliseconds(5000), + {key1_selected} + ); + if (ret < 0){ // failed to detect Key 1 being highlighted. Reset game and re-try + env.console.log("claim_mystery_gift: Failed to detect the Mystery Gift window. Reset game and re-try.", COLOR_YELLOW); + reset_game(env.program_info(), env.console, context); + continue; + } + + enter_mystery_gift_code(env, context); + return; + } + + OperationFailedException::fire( + ErrorReport::SEND_ERROR_REPORT, + "claim_mystery_gift(): Failed to reach Mystery Gift screen after several attempts.", + env.console + ); +} + +void ClaimMysteryGift::run_autostory_until_pokeportal_unlocked(SingleSwitchProgramEnvironment& env, ProControllerContext& context){ + AutoStoryOptions options{ + LANGUAGE, + StarterChoice::FUECOCO, + NOTIFICATION_STATUS_UPDATE + }; + AutoStoryStats stats; // unused + for (size_t segment_index = 0; segment_index <= 6; segment_index++){ + ALL_AUTO_STORY_SEGMENT_LIST()[segment_index]->run_segment(env, context, options, stats); + } +} + + +void ClaimMysteryGift::program(SingleSwitchProgramEnvironment& env, ProControllerContext& context){ + assert_16_9_720p_min(env.logger(), env.console); + // ClaimMysteryGiftStats& stats = env.current_stats(); + + + // Connect controller + pbf_press_button(context, BUTTON_L, 20, 20); + + // env.console.log("Start Segment " + ALL_AUTO_STORY_SEGMENT_LIST()[get_start_segment_index()]->name(), COLOR_ORANGE); + + if (STARTING_POINT == StartingPoint::DONE_TUTORIAL){ + claim_mystery_gift(env, context, 3); + }else{ + + run_autostory_until_pokeportal_unlocked(env, context); + env.console.log("Done Autostory portion. Pokeportal should now be unlocked."); + claim_mystery_gift(env, context, 2); + } + + // run_autostory(env, context); + + send_program_finished_notification(env, NOTIFICATION_PROGRAM_FINISH); + GO_HOME_WHEN_DONE.run_end_of_program(context); +} + + + + + + +} +} +} diff --git a/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_ClaimMysteryGift.h b/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_ClaimMysteryGift.h new file mode 100644 index 0000000000..05912fc25f --- /dev/null +++ b/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_ClaimMysteryGift.h @@ -0,0 +1,80 @@ +/* Claim Mystery Gift + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#ifndef PokemonAutomation_PokemonSV_ClaimMysteryGift_H +#define PokemonAutomation_PokemonSV_ClaimMysteryGift_H + +#include "Common/Cpp/Options/StaticTextOption.h" +#include "Common/Cpp/Options/SimpleIntegerOption.h" +#include "Common/Cpp/Options/FloatingPointOption.h" +#include "Common/Cpp/Options/EnumDropdownOption.h" +#include "CommonFramework/Notifications/EventNotificationsTable.h" +#include "CommonTools/Options/StringSelectOption.h" +#include "CommonTools/Options/LanguageOCROption.h" +#include "NintendoSwitch/Options/NintendoSwitch_GoHomeWhenDoneOption.h" +#include "Common/Cpp/Options/TextEditOption.h" +#include "PokemonSV/Programs/FastCodeEntry/PokemonSV_CodeEntry.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonSV{ + + + +class ClaimMysteryGift_Descriptor : public SingleSwitchProgramDescriptor{ +public: + ClaimMysteryGift_Descriptor(); + + struct Stats; + // virtual std::unique_ptr make_stats() const override; +}; + +class ClaimMysteryGift : public SingleSwitchProgramInstance, public ConfigOption::Listener{ +public: + ~ClaimMysteryGift(); + ClaimMysteryGift(); + + virtual void program(SingleSwitchProgramEnvironment& env, ProControllerContext& context) override; + + void run_autostory_until_pokeportal_unlocked(SingleSwitchProgramEnvironment& env, ProControllerContext& context); + void claim_mystery_gift(SingleSwitchProgramEnvironment& env, ProControllerContext& context, int menu_index); + void enter_mystery_gift_code(SingleSwitchProgramEnvironment& env, ProControllerContext& context); + +private: + virtual void on_config_value_changed(void* object) override; + + std::string start_segment_description(); + std::string end_segment_description(); + +private: + OCR::LanguageOCROption LANGUAGE; + + enum class StartingPoint{ + NEW_GAME, + DONE_TUTORIAL, + }; + + EnumDropdownOption STARTING_POINT; + StaticTextOption MYSTERY_GIFT_NOTE; + TextEditOption CODE; + FastCodeEntrySettingsOption SETTINGS; + + GoHomeWhenDoneOption GO_HOME_WHEN_DONE; + + EventNotificationOption NOTIFICATION_STATUS_UPDATE; + EventNotificationsOption NOTIFICATIONS; +}; + + + + + + + +} +} +} +#endif