From 01e50592748981c2ec9303837b2a2d49ec7287d9 Mon Sep 17 00:00:00 2001 From: dayfine Date: Wed, 21 Oct 2026 13:10:16 -0700 Subject: [PATCH] Let the BBQ farmer reroll or stop on a quest that fails all its retries A quest that fails all its retries is skipped while it stays on the panel. That keeps the farmer going, but the quest blocks its slot, and if every doable quest is one that failed the farmer stops. OUT_OF_RETRIES now chooses what happens: - Skip (default): as before. - Reroll: reroll the failed quest, so its slot gets a new quest. Uses reroll_quest_slot(), which checks which quest it pays for and that it was replaced. - Stop: end the program there, through the normal end of program. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- .../PokemonSV/Options/PokemonSV_BBQOption.cpp | 11 ++++++ .../PokemonSV/Options/PokemonSV_BBQOption.h | 7 ++++ .../Farming/PokemonSV_BBQSoloFarmer.cpp | 22 +++++++++++- .../Farming/PokemonSV_BBQSoloFarmer.h | 7 +++- .../Programs/Farming/PokemonSV_BBQTests.cpp | 36 ++++++++++++++++--- 5 files changed, 77 insertions(+), 6 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Options/PokemonSV_BBQOption.cpp b/SerialPrograms/Source/VideoGames/PokemonSV/Options/PokemonSV_BBQOption.cpp index da09d46a59..008307024b 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Options/PokemonSV_BBQOption.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Options/PokemonSV_BBQOption.cpp @@ -190,6 +190,16 @@ BBQOption::BBQOption(OCR::LanguageOCROption* language_option) "Number of Retries:
Reattempt a quest this many times if it fails.", LockMode::UNLOCK_WHILE_RUNNING, 1, 0, 5 ) + , OUT_OF_RETRIES( + "Out of Retries:
When a quest fails all its retries, do the selected option.", + { + {OutOfRetries::Skip, "skip", "Skip Quest - Not attempted again while it stays on the panel"}, + {OutOfRetries::Reroll, "reroll", "Reroll Quest - Costs BP"}, + {OutOfRetries::Stop, "stop", "Stop Program"}, + }, + LockMode::UNLOCK_WHILE_RUNNING, + OutOfRetries::Skip + ) , FIX_TIME_WHEN_DONE( "Fix Time when Done:
Fix the time after the program finishes.", LockMode::UNLOCK_WHILE_RUNNING, false @@ -210,6 +220,7 @@ BBQOption::BBQOption(OCR::LanguageOCROption* language_option) PA_ADD_OPTION(BATTLE_AI); PA_ADD_OPTION(CATCH_ON_WIN); PA_ADD_OPTION(NUM_RETRIES); + PA_ADD_OPTION(OUT_OF_RETRIES); PA_ADD_OPTION(FIX_TIME_WHEN_DONE); } diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Options/PokemonSV_BBQOption.h b/SerialPrograms/Source/VideoGames/PokemonSV/Options/PokemonSV_BBQOption.h index f5715a10c7..0f45903656 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Options/PokemonSV_BBQOption.h +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Options/PokemonSV_BBQOption.h @@ -74,6 +74,12 @@ class BBQOption : public GroupOption{ KeepGoing, }; + enum class OutOfRetries{ + Skip, + Reroll, + Stop, + }; + OCR::LanguageOCROption& LANGUAGE; SimpleIntegerOption NUM_QUESTS; @@ -98,6 +104,7 @@ class BBQOption : public GroupOption{ TeraFarmerCatchOnWin CATCH_ON_WIN; SimpleIntegerOption NUM_RETRIES; + EnumDropdownOption OUT_OF_RETRIES; BooleanCheckBoxOption FIX_TIME_WHEN_DONE; diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.cpp b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.cpp index 7cd2c4c15e..84fd26495c 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.cpp @@ -199,7 +199,18 @@ void run_bbq_rounds(Logger& logger, const BBQOption& options, BBQGameActions& ga num_completed_quests++; }else{ logger.log("Quest did not complete successfully."); - failed_quests.insert(current_quest); + switch (options.OUT_OF_RETRIES){ + case BBQOption::OutOfRetries::Skip: + failed_quests.insert(current_quest); + break; + case BBQOption::OutOfRetries::Reroll: + logger.log("Reroll selected. Rerolling the failed quest."); + game.reroll_quest(current_quest); + break; + case BBQOption::OutOfRetries::Stop: + logger.log("Stop selected. Stopping program.", COLOR_RED); + return; + } } }else{ //Note: This doesn't account for case such as "sneak up" being added and then completed alongside the next quest @@ -244,6 +255,15 @@ class BBQSoloFarmerGameActions : public BBQGameActions{ virtual bool do_quest(BBQuests quest, uint8_t& eggs_hatched) override{ return process_and_do_quest(m_env, m_env.console, m_context, m_options, quest, eggs_hatched); } + virtual void reroll_quest(BBQuests quest) override{ + std::vector quests = PokemonSV::read_quests(m_env.program_info(), m_env.console, m_context, m_options); + auto iter = std::find(quests.begin(), quests.end(), quest); + if (iter == quests.end()){ + m_env.log("Failed quest is no longer on the panel. Not rerolling."); + return; + } + reroll_quest_slot(m_env.program_info(), m_env.console, m_context, m_options, quests, iter - quests.begin()); + } virtual void quest_completed() override{ m_stats.questsCompleted++; m_env.update_stats(); diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.h b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.h index 40daefa8bf..86c7865151 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.h +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.h @@ -43,6 +43,10 @@ class BBQGameActions{ // Increments `eggs_hatched` when the quest hatches eggs. virtual bool do_quest(BBQuests quest, uint8_t& eggs_hatched) = 0; + // Reroll a quest that failed all its attempts, if it is still on the + // panel. Spends BP. + virtual void reroll_quest(BBQuests quest) = 0; + // Progress reporting only: a quest was counted as completed. Lets stats // update after every quest instead of once per round. virtual void quest_completed() = 0; @@ -55,7 +59,8 @@ class BBQGameActions{ // Run rounds of quests until NUM_QUESTS have been completed, or until // eggs run out when OUT_OF_EGGS is Stop, or until every doable quest on the -// panel is one that already failed all its attempts. +// panel is one that already failed all its attempts, or until a quest fails +// all its attempts when OUT_OF_RETRIES is Stop. // Throws UserSetupError if the exclusions leave no blue quest to do, or if // the panel shows nothing doable for many reads in a row. void run_bbq_rounds(Logger& logger, const BBQOption& options, BBQGameActions& game); diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp index c35ca22e4f..569af8ee21 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp @@ -146,6 +146,13 @@ class SimulatedBBQGameActions : public BBQGameActions{ } return success; } + virtual void reroll_quest(BBQuests quest) override{ + events.push_back("reroll"); + auto iter = std::find(panel.begin(), panel.end(), quest); + if (iter != panel.end()){ + *iter = next_new_quest(); + } + } virtual void quest_completed() override{ events.push_back("completed"); } @@ -199,6 +206,7 @@ struct BBQRoundsScenario{ size_t max_reads = 1000; std::vector new_quests = {}; std::vector> exclusions = {}; + BBQOption::OutOfRetries out_of_retries = BBQOption::OutOfRetries::Skip; uint64_t expected_completed = 0; std::string expected; }; @@ -224,6 +232,7 @@ class Test_BBQFarmerRounds : public UnitTest{ row->action.set(action); options.QUEST_EXCLUSIONS.append_row(std::move(row)); } + options.OUT_OF_RETRIES.set(m_scenario.out_of_retries); SimulatedBBQGameActions game; game.panel = m_scenario.panel; @@ -371,14 +380,15 @@ static void add_tests_BBQFarmerRounds(UnitTestDatabase& database){ { // Round 1 completes nothing. It must not save, even though the // count (0) is a multiple of the interval. - // Every quest fails, so nothing doable is left and the farmer - // stops, but the round with no completions doesn't save. + // Every quest fails and is rerolled, so round 1 completes + // nothing and doesn't save; round 2 reaches the milestone. .name = "round without completions does not save", .num_quests = 3, .save_num_quests = 2, .outcomes = {false, false, false}, - .expected_completed = 0, - .expected = "read process read do read do read do end read process", + .out_of_retries = BBQOption::OutOfRetries::Reroll, + .expected_completed = 3, + .expected = "read process read do reroll read do reroll read do reroll end " + round_of_3 + " end(save)", }, { // sneak-up fails, then leaves the panel along with make-tm. Round 2 @@ -428,6 +438,24 @@ static void add_tests_BBQFarmerRounds(UnitTestDatabase& database){ .expected_completed = 3, .expected = round_of_3 + " end", }, + { + // sneak-up is rerolled to photo-polar, which round 2 attempts. + .name = "out of retries with reroll replaces the failed quest", + .num_quests = 3, + .never_completes = {BBQuests::sneak_up}, + .out_of_retries = BBQOption::OutOfRetries::Reroll, + .expected_completed = 5, + .expected = "read process read do completed read do completed read do reroll end " + round_of_3 + " end", + }, + { + .name = "out of retries with stop stops at once", + .num_quests = 3, + .panel = {BBQuests::sneak_up, BBQuests::make_tm, BBQuests::auto_10}, + .never_completes = {BBQuests::sneak_up}, + .out_of_retries = BBQOption::OutOfRetries::Stop, + .expected_completed = 0, + .expected = "read process read do", + }, }; for (const BBQRoundsScenario& scenario : scenarios){ database.add(scenario);