Skip to content

Commit df7eeec

Browse files
committed
Segment 20 and placeholder segments, handle_failed_action()
1 parent 19c7762 commit df7eeec

15 files changed

+1305
-13
lines changed

SerialPrograms/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,6 +1484,16 @@ file(GLOB MAIN_SOURCES
14841484
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_18.h
14851485
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_19.cpp
14861486
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_19.h
1487+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_20.cpp
1488+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_20.h
1489+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_21.cpp
1490+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_21.h
1491+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.cpp
1492+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.h
1493+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.cpp
1494+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.h
1495+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_24.cpp
1496+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_24.h
14871497
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp
14881498
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.h
14891499
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp

SerialPrograms/SerialPrograms.pro

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,11 @@ SOURCES += \
740740
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_17.cpp \
741741
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_18.cpp \
742742
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_19.cpp \
743+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_20.cpp \
744+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_21.cpp \
745+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.cpp \
746+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.cpp \
747+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_24.cpp \
743748
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp \
744749
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp \
745750
Source/PokemonSV/Programs/AutoStory/PokemonSV_MenuOption.cpp \
@@ -1857,6 +1862,11 @@ HEADERS += \
18571862
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_17.h \
18581863
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_18.h \
18591864
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_19.h \
1865+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_20.h \
1866+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_21.h \
1867+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.h \
1868+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.h \
1869+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_24.h \
18601870
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.h \
18611871
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h \
18621872
Source/PokemonSV/Programs/AutoStory/PokemonSV_MenuOption.h \

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@
4040
#include "PokemonSV_AutoStory_Segment_17.h"
4141
#include "PokemonSV_AutoStory_Segment_18.h"
4242
#include "PokemonSV_AutoStory_Segment_19.h"
43-
// #include "PokemonSV_AutoStory_Segment_20.h"
44-
// #include "PokemonSV_AutoStory_Segment_21.h"
45-
// #include "PokemonSV_AutoStory_Segment_22.h"
46-
// #include "PokemonSV_AutoStory_Segment_23.h"
47-
// #include "PokemonSV_AutoStory_Segment_24.h"
43+
#include "PokemonSV_AutoStory_Segment_20.h"
44+
#include "PokemonSV_AutoStory_Segment_21.h"
45+
#include "PokemonSV_AutoStory_Segment_22.h"
46+
#include "PokemonSV_AutoStory_Segment_23.h"
47+
#include "PokemonSV_AutoStory_Segment_24.h"
4848
#include "PokemonSV_AutoStory.h"
4949

5050
// #include <iostream>
@@ -84,7 +84,7 @@ std::vector<std::unique_ptr<AutoStory_Segment>> make_autoStory_segment_list(){
8484
segment_list.emplace_back(std::make_unique<AutoStory_Segment_17>());
8585
segment_list.emplace_back(std::make_unique<AutoStory_Segment_18>());
8686
segment_list.emplace_back(std::make_unique<AutoStory_Segment_19>());
87-
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_20>());
87+
segment_list.emplace_back(std::make_unique<AutoStory_Segment_20>());
8888
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_21>());
8989
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_22>());
9090
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_23>());
@@ -606,13 +606,13 @@ void AutoStory::test_checkpoints(
606606
checkpoint_list.push_back([&](){checkpoint_40(env, context, notif_status_update);});
607607
checkpoint_list.push_back([&](){checkpoint_41(env, context, notif_status_update);});
608608
checkpoint_list.push_back([&](){checkpoint_42(env, context, notif_status_update);});
609-
// checkpoint_list.push_back([&](){checkpoint_43(env, context, notif_status_update);});
610-
// checkpoint_list.push_back([&](){checkpoint_44(env, context, notif_status_update);});
611-
// checkpoint_list.push_back([&](){checkpoint_45(env, context, notif_status_update);});
612-
// checkpoint_list.push_back([&](){checkpoint_46(env, context, notif_status_update);});
613-
// checkpoint_list.push_back([&](){checkpoint_47(env, context, notif_status_update);});
614-
// checkpoint_list.push_back([&](){checkpoint_48(env, context, notif_status_update);});
615-
// checkpoint_list.push_back([&](){checkpoint_49(env, context, notif_status_update);});
609+
checkpoint_list.push_back([&](){checkpoint_43(env, context, notif_status_update);});
610+
checkpoint_list.push_back([&](){checkpoint_44(env, context, notif_status_update);});
611+
checkpoint_list.push_back([&](){checkpoint_45(env, context, notif_status_update);});
612+
checkpoint_list.push_back([&](){checkpoint_46(env, context, notif_status_update);});
613+
checkpoint_list.push_back([&](){checkpoint_47(env, context, notif_status_update);});
614+
checkpoint_list.push_back([&](){checkpoint_48(env, context, notif_status_update);});
615+
checkpoint_list.push_back([&](){checkpoint_49(env, context, notif_status_update);});
616616

617617
for (int checkpoint = start; checkpoint <= end; checkpoint++){
618618
if (checkpoint == 0){

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,39 @@ void handle_when_stationary_in_overworld(
779779
}
780780

781781

782+
void handle_failed_action(
783+
const ProgramInfo& info,
784+
ConsoleHandle& console,
785+
BotBaseContext& context,
786+
std::function<
787+
void(const ProgramInfo& info,
788+
ConsoleHandle& console,
789+
BotBaseContext& context)
790+
>&& action,
791+
std::function<
792+
void(const ProgramInfo& info,
793+
ConsoleHandle& console,
794+
BotBaseContext& context)
795+
>&& recovery_action,
796+
size_t max_failures
797+
){
798+
size_t num_failures = 0;
799+
while (true){
800+
try {
801+
context.wait_for_all_requests();
802+
action(info, console, context);
803+
return;
804+
}catch (OperationFailedException& e){
805+
num_failures++;
806+
if (num_failures > max_failures){
807+
throw e;
808+
}
809+
recovery_action(info, console, context);
810+
}
811+
}
812+
}
813+
814+
782815
void wait_for_gradient_arrow(
783816
const ProgramInfo& info,
784817
ConsoleHandle& console,

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,24 @@ void handle_when_stationary_in_overworld(
213213
size_t max_attempts = 2
214214
);
215215

216+
// do action. if error is thrown, catch the error and try the recovery action
217+
void handle_failed_action(
218+
const ProgramInfo& info,
219+
ConsoleHandle& console,
220+
BotBaseContext& context,
221+
std::function<
222+
void(const ProgramInfo& info,
223+
ConsoleHandle& console,
224+
BotBaseContext& context)
225+
>&& action,
226+
std::function<
227+
void(const ProgramInfo& info,
228+
ConsoleHandle& console,
229+
BotBaseContext& context)
230+
>&& recovery_action,
231+
size_t max_failures
232+
);
233+
216234
void wait_for_gradient_arrow(
217235
const ProgramInfo& info,
218236
ConsoleHandle& console,

0 commit comments

Comments
 (0)