1212#include " CommonTools/StartupChecks/VideoResolutionCheck.h"
1313#include " NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
1414#include " NintendoSwitch/Controllers/NintendoSwitch_Joycon.h"
15+ #include " NintendoSwitch/Programs/NintendoSwitch_GameEntry.h"
1516#include " Pokemon/Pokemon_Strings.h"
1617#include " CommonTools/VisualDetectors/BlackScreenDetector.h"
1718#include " PokemonLGPE/Inference/PokemonLGPE_ShinySymbolDetector.h"
1819#include " PokemonLGPE_AlolanTrade.h"
1920
20- // #include <iostream>
21- // using std::cout;
22- // using std::endl;
23-
2421namespace PokemonAutomation {
2522namespace NintendoSwitch {
2623namespace PokemonLGPE {
@@ -86,19 +83,20 @@ void AlolanTrade::program(SingleSwitchProgramEnvironment& env, CancellableScope&
8683 AlolanTrade_Descriptor::Stats& stats = env.current_stats <AlolanTrade_Descriptor::Stats>();
8784
8885 /*
89- WARNING: JOYCON TEST PROGRAM. Not well tested. Minimum infra to get this running. Bare minimum in general.
90- Use at your own risk, it won't skip update checks and the like.
91- FLASH RIGHT JOYCON. YOU NEED RIGHT JOYCON. YOU NEED THE HOME BUTTON. (this means no on-switch screenshots)
86+ WARNING: JOYCON TEST PROGRAM. Not well tested. Bare minimum in general.
87+
88+ Only works with Right joycon atm. Do not update right joycon.
89+
90+ Right joycon required for home button (this means no on-switch screenshots).
9291 Also don't remap any of the buttons in the switch button mapping settings. Yet? Could use this to add Home and Screenshot.
9392
9493 Preconditions:
9594 DO NOT have any Pokemon you want to keep in your boxes. Move them out to Home first.
9695 Favoriting a Pokemon does not prevent it from being traded.
97- This must not be your first time doing the trade. (I've done all the trades, can't check first time trade behavior.)
98- In your boxes, sort by ORDER CAUGHT
96+ This must not be your first time doing the trade. (I've done all the trades, so I can't check first time trade behavior.)
9997
10098 Setup:
101- Catch the Kanto variant of the target.
99+ Catch the Kanto variant of the target. Put this number in NUM_TRADES.
102100 Stand in front of trade NPC.
103101 Start the program in-game.
104102
@@ -116,7 +114,7 @@ void AlolanTrade::program(SingleSwitchProgramEnvironment& env, CancellableScope&
116114 while (!shiny_found) {
117115 // Run trades
118116 for (uint16_t i = 0 ; i < NUM_TRADES; i++) {
119- // TODO: This is messy, pull it all out. run_trade() ?
117+ // TODO: This is messy, pull it all out?
120118
121119 // Talk to NPC, say Yes, select Pokemon from box.
122120 BlackScreenOverWatcher trade_started (COLOR_RED);
@@ -160,7 +158,8 @@ void AlolanTrade::program(SingleSwitchProgramEnvironment& env, CancellableScope&
160158 env.log (" Trade completed." );
161159 }
162160
163- // Summary will appear the first time you trade in a session(?) Close that as well.
161+ // Summary will appear the first time you trade in a session(?)
162+ // Sometimes it appears anyway, don't know what determines it
164163 // Exit menu and dialog.
165164 pbf_mash_button (context, BUTTON_B, 3000ms);
166165 context.wait_for_all_requests ();
@@ -169,14 +168,18 @@ void AlolanTrade::program(SingleSwitchProgramEnvironment& env, CancellableScope&
169168 env.update_stats ();
170169 }
171170
172- // to check pokemon in menu boxes
171+ env.log (" Done trading. Checking boxes." );
172+ send_program_status_notification (
173+ env, NOTIFICATION_STATUS_UPDATE,
174+ " Done trading. Checking boxes."
175+ );
176+
177+ // To check pokemon in menu boxes
173178 // Open menu - always defaults to center (Party)
174179 /* Menu:
175180 Play with Partner
176181 Pokedex - Bag - Party - Communicate - Save (these all have a colored line under when selected)
177182 (Press Y for options)
178-
179- sort boxes by recently caught and press left to get to most recent pokemon
180183 */
181184
182185 // Wait a bit.
@@ -223,7 +226,7 @@ void AlolanTrade::program(SingleSwitchProgramEnvironment& env, CancellableScope&
223226 env.log (" Shiny detected!" );
224227 stats.shinies ++;
225228 env.update_stats ();
226- send_program_status_notification (env, NOTIFICATION_SHINY, " Shiny found!" , screen, true );
229+ send_program_notification (env, NOTIFICATION_SHINY, COLOR_YELLOW, " Shiny found!" , {}, " " , screen, true );
227230 shiny_found = true ;
228231 }
229232 else {
@@ -236,6 +239,7 @@ void AlolanTrade::program(SingleSwitchProgramEnvironment& env, CancellableScope&
236239 context.wait_for_all_requests ();
237240 }
238241
242+ /*
239243 if (!shiny_found) {
240244 //TODO? Check if home button even exists before attempting to reset.
241245 //This way, if on left joycon, stop the program and alert the user.
@@ -250,15 +254,18 @@ void AlolanTrade::program(SingleSwitchProgramEnvironment& env, CancellableScope&
250254 //Thankfully, Joycon is upright after going to home.
251255 //Go to home and close game
252256 pbf_press_button(context, BUTTON_HOME, 200ms, 3000ms);
253- pbf_press_button (context, BUTTON_X, 200ms, 1000ms);
254- pbf_press_button (context, BUTTON_A, 200ms, 1000ms);
255257
256- // Enter game from home
257- // break;
258+ //TODO:
259+ //joycon context->pro controller context?
260+ start_game_from_home(env.console, context, true, 0, 0, std::chrono::milliseconds(2000));
258261
259262 stats.resets++;
260263 env.update_stats();
261264 }
265+ */
266+
267+ // Break for now since resetting the game doesn't work.
268+ break ;
262269 }
263270
264271 // GO_HOME_WHEN_DONE.run_end_of_program(context);
0 commit comments