diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Options/PokemonSV_BBQOption.h b/SerialPrograms/Source/VideoGames/PokemonSV/Options/PokemonSV_BBQOption.h index 48db02d5f9..f5715a10c7 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Options/PokemonSV_BBQOption.h +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Options/PokemonSV_BBQOption.h @@ -16,23 +16,12 @@ #include "VideoGames/PokemonSwSh/Options/PokemonSwSh_BallSelectOption.h" #include "VideoGames/PokemonSV/Options/PokemonSV_TeraAIOption.h" #include "VideoGames/PokemonSV/Options/PokemonSV_TeraCatchOnWinOption.h" +#include "VideoGames/PokemonSV/Options/PokemonSV_BBQuests.h" namespace PokemonAutomation{ namespace NintendoSwitch{ namespace PokemonSV{ -enum class BBQuests{ - auto_10, make_tm, pickup_10, sneak_up, photo_fly, photo_swim, photo_canyon, photo_coastal, photo_polar, photo_savanna, tera_self_defeat, - travel_500, catch_any, catch_normal, catch_fighting, catch_flying, catch_poison, catch_ground, catch_rock, catch_bug, catch_ghost, catch_steel, - catch_fire, catch_water, catch_grass, catch_electric, catch_psychic, catch_ice, catch_dragon, catch_dark, catch_fairy, - wash_pokemon, wild_tera, auto_30, tera_raid, sandwich_three, bitter_sandwich, sweet_sandwich, salty_sandwich, sour_sandwich, spicy_sandwich, hatch_egg, - photo_normal, photo_fighting, photo_flying, photo_poison, photo_ground, photo_rock, photo_bug, photo_ghost, photo_steel, photo_fire, photo_water, - photo_grass, photo_electric, photo_psychic, photo_ice, photo_dragon, photo_dark, photo_fairy, - ditto_central, ditto_canyon, ditto_coastal, ditto_polar, ditto_savanna, group_canyon, group_coastal, group_polar, group_savanna, group_eyewear, group_nonuniform, - group_masks, sandwich_four, catch_hint, catch_hint2, - UnableToDetect -}; - enum class BBQAction{ run, skip, diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Options/PokemonSV_BBQuests.cpp b/SerialPrograms/Source/VideoGames/PokemonSV/Options/PokemonSV_BBQuests.cpp new file mode 100644 index 0000000000..9e90e5702d --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Options/PokemonSV_BBQuests.cpp @@ -0,0 +1,131 @@ +/* Blueberry Quests + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include "PokemonSV_BBQuests.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonSV{ + +namespace{ + +const std::map& BBQuests_TOKEN_TO_ENUM(){ + static std::map data{ + {"auto-10", BBQuests::auto_10}, + {"make-tm", BBQuests::make_tm }, + {"pickup-10", BBQuests::pickup_10}, + {"sneak-up", BBQuests::sneak_up}, + {"photo-fly", BBQuests::photo_fly}, + {"photo-swim", BBQuests::photo_swim}, + {"photo-canyon", BBQuests::photo_canyon}, + {"photo-coastal", BBQuests::photo_coastal}, + {"photo-polar", BBQuests::photo_polar}, + {"photo-savanna", BBQuests::photo_savanna}, + {"tera-self-defeat", BBQuests::tera_self_defeat}, + {"travel-500", BBQuests::travel_500}, + {"catch-any", BBQuests::catch_any}, + {"catch-normal", BBQuests::catch_normal}, + {"catch-fighting", BBQuests::catch_fighting}, + {"catch-flying", BBQuests::catch_flying}, + {"catch-poison", BBQuests::catch_poison}, + {"catch-ground", BBQuests::catch_ground}, + {"catch-rock", BBQuests::catch_rock}, + {"catch-bug", BBQuests::catch_bug}, + {"catch-ghost", BBQuests::catch_ghost}, + {"catch-steel", BBQuests::catch_steel}, + {"catch-fire", BBQuests::catch_fire}, + {"catch-water", BBQuests::catch_water}, + {"catch-grass", BBQuests::catch_grass}, + {"catch-electric", BBQuests::catch_electric}, + {"catch-psychic", BBQuests::catch_psychic}, + {"catch-ice", BBQuests::catch_ice}, + {"catch-dragon", BBQuests::catch_dragon}, + {"catch-dark", BBQuests::catch_dark}, + {"catch-fairy", BBQuests::catch_fairy}, + {"wash-pokemon", BBQuests::wash_pokemon}, + {"wild-tera", BBQuests::wild_tera}, + {"auto-30", BBQuests::auto_30}, + {"tera-raid", BBQuests::tera_raid}, + {"sandwich-three", BBQuests::sandwich_three}, + {"bitter-sandwich", BBQuests::bitter_sandwich}, + {"sweet-sandwich", BBQuests::sweet_sandwich}, + {"salty-sandwich", BBQuests::salty_sandwich}, + {"sour-sandwich", BBQuests::sour_sandwich}, + {"spicy-sandwich", BBQuests::spicy_sandwich}, + {"hatch-egg", BBQuests::hatch_egg}, + {"photo-normal", BBQuests::photo_normal}, + {"photo-fighting", BBQuests::photo_fighting}, + {"photo-flying", BBQuests::photo_flying}, + {"photo-poison", BBQuests::photo_poison}, + {"photo-ground", BBQuests::photo_ground}, + {"photo-rock", BBQuests::photo_rock}, + {"photo-bug", BBQuests::photo_bug}, + {"photo-ghost", BBQuests::photo_ghost}, + {"photo-steel", BBQuests::photo_steel}, + {"photo-fire", BBQuests::photo_fire}, + {"photo-water", BBQuests::photo_water}, + {"photo-grass", BBQuests::photo_grass}, + {"photo-electric", BBQuests::photo_electric}, + {"photo-psychic", BBQuests::photo_psychic}, + {"photo-ice", BBQuests::photo_ice}, + {"photo-dragon", BBQuests::photo_dragon}, + {"photo-dark", BBQuests::photo_dark}, + {"photo-fairy", BBQuests::photo_fairy}, + {"ditto-central", BBQuests::ditto_central}, + {"ditto-canyon", BBQuests::ditto_canyon}, + {"ditto-coastal", BBQuests::ditto_coastal}, + {"ditto-polar", BBQuests::ditto_polar}, + {"ditto-savanna", BBQuests::ditto_savanna}, + {"group-canyon", BBQuests::group_canyon}, + {"group-coastal", BBQuests::group_coastal}, + {"group-polar", BBQuests::group_polar}, + {"group-savanna", BBQuests::group_savanna}, + {"group-eyewear", BBQuests::group_eyewear}, + {"group-nonuniform", BBQuests::group_nonuniform}, + {"group-masks", BBQuests::group_masks}, + {"sandwich-four", BBQuests::sandwich_four}, + {"catch-hint", BBQuests::catch_hint}, + {"catch-hint2", BBQuests::catch_hint2}, + {"", BBQuests::UnableToDetect}, + }; + return data; +} + +const std::map& BBQuests_ENUM_TO_TOKEN(){ + static std::map data = []{ + std::map ret; + for (const auto& [token, quest] : BBQuests_TOKEN_TO_ENUM()){ + ret.emplace(quest, token); + } + return ret; + }(); + return data; +} + +} + +BBQuests BBQuests_string_to_enum(const std::string& token){ + auto iter = BBQuests_TOKEN_TO_ENUM().find(token); + if (iter == BBQuests_TOKEN_TO_ENUM().end()){ + return BBQuests::UnableToDetect; + } + return iter->second; +} + +const std::string& BBQuests_enum_to_string(BBQuests quest){ + static const std::string EMPTY; + auto iter = BBQuests_ENUM_TO_TOKEN().find(quest); + if (iter == BBQuests_ENUM_TO_TOKEN().end()){ + return EMPTY; + } + return iter->second; +} + + +} +} +} diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Options/PokemonSV_BBQuests.h b/SerialPrograms/Source/VideoGames/PokemonSV/Options/PokemonSV_BBQuests.h new file mode 100644 index 0000000000..2f37ade6bf --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Options/PokemonSV_BBQuests.h @@ -0,0 +1,39 @@ +/* Blueberry Quests + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#ifndef PokemonAutomation_PokemonSV_BBQuests_H +#define PokemonAutomation_PokemonSV_BBQuests_H + +#include + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonSV{ + +enum class BBQuests{ + auto_10, make_tm, pickup_10, sneak_up, photo_fly, photo_swim, photo_canyon, photo_coastal, photo_polar, photo_savanna, tera_self_defeat, + travel_500, catch_any, catch_normal, catch_fighting, catch_flying, catch_poison, catch_ground, catch_rock, catch_bug, catch_ghost, catch_steel, + catch_fire, catch_water, catch_grass, catch_electric, catch_psychic, catch_ice, catch_dragon, catch_dark, catch_fairy, + wash_pokemon, wild_tera, auto_30, tera_raid, sandwich_three, bitter_sandwich, sweet_sandwich, salty_sandwich, sour_sandwich, spicy_sandwich, hatch_egg, + photo_normal, photo_fighting, photo_flying, photo_poison, photo_ground, photo_rock, photo_bug, photo_ghost, photo_steel, photo_fire, photo_water, + photo_grass, photo_electric, photo_psychic, photo_ice, photo_dragon, photo_dark, photo_fairy, + ditto_central, ditto_canyon, ditto_coastal, ditto_polar, ditto_savanna, group_canyon, group_coastal, group_polar, group_savanna, group_eyewear, group_nonuniform, + group_masks, sandwich_four, catch_hint, catch_hint2, + UnableToDetect +}; + +// Map a quest slug (as returned by BlueberryQuestDetector) to its enum. +// Unrecognized slugs return UnableToDetect. +BBQuests BBQuests_string_to_enum(const std::string& token); + +// Map a quest to its slug. UnableToDetect maps to the empty string. +const std::string& BBQuests_enum_to_string(BBQuests quest); + + +} +} +} +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/PokemonSV_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonSV/PokemonSV_Tests.cpp index 72f796e493..7788036545 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/PokemonSV_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSV/PokemonSV_Tests.cpp @@ -25,6 +25,7 @@ #include "Inference/Overworld/PokemonSV_LetsGoKillDetector.h" #include "Inference/Picnics/PokemonSV_SandwichRecipeDetector.h" #include "Inference/Picnics/PokemonSV_SandwichHandDetector.h" +#include "Options/PokemonSV_BBQuests.h" #include "Programs/Farming/PokemonSV_BlueberryQuests.h" #include "PokemonSV_Tests.h" @@ -84,9 +85,39 @@ void add_tests_TeraEncounterAction(UnitTestDatabase& database){ } } +namespace{ + +class Test_BBQuestsSlugs : public UnitTest{ +public: + Test_BBQuestsSlugs() + : UnitTest("PokemonSV::BBQuests - slug round trip") + {} + virtual UnitTestResult run(Logger&, CancellableScope&) const override{ + for (int c = 0; c < (int)BBQuests::UnableToDetect; c++){ + const BBQuests quest = (BBQuests)c; + const std::string& slug = BBQuests_enum_to_string(quest); + if (slug.empty()){ + return "Quest " + std::to_string(c) + " has no slug."; + } + if (BBQuests_string_to_enum(slug) != quest){ + return "Slug " + slug + " does not map back to quest " + std::to_string(c) + "."; + } + } + if (!BBQuests_enum_to_string(BBQuests::UnableToDetect).empty()){ + return "UnableToDetect must map to the empty slug."; + } + if (BBQuests_string_to_enum("not-a-quest") != BBQuests::UnableToDetect){ + return "An unrecognized slug must map to UnableToDetect."; + } + return true; + } +}; + +} void add_tests(UnitTestDatabase& database){ + database.add(); add_tests_WhiteButtonDetector(database); add_tests_BoxInfoDetector(database); add_tests_BoxEggDetector(database); diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryCatchPhoto.cpp b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryCatchPhoto.cpp index 73e2456cf5..3a24e1d187 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryCatchPhoto.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryCatchPhoto.cpp @@ -26,7 +26,6 @@ #include "VideoGames/PokemonSV/Programs/PokemonSV_WorldNavigation.h" #include "VideoGames/PokemonSV/Programs/Battles/PokemonSV_BasicCatcher.h" #include "VideoGames/PokemonSV/Programs/PokemonSV_Terarium.h" -#include "PokemonSV_BlueberryQuests.h" #include "PokemonSV_BlueberryCatchPhoto.h" namespace PokemonAutomation{ diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryCatchPhoto.h b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryCatchPhoto.h index c4a99efb65..862285c3c3 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryCatchPhoto.h +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryCatchPhoto.h @@ -9,7 +9,7 @@ #include "NintendoSwitch/Controllers/Procon/NintendoSwitch_ProController.h" #include "NintendoSwitch/NintendoSwitch_Settings.h" -#include "VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.h" +#include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h" #include "VideoGames/PokemonSV/Options/PokemonSV_BBQOption.h" using namespace std; @@ -19,6 +19,12 @@ namespace PokemonAutomation{ namespace NintendoSwitch{ namespace PokemonSV{ +enum class CameraAngle{ + none, + up, + down +}; + //Navigate to a photo target CameraAngle quest_photo_navi( const ProgramInfo& info, diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp index 2be8e7e022..c603b898f6 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp @@ -48,96 +48,6 @@ namespace PokemonAutomation{ namespace NintendoSwitch{ namespace PokemonSV{ -const std::map& BBQuests_TOKEN_TO_ENUM(){ - static std::map data{ - {"auto-10", BBQuests::auto_10}, - {"make-tm", BBQuests::make_tm }, - {"pickup-10", BBQuests::pickup_10}, - {"sneak-up", BBQuests::sneak_up}, - {"photo-fly", BBQuests::photo_fly}, - {"photo-swim", BBQuests::photo_swim}, - {"photo-canyon", BBQuests::photo_canyon}, - {"photo-coastal", BBQuests::photo_coastal}, - {"photo-polar", BBQuests::photo_polar}, - {"photo-savanna", BBQuests::photo_savanna}, - {"tera-self-defeat", BBQuests::tera_self_defeat}, - {"travel-500", BBQuests::travel_500}, - {"catch-any", BBQuests::catch_any}, - {"catch-normal", BBQuests::catch_normal}, - {"catch-fighting", BBQuests::catch_fighting}, - {"catch-flying", BBQuests::catch_flying}, - {"catch-poison", BBQuests::catch_poison}, - {"catch-ground", BBQuests::catch_ground}, - {"catch-rock", BBQuests::catch_rock}, - {"catch-bug", BBQuests::catch_bug}, - {"catch-ghost", BBQuests::catch_ghost}, - {"catch-steel", BBQuests::catch_steel}, - {"catch-fire", BBQuests::catch_fire}, - {"catch-water", BBQuests::catch_water}, - {"catch-grass", BBQuests::catch_grass}, - {"catch-electric", BBQuests::catch_electric}, - {"catch-psychic", BBQuests::catch_psychic}, - {"catch-ice", BBQuests::catch_ice}, - {"catch-dragon", BBQuests::catch_dragon}, - {"catch-dark", BBQuests::catch_dark}, - {"catch-fairy", BBQuests::catch_fairy}, - {"wash-pokemon", BBQuests::wash_pokemon}, - {"wild-tera", BBQuests::wild_tera}, - {"auto-30", BBQuests::auto_30}, - {"tera-raid", BBQuests::tera_raid}, - {"sandwich-three", BBQuests::sandwich_three}, - {"bitter-sandwich", BBQuests::bitter_sandwich}, - {"sweet-sandwich", BBQuests::sweet_sandwich}, - {"salty-sandwich", BBQuests::salty_sandwich}, - {"sour-sandwich", BBQuests::sour_sandwich}, - {"spicy-sandwich", BBQuests::spicy_sandwich}, - {"hatch-egg", BBQuests::hatch_egg}, - {"photo-normal", BBQuests::photo_normal}, - {"photo-fighting", BBQuests::photo_fighting}, - {"photo-flying", BBQuests::photo_flying}, - {"photo-poison", BBQuests::photo_poison}, - {"photo-ground", BBQuests::photo_ground}, - {"photo-rock", BBQuests::photo_rock}, - {"photo-bug", BBQuests::photo_bug}, - {"photo-ghost", BBQuests::photo_ghost}, - {"photo-steel", BBQuests::photo_steel}, - {"photo-fire", BBQuests::photo_fire}, - {"photo-water", BBQuests::photo_water}, - {"photo-grass", BBQuests::photo_grass}, - {"photo-electric", BBQuests::photo_electric}, - {"photo-psychic", BBQuests::photo_psychic}, - {"photo-ice", BBQuests::photo_ice}, - {"photo-dragon", BBQuests::photo_dragon}, - {"photo-dark", BBQuests::photo_dark}, - {"photo-fairy", BBQuests::photo_fairy}, - {"ditto-central", BBQuests::ditto_central}, - {"ditto-canyon", BBQuests::ditto_canyon}, - {"ditto-coastal", BBQuests::ditto_coastal}, - {"ditto-polar", BBQuests::ditto_polar}, - {"ditto-savanna", BBQuests::ditto_savanna}, - {"group-canyon", BBQuests::group_canyon}, - {"group-coastal", BBQuests::group_coastal}, - {"group-polar", BBQuests::group_polar}, - {"group-savanna", BBQuests::group_savanna}, - {"group-eyewear", BBQuests::group_eyewear}, - {"group-nonuniform", BBQuests::group_nonuniform}, - {"group-masks", BBQuests::group_masks}, - {"sandwich-four", BBQuests::sandwich_four}, - {"catch-hint", BBQuests::catch_hint}, - {"catch-hint2", BBQuests::catch_hint2}, - {"", BBQuests::UnableToDetect}, - }; - return data; -} - -BBQuests BBQuests_string_to_enum(const std::string& token){ - auto iter = BBQuests_TOKEN_TO_ENUM().find(token); - if (iter == BBQuests_TOKEN_TO_ENUM().end()){ - return BBQuests::UnableToDetect; - } - return iter->second; -} - int read_BP(const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ WhiteButtonWatcher right_panel(COLOR_BLUE, WhiteButton::ButtonB, {0.484, 0.117, 0.022, 0.037}); int result = run_until( diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.h b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.h index 16593da3ac..21ad16aa71 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.h +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.h @@ -18,14 +18,6 @@ namespace PokemonAutomation{ namespace NintendoSwitch{ namespace PokemonSV{ -BBQuests BBQuests_string_to_enum(const std::string& token); - -enum class CameraAngle{ - none, - up, - down -}; - //Basic blue quests const std::set blue_quests = { BBQuests::auto_10, BBQuests::make_tm, BBQuests::pickup_10, BBQuests::sneak_up, BBQuests::photo_fly, BBQuests::photo_swim, BBQuests::photo_canyon, BBQuests::photo_coastal, BBQuests::photo_polar, BBQuests::photo_savanna, BBQuests::tera_self_defeat, diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index 60813563de..950ba61ede 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -2430,6 +2430,8 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonSV/Options/PokemonSV_BattleMoveTable.h Source/VideoGames/PokemonSV/Options/PokemonSV_BBQOption.cpp Source/VideoGames/PokemonSV/Options/PokemonSV_BBQOption.h + Source/VideoGames/PokemonSV/Options/PokemonSV_BBQuests.cpp + Source/VideoGames/PokemonSV/Options/PokemonSV_BBQuests.h Source/VideoGames/PokemonSV/Options/PokemonSV_EggPowerSandwichOption.cpp Source/VideoGames/PokemonSV/Options/PokemonSV_EggPowerSandwichOption.h Source/VideoGames/PokemonSV/Options/PokemonSV_EncounterActionsTable.cpp