From 16f0556b910ff2015617bf17d12ad69e940d5883 Mon Sep 17 00:00:00 2001 From: kichithewolf Date: Fri, 19 Dec 2025 11:55:56 -0500 Subject: [PATCH 1/5] donut berries option --- .../Options/PokemonLZA_DonutBerriesOption.cpp | 82 +++++++++++++ .../Options/PokemonLZA_DonutBerriesOption.h | 47 ++++++++ .../Resources/PokemonLZA_DonutBerries.cpp | 109 ++++++++++++++++++ .../Resources/PokemonLZA_DonutBerries.h | 44 +++++++ SerialPrograms/cmake/SourceFiles.cmake | 4 + 5 files changed, 286 insertions(+) create mode 100644 SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_DonutBerriesOption.cpp create mode 100644 SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_DonutBerriesOption.h create mode 100644 SerialPrograms/Source/PokemonLZA/Resources/PokemonLZA_DonutBerries.cpp create mode 100644 SerialPrograms/Source/PokemonLZA/Resources/PokemonLZA_DonutBerries.h diff --git a/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_DonutBerriesOption.cpp b/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_DonutBerriesOption.cpp new file mode 100644 index 000000000..1fe5927e5 --- /dev/null +++ b/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_DonutBerriesOption.cpp @@ -0,0 +1,82 @@ +/* Donut Berries Option + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include "CommonFramework/Logging/Logger.h" +#include "PokemonLZA/Resources/PokemonLZA_DonutBerries.h" +#include "PokemonLZA_DonutBerriesOption.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonLZA{ + +StringSelectDatabase make_donut_berries_database(){ + StringSelectDatabase ret; + for (const auto& slug : DONUT_BERRIES_SLUGS()){ + const DonutBerries& data = get_berry_name(slug); + const SpriteDatabase::Sprite* sprite = DONUT_BERRIES_DATABASE().get_nothrow(slug); + if (sprite == nullptr){ + ret.add_entry(StringSelectEntry(slug, data.display_name())); + global_logger_tagged().log("Missing sprite for: " + slug, COLOR_RED); + }else{ + ret.add_entry(StringSelectEntry(slug, data.display_name(), sprite->icon)); + } + } + return ret; +} +const StringSelectDatabase& DONUT_BERRY_DATABASE(){ + static StringSelectDatabase database = make_donut_berries_database(); + return database; +} + + +DonutBerriesTableCell::DonutBerriesTableCell( + const std::string& default_slug +) + : StringSelectCell( + DONUT_BERRY_DATABASE(), + LockMode::LOCK_WHILE_RUNNING, + default_slug + ) +{} + +DonutBerriesTableRow::DonutBerriesTableRow(EditableTableOption& parent_table) + : EditableTableRow(parent_table) + , berry("hyper-cheri-berry") +{ + PA_ADD_OPTION(berry); +} +std::unique_ptr DonutBerriesTableRow::clone() const{ + std::unique_ptr ret(new DonutBerriesTableRow(parent())); + ret->berry.set_by_index(berry.index()); + return ret; +} + +DonutBerriesTable::DonutBerriesTable(std::string label) + : EditableTableOption_t( + std::move(label), + LockMode::LOCK_WHILE_RUNNING, + make_defaults() + ) +{} + + +std::vector DonutBerriesTable::make_header() const{ + return std::vector{ + "Berry", + }; +} + +std::vector> DonutBerriesTable::make_defaults(){ + std::vector> ret; + ret.emplace_back(std::make_unique(*this)); + return ret; +} + + + +} +} +} diff --git a/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_DonutBerriesOption.h b/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_DonutBerriesOption.h new file mode 100644 index 000000000..3c38aa7f0 --- /dev/null +++ b/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_DonutBerriesOption.h @@ -0,0 +1,47 @@ +/* Donut Berries Option + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#ifndef PokemonAutomation_PokemonLZA_DonutBerriesOption_H +#define PokemonAutomation_PokemonLZA_DonutBerriesOption_H + +#include "CommonTools/Options/StringSelectOption.h" +#include "Common/Cpp/Options/EditableTableOption.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonLZA{ + + +class DonutBerriesTableCell : public StringSelectCell{ +public: + DonutBerriesTableCell(const std::string& default_slug); +}; + +class DonutBerriesTableRow : public EditableTableRow{ +public: + DonutBerriesTableRow(EditableTableOption& parent_table); + virtual std::unique_ptr clone() const override; + +public: + DonutBerriesTableCell berry; +}; + + +class DonutBerriesTable : public EditableTableOption_t{ +public: + DonutBerriesTable(std::string label); + + virtual std::vector make_header() const override; + + std::vector> make_defaults(); +}; + + + +} +} +} +#endif diff --git a/SerialPrograms/Source/PokemonLZA/Resources/PokemonLZA_DonutBerries.cpp b/SerialPrograms/Source/PokemonLZA/Resources/PokemonLZA_DonutBerries.cpp new file mode 100644 index 000000000..cbb5a6095 --- /dev/null +++ b/SerialPrograms/Source/PokemonLZA/Resources/PokemonLZA_DonutBerries.cpp @@ -0,0 +1,109 @@ +/* Donut Berries + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include "Common/Cpp/Json/JsonValue.h" +#include "Common/Cpp/Json/JsonArray.h" +#include "Common/Cpp/Json/JsonObject.h" +#include "CommonFramework/Globals.h" +#include "PokemonLZA_DonutBerries.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonLZA{ + + + +std::vector make_DONUT_BERRIES_SLUGS(){ + std::vector ret; + for (const auto& item : DONUT_BERRIES_DATABASE()){ + ret.emplace_back(item.first); + } + return ret; +} +const std::vector& DONUT_BERRIES_SLUGS(){ + static std::vector database = make_DONUT_BERRIES_SLUGS(); + return database; +} + + + +struct BerryNameDatabase{ + BerryNameDatabase(); + + static const BerryNameDatabase& instance(){ + static BerryNameDatabase database; + return database; + } + + std::map database; + std::map m_display_name_to_slug; +}; +BerryNameDatabase::BerryNameDatabase(){ + { + std::string path = RESOURCE_PATH() + "PokemonLZA/Donuts/donut_berry_ocr.json"; + JsonValue json = load_json_file(path); + JsonObject& object = json.to_object_throw(path); + for (const auto& language_block : object){ + Language language = language_code_to_enum(language_block.first); + const JsonObject& per_language = language_block.second.to_object_throw(path); + for (const auto& slug : per_language){ + const JsonArray& names = slug.second.to_array_throw(path); + if (names.empty()){ + throw JsonParseException(path, "Expected at least one name for: " + language_block.first + " : " + slug.first); + } + database[slug.first].m_display_names[language] = names[0].to_string_throw(); + } + } + for (auto& item : database){ + auto iter = item.second.m_display_names.find(Language::English); + if (iter == item.second.m_display_names.end()){ + throw JsonParseException(path, "English not found for: " + item.first); + } + item.second.m_display_name = iter->second; + m_display_name_to_slug[iter->second] = item.first; + } + } +} + +const DonutBerries& get_berry_name(const std::string& slug){ + const std::map& database = BerryNameDatabase::instance().database; + auto iter = database.find(slug); + if (iter == database.end()){ + throw InternalProgramError( + nullptr, PA_CURRENT_FUNCTION, + "Berry slug not found in database: " + slug + ); + } + return iter->second; +} + +const std::string& parse_berry_name(const std::string& display_name){ + const std::map& database = BerryNameDatabase::instance().m_display_name_to_slug; + auto iter = database.find(display_name); + if (iter == database.end()){ + throw InternalProgramError( + nullptr, PA_CURRENT_FUNCTION, + "Berry name not found in database: " + display_name + ); + } + return iter->second; +} + + + + + + +const SpriteDatabase& DONUT_BERRIES_DATABASE(){ + static const SpriteDatabase database("PokemonLZA/Donuts/donut_berry_sheetSpritesheet.png", "PokemonLZA/Donuts/donut_berry_sheetSpritesheetData.json"); + return database; +} + + + +} +} +} diff --git a/SerialPrograms/Source/PokemonLZA/Resources/PokemonLZA_DonutBerries.h b/SerialPrograms/Source/PokemonLZA/Resources/PokemonLZA_DonutBerries.h new file mode 100644 index 000000000..7052d92a7 --- /dev/null +++ b/SerialPrograms/Source/PokemonLZA/Resources/PokemonLZA_DonutBerries.h @@ -0,0 +1,44 @@ +/* Donut Berries + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#ifndef PokemonAutomation_PokemonLZA_Berries_H +#define PokemonAutomation_PokemonLZA_Berries_H + +#include +#include +#include "CommonFramework/Language.h" +#include "CommonTools/Resources/SpriteDatabase.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonLZA{ + + +const std::vector& DONUT_BERRIES_SLUGS(); + +class DonutBerries{ +public: + const std::string& display_name() const{ return m_display_name; } + +private: + friend struct BerryNameDatabase; + + std::string m_display_name; + std::map m_display_names; +}; + +const DonutBerries& get_berry_name(const std::string& slug); +const std::string& parse_berry_name(const std::string& display_name); + + + +const SpriteDatabase& DONUT_BERRIES_DATABASE(); + + +} +} +} +#endif diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index 5f41392bc..aa724840c 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1627,6 +1627,8 @@ file(GLOB LIBRARY_SOURCES Source/PokemonLZA/InferenceTraining/PokemonLZA_GenerateLocationNameOCR.h Source/PokemonLZA/Options/PokemonLZA_BattleAIOption.cpp Source/PokemonLZA/Options/PokemonLZA_BattleAIOption.h + Source/PokemonLZA/Options/PokemonLZA_DonutBerriesOption.cpp + Source/PokemonLZA/Options/PokemonLZA_DonutBerriesOption.h Source/PokemonLZA/Options/PokemonLZA_HyperspaceRewardOption.cpp Source/PokemonLZA/Options/PokemonLZA_HyperspaceRewardOption.h Source/PokemonLZA/Options/PokemonLZA_HyperspaceRewardTable.cpp @@ -1704,6 +1706,8 @@ file(GLOB LIBRARY_SOURCES Source/PokemonLZA/Programs/Trading/PokemonLZA_TradeRoutines.h Source/PokemonLZA/Resources/PokemonLZA_AvailablePokemon.cpp Source/PokemonLZA/Resources/PokemonLZA_AvailablePokemon.h + Source/PokemonLZA/Resources/PokemonLZA_DonutBerries.cpp + Source/PokemonLZA/Resources/PokemonLZA_DonutBerries.h Source/PokemonLZA/Resources/PokemonLZA_HyperspaceRewardNames.cpp Source/PokemonLZA/Resources/PokemonLZA_HyperspaceRewardNames.h Source/PokemonRSE/Inference/Dialogs/PokemonRSE_DialogDetector.cpp From 3c69644d1ac7161e57ae8c7509b63cff030b3420 Mon Sep 17 00:00:00 2001 From: kichithewolf Date: Fri, 19 Dec 2025 14:52:05 -0500 Subject: [PATCH 2/5] donut options test program --- .../Source/PokemonLZA/PokemonLZA_Panels.cpp | 2 + .../PokemonLZA_DonutOptionsTest.cpp | 93 +++++++++++++++++++ .../PokemonLZA_DonutOptionsTest.h | 49 ++++++++++ SerialPrograms/cmake/SourceFiles.cmake | 2 + 4 files changed, 146 insertions(+) create mode 100644 SerialPrograms/Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_DonutOptionsTest.cpp create mode 100644 SerialPrograms/Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_DonutOptionsTest.h diff --git a/SerialPrograms/Source/PokemonLZA/PokemonLZA_Panels.cpp b/SerialPrograms/Source/PokemonLZA/PokemonLZA_Panels.cpp index 8382da8d0..26e69f31f 100644 --- a/SerialPrograms/Source/PokemonLZA/PokemonLZA_Panels.cpp +++ b/SerialPrograms/Source/PokemonLZA/PokemonLZA_Panels.cpp @@ -48,6 +48,7 @@ #include "Programs/TestPrograms/PokemonLZA_MoveBoxArrow.h" #include "Programs/TestPrograms/PokemonLZA_TestBoxCellInfo.h" #include "InferenceTraining/PokemonLZA_GenerateLocationNameOCR.h" +#include "Programs/TestPrograms/PokemonLZA_DonutOptionsTest.h" namespace PokemonAutomation{ namespace NintendoSwitch{ @@ -114,6 +115,7 @@ std::vector PanelListFactory::make_panels() const{ ret.emplace_back(make_single_switch_program()); ret.emplace_back(make_single_switch_program()); ret.emplace_back(make_single_switch_program()); + ret.emplace_back(make_single_switch_program()); } return ret; } diff --git a/SerialPrograms/Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_DonutOptionsTest.cpp b/SerialPrograms/Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_DonutOptionsTest.cpp new file mode 100644 index 000000000..237d72bf0 --- /dev/null +++ b/SerialPrograms/Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_DonutOptionsTest.cpp @@ -0,0 +1,93 @@ +/* Donut Options Test + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include "CommonFramework/Notifications/ProgramNotifications.h" +#include "CommonFramework/Exceptions/OperationFailedException.h" +#include "CommonTools/Async/InferenceRoutines.h" +#include "CommonTools/StartupChecks/VideoResolutionCheck.h" +#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" +#include "Pokemon/Pokemon_Strings.h" +#include "PokemonLZA/Inference/PokemonLZA_SelectionArrowDetector.h" +#include "PokemonLZA/Inference/PokemonLZA_DialogDetector.h" +#include "PokemonSwSh/Inference/PokemonSwSh_IvJudgeReader.h" //TODO: change/remove later +#include "PokemonLZA_DonutOptionsTest.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonLZA{ + +using namespace Pokemon; + +DonutOptionsTest_Descriptor::DonutOptionsTest_Descriptor() + : SingleSwitchProgramDescriptor( + "PokemonLZA:DonutOptionsTest", + STRING_POKEMON + " LZA", "Donut Options Test", + "Programs/PokemonLZA/DonutOptionsTest.html", + "Testing options layout for donut making.", + ProgramControllerClass::StandardController_NoRestrictions, + FeedbackType::REQUIRED, + AllowCommandsWhenRunning::DISABLE_COMMANDS + ) +{} + +DonutOptionsTest::DonutOptionsTest() + : LANGUAGE( + "Game Language:", + PokemonSwSh::IV_READER().languages(), //TODO: replace? + LockMode::LOCK_WHILE_RUNNING, + true + ) + , BERRIES("Berries:
The berries used to make the donut. Minimum 3 berries, maximum 8 berries.") + , NUM_DONUTS( + "Number of Donuts:
The number of donuts to make.", + LockMode::LOCK_WHILE_RUNNING, + 1, 1 + ) + , GO_HOME_WHEN_DONE(false) + , NOTIFICATION_STATUS_UPDATE("Status Update", true, false, std::chrono::seconds(3600)) + , NOTIFICATIONS({ + &NOTIFICATION_STATUS_UPDATE, + &NOTIFICATION_PROGRAM_FINISH, + &NOTIFICATION_ERROR_FATAL, + }) +{ + PA_ADD_OPTION(LANGUAGE); + PA_ADD_OPTION(BERRIES); + PA_ADD_OPTION(NUM_DONUTS); + PA_ADD_OPTION(GO_HOME_WHEN_DONE); + PA_ADD_OPTION(NOTIFICATIONS); +} + +void DonutOptionsTest::program(SingleSwitchProgramEnvironment& env, ProControllerContext& context){ + assert_16_9_720p_min(env.logger(), env.console); + + const Language language = LANGUAGE; + if (language == Language::None){ + throw UserSetupError(env.console, "Must set game language option to read ingredient lists."); + } + + //Validate number of selected berries + env.log("Checking berry count."); + + size_t num_berries = 0; + std::vector> berries_table = BERRIES.copy_snapshot(); + num_berries = berries_table.size(); + + if (num_berries < 3 || num_berries > 8) { + throw UserSetupError(env.console, "Must have at least 3 berries and no more than 8 berries."); + } + env.log("Number of berries validated.", COLOR_BLACK); + + + GO_HOME_WHEN_DONE.run_end_of_program(context); + send_program_finished_notification(env, NOTIFICATION_PROGRAM_FINISH); +} + + +} +} +} + diff --git a/SerialPrograms/Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_DonutOptionsTest.h b/SerialPrograms/Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_DonutOptionsTest.h new file mode 100644 index 000000000..9fa6e830c --- /dev/null +++ b/SerialPrograms/Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_DonutOptionsTest.h @@ -0,0 +1,49 @@ +/* Donut Options Test + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#ifndef PokemonAutomation_PokemonLZA_DonutOptionsTest_H +#define PokemonAutomation_PokemonLZA_DonutOptionsTest_H + +#include "NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h" +#include "CommonFramework/Notifications/EventNotificationsTable.h" +#include "NintendoSwitch/Options/NintendoSwitch_GoHomeWhenDoneOption.h" +#include "Common/Cpp/Options/SimpleIntegerOption.h" +#include "CommonTools/Options/LanguageOCROption.h" +#include "PokemonLZA/Options/PokemonLZA_DonutBerriesOption.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonLZA{ + +class DonutOptionsTest_Descriptor : public SingleSwitchProgramDescriptor{ +public: + DonutOptionsTest_Descriptor(); +}; + +class DonutOptionsTest : public SingleSwitchProgramInstance{ +public: + DonutOptionsTest(); + + virtual void program(SingleSwitchProgramEnvironment& env, ProControllerContext& context) override; + +private: + OCR::LanguageOCROption LANGUAGE; + DonutBerriesTable BERRIES; + SimpleIntegerOption NUM_DONUTS; + + GoHomeWhenDoneOption GO_HOME_WHEN_DONE; + EventNotificationOption NOTIFICATION_STATUS_UPDATE; + EventNotificationsOption NOTIFICATIONS; +}; + + + + + +} +} +} +#endif diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index aa724840c..994bece0f 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1694,6 +1694,8 @@ file(GLOB LIBRARY_SOURCES Source/PokemonLZA/Programs/ShinyHunting/PokemonLZA_WildZoneCafe.h Source/PokemonLZA/Programs/ShinyHunting/PokemonLZA_WildZoneEntrance.cpp Source/PokemonLZA/Programs/ShinyHunting/PokemonLZA_WildZoneEntrance.h + Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_DonutOptionsTest.cpp + Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_DonutOptionsTest.h Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_MoveBoxArrow.cpp Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_MoveBoxArrow.h Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_OverworldWatcher.cpp From 63aeeba78340d0af65a6f051051aa2b63bb66709 Mon Sep 17 00:00:00 2001 From: kichithewolf Date: Fri, 19 Dec 2025 18:53:10 -0500 Subject: [PATCH 3/5] wip flavor table --- .../Options/PokemonLZA_DonutBerriesOption.cpp | 108 ++++++++++++++++++ .../Options/PokemonLZA_DonutBerriesOption.h | 89 +++++++++++++++ .../PokemonLZA_DonutOptionsTest.cpp | 15 ++- .../PokemonLZA_DonutOptionsTest.h | 6 + 4 files changed, 217 insertions(+), 1 deletion(-) diff --git a/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_DonutBerriesOption.cpp b/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_DonutBerriesOption.cpp index 1fe5927e5..51ade3a61 100644 --- a/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_DonutBerriesOption.cpp +++ b/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_DonutBerriesOption.cpp @@ -12,6 +12,39 @@ namespace PokemonAutomation{ namespace NintendoSwitch{ namespace PokemonLZA{ +const EnumDropdownDatabase& flavor_power_enum_database(){ + static EnumDropdownDatabase database{ + {Flavor_Powers::alpha, "alpha", "Alpha"}, + {Flavor_Powers::humungo, "humungo", "Humungo"}, + {Flavor_Powers::teensy, "teensy", "Teensy"}, + {Flavor_Powers::sparkling, "sparkling", "Sparkling"}, + {Flavor_Powers::item, "item", "Item"}, + }; + return database; +} +const EnumDropdownDatabase& pokemon_power_enum_database(){ + static EnumDropdownDatabase database{ + {Power_Pokemon_Types::all, "all", "All Types"}, + {Power_Pokemon_Types::fire, "fire", "Fire"}, + }; + return database; +} +const EnumDropdownDatabase& item_power_enum_database(){ + static EnumDropdownDatabase database{ + {Power_Item_Types::berries, "berries", "Berry"}, + {Power_Item_Types::candies, "candies", "Candy"}, + }; + return database; +} +const EnumDropdownDatabase& power_level_enum_database(){ + static EnumDropdownDatabase database{ + {Power_Level::one, "one", "Lv.1"}, + {Power_Level::two, "two", "Lv.2"}, + {Power_Level::three, "three", "Lv.3"}, + }; + return database; +} + StringSelectDatabase make_donut_berries_database(){ StringSelectDatabase ret; for (const auto& slug : DONUT_BERRIES_SLUGS()){ @@ -77,6 +110,81 @@ std::vector> DonutBerriesTable::make_defaults( + +FlavorPowerTableRow::~FlavorPowerTableRow(){ + power.remove_listener(*this); +} +FlavorPowerTableRow::FlavorPowerTableRow(EditableTableOption& parent_table) + : EditableTableRow(parent_table) + , power(flavor_power_enum_database(), LockMode::LOCK_WHILE_RUNNING, Flavor_Powers::alpha) + , type_pokemon(pokemon_power_enum_database(), LockMode::LOCK_WHILE_RUNNING, Power_Pokemon_Types::all) + , type_item(item_power_enum_database(), LockMode::LOCK_WHILE_RUNNING, Power_Item_Types::berries) + , level(power_level_enum_database(), LockMode::LOCK_WHILE_RUNNING, Power_Level::three) +{ + PA_ADD_OPTION(power); + PA_ADD_OPTION(type_pokemon); + PA_ADD_OPTION(type_item); + PA_ADD_OPTION(level); + + FlavorPowerTableRow::on_config_value_changed(this); + power.add_listener(*this); +} +std::unique_ptr FlavorPowerTableRow::clone() const{ + std::unique_ptr ret(new FlavorPowerTableRow(parent())); + ret->power.set(power); + ret->type_pokemon.set(type_pokemon); + ret->type_item.set(type_item); + ret->level.set(level); + return ret; +} +void FlavorPowerTableRow::on_config_value_changed(void* object){ + Flavor_Powers power = this->power; + + type_item.set_visibility( + power == Flavor_Powers::item + ? ConfigOptionState::ENABLED + : ConfigOptionState::HIDDEN + ); + + bool req_poke_types = + power == Flavor_Powers::sparkling || + power == Flavor_Powers::catching || + power == Flavor_Powers::move || + power == Flavor_Powers::resistance; + + type_pokemon.set_visibility( + req_poke_types + ? ConfigOptionState::ENABLED + : ConfigOptionState::HIDDEN + ); +} + +FlavorPowerTable::FlavorPowerTable() + : EditableTableOption_t( + "Flavor Powers Table:
" + "Add all desired flavor powers to this table. " + "The program will check the powers of any baked donut and compare them against the selected items in the table. " + "Be sure to set Number of Powers to Match above.", + LockMode::LOCK_WHILE_RUNNING, + make_defaults() + ) +{} +std::vector FlavorPowerTable::make_header() const{ + return { + "Flavor Power ", + "Pokemon Type ", + "Item Type ", + "Level ", + }; +} +std::vector> FlavorPowerTable::make_defaults(){ + std::vector> ret; + ret.emplace_back(new FlavorPowerTableRow(*this)); + return ret; +} + + + } } } diff --git a/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_DonutBerriesOption.h b/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_DonutBerriesOption.h index 3c38aa7f0..7271248ee 100644 --- a/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_DonutBerriesOption.h +++ b/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_DonutBerriesOption.h @@ -9,12 +9,72 @@ #include "CommonTools/Options/StringSelectOption.h" #include "Common/Cpp/Options/EditableTableOption.h" +#include "Common/Cpp/Options/EnumDropdownOption.h" +#include "Common/Cpp/Options/SimpleIntegerOption.h" namespace PokemonAutomation{ namespace NintendoSwitch{ namespace PokemonLZA{ +enum class Flavor_Powers { + alpha, + humungo, + teensy, + sparkling, + atk, + spatk, + move, + speed, + bighaul, + item, + mega, + def, + spdef, + resistance, + encounter, + catching, +}; + +enum class Power_Pokemon_Types { + any, //Accept any of the below options + all, //Accept only the All type (ex. Sparkling Power: All Types (Lv. 3)) Applies to catching and sparkling, but not move or resist + normal, + fire, + water, + electric, + grass, + ice, + fighting, + poison, + ground, + flying, + psychic, + bug, + rock, + ghost, + dragon, + dark, + steel, + fairy, +}; + +enum class Power_Item_Types { + berries, + candies, + treasure, + pokeballs, + special, + coins, +}; + +enum class Power_Level{ + one, + two, + three, +}; + +//Berry + Hyperspace Berry selection class DonutBerriesTableCell : public StringSelectCell{ public: DonutBerriesTableCell(const std::string& default_slug); @@ -41,6 +101,35 @@ class DonutBerriesTable : public EditableTableOption_t{ +//Donut Flavor Power selection +class FlavorPowerTableRow : public EditableTableRow, public ConfigOption::Listener{ +public: + ~FlavorPowerTableRow(); + FlavorPowerTableRow(EditableTableOption& parent_table); + virtual std::unique_ptr clone() const override; + +private: + virtual void on_config_value_changed(void* object) override; + +private: + EnumDropdownCell power; + EnumDropdownCell type_pokemon; + EnumDropdownCell type_item; + EnumDropdownCell level; +}; + + +class FlavorPowerTable : public EditableTableOption_t{ +public: + FlavorPowerTable(); + + virtual std::vector make_header() const; + + std::vector> make_defaults(); + +}; + + } } } diff --git a/SerialPrograms/Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_DonutOptionsTest.cpp b/SerialPrograms/Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_DonutOptionsTest.cpp index 237d72bf0..be9c64eb5 100644 --- a/SerialPrograms/Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_DonutOptionsTest.cpp +++ b/SerialPrograms/Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_DonutOptionsTest.cpp @@ -36,11 +36,18 @@ DonutOptionsTest_Descriptor::DonutOptionsTest_Descriptor() DonutOptionsTest::DonutOptionsTest() : LANGUAGE( "Game Language:", - PokemonSwSh::IV_READER().languages(), //TODO: replace? + PokemonSwSh::IV_READER().languages(), //TODO: replace later or something LockMode::LOCK_WHILE_RUNNING, true ) , BERRIES("Berries:
The berries used to make the donut. Minimum 3 berries, maximum 8 berries.") + , NUM_POWER_REQUIRED( + "Number of Powers to Match:
How many of a dount's powers must be in the the table below. Minimum 1, maximum 3. " + "
Ex. For a target dount of Big Haul Lv.3, Berry Lv.3, and any or none for the 3rd power, set the number as 2." + "
Then, in the flavor powers table, make sure to add Big Haul Lv.3 and Berry Lv. 3.", + LockMode::LOCK_WHILE_RUNNING, + 1, 1, 3 + ) , NUM_DONUTS( "Number of Donuts:
The number of donuts to make.", LockMode::LOCK_WHILE_RUNNING, @@ -56,6 +63,8 @@ DonutOptionsTest::DonutOptionsTest() { PA_ADD_OPTION(LANGUAGE); PA_ADD_OPTION(BERRIES); + PA_ADD_OPTION(NUM_POWER_REQUIRED); + PA_ADD_OPTION(FLAVOR_POWERS); PA_ADD_OPTION(NUM_DONUTS); PA_ADD_OPTION(GO_HOME_WHEN_DONE); PA_ADD_OPTION(NOTIFICATIONS); @@ -82,6 +91,10 @@ void DonutOptionsTest::program(SingleSwitchProgramEnvironment& env, ProControlle env.log("Number of berries validated.", COLOR_BLACK); + //Validate flavor power table + //(not all powers can have all types) + + GO_HOME_WHEN_DONE.run_end_of_program(context); send_program_finished_notification(env, NOTIFICATION_PROGRAM_FINISH); } diff --git a/SerialPrograms/Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_DonutOptionsTest.h b/SerialPrograms/Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_DonutOptionsTest.h index 9fa6e830c..0d5ba9155 100644 --- a/SerialPrograms/Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_DonutOptionsTest.h +++ b/SerialPrograms/Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_DonutOptionsTest.h @@ -12,6 +12,7 @@ #include "NintendoSwitch/Options/NintendoSwitch_GoHomeWhenDoneOption.h" #include "Common/Cpp/Options/SimpleIntegerOption.h" #include "CommonTools/Options/LanguageOCROption.h" +#include "Common/Cpp/Options/EnumDropdownOption.h" #include "PokemonLZA/Options/PokemonLZA_DonutBerriesOption.h" namespace PokemonAutomation{ @@ -32,6 +33,11 @@ class DonutOptionsTest : public SingleSwitchProgramInstance{ private: OCR::LanguageOCROption LANGUAGE; DonutBerriesTable BERRIES; + + SimpleIntegerOption NUM_POWER_REQUIRED; + + FlavorPowerTable FLAVOR_POWERS; + SimpleIntegerOption NUM_DONUTS; GoHomeWhenDoneOption GO_HOME_WHEN_DONE; From 8830d1ccab2b8c1dcec55c051c6fbd3b44a2aeff Mon Sep 17 00:00:00 2001 From: kichithewolf Date: Fri, 19 Dec 2025 21:28:14 -0500 Subject: [PATCH 4/5] filled out power table --- .../Options/PokemonLZA_DonutBerriesOption.cpp | 59 +++++++++++++++---- .../Options/PokemonLZA_DonutBerriesOption.h | 1 - .../PokemonLZA_DonutOptionsTest.cpp | 6 +- .../PokemonLZA_DonutOptionsTest.h | 3 - 4 files changed, 49 insertions(+), 20 deletions(-) diff --git a/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_DonutBerriesOption.cpp b/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_DonutBerriesOption.cpp index 51ade3a61..688e36c51 100644 --- a/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_DonutBerriesOption.cpp +++ b/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_DonutBerriesOption.cpp @@ -14,33 +14,65 @@ namespace PokemonLZA{ const EnumDropdownDatabase& flavor_power_enum_database(){ static EnumDropdownDatabase database{ - {Flavor_Powers::alpha, "alpha", "Alpha"}, - {Flavor_Powers::humungo, "humungo", "Humungo"}, - {Flavor_Powers::teensy, "teensy", "Teensy"}, - {Flavor_Powers::sparkling, "sparkling", "Sparkling"}, - {Flavor_Powers::item, "item", "Item"}, + {Flavor_Powers::alpha, "alpha", "Alpha"}, + {Flavor_Powers::humungo, "humungo", "Humungo"}, + {Flavor_Powers::teensy, "teensy", "Teensy"}, + {Flavor_Powers::sparkling, "sparkling", "Sparkling"}, + {Flavor_Powers::atk, "atk", "Attack"}, + {Flavor_Powers::spatk, "spatk", "Sp. Atk"}, + {Flavor_Powers::move, "move", "Move"}, + {Flavor_Powers::speed, "speed", "Speed"}, + {Flavor_Powers::bighaul, "bighaul", "Big Haul"}, + {Flavor_Powers::item, "item", "Item"}, + {Flavor_Powers::mega, "mega", "Mega"}, + {Flavor_Powers::def, "def", "Defense"}, + {Flavor_Powers::spdef, "spdef", "Sp. Def"}, + {Flavor_Powers::resistance, "resistance", "Resistance"}, + {Flavor_Powers::encounter, "encounter", "Encounter"}, + {Flavor_Powers::catching, "catching", "Catching"}, }; return database; } const EnumDropdownDatabase& pokemon_power_enum_database(){ static EnumDropdownDatabase database{ - {Power_Pokemon_Types::all, "all", "All Types"}, - {Power_Pokemon_Types::fire, "fire", "Fire"}, + {Power_Pokemon_Types::all, "all", "All Types"}, + {Power_Pokemon_Types::normal, "normal", "Normal"}, + {Power_Pokemon_Types::fire, "fire", "Fire"}, + {Power_Pokemon_Types::water, "water", "Water"}, + {Power_Pokemon_Types::electric, "electric", "Electric"}, + {Power_Pokemon_Types::grass, "grass", "Grass"}, + {Power_Pokemon_Types::ice, "ice", "Ice"}, + {Power_Pokemon_Types::fighting, "fighting", "Fighting"}, + {Power_Pokemon_Types::poison, "poison", "Poison"}, + {Power_Pokemon_Types::ground, "ground", "Ground"}, + {Power_Pokemon_Types::flying, "flying", "Flying"}, + {Power_Pokemon_Types::psychic, "psychic", "Psychic"}, + {Power_Pokemon_Types::bug, "bug", "Bug"}, + {Power_Pokemon_Types::rock, "rock", "Rock"}, + {Power_Pokemon_Types::ghost, "ghost", "Ghost"}, + {Power_Pokemon_Types::dragon, "dragon", "Dragon"}, + {Power_Pokemon_Types::dark, "dark", "Dark"}, + {Power_Pokemon_Types::steel, "steel", "Steel"}, + {Power_Pokemon_Types::fairy, "fairy", "Fairy"}, }; return database; } const EnumDropdownDatabase& item_power_enum_database(){ static EnumDropdownDatabase database{ - {Power_Item_Types::berries, "berries", "Berry"}, - {Power_Item_Types::candies, "candies", "Candy"}, + {Power_Item_Types::berries, "berries", "Berries"}, + {Power_Item_Types::candies, "candies", "Candies"}, + {Power_Item_Types::treasure, "treasure", "Treasure"}, + {Power_Item_Types::pokeballs, "pokeballs", "Poke Balls"}, + {Power_Item_Types::special, "special", "Special"}, + {Power_Item_Types::coins, "coins", "Coins"}, }; return database; } const EnumDropdownDatabase& power_level_enum_database(){ static EnumDropdownDatabase database{ - {Power_Level::one, "one", "Lv.1"}, - {Power_Level::two, "two", "Lv.2"}, - {Power_Level::three, "three", "Lv.3"}, + {Power_Level::one, "one", "Lv. 1"}, + {Power_Level::two, "two", "Lv. 2"}, + {Power_Level::three, "three", "Lv. 3"}, }; return database; } @@ -164,7 +196,8 @@ FlavorPowerTable::FlavorPowerTable() "Flavor Powers Table:
" "Add all desired flavor powers to this table. " "The program will check the powers of any baked donut and compare them against the selected items in the table. " - "Be sure to set Number of Powers to Match above.", + "Be sure to set the correct Number of Powers to Match above." + "
Note: \"All Types\" means the All Types Power in-game.", LockMode::LOCK_WHILE_RUNNING, make_defaults() ) diff --git a/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_DonutBerriesOption.h b/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_DonutBerriesOption.h index 7271248ee..f8cf1202e 100644 --- a/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_DonutBerriesOption.h +++ b/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_DonutBerriesOption.h @@ -36,7 +36,6 @@ enum class Flavor_Powers { }; enum class Power_Pokemon_Types { - any, //Accept any of the below options all, //Accept only the All type (ex. Sparkling Power: All Types (Lv. 3)) Applies to catching and sparkling, but not move or resist normal, fire, diff --git a/SerialPrograms/Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_DonutOptionsTest.cpp b/SerialPrograms/Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_DonutOptionsTest.cpp index be9c64eb5..78507afdc 100644 --- a/SerialPrograms/Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_DonutOptionsTest.cpp +++ b/SerialPrograms/Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_DonutOptionsTest.cpp @@ -43,7 +43,7 @@ DonutOptionsTest::DonutOptionsTest() , BERRIES("Berries:
The berries used to make the donut. Minimum 3 berries, maximum 8 berries.") , NUM_POWER_REQUIRED( "Number of Powers to Match:
How many of a dount's powers must be in the the table below. Minimum 1, maximum 3. " - "
Ex. For a target dount of Big Haul Lv.3, Berry Lv.3, and any or none for the 3rd power, set the number as 2." + "
Ex. For a target donut of Big Haul Lv.3, Berry Lv.3, and any or none for the 3rd power, set the number as 2." "
Then, in the flavor powers table, make sure to add Big Haul Lv.3 and Berry Lv. 3.", LockMode::LOCK_WHILE_RUNNING, 1, 1, 3 @@ -91,8 +91,8 @@ void DonutOptionsTest::program(SingleSwitchProgramEnvironment& env, ProControlle env.log("Number of berries validated.", COLOR_BLACK); - //Validate flavor power table - //(not all powers can have all types) + //Todo: Convert to slug and also validate flavor power table (Move and resist powers cannot have All Types) + std::vector> wanted_powers_table = FLAVOR_POWERS.copy_snapshot(); GO_HOME_WHEN_DONE.run_end_of_program(context); diff --git a/SerialPrograms/Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_DonutOptionsTest.h b/SerialPrograms/Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_DonutOptionsTest.h index 0d5ba9155..6031dc416 100644 --- a/SerialPrograms/Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_DonutOptionsTest.h +++ b/SerialPrograms/Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_DonutOptionsTest.h @@ -33,11 +33,8 @@ class DonutOptionsTest : public SingleSwitchProgramInstance{ private: OCR::LanguageOCROption LANGUAGE; DonutBerriesTable BERRIES; - SimpleIntegerOption NUM_POWER_REQUIRED; - FlavorPowerTable FLAVOR_POWERS; - SimpleIntegerOption NUM_DONUTS; GoHomeWhenDoneOption GO_HOME_WHEN_DONE; From fa1899cd4e9debfacbb94fd8612ea2797789d1e7 Mon Sep 17 00:00:00 2001 From: kichithewolf Date: Fri, 19 Dec 2025 22:36:53 -0500 Subject: [PATCH 5/5] string check log --- .../Options/PokemonLZA_DonutBerriesOption.cpp | 162 +++++++++++++++++- .../Options/PokemonLZA_DonutBerriesOption.h | 16 +- .../PokemonLZA_DonutOptionsTest.cpp | 7 +- 3 files changed, 181 insertions(+), 4 deletions(-) diff --git a/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_DonutBerriesOption.cpp b/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_DonutBerriesOption.cpp index 688e36c51..d25a60d94 100644 --- a/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_DonutBerriesOption.cpp +++ b/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_DonutBerriesOption.cpp @@ -24,7 +24,8 @@ const EnumDropdownDatabase& flavor_power_enum_database(){ {Flavor_Powers::speed, "speed", "Speed"}, {Flavor_Powers::bighaul, "bighaul", "Big Haul"}, {Flavor_Powers::item, "item", "Item"}, - {Flavor_Powers::mega, "mega", "Mega"}, + {Flavor_Powers::megacharge, "megacharge", "Mega Charge"}, + {Flavor_Powers::megaconserve,"megaconserve","Mega Conserve"}, {Flavor_Powers::def, "def", "Defense"}, {Flavor_Powers::spdef, "spdef", "Sp. Def"}, {Flavor_Powers::resistance, "resistance", "Resistance"}, @@ -77,6 +78,159 @@ const EnumDropdownDatabase& power_level_enum_database(){ return database; } +std::string FlavorPowerTableEntry::to_str() const{ + std::string selected_power; + + switch (power){ + case Flavor_Powers::alpha: + selected_power += "alpha-power-"; + break; + case Flavor_Powers::humungo: + selected_power += "humungo-power-"; + break; + case Flavor_Powers::teensy: + selected_power += "teensy-power-"; + break; + case Flavor_Powers::sparkling: + selected_power += "sparkling-power-"; + break; + case Flavor_Powers::atk: + selected_power += "attack-power-"; + break; + case Flavor_Powers::spatk: + selected_power += "sp-atk-power-"; + break; + case Flavor_Powers::move: + selected_power += "move-power-"; + break; + case Flavor_Powers::speed: + selected_power += "speed-power-"; + break; + case Flavor_Powers::bighaul: + selected_power += "big-haul-power-"; + break; + case Flavor_Powers::item: + selected_power += "item-power-"; + break; + case Flavor_Powers::megacharge: + selected_power += "mega-power-charging-"; + break; + case Flavor_Powers::megaconserve: + selected_power += "mega-power-conservation-"; + break; + case Flavor_Powers::def: + selected_power += "defense-power-"; + break; + case Flavor_Powers::spdef: + selected_power += "sp-def-power-"; + break; + case Flavor_Powers::resistance: + selected_power += "resistance-power-"; + break; + case Flavor_Powers::encounter: + selected_power += "encounter-power-"; + break; + case Flavor_Powers::catching: + selected_power += "catching-power-"; + break; + } + + if (power == Flavor_Powers::catching || power == Flavor_Powers::sparkling) { + switch (pokemon_type) { + case Power_Pokemon_Types::all: + selected_power += "all-types-"; + break; + case Power_Pokemon_Types::normal: + selected_power += "normal-"; + break; + case Power_Pokemon_Types::fire: + selected_power += "fire-"; + break; + case Power_Pokemon_Types::water: + selected_power += "water-"; + break; + case Power_Pokemon_Types::electric: + selected_power += "electric-"; + break; + case Power_Pokemon_Types::grass: + selected_power += "grass-"; + break; + case Power_Pokemon_Types::ice: + selected_power += "ice-"; + break; + case Power_Pokemon_Types::fighting: + selected_power += "fighting-"; + break; + case Power_Pokemon_Types::poison: + selected_power += "poison-"; + break; + case Power_Pokemon_Types::ground: + selected_power += "ground-"; + break; + case Power_Pokemon_Types::flying: + selected_power += "flying-"; + break; + case Power_Pokemon_Types::psychic: + selected_power += "psychic-"; + break; + case Power_Pokemon_Types::bug: + selected_power += "bug-"; + break; + case Power_Pokemon_Types::rock: + selected_power += "rock-"; + break; + case Power_Pokemon_Types::ghost: + selected_power += "ghost-"; + break; + case Power_Pokemon_Types::dragon: + selected_power += "dragon-"; + break; + case Power_Pokemon_Types::dark: + selected_power += "dark-"; + break; + case Power_Pokemon_Types::steel: + selected_power += "steel-"; + break; + case Power_Pokemon_Types::fairy: + selected_power += "fairy-"; + break; + } + } + else if (power == Flavor_Powers::move || power == Flavor_Powers::resistance) { + switch (item_type) { + case Power_Item_Types::berries: + selected_power += "berries-"; + break; + case Power_Item_Types::candies: + selected_power += "candies-"; + break; + case Power_Item_Types::treasure: + selected_power += "treasure-"; + break; + case Power_Item_Types::pokeballs: + selected_power += "poke-balls-"; + break; + case Power_Item_Types::special: + selected_power += "special-"; + break; + case Power_Item_Types::coins: + selected_power += "coins-"; + break; + } + } + + switch (level) { + case Power_Level::one: + selected_power += "1"; + case Power_Level::two: + selected_power += "2"; + case Power_Level::three: + selected_power += "3"; + } + + return selected_power; +} + StringSelectDatabase make_donut_berries_database(){ StringSelectDatabase ret; for (const auto& slug : DONUT_BERRIES_SLUGS()){ @@ -169,6 +323,9 @@ std::unique_ptr FlavorPowerTableRow::clone() const{ ret->level.set(level); return ret; } +FlavorPowerTableEntry FlavorPowerTableRow::snapshot() const{ + return FlavorPowerTableEntry{power, type_pokemon, type_item, level}; +} void FlavorPowerTableRow::on_config_value_changed(void* object){ Flavor_Powers power = this->power; @@ -202,6 +359,9 @@ FlavorPowerTable::FlavorPowerTable() make_defaults() ) {} +std::vector FlavorPowerTable::snapshot(){ + return EditableTableOption_t::snapshot(); +} std::vector FlavorPowerTable::make_header() const{ return { "Flavor Power ", diff --git a/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_DonutBerriesOption.h b/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_DonutBerriesOption.h index f8cf1202e..7fe6df59d 100644 --- a/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_DonutBerriesOption.h +++ b/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_DonutBerriesOption.h @@ -27,7 +27,8 @@ enum class Flavor_Powers { speed, bighaul, item, - mega, + megacharge, + megaconserve, def, spdef, resistance, @@ -72,6 +73,15 @@ enum class Power_Level{ three, }; +struct FlavorPowerTableEntry{ + Flavor_Powers power; + Power_Pokemon_Types pokemon_type; + Power_Item_Types item_type; + Power_Level level; + + std::string to_str() const; +}; + //Berry + Hyperspace Berry selection class DonutBerriesTableCell : public StringSelectCell{ @@ -107,6 +117,8 @@ class FlavorPowerTableRow : public EditableTableRow, public ConfigOption::Listen FlavorPowerTableRow(EditableTableOption& parent_table); virtual std::unique_ptr clone() const override; + FlavorPowerTableEntry snapshot() const; + private: virtual void on_config_value_changed(void* object) override; @@ -122,6 +134,8 @@ class FlavorPowerTable : public EditableTableOption_t{ public: FlavorPowerTable(); + std::vector snapshot(); + virtual std::vector make_header() const; std::vector> make_defaults(); diff --git a/SerialPrograms/Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_DonutOptionsTest.cpp b/SerialPrograms/Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_DonutOptionsTest.cpp index 78507afdc..8fa786374 100644 --- a/SerialPrograms/Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_DonutOptionsTest.cpp +++ b/SerialPrograms/Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_DonutOptionsTest.cpp @@ -91,9 +91,12 @@ void DonutOptionsTest::program(SingleSwitchProgramEnvironment& env, ProControlle env.log("Number of berries validated.", COLOR_BLACK); - //Todo: Convert to slug and also validate flavor power table (Move and resist powers cannot have All Types) + //Print table to log to check std::vector> wanted_powers_table = FLAVOR_POWERS.copy_snapshot(); - + for (const std::unique_ptr& row : wanted_powers_table){ + FlavorPowerTableEntry table_line = row->snapshot(); + env.log(table_line.to_str()); + } GO_HOME_WHEN_DONE.run_end_of_program(context); send_program_finished_notification(env, NOTIFICATION_PROGRAM_FINISH);