Skip to content

Commit c63e779

Browse files
author
Gin
committed
improve restaurant farmer
1 parent fe6241e commit c63e779

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

SerialPrograms/Source/PokemonLZA/Inference/PokemonLZA_DialogDetector.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class NormalDialogDetector : public VisualInferenceCallback{
4747

4848

4949

50-
50+
// Common white dialog box
5151
class FlatWhiteDialogDetector : public StaticScreenDetector{
5252
public:
5353
FlatWhiteDialogDetector(Color color = COLOR_RED, VideoOverlay* overlay = nullptr);
@@ -80,7 +80,7 @@ class FlatWhiteDialogWatcher : public DetectorToFinder<FlatWhiteDialogDetector>{
8080
};
8181

8282

83-
83+
// Blue dialog box for when receiving an item
8484
class BlueDialogDetector : public StaticScreenDetector{
8585
public:
8686
BlueDialogDetector(Color color = COLOR_RED, VideoOverlay* overlay = nullptr);
@@ -113,7 +113,8 @@ class BlueDialogWatcher : public DetectorToFinder<BlueDialogDetector>{
113113
};
114114

115115

116-
116+
// A blue dialog box slightly bigger than BlueDialogDetector with item profile picture
117+
// that appears after BlueDialogDetector to show the item description.
117118
class ItemReceiveDetector : public StaticScreenDetector{
118119
public:
119120
ItemReceiveDetector(Color color = COLOR_RED, VideoOverlay* overlay = nullptr);

SerialPrograms/Source/PokemonLZA/Programs/PokemonLZA_RestaurantFarmer.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void RestaurantFarmer::StopButton::set_pressed(){
9191

9292

9393

94-
void RestaurantFarmer::run_lobby(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
94+
bool RestaurantFarmer::run_lobby(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
9595
RestaurantFarmer_Descriptor::Stats& stats = env.current_stats<RestaurantFarmer_Descriptor::Stats>();
9696

9797
while (true){
@@ -129,15 +129,17 @@ void RestaurantFarmer::run_lobby(SingleSwitchProgramEnvironment& env, ProControl
129129
case 0:
130130
env.log("Detected A button.");
131131
if (m_stop_after_current.load(std::memory_order_relaxed)){
132-
return;
132+
return true;
133133
}
134134
pbf_press_button(context, BUTTON_A, 160ms, 80ms);
135135
continue;
136136

137137
case 1:
138138
env.log("Detected selection arrow.");
139+
// This is when the restaurant receptionist is asking whether you want
140+
// to start the battle
139141
pbf_mash_button(context, BUTTON_A, 5000ms);
140-
return;
142+
return false;
141143

142144
case 2:
143145
env.log("Detected white dialog.");
@@ -256,8 +258,7 @@ void RestaurantFarmer::program(SingleSwitchProgramEnvironment& env, ProControlle
256258
// auto lobby = env.console.video().snapshot();
257259

258260
while (true){
259-
run_lobby(env, context);
260-
if (m_stop_after_current.load(std::memory_order_relaxed)){
261+
if (run_lobby(env, context)){
261262
break;
262263
}
263264
run_battle(env, context);

SerialPrograms/Source/PokemonLZA/Programs/PokemonLZA_RestaurantFarmer.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,12 @@ class RestaurantFarmer : public SingleSwitchProgramInstance, public ButtonListen
4646
std::atomic<bool> m_stop_after_current;
4747
StopButton STOP_AFTER_CURRENT;
4848

49-
void run_lobby(SingleSwitchProgramEnvironment& env, ProControllerContext& context);
49+
// Handle all the logic of talking to the restaurant receptionist.
50+
// Return true when the user clicks the button STOP_AFTER_CURRENT and the player character stops talking to
51+
// the receptionist. Return false when it enters battle.
52+
bool run_lobby(SingleSwitchProgramEnvironment& env, ProControllerContext& context);
53+
// Handle all battle logic. Return when it detects the blue dialog box meaning the player character is at
54+
// the receptionist receiving reward items.
5055
void run_battle(SingleSwitchProgramEnvironment& env, ProControllerContext& context);
5156
};
5257

0 commit comments

Comments
 (0)