From 41635c46441e0deb7e4f11740fa225e0c5ecec32 Mon Sep 17 00:00:00 2001 From: kichithewolf Date: Mon, 29 Dec 2025 12:33:22 -0500 Subject: [PATCH 1/2] desc., stats, notif --- .../Farming/PokemonLZA_DonutMaker.cpp | 29 +++++++++++-------- .../Programs/Farming/PokemonLZA_DonutMaker.h | 1 + 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/SerialPrograms/Source/PokemonLZA/Programs/Farming/PokemonLZA_DonutMaker.cpp b/SerialPrograms/Source/PokemonLZA/Programs/Farming/PokemonLZA_DonutMaker.cpp index 5739e8f5a..038fb04ac 100644 --- a/SerialPrograms/Source/PokemonLZA/Programs/Farming/PokemonLZA_DonutMaker.cpp +++ b/SerialPrograms/Source/PokemonLZA/Programs/Farming/PokemonLZA_DonutMaker.cpp @@ -49,7 +49,7 @@ DonutMaker_Descriptor::DonutMaker_Descriptor() "PokemonLZA:DonutMaker", STRING_POKEMON + " LZA", "Donut Maker", "Programs/PokemonLZA/DonutMaker.html", - "TODO: Add description", + "Make donuts and reset until desired flavor powers are found.", ProgramControllerClass::StandardController_NoRestrictions, FeedbackType::REQUIRED, AllowCommandsWhenRunning::DISABLE_COMMANDS @@ -59,14 +59,17 @@ DonutMaker_Descriptor::DonutMaker_Descriptor() class DonutMaker_Descriptor::Stats : public StatsTracker{ public: Stats() - : resets(m_stats["Resets"]) + : matched(m_stats["Donuts Matched"]) + , resets(m_stats["Resets"]) , errors(m_stats["Errors"]) { // TODO: Add more stats here + m_display_order.emplace_back("Donuts Matched"); m_display_order.emplace_back("Resets"); m_display_order.emplace_back("Errors", HIDDEN_IF_ZERO); } + std::atomic& matched; std::atomic& resets; std::atomic& errors; }; @@ -97,6 +100,11 @@ DonutMaker::DonutMaker() // 1, 1 //) , GO_HOME_WHEN_DONE(false) + , NOTIFICATION_DONUT_FOUND( + "Donut Found", + true, true, ImageAttachmentMode::JPG, + {"Notifs", "Showcase"} + ) , NOTIFICATION_STATUS("Status Update", true, false, std::chrono::seconds(3600)) , NOTIFICATIONS({ &NOTIFICATION_STATUS, @@ -117,6 +125,8 @@ DonutMaker::DonutMaker() // Read flavor power and check if they match user requirement. // Return true if the user requirement is fulfilled. bool DonutMaker::match_powers(SingleSwitchProgramEnvironment& env, ProControllerContext& context) { + DonutMaker_Descriptor::Stats& stats = env.current_stats(); + env.log("Reading in table of desired powers."); std::vector power_table; std::vector> wanted_powers_table = FLAVOR_POWERS.copy_snapshot(); @@ -125,6 +135,8 @@ bool DonutMaker::match_powers(SingleSwitchProgramEnvironment& env, ProController power_table.push_back(table_line.to_str()); env.log(table_line.to_str()); } + //TODO: Validate powers? The "All Types" type only applies to catching and sparkling powers. Move and resist do not have "All Types" + //Are people even going to target move and resist power? Big Haul/Item Berry/Alpha/Sparkling seems more likely. env.log("Reading powers and counting up hits."); uint8_t num_hits = 0; @@ -144,6 +156,9 @@ bool DonutMaker::match_powers(SingleSwitchProgramEnvironment& env, ProController } if (num_hits >= NUM_POWER_REQUIRED) { + stats.matched++; + env.update_stats(); + send_program_status_notification(env, NOTIFICATION_DONUT_FOUND, "Match found!", screen, true); return true; } @@ -439,16 +454,6 @@ void DonutMaker::program(SingleSwitchProgramEnvironment& env, ProControllerConte } } - //Print table to log to check - //std::vector> wanted_powers_table = FLAVOR_POWERS.copy_snapshot(); - //for (const std::unique_ptr& row : wanted_powers_table){ - // FlavorPowerTableEntry table_line = row->snapshot(); - // env.log(table_line.to_str()); - //} - //TODO: Validate powers. The "All Types" type only applies to catching and sparkling powers. Move and resist do not have "All Types" - //Are people even going to target move and resist power? Big Haul/Item Berry/Alpha/Sparkling seems more likely. - //also TODO: powers table to however we're going to check it once that is written - // Mash button B to let Switch register the controller pbf_mash_button(context, BUTTON_B, 200ms); diff --git a/SerialPrograms/Source/PokemonLZA/Programs/Farming/PokemonLZA_DonutMaker.h b/SerialPrograms/Source/PokemonLZA/Programs/Farming/PokemonLZA_DonutMaker.h index b74d658a2..826df42c0 100644 --- a/SerialPrograms/Source/PokemonLZA/Programs/Farming/PokemonLZA_DonutMaker.h +++ b/SerialPrograms/Source/PokemonLZA/Programs/Farming/PokemonLZA_DonutMaker.h @@ -51,6 +51,7 @@ class DonutMaker : public SingleSwitchProgramInstance{ //SimpleIntegerOption NUM_DONUTS; GoHomeWhenDoneOption GO_HOME_WHEN_DONE; + EventNotificationOption NOTIFICATION_DONUT_FOUND; EventNotificationOption NOTIFICATION_STATUS; EventNotificationsOption NOTIFICATIONS; }; From db8c4a6c542219b2f9cf259225ff97043df2b3e1 Mon Sep 17 00:00:00 2001 From: kichithewolf Date: Mon, 29 Dec 2025 12:48:32 -0500 Subject: [PATCH 2/2] Update PokemonLZA_DonutMaker.cpp --- .../PokemonLZA/Programs/Farming/PokemonLZA_DonutMaker.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SerialPrograms/Source/PokemonLZA/Programs/Farming/PokemonLZA_DonutMaker.cpp b/SerialPrograms/Source/PokemonLZA/Programs/Farming/PokemonLZA_DonutMaker.cpp index 038fb04ac..3b37ae1bf 100644 --- a/SerialPrograms/Source/PokemonLZA/Programs/Farming/PokemonLZA_DonutMaker.cpp +++ b/SerialPrograms/Source/PokemonLZA/Programs/Farming/PokemonLZA_DonutMaker.cpp @@ -103,10 +103,11 @@ DonutMaker::DonutMaker() , NOTIFICATION_DONUT_FOUND( "Donut Found", true, true, ImageAttachmentMode::JPG, - {"Notifs", "Showcase"} + {"Notifs"} ) , NOTIFICATION_STATUS("Status Update", true, false, std::chrono::seconds(3600)) , NOTIFICATIONS({ + &NOTIFICATION_DONUT_FOUND, &NOTIFICATION_STATUS, &NOTIFICATION_PROGRAM_FINISH, &NOTIFICATION_ERROR_RECOVERABLE,