Skip to content

Commit c8111ef

Browse files
authored
minor updates to ClaimMysteryGift (#667)
1 parent 1507670 commit c8111ef

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_ClaimMysteryGift.cpp

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ ClaimMysteryGift::ClaimMysteryGift()
7171
, STARTING_POINT(
7272
"<b>Starting point:",
7373
{
74-
{StartingPoint::NEW_GAME, "new-game", "New Game"},
75-
{StartingPoint::DONE_TUTORIAL, "done-tutorial", "Done Tutorial"},
74+
{StartingPoint::NEW_GAME, "new-game", "New Game: Start after you have selected your username and character appearance"},
75+
{StartingPoint::IN_MYSTERY_GIFT, "in-mystery-gift", "Start in Mystery Gift window, with cursor on the “1” key."},
76+
{StartingPoint::DONE_TUTORIAL, "done-tutorial", "Start in game. But with all menus closed. Tutorial must be completed. You need to be outside, where you can use Pokeportal."},
7677
},
7778
LockMode::LOCK_WHILE_RUNNING,
7879
StartingPoint::NEW_GAME
@@ -137,7 +138,8 @@ void ClaimMysteryGift::enter_mystery_gift_code(SingleSwitchProgramEnvironment& e
137138

138139
}
139140

140-
void ClaimMysteryGift::claim_mystery_gift(SingleSwitchProgramEnvironment& env, ProControllerContext& context, int menu_index){
141+
void ClaimMysteryGift::enter_mystery_gift_window(SingleSwitchProgramEnvironment& env, ProControllerContext& context, int menu_index){
142+
env.console.log("Save game, then try to enter the mystery gift window.", COLOR_YELLOW);
141143
save_game_from_menu_or_overworld(env.program_info(), env.console, context, false);
142144

143145
size_t max_attempts = 5;
@@ -152,7 +154,7 @@ void ClaimMysteryGift::claim_mystery_gift(SingleSwitchProgramEnvironment& env, P
152154
try {
153155
clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 10, {CallbackEnum::PROMPT_DIALOG});
154156
}catch(OperationFailedException&){
155-
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);
157+
env.console.log("enter_mystery_gift_window: Failed to detect the dialog that leads to the Mystery Gift window. Reset game and re-try.", COLOR_YELLOW);
156158
reset_game(env.program_info(), env.console, context);
157159
continue;
158160
}
@@ -197,18 +199,18 @@ void ClaimMysteryGift::claim_mystery_gift(SingleSwitchProgramEnvironment& env, P
197199
{key1_selected}
198200
);
199201
if (ret < 0){ // failed to detect Key 1 being highlighted. Reset game and re-try
200-
env.console.log("claim_mystery_gift: Failed to detect the Mystery Gift window. Reset game and re-try.", COLOR_YELLOW);
202+
env.console.log("enter_mystery_gift_window: Failed to detect the Mystery Gift window. Reset game and re-try.", COLOR_YELLOW);
201203
reset_game(env.program_info(), env.console, context);
202204
continue;
203205
}
204206

205-
enter_mystery_gift_code(env, context);
207+
206208
return;
207209
}
208210

209211
OperationFailedException::fire(
210212
ErrorReport::SEND_ERROR_REPORT,
211-
"claim_mystery_gift(): Failed to reach Mystery Gift screen after several attempts.",
213+
"enter_mystery_gift_window(): Failed to reach Mystery Gift screen after several attempts.",
212214
env.console
213215
);
214216
}
@@ -236,16 +238,19 @@ void ClaimMysteryGift::program(SingleSwitchProgramEnvironment& env, ProControlle
236238

237239
// env.console.log("Start Segment " + ALL_AUTO_STORY_SEGMENT_LIST()[get_start_segment_index()]->name(), COLOR_ORANGE);
238240

239-
if (STARTING_POINT == StartingPoint::DONE_TUTORIAL){
240-
claim_mystery_gift(env, context, 3);
241-
}else{
242-
241+
if (STARTING_POINT == StartingPoint::NEW_GAME){
243242
run_autostory_until_pokeportal_unlocked(env, context);
244243
env.console.log("Done Autostory portion. Pokeportal should now be unlocked.");
245-
claim_mystery_gift(env, context, 2);
244+
enter_mystery_gift_window(env, context, 2);
245+
enter_mystery_gift_code(env, context);
246+
}else if(STARTING_POINT == StartingPoint::IN_MYSTERY_GIFT){
247+
enter_mystery_gift_code(env, context);
248+
}else if (STARTING_POINT == StartingPoint::DONE_TUTORIAL){
249+
enter_mystery_gift_window(env, context, 3);
250+
enter_mystery_gift_code(env, context);
251+
}else{
252+
throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "Unknown STARTING_POINT.");
246253
}
247-
248-
// run_autostory(env, context);
249254

250255
send_program_finished_notification(env, NOTIFICATION_PROGRAM_FINISH);
251256
GO_HOME_WHEN_DONE.run_end_of_program(context);

SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_ClaimMysteryGift.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class ClaimMysteryGift : public SingleSwitchProgramInstance, public ConfigOption
4040
virtual void program(SingleSwitchProgramEnvironment& env, ProControllerContext& context) override;
4141

4242
void run_autostory_until_pokeportal_unlocked(SingleSwitchProgramEnvironment& env, ProControllerContext& context);
43-
void claim_mystery_gift(SingleSwitchProgramEnvironment& env, ProControllerContext& context, int menu_index);
43+
void enter_mystery_gift_window(SingleSwitchProgramEnvironment& env, ProControllerContext& context, int menu_index);
4444
void enter_mystery_gift_code(SingleSwitchProgramEnvironment& env, ProControllerContext& context);
4545

4646
private:
@@ -54,6 +54,7 @@ class ClaimMysteryGift : public SingleSwitchProgramInstance, public ConfigOption
5454

5555
enum class StartingPoint{
5656
NEW_GAME,
57+
IN_MYSTERY_GIFT,
5758
DONE_TUTORIAL,
5859
};
5960

0 commit comments

Comments
 (0)