Skip to content
Closed
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ BBQOption::BBQOption(OCR::LanguageOCROption* language_option)
1000
)
, SAVE_NUM_QUESTS(
"<b>Save and reset the game after attempting this many quests:</b><br>This preserves progress and prevents potential game lags from long runs.<br>0 disables this option.",
"<b>Save and reset the game after completing this many quests:</b><br>This preserves progress and prevents potential game lags from long runs.<br>0 disables this option.",
LockMode::UNLOCK_WHILE_RUNNING, 50
)
, INVERTED_FLIGHT(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,16 @@
// language is wrong so no quest is read, or there is no BP left to reroll.
const size_t MAX_READS_WITHOUT_DOABLE_QUEST = 30;

// Whether a round that took the completed count from previous_completed
// to completed crossed a nonzero multiple of the save interval.
bool bbq_save_due(uint64_t previous_completed, uint64_t completed, uint64_t interval){
return interval != 0 && completed > previous_completed
&& completed / interval > previous_completed / interval;
}

}

void run_bbq_rounds(Logger& logger, const BBQOption& options, BBQGameActions& game){

Check failure on line 135 in SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health

PokemonAutomation::NintendoSwitch::PokemonSV::run_bbq_rounds( Logger & logger , const BBQOption & options , BBQGameActions & game): function_lines=85, limit=50, allowed 83
if (!exclusions_leave_a_blue_quest(options)){
throw UserSetupError(logger, "The quest exclusions table skips or rerolls every blue quest the program can do.");
}
Expand Down Expand Up @@ -179,6 +186,7 @@
quest_list.clear();
}

const uint64_t completed_before_round = num_completed_quests;
for (auto current_quest : quests_to_do){
//Check if quest was already completed (ex. 500 meters completed while navigating to take a photo)
quest_list = read_panel();
Expand All @@ -205,7 +213,8 @@
quests_to_do.clear();

uint64_t temp_save_num_option = options.SAVE_NUM_QUESTS;
game.end_round(temp_save_num_option != 0 && num_completed_quests % temp_save_num_option == 0);
// A round can cross a milestone without ending at an exact multiple.
game.end_round(bbq_save_due(completed_before_round, num_completed_quests, temp_save_num_option));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Pokemon SV BBQ Tests

Check warning on line 1 in SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

<file>: file_lines=877 (advisory above 500, limit 1000)
*
* From: https://github.com/PokemonAutomation/
*
Expand Down Expand Up @@ -373,7 +373,7 @@
.expected = "read process " + round_of_3 + " end",
},
{
.name = "saves at exact multiples",
.name = "saves at each milestone",
.num_quests = 6,
.save_num_quests = 3,
.expected_completed = 6,
Expand All @@ -387,9 +387,7 @@
.expected = "",
},

// The ways the loop gets stuck or loses time. Scenarios named
// "today:" state the current behavior, so that each fix shows up as a
// change to one of them.
// The ways the loop used to get stuck or lose time.
{
// sneak-up fails in round 1 and is still on the panel in round 2,
// where only the two new quests are attempted.
Expand Down Expand Up @@ -419,23 +417,24 @@
.expected = read_30_times + "error",
},
{
// Today: the save check only looks for exact multiples, so going
// from 0 to 3 skips the milestone at 2 without saving.
.name = "today: a round that skips past a milestone does not save",
// 0 -> 3 crosses the milestone at 2 without landing on it.
.name = "saves when a round skips past a milestone",
.num_quests = 6,
.save_num_quests = 2,
.expected_completed = 6,
.expected = round_of_3 + " end " + round_of_3 + " end(save)",
.expected = round_of_3 + " end(save) " + round_of_3 + " end(save)",
},
{
// Today: round 1 completes nothing, but 0 is a multiple of 2, so
// it saves anyway. Every quest failed, so the farmer then stops.
.name = "today: a round without completions saves",
// 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.
.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(save) read process",
.expected = "read process read do read do read do end read process",
},
{
// sneak-up fails, then leaves the panel along with make-tm. Round 2
Expand Down
Loading