Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,17 @@ struct AlolanTrade_Descriptor::Stats : public StatsTracker{
: trades(m_stats["Trades"])
, resets(m_stats["Resets"])
, shinies(m_stats["Shinies"])
, errors(m_stats["Errors"])
{
m_display_order.emplace_back("Trades");
m_display_order.emplace_back("Resets");
m_display_order.emplace_back("Shinies");
m_display_order.emplace_back("Errors", HIDDEN_IF_ZERO);
}
std::atomic<uint64_t>& trades;
std::atomic<uint64_t>& resets;
std::atomic<uint64_t>& shinies;
std::atomic<uint64_t>& errors;
};
std::unique_ptr<StatsTracker> AlolanTrade_Descriptor::make_stats() const{
return std::unique_ptr<StatsTracker>(new Stats());
Expand Down Expand Up @@ -79,6 +82,7 @@ AlolanTrade::AlolanTrade()
}

void AlolanTrade::run_trade(SingleSwitchProgramEnvironment& env, JoyconContext& context){
AlolanTrade_Descriptor::Stats& stats = env.current_stats<AlolanTrade_Descriptor::Stats>();
//Talk to NPC, say Yes, select Pokemon from box.
BlackScreenOverWatcher trade_started(COLOR_RED);
int ret = run_until<JoyconContext>(
Expand All @@ -91,6 +95,8 @@ void AlolanTrade::run_trade(SingleSwitchProgramEnvironment& env, JoyconContext&
context.wait_for_all_requests();
if (ret != 0){
env.log("Failed to start trade.", COLOR_RED);
stats.errors++;
env.update_stats();
OperationFailedException::fire(
ErrorReport::SEND_ERROR_REPORT,
"Failed to start trade.",
Expand All @@ -110,6 +116,8 @@ void AlolanTrade::run_trade(SingleSwitchProgramEnvironment& env, JoyconContext&
);
context.wait_for_all_requests();
if (ret2 != 0){
stats.errors++;
env.update_stats();
env.log("Did not detect end of trade.", COLOR_RED);
OperationFailedException::fire(
ErrorReport::SEND_ERROR_REPORT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,17 @@ struct FossilRevival_Descriptor::Stats : public StatsTracker{
: revives(m_stats["Revives"])
, resets(m_stats["Resets"])
, shinies(m_stats["Shinies"])
, errors(m_stats["Errors"])
{
m_display_order.emplace_back("Revives");
m_display_order.emplace_back("Resets");
m_display_order.emplace_back("Shinies");
m_display_order.emplace_back("Errors", HIDDEN_IF_ZERO);
}
std::atomic<uint64_t>& revives;
std::atomic<uint64_t>& resets;
std::atomic<uint64_t>& shinies;
std::atomic<uint64_t>& errors;
};
std::unique_ptr<StatsTracker> FossilRevival_Descriptor::make_stats() const{
return std::unique_ptr<StatsTracker>(new Stats());
Expand Down Expand Up @@ -90,6 +93,7 @@ FossilRevival::FossilRevival()
}

void FossilRevival::run_revives(SingleSwitchProgramEnvironment& env, JoyconContext& context){
FossilRevival_Descriptor::Stats& stats = env.current_stats<FossilRevival_Descriptor::Stats>();
//Press A to get to selection
env.log("Starting dialog.");
pbf_press_button(context, BUTTON_A, 100ms, 800ms);
Expand Down Expand Up @@ -122,6 +126,8 @@ void FossilRevival::run_revives(SingleSwitchProgramEnvironment& env, JoyconConte
);
context.wait_for_all_requests();
if (ret != 0){
stats.errors++;
env.update_stats();
env.log("Failed to revive fossil.", COLOR_RED);
OperationFailedException::fire(
ErrorReport::SEND_ERROR_REPORT,
Expand All @@ -144,6 +150,8 @@ void FossilRevival::run_revives(SingleSwitchProgramEnvironment& env, JoyconConte
);
context.wait_for_all_requests();
if (ret2 != 0){
stats.errors++;
env.update_stats();
env.log("Did not detect summary over.", COLOR_RED);
OperationFailedException::fire(
ErrorReport::SEND_ERROR_REPORT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,15 @@ struct GiftReset_Descriptor::Stats : public StatsTracker{
Stats()
: resets(m_stats["Resets"])
, shinies(m_stats["Shinies"])
, errors(m_stats["Errors"])
{
m_display_order.emplace_back("Resets");
m_display_order.emplace_back("Shinies");
m_display_order.emplace_back("Errors", HIDDEN_IF_ZERO);
}
std::atomic<uint64_t>& resets;
std::atomic<uint64_t>& shinies;
std::atomic<uint64_t>& errors;
};
std::unique_ptr<StatsTracker> GiftReset_Descriptor::make_stats() const{
return std::unique_ptr<StatsTracker>(new Stats());
Expand Down Expand Up @@ -104,6 +107,8 @@ void GiftReset::program(SingleSwitchProgramEnvironment& env, CancellableScope& s
);
context.wait_for_all_requests();
if (ret != 0){
stats.errors++;
env.update_stats();
env.log("Failed to receive gift Pokemon.", COLOR_RED);
OperationFailedException::fire(
ErrorReport::SEND_ERROR_REPORT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,15 @@ struct LegendaryReset_Descriptor::Stats : public StatsTracker{
Stats()
: resets(m_stats["Resets"])
, shinies(m_stats["Shinies"])
, errors(m_stats["Errors"])
{
m_display_order.emplace_back("Resets");
m_display_order.emplace_back("Shinies");
m_display_order.emplace_back("Errors", HIDDEN_IF_ZERO);
}
std::atomic<uint64_t>& resets;
std::atomic<uint64_t>& shinies;
std::atomic<uint64_t>& errors;
};
std::unique_ptr<StatsTracker> LegendaryReset_Descriptor::make_stats() const{
return std::unique_ptr<StatsTracker>(new Stats());
Expand Down Expand Up @@ -83,6 +86,7 @@ LegendaryReset::LegendaryReset()
}

bool LegendaryReset::run_encounter(SingleSwitchProgramEnvironment& env, JoyconContext& context){
LegendaryReset_Descriptor::Stats& stats = env.current_stats<LegendaryReset_Descriptor::Stats>();
float shiny_coefficient = 1.0;
ShinySoundDetector shiny_detector(env.logger(), [&](float error_coefficient) -> bool{
shiny_coefficient = error_coefficient;
Expand All @@ -94,10 +98,12 @@ bool LegendaryReset::run_encounter(SingleSwitchProgramEnvironment& env, JoyconCo
switch (TARGET) {
case Target::mewtwo:
pbf_mash_button(context, BUTTON_A, 3000ms);
pbf_press_button(context, BUTTON_PLUS, 500ms, 500ms);
context.wait_for_all_requests();
pbf_press_button(context, BUTTON_PLUS, 500ms, 100ms);
break;
case Target::snorlax:
pbf_mash_button(context, BUTTON_A, 5000ms);
context.wait_for_all_requests();
pbf_mash_button(context, BUTTON_B, 10000ms);
break;
case Target::electrode:
Expand All @@ -118,6 +124,8 @@ bool LegendaryReset::run_encounter(SingleSwitchProgramEnvironment& env, JoyconCo
if (ret == 0) {
env.log("HP boxes detected.");
} else {
stats.errors++;
env.update_stats();
OperationFailedException::fire(
ErrorReport::SEND_ERROR_REPORT,
"run_battle(): Did not detect battle start.",
Expand Down Expand Up @@ -171,6 +179,7 @@ void LegendaryReset::program(SingleSwitchProgramEnvironment& env, CancellableSco
env, NOTIFICATION_STATUS_UPDATE,
"No shiny found. Resetting game."
);
context.wait_for_all_requests();

//Reset game
pbf_press_button(context, BUTTON_HOME, 200ms, 2000ms);
Expand All @@ -188,6 +197,8 @@ void LegendaryReset::program(SingleSwitchProgramEnvironment& env, CancellableSco
[&](JoyconContext& context) {
while(true){
if (current_time() - start > std::chrono::minutes(5)){
stats.errors++;
env.update_stats();
env.log("Timed out during battle after 5 minutes.", COLOR_RED);
OperationFailedException::fire(
ErrorReport::SEND_ERROR_REPORT,
Expand All @@ -210,6 +221,8 @@ void LegendaryReset::program(SingleSwitchProgramEnvironment& env, CancellableSco
context.wait_for_all_requests();
break;
default:
stats.errors++;
env.update_stats();
env.log("Timed out during battle. Stuck, crashed, or took more than 30 seconds for a turn.", COLOR_RED);
OperationFailedException::fire(
ErrorReport::SEND_ERROR_REPORT,
Expand All @@ -230,6 +243,8 @@ void LegendaryReset::program(SingleSwitchProgramEnvironment& env, CancellableSco
);
break;
default:
stats.errors++;
env.update_stats();
OperationFailedException::fire(
ErrorReport::SEND_ERROR_REPORT,
"Failed to detect catching menu.",
Expand Down
Loading