From dd3fc77c11c9592d84e4a5d110725983892dd6e2 Mon Sep 17 00:00:00 2001 From: Dalton-V Date: Mon, 27 Oct 2025 21:07:48 -0500 Subject: [PATCH 1/2] Added Number of Battles to run and discord notifications. --- .../Programs/PokemonLZA_RestaurantFarmer.cpp | 28 ++++++++++++++++++- .../Programs/PokemonLZA_RestaurantFarmer.h | 7 +++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/SerialPrograms/Source/PokemonLZA/Programs/PokemonLZA_RestaurantFarmer.cpp b/SerialPrograms/Source/PokemonLZA/Programs/PokemonLZA_RestaurantFarmer.cpp index 55ada73ce4..706da8ddad 100644 --- a/SerialPrograms/Source/PokemonLZA/Programs/PokemonLZA_RestaurantFarmer.cpp +++ b/SerialPrograms/Source/PokemonLZA/Programs/PokemonLZA_RestaurantFarmer.cpp @@ -20,6 +20,7 @@ #include "PokemonLZA/Inference/PokemonLZA_ButtonDetector.h" #include "PokemonLZA/Inference/PokemonLZA_MoveEffectivenessSymbol.h" #include "PokemonLZA_RestaurantFarmer.h" +#include "CommonFramework/Notifications/ProgramNotifications.h" namespace PokemonAutomation{ namespace NintendoSwitch{ @@ -64,6 +65,19 @@ RestaurantFarmer::~RestaurantFarmer(){ RestaurantFarmer::RestaurantFarmer() : m_stop_after_current(false) + , NUM_ROUNDS( + "Number of Battles to run:
Zero will run until 'Stop after Current Battle' is pressed.", + LockMode::UNLOCK_WHILE_RUNNING, + 100, + 0 + ), + GO_HOME_WHEN_DONE(false), + NOTIFICATION_STATUS_UPDATE("Status Update", true, false, std::chrono::seconds(3600)), + NOTIFICATIONS({ + &NOTIFICATION_STATUS_UPDATE, + &NOTIFICATION_PROGRAM_FINISH, + &NOTIFICATION_ERROR_FATAL, + }) , MOVE_AI( "Move Selection AI:
" "If enabled, it will be smarter with move selection.
" @@ -83,6 +97,10 @@ RestaurantFarmer::RestaurantFarmer() PA_ADD_OPTION(MOVE_AI); PA_ADD_OPTION(USE_PLUS_MOVES); + PA_ADD_OPTION(NUM_ROUNDS); + PA_ADD_OPTION(GO_HOME_WHEN_DONE); + PA_ADD_OPTION(NOTIFICATIONS); + STOP_AFTER_CURRENT.set_idle(); STOP_AFTER_CURRENT.add_listener(*this); } @@ -362,14 +380,22 @@ void RestaurantFarmer::program(SingleSwitchProgramEnvironment& env, ProControlle // auto lobby = env.console.video().snapshot(); + uint32_t current_round = 0; while (true){ + send_program_status_notification(env, NOTIFICATION_STATUS_UPDATE); + if (NUM_ROUNDS != 0 && current_round >= NUM_ROUNDS) { + m_stop_after_current.store(true, std::memory_order_relaxed); + STOP_AFTER_CURRENT.set_pressed(); + } if (run_lobby(env, context)){ break; } run_battle(env, context); + current_round++; } - + send_program_finished_notification(env, NOTIFICATION_PROGRAM_FINISH); + GO_HOME_WHEN_DONE.run_end_of_program(context); } diff --git a/SerialPrograms/Source/PokemonLZA/Programs/PokemonLZA_RestaurantFarmer.h b/SerialPrograms/Source/PokemonLZA/Programs/PokemonLZA_RestaurantFarmer.h index fe9e07311f..3fed3b3767 100644 --- a/SerialPrograms/Source/PokemonLZA/Programs/PokemonLZA_RestaurantFarmer.h +++ b/SerialPrograms/Source/PokemonLZA/Programs/PokemonLZA_RestaurantFarmer.h @@ -9,8 +9,11 @@ #include #include "Common/Cpp/Options/BooleanCheckBoxOption.h" +#include #include "Common/Cpp/Options/ButtonOption.h" +#include "CommonFramework/Notifications/EventNotificationsTable.h" #include "NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h" +#include "NintendoSwitch/Options/NintendoSwitch_GoHomeWhenDoneOption.h" namespace PokemonAutomation{ namespace NintendoSwitch{ @@ -57,6 +60,10 @@ class RestaurantFarmer : public SingleSwitchProgramInstance, public ButtonListen std::atomic m_stop_after_current; StopButton STOP_AFTER_CURRENT; + SimpleIntegerOption NUM_ROUNDS; + GoHomeWhenDoneOption GO_HOME_WHEN_DONE; + EventNotificationOption NOTIFICATION_STATUS_UPDATE; + EventNotificationsOption NOTIFICATIONS; BooleanCheckBoxOption MOVE_AI; BooleanCheckBoxOption USE_PLUS_MOVES; From b36da10286c2e59e9b1dcc0ee7881d0715411ff5 Mon Sep 17 00:00:00 2001 From: Dalton-V Date: Wed, 29 Oct 2025 16:08:24 -0500 Subject: [PATCH 2/2] Use stats.battles to track current round --- .../PokemonLZA/Programs/PokemonLZA_RestaurantFarmer.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/SerialPrograms/Source/PokemonLZA/Programs/PokemonLZA_RestaurantFarmer.cpp b/SerialPrograms/Source/PokemonLZA/Programs/PokemonLZA_RestaurantFarmer.cpp index 706da8ddad..103ac96714 100644 --- a/SerialPrograms/Source/PokemonLZA/Programs/PokemonLZA_RestaurantFarmer.cpp +++ b/SerialPrograms/Source/PokemonLZA/Programs/PokemonLZA_RestaurantFarmer.cpp @@ -372,7 +372,7 @@ void RestaurantFarmer::on_press(){ } void RestaurantFarmer::program(SingleSwitchProgramEnvironment& env, ProControllerContext& context){ - + RestaurantFarmer_Descriptor::Stats& stats = env.current_stats(); m_stop_after_current.store(false, std::memory_order_relaxed); STOP_AFTER_CURRENT.set_ready(); ResetOnExit reset_button_on_exit(STOP_AFTER_CURRENT); @@ -380,10 +380,9 @@ void RestaurantFarmer::program(SingleSwitchProgramEnvironment& env, ProControlle // auto lobby = env.console.video().snapshot(); - uint32_t current_round = 0; while (true){ send_program_status_notification(env, NOTIFICATION_STATUS_UPDATE); - if (NUM_ROUNDS != 0 && current_round >= NUM_ROUNDS) { + if (NUM_ROUNDS != 0 && stats.battles >= NUM_ROUNDS) { m_stop_after_current.store(true, std::memory_order_relaxed); STOP_AFTER_CURRENT.set_pressed(); } @@ -391,7 +390,6 @@ void RestaurantFarmer::program(SingleSwitchProgramEnvironment& env, ProControlle break; } run_battle(env, context); - current_round++; } send_program_finished_notification(env, NOTIFICATION_PROGRAM_FINISH);