diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp index 6dd1d9ef43..af140d18f5 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp @@ -131,6 +131,13 @@ class NullLogger : public Logger{ public: virtual void log(const std::string&, Color) override{} }; +class RecordingLogger : public Logger{ +public: + std::vector lines; + virtual void log(const std::string& line, Color) override{ + lines.push_back(line); + } +}; // A singleplayer quest panel that behaves like the game's: 3 blue quests, // and a completed quest is replaced by a new one. process_quest_list() @@ -592,9 +599,18 @@ class Test_BBQReroll : public UnitTest{ panel.out_of_bp = m_scenario.out_of_bp; panel.missed_reads = m_scenario.missed_reads; - NullLogger logger; + RecordingLogger logger; std::vector quests = m_scenario.quests; const BBQRerollResult result = reroll_quest(logger, panel, quests, m_scenario.slot); + //Each reroll logs one line naming its slot and quest, whatever the result. + const std::string reroll_line = "Rerolling quest " + std::to_string(m_scenario.slot + 1) + + " (" + BBQuests_enum_to_string(m_scenario.quests[m_scenario.slot]) + ")."; + const size_t reroll_lines = std::count_if(logger.lines.begin(), logger.lines.end(), [](const std::string& line){ + return line.starts_with("Rerolling quest "); + }); + if (reroll_lines != 1 || std::find(logger.lines.begin(), logger.lines.end(), reroll_line) == logger.lines.end()){ + return "Expected one log line \"" + reroll_line + "\", got " + std::to_string(reroll_lines) + " reroll lines."; + } if (result != m_scenario.expected){ return "Expected " + reroll_result_to_string(m_scenario.expected) + ", got " + reroll_result_to_string(result); diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp index 2861283c87..165f36b8f4 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp @@ -292,6 +292,9 @@ BBQRerollResult reroll_quest( std::vector& quests, size_t slot ){ + //Every slot reroll logs this one line, whatever decided it, so a log shows each BP spent. + const std::string quest = slot < quests.size() ? BBQuests_enum_to_string(quests[slot]) : ""; + logger.log("Rerolling quest " + std::to_string(slot + 1) + " (" + (quest.empty() ? "unknown" : quest) + ")."); if (!actions.open_panel()){ return BBQRerollResult::PanelNotOpened; }