-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathPokemonLA_SkipToFullMoon.cpp
More file actions
128 lines (102 loc) · 4.26 KB
/
PokemonLA_SkipToFullMoon.cpp
File metadata and controls
128 lines (102 loc) · 4.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/* Skip to Full Moon
*
* From: https://github.com/PokemonAutomation/
*
*/
#include "CommonFramework/Exceptions/OperationFailedException.h"
#include "CommonFramework/Notifications/ProgramNotifications.h"
#include "CommonFramework/VideoPipeline/VideoFeed.h"
#include "CommonTools/Async/InferenceRoutines.h"
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
#include "Pokemon/Pokemon_Strings.h"
#include "PokemonLA/Inference/Objects/PokemonLA_ArcPhoneDetector.h"
#include "PokemonLA/Inference/PokemonLA_ItemCompatibilityDetector.h"
#include "PokemonLA_SkipToFullMoon.h"
namespace PokemonAutomation{
namespace NintendoSwitch{
namespace PokemonLA{
using namespace Pokemon;
SkipToFullMoon_Descriptor::SkipToFullMoon_Descriptor()
: SingleSwitchProgramDescriptor(
"PokemonLA:SkipToFullMoon",
STRING_POKEMON + " LA", "Skip to Full Moon",
"Programs/PokemonLA/SkipToFullMoon.html",
"Skip nights until full moon.",
ProgramControllerClass::StandardController_NoRestrictions,
FeedbackType::REQUIRED,
AllowCommandsWhenRunning::DISABLE_COMMANDS
)
{}
SkipToFullMoon::SkipToFullMoon()
: NOTIFICATIONS({
&NOTIFICATION_PROGRAM_FINISH,
&NOTIFICATION_ERROR_FATAL,
})
{
PA_ADD_OPTION(NOTIFICATIONS);
}
void SkipToFullMoon::program(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
// Connect the controller.
pbf_press_button(context, BUTTON_LCLICK, 40ms, 40ms);
while (true){
// Open menu
pbf_press_dpad(context, DPAD_UP, 160ms, 960ms);
context.wait_for_all_requests();
const auto compatibility = detect_item_compatibility(env.console.video().snapshot());
if (compatibility == ItemCompatibility::NONE){
OperationFailedException::fire(
ErrorReport::SEND_ERROR_REPORT,
"Unable to detect item compatibility.",
env.console
);
}
if (compatibility == ItemCompatibility::COMPATIBLE){
// Ursaring can evolve, it's full moon now.
break;
}
// Do another time skip:
// Close menu
pbf_press_button(context, BUTTON_B, 160ms, 800ms);
// Character turn around to face the tent
pbf_move_left_joystick(context, {0, +1}, 160ms, 800ms);
// Press A to show the "how long do you rest" dialogue
pbf_press_button(context, BUTTON_A, 80ms, 800ms);
// Press A to show the time menu
pbf_press_button(context, BUTTON_A, 80ms, 240ms);
// Move the selection to "Until nightfall"
pbf_press_dpad(context, DPAD_UP, 80ms, 240ms);
pbf_press_dpad(context, DPAD_UP, 80ms, 400ms);
// Press A to sleep to next night
pbf_press_button(context, BUTTON_A, 160ms, 400ms);
// Sleeping
pbf_wait(context, 8000ms);
context.wait_for_all_requests();
const bool stop_on_detected = true;
// DialogueEllipseDetector dialogue_ellipse_detector(env.console, env.console, std::chrono::milliseconds(200),
// DialogueEllipseDetector::EllipseLocation::TENT, stop_on_detected);
// int ret = wait_until(
// env.console, context, std::chrono::seconds(8),
// {{dialogue_ellipse_detector}}
// );
// if (ret != 0){
// std::cout << "ERROR! Cannot detect the dialogue ellipse" << std::endl;
// }
// Press B to clear the "You Pokemon happy and healthy" dialogue.
// pbf_press_button(context, BUTTON_B, 160ms, 800ms);
ArcPhoneDetector arc_phone_detector(env.console, env.console, std::chrono::milliseconds(100), stop_on_detected);
run_until<ProControllerContext>(
env.console, context,
[](ProControllerContext& local_context){
// pbf_mash_button(local_context, BUTTON_B, 7000ms);
for (size_t i = 0; i < 15; i++){
pbf_press_button(local_context, BUTTON_B, 160ms, 640ms);
}
},
{{arc_phone_detector}}
);
}
send_program_finished_notification(env, NOTIFICATION_PROGRAM_FINISH);
}
}
}
}