diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Options/PokemonSV_BBQOption.cpp b/SerialPrograms/Source/VideoGames/PokemonSV/Options/PokemonSV_BBQOption.cpp
index 01bad40e56..6393923e5a 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 bc137c2967..3fdfab30ec 100644
--- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp
+++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp
@@ -202,6 +202,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");
}
@@ -255,6 +262,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;
};
@@ -280,6 +288,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;
@@ -427,14 +436,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
@@ -484,6 +494,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);