55 */
66
77#include " Common/Cpp/Exceptions.h"
8+ #include " CommonFramework/Exceptions/OperationFailedException.h"
89#include " CommonFramework/Exceptions/ProgramFinishedException.h"
10+ #include " CommonFramework/Exceptions/ScreenshotException.h"
911#include " CommonFramework/ImageTools/ImageStats.h"
1012#include " CommonFramework/Notifications/ProgramNotifications.h"
1113#include " CommonFramework/VideoPipeline/VideoFeed.h"
1214#include " NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
1315#include " Pokemon/Pokemon_Strings.h"
16+ #include " PokemonLA/Inference/Objects/PokemonLA_ButtonDetector.h"
1417#include " PokemonLA/Programs/PokemonLA_GameEntry.h"
18+ #include " PokemonLA/Programs/PokemonLA_RegionNavigation.h"
19+ #include " PokemonLA/PokemonLA_TravelLocations.h"
1520#include " PokemonLA_GeneratePokemonImageTrainingData.h"
1621
1722namespace PokemonAutomation {
@@ -20,6 +25,39 @@ namespace PokemonLA{
2025
2126using namespace Pokemon ;
2227
28+ const TravelLocation& to_travel_location (StartingLocation location){
29+ const TravelLocations& locations = TravelLocations::instance ();
30+
31+ switch (location){
32+ case StartingLocation::JUBILIFE_VILLAGE:
33+ break ;
34+ case StartingLocation::FIELDLANDS_FIELDLANDS:
35+ return locations.Fieldlands_Fieldlands ;
36+ case StartingLocation::FIELDLANDS_HEIGHTS:
37+ return locations.Fieldlands_Heights ;
38+ case StartingLocation::MIRELANDS_MIRELANDS:
39+ return locations.Mirelands_Mirelands ;
40+ case StartingLocation::MIRELANDS_BOGBOUND:
41+ return locations.Mirelands_Bogbound ;
42+ case StartingLocation::COASTLANDS_BEACHSIDE:
43+ return locations.Coastlands_Beachside ;
44+ case StartingLocation::COASTLANDS_COASTLANDS:
45+ return locations.Coastlands_Coastlands ;
46+ case StartingLocation::HIGHLANDS_HIGHLANDS:
47+ return locations.Highlands_Highlands ;
48+ case StartingLocation::HIGHLANDS_MOUNTAIN:
49+ return locations.Highlands_Mountain ;
50+ case StartingLocation::HIGHLANDS_SUMMIT:
51+ return locations.Highlands_Summit ;
52+ case StartingLocation::ICELANDS_SNOWFIELDS:
53+ return locations.Icelands_Snowfields ;
54+ case StartingLocation::ICELANDS_ICEPEAK:
55+ return locations.Icelands_Icepeak ;
56+ }
57+
58+ // Should never reach here, but return default to avoid compiler warning
59+ throw InternalProgramError (nullptr , PA_CURRENT_FUNCTION, " Invalid StartingLocation: " + std::to_string (int (location)));
60+ }
2361
2462GeneratePokemonImageTrainingData_Descriptor::GeneratePokemonImageTrainingData_Descriptor ()
2563 : SingleSwitchProgramDescriptor(
@@ -35,19 +73,41 @@ GeneratePokemonImageTrainingData_Descriptor::GeneratePokemonImageTrainingData_De
3573
3674
3775GeneratePokemonImageTrainingData::GeneratePokemonImageTrainingData ()
38- : NUM_BOXES(
76+ : STARTING_LOCATION(
77+ " <b>Starting Location:</b><br>Where you are starting the program." ,
78+ {
79+ {StartingLocation::JUBILIFE_VILLAGE, " jubilife_village" , " Jubilife Village" },
80+ {StartingLocation::FIELDLANDS_FIELDLANDS, " fieldlands_fieldlands" , " Fieldlands - Fieldlands Camp" },
81+ {StartingLocation::FIELDLANDS_HEIGHTS, " fieldlands_heights" , " Fieldlands - Heights Camp" },
82+ {StartingLocation::MIRELANDS_MIRELANDS, " mirelands_mirelands" , " Mirelands - Mirelands Camp" },
83+ {StartingLocation::MIRELANDS_BOGBOUND, " mirelands_bogbound" , " Mirelands - Bogbound Camp" },
84+ {StartingLocation::COASTLANDS_BEACHSIDE, " coastlands_beachside" , " Coastlands - Beachside Camp" },
85+ {StartingLocation::COASTLANDS_COASTLANDS, " coastlands_coastlands" , " Coastlands - Coastlands Camp" },
86+ {StartingLocation::HIGHLANDS_HIGHLANDS, " highlands_highlands" , " Highlands - Highlands Camp" },
87+ {StartingLocation::HIGHLANDS_MOUNTAIN, " highlands_mountain" , " Highlands - Mountain Camp" },
88+ {StartingLocation::HIGHLANDS_SUMMIT, " highlands_summit" , " Highlands - Summit Camp" },
89+ {StartingLocation::ICELANDS_SNOWFIELDS, " icelands_snowfields" , " Icelands - Snowfields Camp" },
90+ {StartingLocation::ICELANDS_ICEPEAK, " icelands_icepeak" , " Icelands - Icepeak Camp" },
91+ },
92+ LockMode::LOCK_WHILE_RUNNING,
93+ StartingLocation::JUBILIFE_VILLAGE
94+ )
95+ , NUM_BOXES(
3996 " <b>Number of Boxes to Process:</b><br>How many boxes to capture " + STRING_POKEMON + " from." ,
4097 LockMode::LOCK_WHILE_RUNNING,
4198 5 , 1 , 30
4299 )
100+ , GO_HOME_WHEN_DONE(false )
43101 , NOTIFICATION_STATUS_UPDATE(" Status Update" , true , false , std::chrono::seconds(3600 ))
44102 , NOTIFICATIONS({
45103 &NOTIFICATION_STATUS_UPDATE,
46104 &NOTIFICATION_PROGRAM_FINISH,
47105 &NOTIFICATION_ERROR_FATAL,
48106 })
49107{
108+ PA_ADD_OPTION (STARTING_LOCATION);
50109 PA_ADD_OPTION (NUM_BOXES);
110+ PA_ADD_OPTION (GO_HOME_WHEN_DONE);
51111 PA_ADD_OPTION (NOTIFICATIONS);
52112}
53113
@@ -56,17 +116,92 @@ void GeneratePokemonImageTrainingData::program(SingleSwitchProgramEnvironment& e
56116 send_program_status_notification (env, NOTIFICATION_STATUS_UPDATE);
57117
58118 try {
59- // Send completion notification
60- send_program_finished_notification (env, NOTIFICATION_PROGRAM_FINISH);
119+ // Step 1: Select starting location and navigate to box NPC
120+ select_starting_location (env, context);
121+
122+ // Step 2: Talk to box NPC to access box system
123+ talk_to_box_npc (env, context);
124+
125+ // TODO: Implement remaining steps
61126 }catch (ProgramFinishedException&){
62127 // Program was stopped by user
63128 send_program_finished_notification (env, NOTIFICATION_PROGRAM_FINISH);
64129 throw ;
65- }catch (std::exception& e){
66- // Handle any other errors
67- send_program_fatal_error_notification (env, NOTIFICATION_ERROR_FATAL, " Fatal error occurred: " + std::string (e.what ()));
130+ }catch (ScreenshotException& e){
131+ std::string fail_message = e.message ();
132+ OperationFailedException::fire (
133+ ErrorReport::SEND_ERROR_REPORT,
134+ fail_message,
135+ env.console
136+ );
68137 throw ;
69138 }
139+ env.update_stats ();
140+ GO_HOME_WHEN_DONE.run_end_of_program (context);
141+ send_program_finished_notification (env, NOTIFICATION_PROGRAM_FINISH);
142+ }
143+
144+ void GeneratePokemonImageTrainingData::select_starting_location (SingleSwitchProgramEnvironment& env, ProControllerContext& context){
145+ env.log (" Selecting starting location..." );
146+
147+ StartingLocation location = STARTING_LOCATION;
148+ const TravelLocation& travel_loc = to_travel_location (location);
149+ // fast travel to the target camp to reset player character position
150+ goto_any_camp_from_overworld (env, env.console , context, travel_loc);
151+
152+ // move to the npc to open box system
153+ switch (location){
154+ case StartingLocation::JUBILIFE_VILLAGE:
155+ env.log (" Starting at Jubilife Village" );
156+ break ;
157+ case StartingLocation::FIELDLANDS_FIELDLANDS:
158+ env.log (" Starting at Fieldlands - Fieldlands Camp" );
159+ pbf_move_left_joystick (context, 50 , 0 , 130 , 10 );
160+ break ;
161+ case StartingLocation::FIELDLANDS_HEIGHTS:
162+ env.log (" Starting at Fieldlands - Heights Camp" );
163+ pbf_move_left_joystick (context, 40 , 0 , 165 , 10 );
164+ break ;
165+ case StartingLocation::MIRELANDS_MIRELANDS:
166+ env.log (" Starting at Mirelands - Mirelands Camp" );
167+ pbf_move_left_joystick (context, 200 , 0 , 140 , 10 );
168+ break ;
169+ case StartingLocation::MIRELANDS_BOGBOUND:
170+ env.log (" Starting at Mirelands - Bogbound Camp" );
171+ pbf_move_left_joystick (context, 0 , 55 , 215 , 10 );
172+ break ;
173+ case StartingLocation::COASTLANDS_BEACHSIDE:
174+ env.log (" Starting at Coastlands - Beachside Camp" );
175+ break ;
176+ case StartingLocation::COASTLANDS_COASTLANDS:
177+ env.log (" Starting at Coastlands - Coastlands Camp" );
178+ break ;
179+ case StartingLocation::HIGHLANDS_HIGHLANDS:
180+ env.log (" Starting at Highlands - Highlands Camp" );
181+ break ;
182+ case StartingLocation::HIGHLANDS_MOUNTAIN:
183+ env.log (" Starting at Highlands - Mountain Camp" );
184+ break ;
185+ case StartingLocation::HIGHLANDS_SUMMIT:
186+ env.log (" Starting at Highlands - Summit Camp" );
187+ break ;
188+ case StartingLocation::ICELANDS_SNOWFIELDS:
189+ env.log (" Starting at Icelands - Snowfields Camp" );
190+ break ;
191+ case StartingLocation::ICELANDS_ICEPEAK:
192+ env.log (" Starting at Icelands - Icepeak Camp" );
193+ break ;
194+ }
195+ context.wait_for_all_requests ();
196+
197+ // For now, assume player is already at the selected location
198+ // TODO: Add location-specific navigation logic if needed
199+
200+ env.log (" Location selection completed." );
201+ }
202+
203+ void GeneratePokemonImageTrainingData::talk_to_box_npc (SingleSwitchProgramEnvironment& env, ProControllerContext& context){
204+ env.log (" Talking to box NPC..." );
70205}
71206
72207
0 commit comments