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
Expand Up @@ -298,9 +298,28 @@
EventNotificationOption& m_status_update;
};

//Checks before the first round, so that a setup problem stops the program at once instead of
//in the middle of a quest.
void check_before_start(SingleSwitchProgramEnvironment& env, ProControllerContext& context, const BBQOption& options){
//The Switch dims the screen after a few idle minutes, which hides the overworld. Any button
//wakes it, and B is harmless on the overworld.
pbf_press_button(context, BUTTON_B, 160ms, 1000ms);
context.wait_for_all_requests();

if (options.NUM_EGGS > 0 && !box_has_egg(env.program_info(), env.console, context)){
throw UserSetupError(
env.console,
"\"Hatch Quest - Number of Eggs\" is " + std::to_string((int)options.NUM_EGGS) +
", but the current box (the one the box system opens on) has no egg. "
"Put eggs in that box, or set it to 0 and choose Reroll or Keep Going in "
"\"Hatch Quest - Zero Eggs\"."
);
}
}

}

void BBQSoloFarmer::program(SingleSwitchProgramEnvironment& env, ProControllerContext& context){

Check warning on line 322 in SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

PokemonAutomation::NintendoSwitch::PokemonSV::BBQSoloFarmer::program( SingleSwitchProgramEnvironment & env , ProControllerContext & context): function_lines=49 (advisory above 25, limit 50)
StartProgramChecks::check_performance_class_wired_or_wireless(context);
assert_16_9_720p_min(env.logger(), env.console);

Expand All @@ -313,6 +332,8 @@

// Connect the controller.
require_player(env.console, context, BUTTON_LCLICK);

check_before_start(env, context, BBQ_OPTIONS);

//Fly to plaza
open_map_from_overworld(env.program_info(), env.console, context);
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=1541, limit=1000, allowed 1519
*
* From: https://github.com/PokemonAutomation/
*
Expand Down Expand Up @@ -1178,6 +1178,43 @@
context.wait_for_all_requests();
}

namespace{

//Look through the current box for an egg, from the box system. Leaves the cursor on the egg and
//returns its slot, or returns false if the box has none.
bool find_egg_in_box(
const ProgramInfo& info, ConsoleHandle& console, ProControllerContext& context,
uint8_t& row, uint8_t& col
){
BoxCurrentEggDetector egg_detector;
SomethingInBoxSlotDetector sth_in_box_detector(COLOR_RED);
for (row = 0; row < 5; row++){
for (uint8_t j_col = 0; j_col < 6; j_col++){
col = (row % 2 == 0 ? j_col : 5 - j_col);
move_box_cursor(info, console, context, BoxCursorLocation::SLOTS, row, col);
context.wait_for_all_requests();
auto snapshot = console.video().snapshot();
if (sth_in_box_detector.detect(snapshot) && egg_detector.detect(snapshot)){
console.log("Found egg.");
return true;
}
}
}
return false;
}

}

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

View workflow job for this annotation

GitHub Actions / code-health

Code health

namespace-close: close this namespace with // namespace

bool box_has_egg(const ProgramInfo& info, ConsoleHandle& console, ProControllerContext& context){
enter_box_system_from_overworld(info, console, context);
context.wait_for(std::chrono::milliseconds(400));
uint8_t row = 0;
uint8_t col = 0;
const bool found = find_egg_in_box(info, console, context, row, col);
leave_box_system_to_overworld(info, console, context);
return found;
}

void quest_hatch_egg(
ProgramEnvironment& env,
ConsoleHandle& console, ProControllerContext& context,
Expand Down Expand Up @@ -1210,30 +1247,15 @@
context.wait_for(std::chrono::milliseconds(400));

//move_to_left_box(context);
BoxCurrentEggDetector egg_detector;
SomethingInBoxSlotDetector sth_in_box_detector(COLOR_RED);
bool egg_found = false;
uint8_t row = 0;
uint8_t col = 0;
for ( ; row < 5; row++){
for (uint8_t j_col = 0; j_col < 6; j_col++){
col = (row % 2 == 0 ? j_col : 5 - j_col);
move_box_cursor(env.program_info(), console, context, BoxCursorLocation::SLOTS, row, col);
context.wait_for_all_requests();
auto snapshot = console.video().snapshot();
if (sth_in_box_detector.detect(snapshot) && egg_detector.detect(snapshot)){
console.log("Found egg.");
egg_found = true;
break;
}
}
if (egg_found){
break;
}
}

if (!egg_found){
if (!find_egg_in_box(env.program_info(), console, context, row, col)){
//Leave the box and go back, so the quest fails instead of leaving the game in the box.
console.log("No egg found during egg hatching quest!", COLOR_RED);
leave_box_system_to_overworld(env.program_info(), console, context);
pbf_press_button(context, BUTTON_PLUS, 160ms, 400ms);
return_to_plaza(env.program_info(), console, context);
context.wait_for_all_requests();
}else{
swap_two_box_slots(env.program_info(), console, context,
BoxCursorLocation::SLOTS, row, col,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ void quest_wash_pokemon(
VideoStream& stream, ProControllerContext& context
);

//Open the box system from the overworld and check that the current box has an egg.
bool box_has_egg(const ProgramInfo& info, ConsoleHandle& console, ProControllerContext& context);

//Withdraw and hatch an egg
void quest_hatch_egg(
ProgramEnvironment& env,
Expand Down
Loading