Skip to content

Commit 2204035

Browse files
committed
Retry the game resets on LGPE.
1 parent 0675852 commit 2204035

File tree

7 files changed

+31
-20
lines changed

7 files changed

+31
-20
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 = 56;
29-
const int PROGRAM_VERSION_PATCH = 3;
29+
const int PROGRAM_VERSION_PATCH = 4;
3030

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

SerialPrograms/Source/PokemonLGPE/Programs/PokemonLGPE_GameEntry.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,25 @@ bool reset_game_from_home(
126126
}
127127

128128

129+
void reset_game_from_game(
130+
ProgramEnvironment& env,
131+
ConsoleHandle& console, JoyconContext& context,
132+
std::atomic<uint64_t>* errors,
133+
Milliseconds post_wait_time
134+
){
135+
while (true){
136+
pbf_press_button(context, BUTTON_HOME, 200ms, 2000ms);
137+
if (reset_game_from_home(env, console, context, 3000ms)){
138+
break;
139+
}
140+
env.log("Resetting...", COLOR_RED);
141+
if (errors){
142+
(*errors)++;
143+
env.update_stats();
144+
}
145+
}
146+
147+
}
129148

130149

131150

SerialPrograms/Source/PokemonLGPE/Programs/PokemonLGPE_GameEntry.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ bool reset_game_from_home(
4040
Milliseconds post_wait_time = std::chrono::milliseconds(125)
4141
);
4242

43+
void reset_game_from_game(
44+
ProgramEnvironment& env,
45+
ConsoleHandle& console, JoyconContext& context,
46+
std::atomic<uint64_t>* errors,
47+
Milliseconds post_wait_time = std::chrono::milliseconds(125)
48+
);
49+
4350

4451

4552

SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_AlolanTrade.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,11 +281,8 @@ void AlolanTrade::program(SingleSwitchProgramEnvironment& env, CancellableScope&
281281
"Out of Pokemon to trade and no shiny found. Resetting game."
282282
);
283283

284-
//Reset game
285-
pbf_press_button(context, BUTTON_HOME, 200ms, 2000ms);
286-
reset_game_from_home(env, env.console, context, 3000ms);
287-
context.wait_for_all_requests();
288284

285+
reset_game_from_game(env, env.console, context, &stats.errors, 3000ms);
289286
stats.resets++;
290287
env.update_stats();
291288
}

SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_FossilRevival.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,7 @@ void FossilRevival::program(SingleSwitchProgramEnvironment& env, CancellableScop
288288
"Out of Pokemon to check and no shiny found. Resetting game."
289289
);
290290

291-
//Reset game
292-
pbf_press_button(context, BUTTON_HOME, 200ms, 2000ms);
293-
reset_game_from_home(env, env.console, context, 3000ms);
294-
context.wait_for_all_requests();
295-
291+
reset_game_from_game(env, env.console, context, &stats.errors, 3000ms);
296292
stats.resets++;
297293
env.update_stats();
298294
}

SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_GiftReset.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,7 @@ void GiftReset::program(SingleSwitchProgramEnvironment& env, CancellableScope& s
183183
"Not shiny. Resetting game."
184184
);
185185

186-
//Reset game
187-
pbf_press_button(context, BUTTON_HOME, 200ms, 2000ms);
188-
reset_game_from_home(env, env.console, context, 3000ms);
189-
context.wait_for_all_requests();
190-
186+
reset_game_from_game(env, env.console, context, &stats.errors, 3000ms);
191187
stats.resets++;
192188
env.update_stats();
193189
}

SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,7 @@ void LegendaryReset::program(SingleSwitchProgramEnvironment& env, CancellableSco
202202
consecutive_failures++;
203203
}
204204

205-
//Reset game
206-
pbf_press_button(context, BUTTON_HOME, 200ms, 2000ms);
207-
reset_game_from_home(env, env.console, context, 3000ms);
208-
context.wait_for_all_requests();
209-
205+
reset_game_from_game(env, env.console, context, &stats.errors, 3000ms);
210206
stats.resets++;
211207
}
212208
//Shiny found, complete the battle

0 commit comments

Comments
 (0)