Skip to content

Commit 85a6c9c

Browse files
committed
SV eggs, detect getting attacked and break out early for fast recovery.
1 parent d102775 commit 85a6c9c

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

SerialPrograms/Source/CommonFramework/Globals.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace PokemonAutomation{
2626
const bool IS_BETA_VERSION = true;
2727
const int PROGRAM_VERSION_MAJOR = 0;
2828
const int PROGRAM_VERSION_MINOR = 54;
29-
const int PROGRAM_VERSION_PATCH = 16;
29+
const int PROGRAM_VERSION_PATCH = 17;
3030

3131
const std::string PROGRAM_VERSION_BASE =
3232
"v" + std::to_string(PROGRAM_VERSION_MAJOR) +

SerialPrograms/Source/PokemonSV/Programs/Eggs/PokemonSV_EggAutonomous.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ void EggAutonomous::program(SingleSwitchProgramEnvironment& env, ProControllerCo
211211
m_num_sandwich_spent = 0;
212212
m_num_kept = 0;
213213
size_t consecutive_failures = 0;
214-
while(true){
214+
while (true){
215215
m_saved_after_fetched_eggs = false;
216216
m_in_critical_to_save_stage = false;
217217

@@ -227,7 +227,7 @@ void EggAutonomous::program(SingleSwitchProgramEnvironment& env, ProControllerCo
227227

228228
// Recoverable loop to fetch eggs:
229229
int num_party_eggs = -1;
230-
while(true){
230+
while (true){
231231
try{
232232
num_party_eggs = fetch_eggs_full_routine(env, context);
233233
break;
@@ -238,7 +238,7 @@ void EggAutonomous::program(SingleSwitchProgramEnvironment& env, ProControllerCo
238238

239239
// Recoverable loop to hatch eggs
240240
bool game_already_resetted = false;
241-
while(true){
241+
while (true){
242242
try{
243243
hatch_eggs_full_routine(env, context, num_party_eggs);
244244
consecutive_failures = 0;

SerialPrograms/Source/PokemonSV/Programs/Eggs/PokemonSV_EggRoutines.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
#include "Common/Cpp/Exceptions.h"
8+
#include "CommonFramework/Exceptions/OperationFailedException.h"
89
#include "CommonFramework/Tools/ErrorDumper.h"
910
#include "CommonFramework/VideoPipeline/VideoFeed.h"
1011
#include "CommonFramework/VideoPipeline/VideoOverlay.h"
@@ -22,6 +23,7 @@
2223
#include "PokemonSV/Inference/Boxes/PokemonSV_BoxNatureDetector.h"
2324
#include "PokemonSV/Inference/Dialogs/PokemonSV_DialogDetector.h"
2425
#include "PokemonSV/Inference/Dialogs/PokemonSV_GradientArrowDetector.h"
26+
#include "PokemonSV/Inference/Battles/PokemonSV_NormalBattleMenus.h"
2527
#include "PokemonSV/Inference/Overworld/PokemonSV_OverworldDetector.h"
2628
#include "PokemonSV/Programs/PokemonSV_MenuNavigation.h"
2729
#include "PokemonSV/Programs/PokemonSV_WorldNavigation.h"
@@ -122,6 +124,7 @@ void do_egg_cycle_motion(
122124
VideoStream& stream, ProControllerContext& context
123125
){
124126
AdvanceDialogWatcher dialog(COLOR_RED);
127+
NormalBattleMenuWatcher battle_menu(COLOR_GREEN);
125128
int ret = run_until<ProControllerContext>(
126129
stream, context,
127130
[&](ProControllerContext& context){
@@ -132,9 +135,22 @@ void do_egg_cycle_motion(
132135
ssf_press_right_joystick(context, 255, 128, 0ms, std::chrono::minutes(10));
133136
pbf_press_button(context, BUTTON_LCLICK, std::chrono::minutes(10), 0ms);
134137
},
135-
{dialog}
138+
{
139+
dialog,
140+
battle_menu,
141+
}
136142
);
137-
if (ret < 0){
143+
switch (ret){
144+
case 0:
145+
break;
146+
case 1:
147+
OperationFailedException::fire(
148+
ErrorReport::NO_ERROR_REPORT,
149+
"Detected battle menu. You got attacked!",
150+
stream
151+
);
152+
break;
153+
case 2:
138154
dump_image_and_throw_recoverable_exception(
139155
info, stream, "NoEggToHatch",
140156
"hatch_eggs_at_zero_gate(): No more egg hatch after 10 minutes."

0 commit comments

Comments
 (0)