Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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=825 (advisory above 500, limit 1000)
*
* From: https://github.com/PokemonAutomation/
*
Expand Down Expand Up @@ -131,6 +131,13 @@
public:
virtual void log(const std::string&, Color) override{}
};
class RecordingLogger : public Logger{
public:
std::vector<std::string> 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()
Expand Down Expand Up @@ -582,7 +589,7 @@
, m_scenario(std::move(scenario))
{}

virtual UnitTestResult run(Logger&, CancellableScope&) const override{

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

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

PokemonAutomation::NintendoSwitch::PokemonSV::Test_BBQReroll::run( Logger & , CancellableScope &) const: function_lines=39 (advisory above 25, limit 50)
SimulatedQuestPanel panel;
panel.quests = m_scenario.quests;
panel.replacements = m_scenario.replacements;
Expand All @@ -592,9 +599,18 @@
panel.out_of_bp = m_scenario.out_of_bp;
panel.missed_reads = m_scenario.missed_reads;

NullLogger logger;
RecordingLogger logger;
std::vector<BBQuests> 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);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Blueberry Quests

Check failure on line 1 in SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health

<file>: file_lines=1455, limit=1000, allowed 1452
*
* From: https://github.com/PokemonAutomation/
*
Expand Down Expand Up @@ -286,12 +286,15 @@

}

BBQRerollResult reroll_quest(

Check warning on line 289 in SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

PokemonAutomation::NintendoSwitch::PokemonSV::reroll_quest( Logger & logger , BBQRerollActions & actions , std :: vector<BBQuests> & quests , size_t slot): function_lines=50 (advisory above 25, limit 50)
Logger& logger,
BBQRerollActions& actions,
std::vector<BBQuests>& 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;
}
Expand Down
Loading