Skip to content

Commit 75ed4e7

Browse files
committed
cleanup and comments
1 parent 1134e03 commit 75ed4e7

File tree

3 files changed

+33
-26
lines changed

3 files changed

+33
-26
lines changed

SerialPrograms/Source/PokemonLGPE/Inference/PokemonLGPE_ShinySymbolDetector.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@ void ShinySymbolDetector::make_overlays(VideoOverlaySet& items) const{
2929
}
3030
bool ShinySymbolDetector::read(Logger& logger, const ImageViewRGB32& frame){
3131
/*
32-
Shiny:
32+
Shiny (charizard):
3333
Add infer box: (0.6660, 0.7790, 0.0280, 0.0440), RGB avg [159, 123, 125] avg sum 408 ratio [0.391, 0.301, 0.308] stddev [74.898, 54.696, 53.354] sum 182.948 crop size (54, 48)
3434
35-
Not shiny:
35+
Not shiny (chansey):
3636
Add infer box: (0.6660, 0.7790, 0.0280, 0.0440), RGB avg [82, 113, 100] avg sum 295 ratio [0.276, 0.384, 0.340] stddev [15.477, 2.178, 2.648] sum 20.303 crop size (54, 48)
37-
*/
3837
38+
Only had the two to test with for now.
39+
*/
3940

4041
const auto stats = image_stats(extract_box_reference(frame, m_box_star));
4142
return stats.stddev.sum() > 100;

SerialPrograms/Source/PokemonLGPE/Inference/PokemonLGPE_ShinySymbolDetector.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ namespace PokemonAutomation{
1414
namespace NintendoSwitch{
1515
namespace PokemonLGPE{
1616

17-
// After an in-game trade, the Pokemon's summary will appear.
18-
// Red star for shiny. No star if not.
19-
// Position is different when viewing in boxes. Do not use this for that.
17+
//Check for the red shiny star on a Pokemon's summary from the Party/Box menu.
18+
//This does not work for the summary that appears after a catch.
2019
class ShinySymbolDetector{
2120
public:
2221
ShinySymbolDetector(Color color);

SerialPrograms/Source/PokemonLGPE/Programs/PokemonLGPE_AlolanTrade.cpp

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,12 @@
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-
2421
namespace PokemonAutomation{
2522
namespace NintendoSwitch{
2623
namespace 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

Comments
 (0)