-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathPokemonSwSh_MaxLair_Standard.cpp
More file actions
223 lines (185 loc) · 6.63 KB
/
PokemonSwSh_MaxLair_Standard.cpp
File metadata and controls
223 lines (185 loc) · 6.63 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
/* Max Lair (Normal Mode)
*
* From: https://github.com/PokemonAutomation/
*
*/
#include "Common/Cpp/Exceptions.h"
#include "CommonFramework/Notifications/ProgramNotifications.h"
#include "CommonTools/StartupChecks/VideoResolutionCheck.h"
#include "NintendoSwitch/NintendoSwitch_Settings.h"
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
#include "Pokemon/Pokemon_Strings.h"
#include "PokemonSwSh/Options/PokemonSwSh_BallSelectOption.h"
#include "PokemonSwSh/Programs/PokemonSwSh_GameEntry.h"
#include "Program/PokemonSwSh_MaxLair_Run_Adventure.h"
#include "PokemonSwSh_MaxLair_Standard.h"
#include <iostream>
using std::cout;
using std::endl;
namespace PokemonAutomation{
namespace NintendoSwitch{
namespace PokemonSwSh{
using namespace MaxLairInternal;
MaxLairStandard_Descriptor::MaxLairStandard_Descriptor()
: MultiSwitchProgramDescriptor(
"PokemonSwSh:MaxLair-Standard",
STRING_POKEMON + " SwSh", "Max Lair - Standard",
"Programs/PokemonSwSh/MaxLair-Standard.html",
"Auto Max Lair 2.0 - Run Dynamax Adventures until a shiny legendary is found.",
ProgramControllerClass::StandardController_NoRestrictions,
FeedbackType::REQUIRED,
AllowCommandsWhenRunning::DISABLE_COMMANDS,
1, 4, 1
)
{}
std::unique_ptr<StatsTracker> MaxLairStandard_Descriptor::make_stats() const{
return std::unique_ptr<StatsTracker>(new Stats());
}
class MaxLairStandard_ConsoleOptions : public ConsoleSpecificOptions{
public:
MaxLairStandard_ConsoleOptions(
std::string label,
const LanguageSet& languages,
bool host
)
: ConsoleSpecificOptions(std::move(label), languages, host)
, normal_ball(
"<b>Normal Ball:</b> Ball for catching non-boss " + STRING_POKEMON + ".",
LockMode::LOCK_WHILE_RUNNING,
"poke-ball"
)
, boss_ball(
"<b>Boss Ball:</b> Ball for catching the boss/legendary " + STRING_POKEMON + ".",
LockMode::LOCK_WHILE_RUNNING,
"poke-ball"
)
, actions(true, false)
{
PA_ADD_OPTION(normal_ball);
PA_ADD_OPTION(boss_ball);
PA_ADD_OPTION(actions);
}
PokemonBallSelectOption normal_ball;
PokemonBallSelectOption boss_ball;
CaughtScreenActionsOption actions;
};
class MaxLairStandard_ConsoleFactory : public ConsoleSpecificOptionsFactory{
public:
virtual std::unique_ptr<ConsoleSpecificOptions> make(
std::string label,
const LanguageSet& languages,
bool is_host
) const override{
return std::unique_ptr<ConsoleSpecificOptions>(new MaxLairStandard_ConsoleOptions(std::move(label), languages, is_host));
}
};
MaxLairStandard::MaxLairStandard()
: MultiSwitchProgramInstance({"Notifs", "LiveHost"})
, GO_HOME_WHEN_DONE(false)
, CONSOLES(MaxLairStandard_ConsoleFactory())
, NOTIFICATION_STATUS("Status Update", true, false)
, NOTIFICATION_SHINY("Shiny Catch", true, true, ImageAttachmentMode::JPG, {"Notifs", "Showcase"})
, NOTIFICATIONS({
&HOSTING.NOTIFICATIONS.NOTIFICATION,
&NOTIFICATION_STATUS,
&NOTIFICATION_SHINY,
&NOTIFICATION_PROGRAM_FINISH,
&NOTIFICATION_ERROR_FATAL,
})
{
PA_ADD_OPTION(START_LOCATION);
PA_ADD_OPTION(GO_HOME_WHEN_DONE);
PA_ADD_OPTION(BOSS_SLOT);
PA_ADD_OPTION(CONSOLES);
PA_ADD_OPTION(HOSTING);
PA_ADD_OPTION(TOUCH_DATE_INTERVAL);
PA_ADD_OPTION(NOTIFICATIONS);
}
std::string MaxLairStandard::check_validity() const{
std::string error = MultiSwitchProgramInstance::check_validity();
if (!error.empty()){
return error;
}
size_t active_consoles = CONSOLES.active_consoles();
error = CONSOLES.HOST.check_validity(active_consoles);
if (!error.empty()){
return error;
}
error = HOSTING.check_validity(active_consoles);
if (!error.empty()){
return error;
}
return std::string();
}
void MaxLairStandard::update_active_consoles(size_t switch_count){
CONSOLES.set_active_consoles(switch_count);
}
class EndBattleDecider_Standard : public EndBattleDecider{
public:
EndBattleDecider_Standard(const Consoles& consoles)
: m_consoles(consoles)
{}
virtual const std::string& normal_ball(
size_t console_index
) const override{
return console(console_index).normal_ball.slug();
}
virtual const std::string& boss_ball(
size_t console_index, const std::string& boss_slug
) const override{
return console(console_index).boss_ball.slug();
}
virtual CaughtScreenAction end_adventure_action(
size_t console_index, const std::string& boss_slug,
const PathStats& path_stats,
bool any_shiny, bool boss_is_shiny
) const override{
const CaughtScreenActionsOption& actions = console(console_index).actions;
if (boss_is_shiny){
return actions.shiny_boss;
}
if (any_shiny){
return actions.shiny_nonboss;
}
return actions.no_shinies;
}
virtual bool stop_for_non_boss(const std::string& slug) const override {
return false;
}
private:
const MaxLairStandard_ConsoleOptions& console(size_t index) const{
return static_cast<const MaxLairStandard_ConsoleOptions&>(m_consoles[index]);
}
const Consoles& m_consoles;
};
void MaxLairStandard::program(MultiSwitchProgramEnvironment& env, CancellableScope& scope){
size_t host_index = CONSOLES.HOST.current_value();
if (host_index >= env.consoles.size()){
throw UserSetupError(env.logger(), "Invalid Host Switch");
}
env.run_in_parallel(scope, [&](ConsoleHandle& console, ProControllerContext& context){
assert_16_9_720p_min(console, console);
if (START_LOCATION.start_in_grip_menu()){
grip_menu_connect_go_home(context);
resume_game_no_interact(console, context, ConsoleSettings::instance().TOLERATE_SYSTEM_UPDATE_MENU_FAST);
}else{
pbf_press_button(context, BUTTON_B, 40ms, 40ms);
}
});
EndBattleDecider_Standard decider(CONSOLES);
loop_adventures(
env, scope, CONSOLES,
host_index, BOSS_SLOT.current_value(),
decider,
GO_HOME_WHEN_DONE,
HOSTING,
TOUCH_DATE_INTERVAL,
NOTIFICATION_STATUS,
NOTIFICATION_SHINY
);
env.update_stats();
send_program_finished_notification(env, NOTIFICATION_PROGRAM_FINISH);
}
}
}
}