-
Notifications
You must be signed in to change notification settings - Fork 106
Pokopia Palette Town Reset #1185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| /* Palette Reset | ||
| * | ||
| * From: https://github.com/PokemonAutomation/ | ||
| * | ||
| */ | ||
|
|
||
| //#include "CommonFramework/Logging/Logger.h" | ||
| #include "Common/Cpp/PrettyPrint.h" | ||
| #include "CommonFramework/Notifications/ProgramNotifications.h" | ||
| #include "CommonTools/StartupChecks/VideoResolutionCheck.h" | ||
| #include "NintendoSwitch/NintendoSwitch_Settings.h" | ||
| #include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" | ||
| #include "NintendoSwitch/Programs/NintendoSwitch_GameEntry.h" | ||
| #include "NintendoSwitch/Programs/DateSpam/NintendoSwitch_HomeToDateTime.h" | ||
| #include "Pokemon/Pokemon_Strings.h" | ||
| #include "PokemonPokopia/Inference/PokemonPokopia_ButtonDetector.h" | ||
| #include "PokemonPokopia/Inference/PokemonPokopia_MovesDetection.h" | ||
| #include "PokemonPokopia/Inference/PokemonPokopia_PCDetection.h" | ||
| #include "PokemonPokopia/Inference/PokemonPokopia_SettingsScreenDetector.h" | ||
| #include "CommonFramework/Notifications/ProgramNotifications.h" | ||
| #include "PokemonPokopia/PokemonPokopia_Settings.h" | ||
|
|
||
| #include "PokemonPokopia/Programs/PokemonPokopia_PCNavigation.h" | ||
| #include "PokemonPokopia/Programs/PokemonPokopia_PaletteReset.h" | ||
|
|
||
| namespace PokemonAutomation{ | ||
| namespace NintendoSwitch{ | ||
| namespace PokemonPokopia{ | ||
|
|
||
| using namespace Pokemon; | ||
|
|
||
|
|
||
| PaletteReset_Descriptor::PaletteReset_Descriptor() | ||
| : SingleSwitchProgramDescriptor( | ||
| "PokemonPokopia:PaletteReset", | ||
| STRING_POKEMON + " Pokopia", "Palette Reset", | ||
| "Programs/PokemonPokopia/PaletteReset.html", | ||
| "Reset Palette Town for Mew stamps and recipes.", | ||
| ProgramControllerClass::StandardController_NoRestrictions, | ||
| FeedbackType::REQUIRED, | ||
| AllowCommandsWhenRunning::DISABLE_COMMANDS | ||
| ) | ||
| {} | ||
|
|
||
|
|
||
| PaletteReset::PaletteReset() | ||
| : SKIPS( | ||
| "<b>Number of Attempts:</b>", | ||
| LockMode::UNLOCK_WHILE_RUNNING, | ||
| 1500 | ||
| ) | ||
| , GO_HOME_WHEN_DONE(false) | ||
| , NOTIFICATIONS({ | ||
| &NOTIFICATION_PROGRAM_FINISH, | ||
| &NOTIFICATION_ERROR_FATAL, | ||
| }) | ||
| { | ||
| PA_ADD_OPTION(SKIPS); | ||
| PA_ADD_OPTION(GO_HOME_WHEN_DONE); | ||
| PA_ADD_OPTION(NOTIFICATIONS); | ||
| } | ||
|
|
||
|
|
||
|
|
||
| void PaletteReset::program(SingleSwitchProgramEnvironment& env, ProControllerContext& context){ | ||
| assert_16_9_720p_min(env.logger(), env.console); | ||
|
|
||
| //start in game facing a PC, with the A button visible, | ||
| for (uint32_t c = 0; c < SKIPS; c++){ | ||
| env.log("Resets: " + tostr_u_commas(c)); | ||
|
|
||
| wait_for_overworld(env.console, context); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
|
|
||
| access_pc_from_overworld(env.console, context, true); | ||
| env.console.log("Opened Cloud Island PC menu"); | ||
| pbf_wait(context, 2000ms); | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor non-gating suggestion: It may be worthwhile to add some logic to detect that the stamp card is actually open before get_stamp(). Possibly by using a watcher for SelectionArrowDetector on ADD_STAMP_BOX. Having some detection here would stop the program from trailing off in an unknown state in case of something unexpected or setup error (ie. forgetting to pick up Ditto flag). get_stamp() does not distinguish between "not a ditto stamp" and "this isn't even a stamp at all" |
||
| Stamp todays_stamp = get_stamp(env.console, context, TODAYS_STAMP_BOX); | ||
|
Comment on lines
+75
to
+79
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would break if the user already opened the PC once today since the stamp card would not automatically pop up |
||
| if (todays_stamp == Stamp::MEW){ | ||
| env.log("Mew Stamp found."); | ||
| GO_HOME_WHEN_DONE.run_end_of_program(context); | ||
| send_program_finished_notification(env, NOTIFICATION_PROGRAM_FINISH); | ||
| break; | ||
| } | ||
|
|
||
| exit_pc(env.console, context); | ||
|
|
||
| // Date skip | ||
| pbf_press_button(context, BUTTON_HOME, 160ms, GameSettings::instance().GAME_TO_HOME_DELAY0); | ||
| home_to_date_time(env.console, context, true); | ||
|
|
||
| pbf_press_button(context, BUTTON_A, 160ms, 840ms); | ||
| pbf_press_button(context, BUTTON_A, 48ms, 24ms);//month | ||
| pbf_move_left_joystick(context, {0,-1}, 48ms, 24ms); | ||
| pbf_press_button(context, BUTTON_A, 48ms, 24ms);//day | ||
| pbf_press_button(context, BUTTON_A, 48ms, 24ms);//year | ||
| pbf_press_button(context, BUTTON_A, 48ms, 24ms);//hour | ||
| pbf_press_button(context, BUTTON_A, 48ms, 24ms);//minute | ||
| pbf_press_button(context, BUTTON_A, 48ms, 24ms);//am-pm | ||
| pbf_press_button(context, BUTTON_A, 160ms, 840ms); | ||
|
Comment on lines
+93
to
+101
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This may be different for different locales. The NintendoSwitch/Programs/DateSkip area should have routines to abstract this |
||
|
|
||
| pbf_press_button(context, BUTTON_HOME, 160ms, ConsoleSettings::instance().SETTINGS_TO_HOME_DELAY0); | ||
| //resume game | ||
| resume_game_from_home(env.console, context); | ||
|
|
||
| // Date skip | ||
| pbf_press_button(context, BUTTON_HOME, 160ms, GameSettings::instance().GAME_TO_HOME_DELAY0); | ||
| home_to_date_time(env.console, context, true); | ||
|
|
||
| pbf_press_button(context, BUTTON_A, 160ms, 840ms); | ||
| pbf_press_button(context, BUTTON_A, 48ms, 24ms);//month | ||
| pbf_move_left_joystick(context, {0,+1}, 48ms, 24ms); | ||
| pbf_press_button(context, BUTTON_A, 48ms, 24ms);//day | ||
| pbf_press_button(context, BUTTON_A, 48ms, 24ms);//year | ||
| pbf_press_button(context, BUTTON_A, 48ms, 24ms);//hour | ||
| pbf_press_button(context, BUTTON_A, 48ms, 24ms);//minute | ||
| pbf_press_button(context, BUTTON_A, 48ms, 24ms);//am-pm | ||
| pbf_press_button(context, BUTTON_A, 160ms, 840ms); | ||
|
|
||
| pbf_press_button(context, BUTTON_HOME, 160ms, ConsoleSettings::instance().SETTINGS_TO_HOME_DELAY0); | ||
| //resume game | ||
| resume_game_from_home(env.console, context); | ||
|
|
||
| pbf_wait(context, 2000ms); | ||
|
|
||
| send_program_finished_notification(env, NOTIFICATION_PROGRAM_FINISH); | ||
| GO_HOME_WHEN_DONE.run_end_of_program(context); | ||
| } | ||
|
|
||
|
|
||
|
|
||
| } | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| /* Palette Reset | ||
| * | ||
| * From: https://github.com/PokemonAutomation/ | ||
| * | ||
| */ | ||
|
|
||
| #ifndef PokemonAutomation_PokemonPokopia_PaletteReset_H | ||
| #define PokemonAutomation_PokemonPokopia_PaletteReset_H | ||
|
|
||
| #include "Common/Cpp/Options/SimpleIntegerOption.h" | ||
| #include "Common/Cpp/Options/ButtonOption.h" | ||
| #include "CommonFramework/Notifications/EventNotificationsTable.h" | ||
| #include "NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h" | ||
| #include "NintendoSwitch/Options/NintendoSwitch_GoHomeWhenDoneOption.h" | ||
|
|
||
| namespace PokemonAutomation{ | ||
|
|
||
| template <typename Type> class ControllerContext; | ||
|
|
||
| namespace NintendoSwitch{ | ||
|
|
||
| class ProController; | ||
| using ProControllerContext = ControllerContext<ProController>; | ||
|
|
||
| namespace PokemonPokopia{ | ||
|
|
||
|
|
||
| class PaletteReset_Descriptor : public SingleSwitchProgramDescriptor{ | ||
| public: | ||
| PaletteReset_Descriptor(); | ||
|
|
||
| }; | ||
|
|
||
|
|
||
| class PaletteReset : public SingleSwitchProgramInstance{ | ||
| public: | ||
| PaletteReset(); | ||
|
|
||
| virtual void program(SingleSwitchProgramEnvironment& env, ProControllerContext& context) override; | ||
|
|
||
|
|
||
| private: | ||
| SimpleIntegerOption<uint32_t> SKIPS; | ||
| GoHomeWhenDoneOption GO_HOME_WHEN_DONE; | ||
| EventNotificationsOption NOTIFICATIONS; | ||
| }; | ||
|
|
||
|
|
||
|
|
||
| } | ||
| } | ||
| } | ||
| #endif |

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The resets can be added as a program stat