diff --git a/SerialPrograms/CMakeLists.txt b/SerialPrograms/CMakeLists.txt index bd7c93a134..4822575e56 100644 --- a/SerialPrograms/CMakeLists.txt +++ b/SerialPrograms/CMakeLists.txt @@ -234,7 +234,7 @@ pa_embed_text_files(SerialProgramsLib "${FRLG_MAP_RESOURCES}" pa_embed_text_files(SerialProgramsLib Source/VideoGames/PokemonFRLG/Programs/AutoStory/BattleData VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleData.h PokemonAutomation::NintendoSwitch::PokemonFRLG autostory_battle_json) pa_embed_text_files(SerialProgramsLib Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData - VideoGames/PokemonFRLG/Programs/AutoStory/Data/JsonParser.h PokemonAutomation::NintendoSwitch::PokemonFRLG autostory_checkpoint_json) + VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h PokemonAutomation::NintendoSwitch::PokemonFRLG autostory_checkpoint_json) # Create binary target diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.cpp index 9053f963ea..2c892018fe 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.cpp @@ -111,20 +111,20 @@ class RouteLogLines{ for (const RouteStep& step : steps){ legs.push_back({.leg = route_log_leg(step), .after = route_tiles(step.end)}); } - m_calls.log(ROUTE_LOG_TAG + Pokemon::route_plan_line(m_label, route_tiles(from), legs)); + m_calls.log(std::string(ROUTE_LOG_TAG) + Pokemon::route_plan_line(m_label, route_tiles(from), legs)); } void leg(size_t index, const std::vector& steps) const{ const RouteStep& step = steps[index]; - m_calls.log(ROUTE_LOG_TAG + Pokemon::route_leg_line(index + 1, steps.size(), {.leg = route_log_leg(step), .after = route_tiles(step.end)})); + m_calls.log(std::string(ROUTE_LOG_TAG) + Pokemon::route_leg_line(index + 1, steps.size(), {.leg = route_log_leg(step), .after = route_tiles(step.end)})); } void end(const RouteStep& step, const std::optional& at, EndBasis basis, const std::string& why) const{ - m_calls.log(ROUTE_LOG_TAG + Pokemon::route_leg_end_line(m_label, route_log_leg(step), route_tiles(at), basis, why)); + m_calls.log(std::string(ROUTE_LOG_TAG) + Pokemon::route_leg_end_line(m_label, route_log_leg(step), route_tiles(at), basis, why)); } void trainer_stopped(const RouteStep& step, const MapPosition& at) const{ - m_calls.log(ROUTE_LOG_TAG + Pokemon::route_replan_line(m_label, route_log_leg(step), "stopped by a trainer who saw the player", route_tiles(at))); + m_calls.log(std::string(ROUTE_LOG_TAG) + Pokemon::route_replan_line(m_label, route_log_leg(step), "stopped by a trainer who saw the player", route_tiles(at))); } void found(const MapPosition& at, size_t holds) const{ - m_calls.log(ROUTE_LOG_TAG + Pokemon::route_found_line(m_label, route_tiles(at), holds)); + m_calls.log(std::string(ROUTE_LOG_TAG) + Pokemon::route_found_line(m_label, route_tiles(at), holds)); } // Step `number` (from 1) of a plan whose first `holds` steps are holds // to walls, walked to its end. diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp index 2bf7183092..89651ccde3 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp @@ -51,6 +51,7 @@ #include "Programs/AutoStory/PokemonFRLG_AutoStoryPaceSim.h" #include "Programs/AutoStory/PokemonFRLG_AutoStoryPcStorage.h" #include "Programs/AutoStory/PokemonFRLG_AutoStoryRngLoop.h" +#include "Programs/AutoStory/PokemonFRLG_AutoStoryRows_Tests.h" #include "Programs/AutoStory/PokemonFRLG_AutoStoryTable.h" #include "Programs/AutoStory/PokemonFRLG_AutoStoryTrashCans.h" #include "Programs/AutoStory/Data/Json_Tests.h" @@ -890,7 +891,6 @@ static void add_tests_Naming(UnitTestDatabase& database){ add_tests_NamingText(database); } -// The story's rows on the overworld sim, a file of tests per stage. static void add_tests_AutoStoryRows(UnitTestDatabase& database){ add_tests_AutoStoryVermilion(database); add_tests_AutoStoryVermilionGym(database); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/Data/JsonParser.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/Data/JsonParser.cpp deleted file mode 100644 index 780b3a9a88..0000000000 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/Data/JsonParser.cpp +++ /dev/null @@ -1,233 +0,0 @@ -/* FRLG Checkpoint JSON Parser - * From: https://github.com/PokemonAutomation/ - */ - -#include -#include -#include -#include -#include "Common/Cpp/Exceptions.h" -#include "Common/Cpp/Json/JsonArray.h" -#include "Common/Cpp/Json/JsonObject.h" -#include "Pokemon/AutoStory/Pokemon_StoryStepJson.h" -#include "Pokemon/AutoStory/Pokemon_AuthoredCheckpointJson.h" -#include "LegacyJsonFormat.h" -#include "JsonParser.h" - -namespace PokemonAutomation{ -namespace NintendoSwitch{ -namespace PokemonFRLG{ - - -namespace{ - -// Reading. Every field is required and no other is allowed, as in the -// shared codec: the record says what the table said, not what it left out. -const JsonObject& fields(const JsonValue& value, std::initializer_list keys, std::string_view source){ - const JsonObject& object = value.to_object_throw(std::string(source)); - for (const auto& [key, unused] : object){ - bool known = false; - for (std::string_view allowed : keys){ - known |= key == allowed; - } - if (!known){ - throw ParseException(std::format("{}: unsupported field {}", source, key)); - } - } - return object; -} - -void expect_string(const JsonObject& root, const std::string& key, std::string_view expected, std::string_view source){ - const std::string& actual = root.get_string_throw(key, std::string(source)); - if (actual != expected){ - throw ParseException(std::format("{}: {} is {}, not {}", source, key, actual, expected)); - } -} - -// The value of `values` that `name` names `label`. -template -Enum read_named(std::initializer_list values, const char* (*name)(Enum), const std::string& label, std::string_view source){ - for (Enum value : values){ - if (label == name(value)){ - return value; - } - } - throw ParseException(std::format("{}: unsupported value {}", source, label)); -} - -// An integer within [`low`, `high`], as the native field's type holds it. -int64_t bounded(const JsonValue& value, int64_t low, int64_t high, std::string_view source){ - const int64_t number = value.to_integer_throw(std::string(source)); - if (number < low || number > high){ - throw ParseException(std::format("{}: {} is out of range", source, number)); - } - return number; -} - -int read_int(const JsonValue& value, std::string_view source){ - return (int)bounded(value, std::numeric_limits::min(), std::numeric_limits::max(), source); -} - -uint8_t read_byte(const JsonValue& value, std::string_view source){ - return (uint8_t)bounded(value, 0, std::numeric_limits::max(), source); -} - -uint16_t read_word(const JsonValue& value, std::string_view source){ - return (uint16_t)bounded(value, 0, std::numeric_limits::max(), source); -} - -size_t read_count(const JsonValue& value, std::string_view source){ - return (size_t)bounded(value, 0, std::numeric_limits::max(), source); -} - -std::vector read_strings(const JsonValue& value, std::string_view source){ - std::vector result; - for (const JsonValue& item : value.to_array_throw(std::string(source))){ - result.push_back(item.to_string_throw(std::string(source))); - } - return result; -} - -std::optional read_stats(const JsonValue& value, std::string_view source){ - if (value.is_null()){ - return std::nullopt; - } - const JsonObject& root = fields(value, {"hp", "attack", "defense", "sp_attack", "sp_defense", "speed"}, source); - return Stats{ - .hp = read_word(root.get_value_throw("hp"), source), - .attack = read_word(root.get_value_throw("attack"), source), - .defense = read_word(root.get_value_throw("defense"), source), - .sp_attack = read_word(root.get_value_throw("sp_attack"), source), - .sp_defense = read_word(root.get_value_throw("sp_defense"), source), - .speed = read_word(root.get_value_throw("speed"), source), - }; -} - -std::vector read_moves(const JsonValue& value, std::string_view source){ - std::vector result; - for (const JsonValue& item : value.to_array_throw(std::string(source))){ - const JsonObject& row = fields(item, {"move", "pp"}, source); - result.push_back({.move = row.get_string_throw("move"), .pp = read_byte(row.get_value_throw("pp"), source)}); - } - return result; -} - -PartyMember read_member(const JsonValue& value, std::string_view source){ - const JsonObject& root = fields(value, {"species", "moves", "moves_through_level", "moves_read", "level", "stats"}, source); - return PartyMember{ - .species = root.get_string_throw("species"), - .moves = read_moves(root.get_value_throw("moves"), source), - .moves_through_level = read_byte(root.get_value_throw("moves_through_level"), source), - .moves_read = root.get_boolean_throw("moves_read"), - .level = read_byte(root.get_value_throw("level"), source), - .stats = read_stats(root.get_value_throw("stats"), source), - }; -} - -std::vector read_slots(const JsonValue& value, std::string_view source){ - std::vector result; - for (const JsonValue& item : value.to_array_throw(std::string(source))){ - result.push_back(read_count(item, source)); - } - return result; -} - -std::optional read_foe_out(const JsonValue& value, std::string_view source){ - if (value.is_null()){ - return std::nullopt; - } - return read_count(value, source); -} - -Supplies read_supplies(const JsonValue& value, std::string_view source){ - const JsonObject& root = fields(value, {"potions", "antidotes", "parlyz_heals", "pocket", "status", "hurt", "hp_red", - "hp_fill", "lead", "protected_slots", "foes", "trainer", "risk", "foe_out", "wild_foes"}, source); - Supplies result; - result.potions = read_int(root.get_value_throw("potions"), source); - result.antidotes = read_int(root.get_value_throw("antidotes"), source); - result.parlyz_heals = read_int(root.get_value_throw("parlyz_heals"), source); - result.pocket = read_strings(root.get_value_throw("pocket"), source); - result.status = read_named({StatusCondition::NONE, StatusCondition::POISON, StatusCondition::PARALYSIS, StatusCondition::OTHER}, - status_name, root.get_string_throw("status"), source); - result.hurt = root.get_boolean_throw("hurt"); - result.hp_red = root.get_boolean_throw("hp_red"); - result.hp_fill = root.get_double_throw("hp_fill"); - result.lead = read_member(root.get_value_throw("lead"), source); - result.protected_slots = read_slots(root.get_value_throw("protected_slots"), source); - result.foes = read_strings(root.get_value_throw("foes"), source); - result.trainer = root.get_string_throw("trainer"); - result.risk = read_named({BattleRisk::LOW, BattleRisk::HIGH}, battle_risk_name, root.get_string_throw("risk"), source); - result.foe_out = read_foe_out(root.get_value_throw("foe_out"), source); - result.wild_foes = read_strings(root.get_value_throw("wild_foes"), source); - return result; -} - -void check_envelope(const JsonObject& root, std::string_view source){ - expect_string(root, "format", StoryJsonInternal::FORMAT, source); - expect_string(root, "game", StoryJsonInternal::GAME, source); - expect_string(root, "status", StoryJsonInternal::STATUS, source); - expect_string(root, "state_basis", StoryJsonInternal::STATE_BASIS, source); - if (read_strings(root.get_value_throw("unbound"), source) != StoryJsonInternal::unbound_fields()){ - throw ParseException(std::format("{}: unbound is not the export's list", source)); - } - if (root.get_string_throw("source_revision").empty()){ - throw ParseException(std::format("{}: source_revision names no revision", source)); - } -} - -StoryCheckpoint apply_execution(Pokemon::AuthoredCheckpoint parsed, std::string_view source){ - const JsonObject& execution = parsed.execution; - Pokemon::require_story_json_fields(execution, {"menu"}, source); - StoryCheckpoint result; - static_cast(result) = std::move(parsed.checkpoint); - const std::string& menu = execution.get_string_throw("menu"); - if (menu == "before_pokemon"){ - result.menu = StartMenu::BEFORE_POKEMON; - }else if (menu == "before_pokedex"){ - result.menu = StartMenu::BEFORE_POKEDEX; - }else if (menu == "full"){ - result.menu = StartMenu::FULL; - }else{ - throw ParseException("Unsupported authored checkpoint menu."); - } - return result; -} - - -} // namespace - -StoryCheckpoint read_authored_checkpoint(const JsonValue& value, std::string_view source){ - return apply_execution(Pokemon::read_authored_checkpoint(value, "frlg", source), source); -} - -StoryCheckpoint load_authored_checkpoint(std::string_view file){ - return apply_execution(Pokemon::load_authored_checkpoint(autostory_checkpoint_json(), file, "frlg"), file); -} - -StoryCheckpoint read_story_checkpoint_export(const JsonValue& value, std::string_view source){ - const JsonObject& root = fields(value, - {"format", "game", "status", "checkpoint", "native_fields", "state_basis", "unbound", "source_revision"}, source); - check_envelope(root, source); - StoryCheckpoint result; - Pokemon::StoryCheckpoint& common = result; - common = Pokemon::read_story_checkpoint(root.get_value_throw("checkpoint"), source); - const JsonObject& native = fields(root.get_value_throw("native_fields"), {"menu", "supplies"}, source); - result.menu = read_named({StartMenu::BEFORE_POKEMON, StartMenu::BEFORE_POKEDEX, StartMenu::FULL}, - StoryJsonInternal::menu_name, native.get_string_throw("menu"), source); - result.supplies = read_supplies(native.get_value_throw("supplies"), source); - return result; -} - -StoryCheckpoint load_story_checkpoint(std::string_view file){ - for (const auto& [name, text] : autostory_checkpoint_json()){ - if (name == file){ - return read_story_checkpoint_export(parse_json(text), std::format("StoryData/{}.json", file)); - } - } - throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, std::format("StoryData/{}.json is not built into the program.", file)); -} - - -} // namespace PokemonFRLG -} // namespace NintendoSwitch -} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/Data/JsonParser.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/Data/JsonParser.h deleted file mode 100644 index 9b20466141..0000000000 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/Data/JsonParser.h +++ /dev/null @@ -1,47 +0,0 @@ -/* FRLG Checkpoint JSON Parser - * From: https://github.com/PokemonAutomation/ - */ - -#ifndef PokemonAutomation_PokemonFRLG_CheckpointJsonParser_H -#define PokemonAutomation_PokemonFRLG_CheckpointJsonParser_H - -#include -#include -#include -#include -#include "Common/Cpp/Json/JsonValue.h" -#include "VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.h" - -namespace PokemonAutomation{ -namespace NintendoSwitch{ -namespace PokemonFRLG{ - - -// Read a data-authored checkpoint, retaining native bookkeeping defaults. -// Unknown envelope fields/menu values and malformed common actions throw ParseException. -StoryCheckpoint read_authored_checkpoint(const JsonValue& value, std::string_view source); - -// Load an embedded authored plan by filename without .json; no controller IO. -StoryCheckpoint load_authored_checkpoint(std::string_view file); - - -// Embedded StoryData/*.json records: (filename without .json, text), sorted by name. -const std::vector>& autostory_checkpoint_json(); - - -// Migration only: read a captured native-table export, including all bookkeeping. -// Validate the format/game/status/state basis/unbound list and require a nonempty -// source revision. Unknown fields/values and missing native fields throw ParseException. -// The reader cannot verify the source revision against the captured table. -StoryCheckpoint read_story_checkpoint_export(const JsonValue& value, std::string_view source); - -// Migration only: read an embedded export capture by filename without .json. -// Throws InternalProgramError if the file is not built into the program. -StoryCheckpoint load_story_checkpoint(std::string_view file); - - -} // namespace PokemonFRLG -} // namespace NintendoSwitch -} // namespace PokemonAutomation - -#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/Data/JsonWriter.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/Data/JsonWriter.cpp index 069658edee..da536d951b 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/Data/JsonWriter.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/Data/JsonWriter.cpp @@ -6,7 +6,7 @@ #include #include "Common/Cpp/Json/JsonArray.h" #include "Common/Cpp/Json/JsonObject.h" -#include "Pokemon/AutoStory/Pokemon_StoryStepJson.h" +#include "Pokemon/AutoStory/Data/Pokemon_StoryStepJson.h" #include "LegacyJsonFormat.h" #include "JsonWriter.h" diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/Data/Json_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/Data/Json_Tests.cpp index 2b4715df94..c175628922 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/Data/Json_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/Data/Json_Tests.cpp @@ -5,8 +5,7 @@ #include "Common/Cpp/Exceptions.h" #include "Common/Cpp/Json/JsonArray.h" #include "Common/Cpp/Json/JsonObject.h" -#include "Pokemon/AutoStory/Pokemon_StoryStepJson.h" -#include "JsonParser.h" +#include "Pokemon/AutoStory/Data/Pokemon_StoryStepJson.h" #include "JsonWriter.h" #include "VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h" #include "Json_Tests.h" @@ -63,13 +62,6 @@ void customize(StoryCheckpoint& row){ state.wild_foes = {"pidgey"}; } -// The export as the tool writes it to a file: with its source revision. -JsonValue exported_file(const StoryCheckpoint& row, const std::string& revision){ - JsonValue result = story_checkpoint_export(row); - result.to_object_throw()["source_revision"] = revision; - return result; -} - std::string check_export(StoryCheckpoint row, const ExportCase& test){ if (test.input.custom){ customize(row); @@ -87,11 +79,6 @@ std::string check_export(StoryCheckpoint row, const ExportCase& test){ if (!(Pokemon::story_checkpoint_json(decoded) == Pokemon::story_checkpoint_json(row))){ return "Expected every authored common field to survive export/import."; } - // Every native field too: the whole file, read back, exports the same. - const StoryCheckpoint reread = read_story_checkpoint_export(exported_file(row, "test"), "export test"); - if (!(exported_file(reread, "test") == exported_file(row, "test"))){ - return "Expected every native field to survive export/import, read " + story_checkpoint_export(reread).dump(-1); - } std::vector names; for (const auto& step : decoded.steps){ names.push_back(step.name); @@ -117,164 +104,12 @@ class ExportTest : public UnitTest{ }; -// Reading the Parcel capture built into the program (StoryData/ -// frlg-parcel-00.05.json, PokemonSimulation's data/story/native copy of -// the export tool's output): as written, it is row 00.05 and exports back -// to the same file; changed, it is refused rather than read with a guess. -struct LoadInput{ - std::string_view name; - // Applied to the capture before reading; none reads it as written. - void (*mutate)(JsonObject& root) = nullptr; - bool authored = false; -}; - -struct LoadExpectation{ - // The table row the loaded one must export like; empty when rejected. - std::string_view row = {}; - bool rejected = false; -}; - -struct LoadCase{ - LoadInput input; - LoadExpectation expectation; -}; - -// `object` without `key`: JsonObject has no erase. -JsonObject without(const JsonObject& object, std::string_view key){ - JsonObject result; - for (const auto& [name, value] : object){ - if (name != key){ - result[name] = value.clone(); - } - } - return result; -} - -void add_top_level_field(JsonObject& root){ - root["mystery"] = 1; -} - -void change_format(JsonObject& root){ - root["format"] = "pokesim-story-plan/1"; -} - -void add_native_field(JsonObject& root){ - root.get_object_throw("native_fields")["speed"] = "fast"; -} - -void unknown_menu(JsonObject& root){ - root.get_object_throw("native_fields")["menu"] = "before_bag"; -} - -void drop_potions(JsonObject& root){ - JsonObject& native = root.get_object_throw("native_fields"); - native["supplies"] = without(native.get_object_throw("supplies"), "potions"); -} - -void negative_pp(JsonObject& root){ - JsonObject& supplies = root.get_object_throw("native_fields").get_object_throw("supplies"); - supplies.get_object_throw("lead").get_array_throw("moves")[0].to_object_throw()["pp"] = -1; -} - -void foe_out_as_text(JsonObject& root){ - root.get_object_throw("native_fields").get_object_throw("supplies")["foe_out"] = "0"; -} - -void drop_revision(JsonObject& root){ - root = without(root, "source_revision"); -} - -void unknown_execution_menu(JsonObject& root){ - root.get_object_throw("execution")["menu"] = "guess"; -} - -const LoadCase LOAD_CASES[] = { - {.input = {.name = "authored Parcel plan", .authored = true}, .expectation = {.row = "00.05"}}, - {.input = {.name = "authored plan unknown field", .mutate = add_top_level_field, .authored = true}, .expectation = {.rejected = true}}, - {.input = {.name = "authored plan unknown format", .mutate = change_format, .authored = true}, .expectation = {.rejected = true}}, - {.input = {.name = "authored plan unknown menu", .mutate = unknown_execution_menu, .authored = true}, .expectation = {.rejected = true}}, - {.input = {.name = "the Parcel capture is row 00.05"}, .expectation = {.row = "00.05"}}, - {.input = {.name = "an unknown envelope field", .mutate = add_top_level_field}, .expectation = {.rejected = true}}, - {.input = {.name = "another format", .mutate = change_format}, .expectation = {.rejected = true}}, - {.input = {.name = "an unknown native field", .mutate = add_native_field}, .expectation = {.rejected = true}}, - {.input = {.name = "an unknown START menu", .mutate = unknown_menu}, .expectation = {.rejected = true}}, - {.input = {.name = "a missing supplies field", .mutate = drop_potions}, .expectation = {.rejected = true}}, - {.input = {.name = "PP below zero", .mutate = negative_pp}, .expectation = {.rejected = true}}, - {.input = {.name = "foe_out as text", .mutate = foe_out_as_text}, .expectation = {.rejected = true}}, - {.input = {.name = "no source revision", .mutate = drop_revision}, .expectation = {.rejected = true}}, -}; - -const std::string& parcel_text(const LoadInput& input){ - for (const auto& [name, text] : autostory_checkpoint_json()){ - if (name == (input.authored ? "frlg-parcel-00.05.plan" : "frlg-parcel-00.05")){ - return text; - } - } - throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "StoryData/frlg-parcel-00.05.json is not built into the program."); -} - -const StoryCheckpoint* table_row(std::string_view id){ - for (const StoryCheckpoint& row : story_checkpoints()){ - if (row.id == id){ - return &row; - } - } - return nullptr; -} - -std::string check_loaded(const StoryCheckpoint& loaded, const JsonValue& capture, const LoadCase& test){ - const std::string revision = test.input.authored ? "" : capture.to_object_throw().get_string_throw("source_revision"); - if (!test.input.authored && !(exported_file(loaded, revision) == capture)){ - return "Expected the loaded row to export as the capture, read " + story_checkpoint_export(loaded).dump(-1); - } - const StoryCheckpoint* row = table_row(test.expectation.row); - if (!row){ - return "Expected table row " + std::string(test.expectation.row) + ", read no matching row."; - } - if (!(story_checkpoint_export(loaded) == story_checkpoint_export(*row))){ - return "Expected the loaded row to export as the table's " + row->id + ", read " + story_checkpoint_export(loaded).dump(-1); - } - return ""; -} - -std::string check_load(const LoadCase& test){ - JsonValue capture = parse_json(parcel_text(test.input)); - if (test.input.mutate){ - test.input.mutate(capture.to_object_throw()); - } - try{ - const StoryCheckpoint loaded = test.input.authored ? read_authored_checkpoint(capture, test.input.name) - : read_story_checkpoint_export(capture, test.input.name); - if (test.expectation.rejected){ - return "Expected rejection, read checkpoint " + loaded.id; - } - return check_loaded(loaded, capture, test); - }catch (const ParseException& error){ - return test.expectation.rejected ? "" : "Unexpected parse failure: " + error.message(); - } -} - -class LoadTest : public UnitTest{ -public: - explicit LoadTest(LoadCase test) - : UnitTest("PokemonFRLG::CheckpointExport - read " + std::string(test.input.name)), m_test(test){} - virtual UnitTestResult run(Logger&, CancellableScope&) const override{ - const std::string error = check_load(m_test); - return error.empty() ? UnitTestResult(true) : UnitTestResult(error); - } -private: - LoadCase m_test; -}; - } // namespace void add_tests_AutoStoryJson(UnitTestDatabase& database){ for (const ExportCase& test : CASES){ database.add(test); } - for (const LoadCase& test : LOAD_CASES){ - database.add(test); - } } } // namespace PokemonFRLG diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory.cpp index 8f9fb0623a..b5ddf87766 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory.cpp @@ -13,7 +13,9 @@ #include "CommonFramework/Notifications/ProgramNotifications.h" #include "CommonFramework/VideoPipeline/VideoOverlay.h" #include "Pokemon/AutoStory/Pokemon_AutoStoryStats.h" +#include "Pokemon/AutoStory/Pokemon_StoryLog.h" #include "Pokemon/AutoStory/Pokemon_StorySegments.h" +#include "Pokemon/Options/Pokemon_GameLanguages.h" #include "Pokemon/Pokemon_Strings.h" #include "VideoGames/PokemonFRLG/PokemonFRLG_Navigation.h" #include "VideoGames/PokemonFRLG/Programs/PokemonFRLG_NamingScreenKeyboard.h" @@ -58,7 +60,14 @@ namespace{ // The start and end dropdowns' entries: the table's checkpoints, 00.01 to // 00.12b. The options hold a reference to it. const StringSelectDatabase& checkpoint_database(){ - static const StringSelectDatabase database = Pokemon::story_checkpoint_database(story_checkpoints()); + static const std::vector labels = []{ + std::vector result; + for (const StoryCheckpoint& checkpoint : story_checkpoints()){ + result.push_back(Pokemon::story_checkpoint_label(checkpoint)); + } + return result; + }(); + static const StringSelectDatabase database = Pokemon::story_checkpoint_database(labels); return database; } @@ -86,7 +95,7 @@ const char* const RUN_GIFT_RNG_TEXT = "English only. The Magikarp costs 500 and needs a free party slot; AutoStory's options leave the text fast."; AutoStory::AutoStory() - : RUN(checkpoint_database()) + : RUN(checkpoint_database(), Pokemon::FireRedLeafGreenLanguages_Database()) , NEW_GAME_FROM_TITLE( "New game from the title screen:
The game is on its title screen with no save data. " "Needed to start at 00.01. Otherwise the program loads the save, which must be the one the start checkpoint begins from.", @@ -171,7 +180,7 @@ void check_player_name(ConsoleHandle& console, const std::string& name){ // the screen as its frame if `keep_start_frame` (a save made by hand). StoryEnv story_env( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - const StoryCheckpoint& checkpoint, StoryChecks checks, bool keep_start_frame + const StoryCheckpoint& checkpoint, Pokemon::StoryCheckLevel checks, bool keep_start_frame ){ StoryEnv story{env.console, context, checkpoint.supplies, checkpoint.supplies, false, checks}; story.start_frames = program_start_frames(); @@ -251,11 +260,10 @@ void verify_story_checkpoint( ){ const std::vector& checkpoints = story_checkpoints(); const StoryCheckpoint& checkpoint = checkpoints[run.start_index()]; - StoryEnv story = story_env(env, context, checkpoint, run.checks(), false); + StoryEnv story = story_env(env, context, checkpoint, run.check_level(), false); load_verify_save(env, context, story, checkpoint); + story.language = run.language(); StoryExecutor executor(story); - executor.set_checks(run.checks()); - executor.set_language(run.language()); Pokemon::Segment segment = make_story_segment(checkpoints, executor); Pokemon::SegmentHooks hooks = story_hooks(env, story); @@ -456,7 +464,7 @@ static void run_story_rows( const Pokemon::SegmentReport report = run_segment( state, segment, Pokemon::SegmentRange{rows.front().id, rows.back().id}, policy, hooks ); - Pokemon::record_story_stats(env.current_stats(), report); + Pokemon::record_story_counts(env.current_stats(), report.story_counts()); env.update_stats(); throw_if_failed(report); } @@ -664,13 +672,12 @@ void AutoStory::program(SingleSwitchProgramEnvironment& env, ProControllerContex first = checkpoint_index(checkpoints, "00.01b"); plan = plan_story_run(checkpoints, first, last, handoffs); } - StoryEnv story = story_env(env, context, checkpoints[first], RUN.checks(), KEEP_START_FRAME); + StoryEnv story = story_env(env, context, checkpoints[first], RUN.check_level(), KEEP_START_FRAME); story.player_name = player_name; const bool at_gift_rng = plan.stop == StoryHandoff::GIFT_RNG && plan.rows.empty(); prepare_start(env, context, checkpoints, first, story, at_gift_rng); + story.language = RUN.language(); StoryExecutor executor(story); - executor.set_checks(RUN.checks()); - executor.set_language(RUN.language()); const std::optional done_through = at_gift_rng ? run_from_gift_rng_save(env, context, story, executor, first) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryAbilities.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryAbilities.cpp index c6463b2ae8..cdd03cc1a6 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryAbilities.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryAbilities.cpp @@ -82,29 +82,28 @@ Outcome fossil(Logger& logger, Fossil fossil, StoryAbilities& abilities){ std::optional run_ability_game_step( Logger& logger, VideoStream* stream, const Pokemon::StoryStep& step, StoryAbilities& abilities ){ - const std::string_view variant = step.variant; - if (variant.starts_with(MART_VARIANT_PREFIX)){ - const std::optional plan = parse_mart_variant(variant); - return plan ? mart(logger, *plan, abilities) : Pokemon::outcome_failed("bad_variant", step.variant); + if (step.action == MART_ACTION){ + const std::optional plan = mart_plan_of(step.args); + return plan ? mart(logger, *plan, abilities) : Pokemon::outcome_failed("bad_args", step.action); } - if (variant.starts_with(TEACH_VARIANT_PREFIX)){ - const std::optional plan = parse_teach_variant(variant); - return plan ? teach(logger, *plan, abilities) : Pokemon::outcome_failed("bad_variant", step.variant); + if (step.action == TEACH_ACTION){ + const std::optional plan = teach_plan_of(step.args); + return plan ? teach(logger, *plan, abilities) : Pokemon::outcome_failed("bad_args", step.action); } - if (variant.starts_with(LEVEL_VARIANT_PREFIX)){ - const std::optional check = parse_level_variant(variant); - return check ? level(logger, *check, abilities) : Pokemon::outcome_failed("bad_variant", step.variant); + if (step.action == LEVEL_ACTION){ + const std::optional check = level_check_of(step.args); + return check ? level(logger, *check, abilities) : Pokemon::outcome_failed("bad_args", step.action); } - if (variant.starts_with(GRIND_VARIANT_PREFIX)){ - const std::optional plan = parse_grind_variant(variant); - if (!plan || !step.target){ - return Pokemon::outcome_failed("bad_variant", step.variant + (step.target ? "" : " (no nurse)")); + if (step.action == GRIND_ACTION){ + const std::optional plan = grind_plan_of(step.args); + if (!plan || !step.args.contains("nurse")){ + return Pokemon::outcome_failed("bad_args", step.action + (step.args.contains("nurse") ? "" : " (no nurse)")); } return grind(logger, stream, *plan, abilities); } - if (variant.starts_with(FOSSIL_VARIANT_PREFIX)){ - const std::optional choice = parse_fossil_variant(variant); - return choice ? fossil(logger, *choice, abilities) : Pokemon::outcome_failed("bad_variant", step.variant); + if (step.action == FOSSIL_ACTION){ + const std::optional choice = fossil_of(step.args); + return choice ? fossil(logger, *choice, abilities) : Pokemon::outcome_failed("bad_args", step.action); } return std::nullopt; } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryAbilities.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryAbilities.h index 44e578840b..add8e48eff 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryAbilities.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryAbilities.h @@ -5,7 +5,7 @@ * The GAME steps beyond walking and talking that later checkpoints name * in the table: MART (a budgeted buy list), TEACH (a TM or HM), LEVEL (a * member's level checked), GRIND (wild battles to a level) and - * CHOICE(fossil). Each is a variant of a GAME step; this runs the one a + * CHOICE(fossil). Each is an action of a GAME step; this runs the one a * step names with the game steps it is given. * */ @@ -17,7 +17,7 @@ #include "Common/Cpp/Logging/AbstractLogger.h" #include "CommonFramework/Tools/VideoStream.h" #include "Pokemon/AutoStory/Pokemon_StoryEvents.h" -#include "Pokemon/AutoStory/Pokemon_StorySteps.h" +#include "Pokemon/AutoStory/Pokemon_StoryStepExecutor.h" #include "PokemonFRLG_AutoStoryChoice.h" #include "PokemonFRLG_AutoStoryGrind.h" #include "PokemonFRLG_AutoStoryMart.h" @@ -39,7 +39,7 @@ struct StoryAbilities{ }; // A MART, TEACH, LEVEL, GRIND or fossil step with `abilities`: nothing for -// another variant. A GRIND that meets a shiny throws +// another action. A GRIND that meets a shiny throws // ProgramFinishedException, with a screenshot from `stream` if given, so // the segment stops without reloading. Any other end but success is a // failed Outcome; a MART that buys nothing because the money doesn't diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryAbilities_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryAbilities_Tests.cpp index de19009225..75ecd16cc3 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryAbilities_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryAbilities_Tests.cpp @@ -115,11 +115,12 @@ class Test_AutoStoryAbilities : public UnitTest{ }; -Pokemon::StoryStep game_step(std::string variant){ +Pokemon::StoryStep game_step(std::string action, Pokemon::StoryActionArgs args){ Pokemon::StoryStep step; step.kind = Pokemon::StoryStepKind::GAME; step.name = "test"; - step.variant = std::move(variant); + step.action = std::move(action); + step.args = std::move(args); return step; } @@ -151,20 +152,21 @@ struct StepCase{ std::vector step_cases(){ const auto none = [](StubGame&){}; + const Pokemon::StoryStep mart = mart_step("mart", "", {.map = "PewterCity_Mart", .lines = {{"potion", 5}}, .budget = 2000}); const Pokemon::StoryStep grind = grind_step("grind", "", {.member = 0, .level = 20, .max_encounters = 5, .pace = Pokemon::Direction::EAST, .heal_every = 0}, {}); return { {"level reached", none, level_step("check", "", {.slot = 0, .level = 16}), "unchanged"}, {"level below", none, level_step("check", "", {.slot = 0, .level = 17}), "level_below"}, {"level unread", [](StubGame& game){ game.level.reset(); }, level_step("check", "", {.slot = 0, .level = 16}), "level_unread"}, - {"a Mart with too little money succeeds", [](StubGame& game){ game.mart.money = 100; }, game_step("mart PewterCity_Mart budget=2000 potion=5"), "unchanged"}, - {"a Mart purchase that fails", none, game_step("mart PewterCity_Mart budget=2000 potion=5"), "mart_failed"}, - {"a move it knows already succeeds", none, game_step("teach hm03 surf slot=1"), "unchanged"}, - {"a TM not in the TM Case is skipped", none, game_step("teach tm03 water-pulse slot=1 forget=water-gun"), "unchanged"}, + {"a Mart with too little money succeeds", [](StubGame& game){ game.mart.money = 100; }, mart, "unchanged"}, + {"a Mart purchase that fails", none, mart, "mart_failed"}, + {"a move it knows already succeeds", none, teach_step("teach", "", {.item = "hm03", .move = "surf", .member = 0}), "unchanged"}, + {"a TM not in the TM Case is skipped", none, teach_step("teach", "", {.item = "tm03", .move = "water-pulse", .member = 0, .forget_move = "water-gun"}), "unchanged"}, {"a level that can't be read stops a GRIND", [](StubGame& game){ game.level.reset(); }, grind, "grind_unread"}, - {"a GRIND without a nurse", none, game_step("grind slot=1 level=20"), "bad_variant"}, + {"a GRIND without a nurse", none, game_step(GRIND_ACTION, {{"slot", int64_t(1)}, {"level", int64_t(20)}}), "bad_args"}, {"no YES/NO at the fossil", none, fossil_step("fossil", "", Fossil::HELIX), "fossil_failed"}, - {"a bad variant", none, game_step("mart PewterCity_Mart"), "bad_variant"}, - {"another game step", none, game_step("capture rattata"), "none"}, + {"bad args", none, game_step(MART_ACTION, {{"map", std::string("PewterCity_Mart")}}), "bad_args"}, + {"another game step", none, capture_step("capture", "", {.species = "rattata"}), "none"}, }; } @@ -217,15 +219,21 @@ UnitTestResult test_grind_shiny_stops(){ } -UnitTestResult test_level_variant(){ - const std::string variant = level_variant({.slot = 1, .level = 23}); - const std::optional back = parse_level_variant(variant); - if (variant != "level slot=2 min=23" || !back || back->slot != 1 || back->level != 23){ - return "Unexpected level variant \"" + variant + "\"."; +UnitTestResult test_level_args(){ + const std::optional back = level_check_of(level_args({.slot = 1, .level = 23})); + if (!back || back->slot != 1 || back->level != 23){ + return "Expected slot 2, level 23 to read back."; } - for (std::string_view bad : {"level", "level slot=1", "level min=5", "level slot=0 min=5", "level slot=1 min=101"}){ - if (parse_level_variant(bad)){ - return "Expected \"" + std::string(bad) + "\" refused."; + const std::vector bad_args{ + {}, + {{"slot", int64_t(1)}}, + {{"min", int64_t(5)}}, + {{"slot", int64_t(0)}, {"min", int64_t(5)}}, + {{"slot", int64_t(1)}, {"min", int64_t(101)}}, + }; + for (const Pokemon::StoryActionArgs& bad : bad_args){ + if (level_check_of(bad)){ + return "Expected args with a missing or out-of-range value refused."; } } return true; @@ -244,7 +252,7 @@ const AutoStoryAbilitiesCase AUTO_STORY_ABILITIES_CASES[] = { .expectation = {}, }, { - .input = {"the LEVEL step's variant", test_level_variant}, + .input = {"the LEVEL step's args", test_level_args}, .expectation = {}, }, { diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryActions.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryActions.cpp index 0f4ef4de91..01f96cdb61 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryActions.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryActions.cpp @@ -895,7 +895,7 @@ static void check_mart_row(ConsoleHandle& console, ProControllerContext& context void buy_items( ConsoleHandle& console, ProControllerContext& context, - const std::vector& orders, StoryChecks checks, Language language + const std::vector& orders, Pokemon::StoryCheckLevel checks, Language language ){ // "May I help you?" with BUY on top, then the list, cursor on its top. press(context, BUTTON_A, 2000ms); @@ -912,7 +912,7 @@ void buy_items( } cursor = order.row; mart_shot(console, context, std::format("row{}-list", order.row + 1)); - if (checks == StoryChecks::THOROUGH){ + if (checks_screen(checks)){ check_mart_row(console, context, order, language); } // "How many?" drops presses while its text prints. diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryActions.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryActions.h index e08122242b..72ce278062 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryActions.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryActions.h @@ -24,7 +24,8 @@ #include "CommonFramework/ImageTypes/ImageViewRGB32.h" #include "NintendoSwitch/Controllers/Procon/NintendoSwitch_ProController.h" #include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h" -#include "Pokemon/AutoStory/Pokemon_StorySteps.h" +#include "Pokemon/AutoStory/Pokemon_StoryStepExecutor.h" +#include "Pokemon/AutoStory/Types/Pokemon_StoryCheckLevel.h" #include "Pokemon/Navigation/Pokemon_Grid.h" namespace PokemonAutomation{ @@ -32,13 +33,15 @@ namespace NintendoSwitch{ namespace PokemonFRLG{ -// How much the story checks the screen before and after it acts: the -// shared level (Pokemon_StorySteps.h, set by StoryRunOptions). For FRLG, -// THOROUGH reads a Mart row's item before buying it, the bag's Items -// pocket after shopping (the counts the story then keeps), and an item's -// name in the bag before using it. FAST trusts the counts it keeps and the -// timings. -using StoryChecks = Pokemon::StoryChecks; +// Whether the shared check level (Types/Pokemon_StoryCheckLevel.h, set by +// StoryRunOptions) has the story check the screen before and after it +// acts: DEFAULT and above (TESTING, THOROUGH). Then FRLG reads a Mart +// row's item before buying it, the bag's Items pocket after shopping (the +// counts the story then keeps), and an item's name in the bag before +// using it. FAST and SPEEDRUN trust the counts it keeps and the timings. +inline bool checks_screen(Pokemon::StoryCheckLevel level){ + return level <= Pokemon::StoryCheckLevel::DEFAULT; +} // The START menu as the story grows it. Before the starter: BAG, the // player, SAVE, OPTION, EXIT; the starter adds POKEMON on top, the Pokedex @@ -248,7 +251,7 @@ int mart_cursor_moves(int cursor, int row); // bought by position only. void buy_items( ConsoleHandle& console, ProControllerContext& context, - const std::vector& orders, StoryChecks checks, Language language + const std::vector& orders, Pokemon::StoryCheckLevel checks, Language language ); // From the title screen of a game with no save, to the bedroom: the diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattle.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattle.cpp index 9d5e93b652..8b29646821 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattle.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattle.cpp @@ -145,9 +145,9 @@ void tap(ProControllerContext& context, DpadPosition position){ // no names for) is taken by its position; only another item's name stops it. bool bag_row_is( ConsoleHandle& console, ProControllerContext& context, - int row, const std::string& item, StoryChecks checks, Language language + int row, const std::string& item, Pokemon::StoryCheckLevel checks, Language language ){ - if (checks == StoryChecks::FAST){ + if (!checks_screen(checks)){ return true; } context.wait_for_all_requests(); @@ -170,7 +170,7 @@ bool bag_row_is( // Returns whether it was used; else (THOROUGH) backs out to the menu. bool use_item( ConsoleHandle& console, ProControllerContext& context, - int row, const std::string& item, StoryChecks checks, Language language + int row, const std::string& item, Pokemon::StoryCheckLevel checks, Language language ){ console.log(std::format("Battle: using the {} in row {} of the Items pocket.", item, row + 1)); tap(context, DPAD_LEFT); @@ -300,7 +300,7 @@ class BattleLoop{ public: BattleLoop( ConsoleHandle& console, ProControllerContext& context, - Supplies& supplies, BattleKind kind, StoryChecks checks, Language language + Supplies& supplies, BattleKind kind, Pokemon::StoryCheckLevel checks, Language language ) : m_console(console) , m_context(context) @@ -647,7 +647,7 @@ class BattleLoop{ BattleEndWatch m_end; MoveRefusalWatch m_refusal; const BattleKind m_kind; - const StoryChecks m_checks; + const Pokemon::StoryCheckLevel m_checks; const Language m_language; const WallClock m_start; WallClock m_last_battle; @@ -682,7 +682,7 @@ void open_items_pocket(ConsoleHandle& console, ProControllerContext& context){ // Not run on the console yet. bool use_item_on_overworld( ConsoleHandle& console, ProControllerContext& context, - int row, const std::string& item, StoryChecks checks, Language language + int row, const std::string& item, Pokemon::StoryCheckLevel checks, Language language ){ console.log(std::format("Story: using a {} from the bag (Items pocket, row {}).", item, row + 1)); open_items_pocket(console, context); @@ -715,7 +715,7 @@ void fail_on_blackout(ConsoleHandle& console, BattleEnd end){ // appeared!". class StoryWildBattle : public OverworldInterrupt{ public: - StoryWildBattle(Supplies& supplies, bool fight, bool late, StoryChecks checks, Language language) + StoryWildBattle(Supplies& supplies, bool fight, bool late, Pokemon::StoryCheckLevel checks, Language language) : m_supplies(supplies) , m_checks(checks) , m_language(language) @@ -746,7 +746,7 @@ class StoryWildBattle : public OverworldInterrupt{ private: Supplies& m_supplies; - const StoryChecks m_checks; + const Pokemon::StoryCheckLevel m_checks; const Language m_language; const bool m_fight; const bool m_late; @@ -755,7 +755,7 @@ class StoryWildBattle : public OverworldInterrupt{ // A message: read to its end, then a trainer's battle if one starts. class StoryMessage : public OverworldInterrupt{ public: - StoryMessage(Supplies& supplies, StoryChecks checks, Language language) + StoryMessage(Supplies& supplies, Pokemon::StoryCheckLevel checks, Language language) : m_supplies(supplies) , m_checks(checks) , m_language(language) @@ -775,7 +775,7 @@ class StoryMessage : public OverworldInterrupt{ private: Supplies& m_supplies; - const StoryChecks m_checks; + const Pokemon::StoryCheckLevel m_checks; const Language m_language; }; @@ -941,7 +941,7 @@ std::vector read_items_pocket(ConsoleHandle& console, ProControllerConte void recover_after_battle( ConsoleHandle& console, ProControllerContext& context, - Supplies& supplies, StoryChecks checks, Language language + Supplies& supplies, Pokemon::StoryCheckLevel checks, Language language ){ if (supplies.status == StatusCondition::POISON && supplies.antidotes > 0){ if (use_item_on_overworld(console, context, item_row(supplies, "antidote"), "antidote", checks, language)){ @@ -968,12 +968,12 @@ void recover_after_battle( BattleEnd fight_battle( ConsoleHandle& console, ProControllerContext& context, - Supplies& supplies, BattleKind kind, StoryChecks checks, Language language + Supplies& supplies, BattleKind kind, Pokemon::StoryCheckLevel checks, Language language ){ return BattleLoop(console, context, supplies, kind, checks, language).run(); } -void clear_overworld_message(ConsoleHandle& console, ProControllerContext& context, Supplies& supplies, StoryChecks checks, Language language){ +void clear_overworld_message(ConsoleHandle& console, ProControllerContext& context, Supplies& supplies, Pokemon::StoryCheckLevel checks, Language language){ if (advance_text(console, context, AFTER_BATTLE_TEXT, true) == TextEnd::OVERWORLD){ return; } @@ -983,7 +983,7 @@ void clear_overworld_message(ConsoleHandle& console, ProControllerContext& conte recover_after_battle(console, context, supplies, checks, language); } -OverworldInterruptSet story_interrupts(Supplies& supplies, bool fight_wild, StoryChecks checks, Language language){ +OverworldInterruptSet story_interrupts(Supplies& supplies, bool fight_wild, Pokemon::StoryCheckLevel checks, Language language){ // Battles first: their screens are checked before the message box's. OverworldInterruptSet ret; ret.wild.emplace_back(std::make_unique(supplies, fight_wild, false, checks, language)); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattle.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattle.h index 6ca186175e..e4ce8eb461 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattle.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattle.h @@ -193,7 +193,7 @@ bool battle_shows(const ImageViewRGB32& screen); // different one isn't used. BattleEnd fight_battle( ConsoleHandle& console, ProControllerContext& context, - Supplies& supplies, BattleKind kind, StoryChecks checks, Language language + Supplies& supplies, BattleKind kind, Pokemon::StoryCheckLevel checks, Language language ); @@ -202,7 +202,7 @@ BattleEnd fight_battle( // The bag's inputs are not checked on the console yet. void recover_after_battle( ConsoleHandle& console, ProControllerContext& context, - Supplies& supplies, StoryChecks checks, Language language + Supplies& supplies, Pokemon::StoryCheckLevel checks, Language language ); @@ -212,7 +212,7 @@ void recover_after_battle( // OperationFailedException. void clear_overworld_message( ConsoleHandle& console, ProControllerContext& context, - Supplies& supplies, StoryChecks checks, Language language + Supplies& supplies, Pokemon::StoryCheckLevel checks, Language language ); @@ -220,7 +220,7 @@ void clear_overworld_message( // fought if `fight_wild`. A message is advanced until the overworld is // back; a battle that starts after it (a trainer who saw the player) is // fought. A battle lost (a blackout) throws OperationFailedException. -OverworldInterruptSet story_interrupts(Supplies& supplies, bool fight_wild, StoryChecks checks, Language language); +OverworldInterruptSet story_interrupts(Supplies& supplies, bool fight_wild, Pokemon::StoryCheckLevel checks, Language language); // Registers AutoStory item usage unit tests. diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCapture.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCapture.cpp index 860a78a259..dda0707877 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCapture.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCapture.cpp @@ -22,6 +22,7 @@ #include "VideoGames/PokemonFRLG/Programs/PokemonFRLG_BattleMenuNavigation.h" #include "PokemonFRLG_AutoStoryActions.h" #include "PokemonFRLG_AutoStoryCapture.h" +#include "PokemonFRLG_AutoStoryGameArgs.h" namespace PokemonAutomation{ namespace NintendoSwitch{ @@ -36,45 +37,6 @@ namespace{ constexpr size_t PARTY_SIZE = 6; constexpr size_t MOVE_COUNT = 4; -std::vector words_of(std::string_view text){ - std::vector words; - while (!text.empty()){ - const size_t space = text.find(' '); - const std::string_view word = text.substr(0, space); - if (!word.empty()){ - words.push_back(word); - } - if (space == std::string_view::npos){ - break; - } - text.remove_prefix(space + 1); - } - return words; -} - -std::optional number_of(std::string_view text){ - if (text.empty() || text.size() > 4){ - return std::nullopt; - } - size_t value = 0; - for (char c : text){ - if (c < '0' || c > '9'){ - return std::nullopt; - } - value = value * 10 + size_t(c - '0'); - } - return value; -} - -std::optional direction_of(std::string_view text){ - for (Direction direction : Pokemon::ALL_DIRECTIONS){ - if (text == direction_name(direction)){ - return direction; - } - } - return std::nullopt; -} - Direction opposite(Direction direction){ switch (direction){ case Direction::NORTH: return Direction::SOUTH; @@ -110,57 +72,38 @@ const char* capture_end_name(CaptureEnd end){ } -std::string capture_variant(const CapturePlan& plan){ - std::string variant = std::format( - "{}{} catches={} encounters={} balls={} pace={}", - CAPTURE_VARIANT_PREFIX, plan.species, plan.catches, plan.max_encounters, plan.max_balls, direction_name(plan.pace) - ); +Pokemon::StoryActionArgs capture_args(const CapturePlan& plan){ + Pokemon::StoryActionArgs args{ + {"species", plan.species}, + {"catches", int64_t(plan.catches)}, + {"encounters", int64_t(plan.max_encounters)}, + {"balls", int64_t(plan.max_balls)}, + {"pace", plan.pace}, + {"turns", int64_t(plan.max_weaken_turns)}, + }; if (plan.weaken_move){ - variant += std::format(" move={} turns={}", *plan.weaken_move + 1, plan.max_weaken_turns); + args.emplace("move", int64_t(*plan.weaken_move + 1)); } - return variant; + return args; } -std::optional parse_capture_variant(std::string_view variant){ - if (!variant.starts_with(CAPTURE_VARIANT_PREFIX)){ - return std::nullopt; - } - const std::vector words = words_of(variant.substr(CAPTURE_VARIANT_PREFIX.size())); - if (words.empty() || words[0].find('=') != std::string_view::npos){ +std::optional capture_plan_of(const Pokemon::StoryActionArgs& args){ + const std::string* species = game_arg(args, "species"); + const std::optional catches = number_arg(args, "catches", 1, 999); + const std::optional encounters = number_arg(args, "encounters", 1, 9999); + const std::optional balls = number_arg(args, "balls", 1, 999); + const std::optional turns = number_arg(args, "turns", 0, 99); + const Direction* pace = game_arg(args, "pace"); + if (species == nullptr || species->empty() || !catches || !encounters || !balls || !turns || pace == nullptr){ return std::nullopt; } - CapturePlan plan; - plan.species = std::string(words[0]); - for (size_t c = 1; c < words.size(); c++){ - const size_t equals = words[c].find('='); - if (equals == std::string_view::npos){ - return std::nullopt; - } - const std::string_view key = words[c].substr(0, equals); - const std::string_view value = words[c].substr(equals + 1); - if (key == "pace"){ - const std::optional pace = direction_of(value); - if (!pace){ - return std::nullopt; - } - plan.pace = *pace; - continue; - } - const std::optional number = number_of(value); - if (!number){ - return std::nullopt; - } - if (key == "catches" && *number >= 1){ - plan.catches = *number; - }else if (key == "encounters" && *number >= 1){ - plan.max_encounters = *number; - }else if (key == "balls" && *number >= 1){ - plan.max_balls = *number; - }else if (key == "move" && *number >= 1 && *number <= MOVE_COUNT){ - plan.weaken_move = *number - 1; - }else if (key == "turns"){ - plan.max_weaken_turns = *number; - }else{ + CapturePlan plan{ + .species = *species, .catches = *catches, .max_encounters = *encounters, .max_balls = *balls, + .pace = *pace, .max_weaken_turns = *turns, + }; + if (args.contains("move")){ + plan.weaken_move = counted_arg(args, "move", MOVE_COUNT); + if (!plan.weaken_move){ return std::nullopt; } } @@ -172,7 +115,8 @@ Pokemon::StoryStep capture_step(std::string name, std::string why, const Capture step.kind = Pokemon::StoryStepKind::GAME; step.name = std::move(name); step.why = std::move(why); - step.variant = capture_variant(plan); + step.action = CAPTURE_ACTION; + step.args = capture_args(plan); return step; } @@ -181,7 +125,8 @@ Pokemon::StoryStep pc_step(std::string name, std::string why, const PcTransfer& step.kind = Pokemon::StoryStepKind::GAME; step.name = std::move(name); step.why = std::move(why); - step.variant = pc_variant(transfer); + step.action = PC_ACTION; + step.args = pc_args(transfer); return step; } @@ -396,10 +341,10 @@ std::optional run_storage_game_step( Logger& logger, VideoStream* stream, const Pokemon::StoryStep& step, CaptureActions& capture, PcStorageActions& pc ){ - if (step.variant.starts_with(CAPTURE_VARIANT_PREFIX)){ - const std::optional plan = parse_capture_variant(step.variant); + if (step.action == CAPTURE_ACTION){ + const std::optional plan = capture_plan_of(step.args); if (!plan){ - return Pokemon::outcome_failed("bad_variant", step.variant); + return Pokemon::outcome_failed("bad_args", step.action); } const CaptureResult result = run_capture(logger, capture, *plan, pc.read_party().size()); const std::string message = capture_message(*plan, result); @@ -416,10 +361,10 @@ std::optional run_storage_game_step( } return Pokemon::outcome_failed(std::string("capture_") + capture_end_name(result.end), message); } - if (step.variant.starts_with(PC_VARIANT_PREFIX)){ - const std::optional transfer = parse_pc_variant(step.variant); + if (step.action == PC_ACTION){ + const std::optional transfer = pc_transfer_of(step.args); if (!transfer){ - return Pokemon::outcome_failed("bad_variant", step.variant); + return Pokemon::outcome_failed("bad_args", step.action); } const PcResult result = run_pc_transfer(logger, pc, *transfer); switch (result.end){ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCapture.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCapture.h index 26b99c5df5..b254a9a30a 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCapture.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCapture.h @@ -36,7 +36,8 @@ #include "NintendoSwitch/Controllers/Procon/NintendoSwitch_ProController.h" #include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h" #include "Pokemon/AutoStory/Pokemon_StoryEvents.h" -#include "Pokemon/AutoStory/Pokemon_StorySteps.h" +#include "Pokemon/AutoStory/Pokemon_StoryStepExecutor.h" +#include "Pokemon/AutoStory/Types/Pokemon_StoryActionSpec.h" #include "Pokemon/Navigation/Pokemon_Grid.h" #include "PokemonFRLG_AutoStoryPcStorage.h" @@ -65,17 +66,16 @@ struct CapturePlan{ size_t max_weaken_turns = 2; }; -// The prefix of a GAME step's variant that names a capture step. -inline constexpr std::string_view CAPTURE_VARIANT_PREFIX = "capture "; - -// `plan` as a GAME step's variant, e.g. "capture rattata catches=1 -// encounters=20 balls=5 pace=east", with " move=1 turns=2" when it -// weakens (the move counted from 1). -std::string capture_variant(const CapturePlan& plan); -// A variant from capture_variant(), whose keys after the species may come -// in any order or be left out (their defaults); nothing if `variant` isn't -// one or has a key or value it doesn't know. -std::optional parse_capture_variant(std::string_view variant); +// The GAME action of a capture step: species WORD (required); catches +// INTEGER (1); encounters INTEGER (20); balls INTEGER (5); pace DIRECTION +// (east); move INTEGER (optional, from 1), the move that weakens; turns +// INTEGER (2). +inline const std::string CAPTURE_ACTION = "capture"; +// `plan` as its action's args. +Pokemon::StoryActionArgs capture_args(const CapturePlan& plan); +// The plan a CAPTURE_ACTION step's args give; nothing if one is out of +// range. +std::optional capture_plan_of(const Pokemon::StoryActionArgs& args); // The table's step that runs `plan`. Pokemon::StoryStep capture_step(std::string name, std::string why, const CapturePlan& plan); @@ -98,7 +98,7 @@ enum class FoeHp{ RED, }; -// How an attack turn during a capture concluded. +// How an attack turn during a capture concluded. enum class TurnEnd{ // The battle menu is back. MENU, @@ -109,7 +109,7 @@ enum class TurnEnd{ FAILED, }; -// The result of throwing a ball during a capture attempt. +// The result of throwing a ball during a capture attempt. enum class ThrowEnd{ // Caught: its first message shows. CAUGHT, @@ -121,12 +121,12 @@ enum class ThrowEnd{ FAILED, }; -// Where a captured Pokemon was sent. +// Where a captured Pokemon was sent. enum class CatchDestination{ PARTY, PC, }; -// The human-readable name of a catch destination. +// The human-readable name of a catch destination. const char* destination_name(CatchDestination destination); // The game steps a capture takes, injected so its decisions run in tests. @@ -155,7 +155,7 @@ class CaptureActions{ virtual bool finish_catch(CatchDestination destination) = 0; }; -// How an encounter capture attempt concluded. +// How an encounter capture attempt concluded. enum class CaptureEnd{ CAUGHT, OUT_OF_ENCOUNTERS, @@ -166,10 +166,10 @@ enum class CaptureEnd{ PLAYER_FAINTED, FAILED, }; -// The human-readable name of a capture end outcome. +// The human-readable name of a capture end outcome. const char* capture_end_name(CaptureEnd end); -// The summary result of a capture attempt. +// The summary result of a capture attempt. struct CaptureResult{ CaptureEnd end = CaptureEnd::FAILED; size_t encounters = 0; @@ -192,7 +192,7 @@ std::string capture_message(const CapturePlan& plan, const CaptureResult& result // A capture or PC GAME step (see capture_step(), pc_step()) with these -// actions, the party read from `pc`: nothing for another variant. A capture that ends on a shiny +// actions, the party read from `pc`: nothing for another action. A capture that ends on a shiny // throws ProgramFinishedException, so the segment stops without // reloading, with a screenshot from `stream` if given; any other end but // CAUGHT is a failed Outcome, as is a PC step that fails or is refused. @@ -311,12 +311,12 @@ class ConsoleCaptureActions : public CaptureActions{ }; -// Register auto-story capture unit tests. +// Register auto-story capture unit tests. void add_tests_AutoStoryCapture(UnitTestDatabase& database); -} // namespace PokemonFRLG -} // namespace NintendoSwitch -} // namespace PokemonAutomation +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation #endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCapture_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCapture_Tests.cpp index f3fa9e4161..015231f01a 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCapture_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCapture_Tests.cpp @@ -4,7 +4,7 @@ * * The capture step's decisions against a fake game: which encounters are * run from, when balls or encounters run out, where a catch goes, what a - * shiny stops; its table variant; and a capture and a PC step run by the + * shiny stops; its args; and a capture and a PC step run by the * shared segment runner, as the program runs them, to show which failures * reload the save and which stop the program. * @@ -20,8 +20,9 @@ #include "Common/Cpp/TestRunners/UnitTest.h" #include "CommonFramework/Exceptions/ProgramFinishedException.h" #include "Pokemon/AutoStory/Pokemon_StorySegments.h" -#include "Pokemon/AutoStory/Pokemon_StorySteps.h" +#include "Pokemon/AutoStory/Pokemon_StoryStepExecutor.h" #include "PokemonFRLG_AutoStoryCapture.h" +#include "PokemonFRLG_AutoStoryStepTable.h" namespace PokemonAutomation{ namespace NintendoSwitch{ @@ -169,35 +170,35 @@ class FakeCaptureGame : public CaptureActions{ }; -struct AutoStoryCaptureInput{ - std::string name; - std::function body; -}; - -struct AutoStoryCaptureExpectation{ -}; - -struct AutoStoryCaptureCase{ - AutoStoryCaptureInput input; - AutoStoryCaptureExpectation expectation; -}; - +struct AutoStoryCaptureInput{ + std::string name; + std::function body; +}; + +struct AutoStoryCaptureExpectation{ +}; + +struct AutoStoryCaptureCase{ + AutoStoryCaptureInput input; + AutoStoryCaptureExpectation expectation; +}; + class Test_AutoStoryCapture : public UnitTest{ public: - explicit Test_AutoStoryCapture(AutoStoryCaptureCase test_case) - : UnitTest("PokemonFRLG::AutoStoryCapture - " + test_case.input.name) - , m_case(std::move(test_case)) + explicit Test_AutoStoryCapture(AutoStoryCaptureCase test_case) + : UnitTest("PokemonFRLG::AutoStoryCapture - " + test_case.input.name) + , m_case(std::move(test_case)) {} virtual UnitTestResult run(Logger&, CancellableScope&) const override{ try{ - return m_case.input.body(); + return m_case.input.body(); }catch (Exception& e){ return std::string(e.name()) + ": " + e.message(); } } private: - AutoStoryCaptureCase m_case; + AutoStoryCaptureCase m_case; }; @@ -341,39 +342,48 @@ UnitTestResult test_capture_decisions(){ } -// The table's variant, both ways, and the variants it refuses. -UnitTestResult test_capture_variant(){ +// The step's args, both ways, and the args it refuses. +UnitTestResult test_capture_args(){ const std::vector plans = { RATTATA, {.species = "pidgey", .catches = 2, .max_encounters = 30, .max_balls = 8, .pace = Direction::NORTH, .weaken_move = 3, .max_weaken_turns = 1}, }; for (const CapturePlan& plan : plans){ - const std::string variant = capture_variant(plan); - const std::optional back = parse_capture_variant(variant); + const std::optional back = capture_plan_of(capture_args(plan)); if (!back || back->species != plan.species || back->catches != plan.catches || back->max_encounters != plan.max_encounters || back->max_balls != plan.max_balls || back->pace != plan.pace || back->weaken_move != plan.weaken_move - || (plan.weaken_move && back->max_weaken_turns != plan.max_weaken_turns) + || back->max_weaken_turns != plan.max_weaken_turns ){ - return "\"" + variant + "\" didn't read back as the plan it was made from."; + return "The " + plan.species + " plan didn't read back from its args."; } } - const std::optional short_form = parse_capture_variant("capture rattata"); - if (!short_form || short_form->species != "rattata" || short_form->max_balls != 5 || short_form->weaken_move){ - return "Expected \"capture rattata\" to read with the defaults."; + const Pokemon::StoryActionSpec* spec = Pokemon::find_story_action(story_action_specs(), Pokemon::StoryStepKind::GAME, CAPTURE_ACTION); + if (spec == nullptr){ + return "No capture action among FRLG's actions."; } - for (std::string_view bad : { - "capture", "capture ", "capture balls=3", "capture rattata balls=0", "capture rattata move=5", - "capture rattata pace=up", "capture rattata colour=red", "capture rattata balls", "pc deposit slot=2 box=1", - }){ - if (parse_capture_variant(bad)){ - return "Expected \"" + std::string(bad) + "\" refused."; + const Pokemon::StoryActionArgs short_form = Pokemon::with_fallbacks(*spec, {{"species", std::string("rattata")}}); + const std::optional defaults = capture_plan_of(short_form); + if (!defaults || defaults->species != "rattata" || defaults->max_balls != 5 || defaults->weaken_move){ + return "Expected a capture of only a species to read with the defaults."; + } + const std::vector> bad_args{ + {"species", std::string("")}, + {"balls", int64_t(0)}, + {"move", int64_t(5)}, + {"pace", std::string("up")}, + }; + for (const auto& [key, value] : bad_args){ + Pokemon::StoryActionArgs args = short_form; + args[key] = value; + if (capture_plan_of(args)){ + return "Expected a bad " + key + " refused."; } } const Pokemon::StoryStep step = capture_step("catch_rattata", "Cut user", RATTATA); - if (step.kind != Pokemon::StoryStepKind::GAME || !parse_capture_variant(step.variant)){ - return "Expected capture_step() to be a GAME step with a capture variant."; + if (step.kind != Pokemon::StoryStepKind::GAME || step.action != CAPTURE_ACTION || !capture_plan_of(step.args)){ + return "Expected capture_step() to be a GAME capture step with its plan's args."; } return true; } @@ -436,8 +446,10 @@ class StorageExecutor : public Pokemon::StoryStepExecutor{ FakeCaptureGame capture; IdlePc pc; -protected: - virtual Pokemon::Outcome game(Pokemon::RunState&, const StoryStep& step) override{ + virtual Pokemon::Outcome run(Pokemon::RunState&, const StoryStep& step) override{ + if (step.kind != Pokemon::StoryStepKind::GAME){ + return Pokemon::unsupported_step(step); + } const std::optional outcome = run_storage_game_step(logger, nullptr, step, capture, pc); return outcome ? *outcome : Pokemon::unsupported_step(step); } @@ -613,40 +625,40 @@ UnitTestResult test_pace_until_battle(){ return true; } -} // namespace - - -const AutoStoryCaptureCase AUTO_STORY_CAPTURE_CASES[] = { - { - .input = {"decisions by encounter", test_capture_decisions}, - .expectation = {}, - }, - { - .input = {"the table's variant", test_capture_variant}, - .expectation = {}, - }, - { - .input = {"messages", test_capture_messages}, - .expectation = {}, - }, - { - .input = {"capture and PC steps in a segment: reloads and stops", test_capture_in_segment}, - .expectation = {}, - }, - { - .input = {"pacing finds a battle whose flash was missed", test_pace_until_battle}, - .expectation = {}, - }, -}; - +} // namespace + + +const AutoStoryCaptureCase AUTO_STORY_CAPTURE_CASES[] = { + { + .input = {"decisions by encounter", test_capture_decisions}, + .expectation = {}, + }, + { + .input = {"the step's args", test_capture_args}, + .expectation = {}, + }, + { + .input = {"messages", test_capture_messages}, + .expectation = {}, + }, + { + .input = {"capture and PC steps in a segment: reloads and stops", test_capture_in_segment}, + .expectation = {}, + }, + { + .input = {"pacing finds a battle whose flash was missed", test_pace_until_battle}, + .expectation = {}, + }, +}; + void add_tests_AutoStoryCapture(UnitTestDatabase& database){ - for (const auto& item : AUTO_STORY_CAPTURE_CASES){ - database.add(item); - } + for (const auto& item : AUTO_STORY_CAPTURE_CASES){ + database.add(item); + } } -} // namespace PokemonFRLG -} // namespace NintendoSwitch -} // namespace PokemonAutomation +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCeladon_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCeladon_Tests.cpp index 853b4e4af7..d82280fc15 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCeladon_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCeladon_Tests.cpp @@ -2,7 +2,7 @@ * * From: https://github.com/PokemonAutomation/ * - * Rows from 00.26 on (PokemonFRLG_AutoStoryTableCeladon.cpp) on the + * Rows from 00.26 on (StoryData/frlg-00.26.plan.json and after) on the * overworld sim: 00.26 from where 00.25 ends, to the Fan Club's chairman, * north past Route 6's trainers, through the tree into Cerulean, to the * Bike Shop's clerk, the Mart and the nurse, with Oak's aide on @@ -21,14 +21,16 @@ #include #include "Common/Cpp/Exceptions.h" #include "Common/Cpp/TestRunners/UnitTest.h" +#include "Pokemon/AutoStory/Pokemon_BuiltinStoryActions.h" +#include "Pokemon/AutoStory/Pokemon_StoryStepExecutor.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h" #include "PokemonFRLG_AutoStoryEvents.h" #include "PokemonFRLG_AutoStoryMart.h" #include "PokemonFRLG_AutoStoryRowSim.h" +#include "PokemonFRLG_AutoStoryRows_Tests.h" #include "PokemonFRLG_AutoStoryTable.h" -#include "PokemonFRLG_AutoStoryTableSteps.h" namespace PokemonAutomation{ namespace NintendoSwitch{ @@ -37,6 +39,14 @@ namespace PokemonFRLG{ namespace{ +const std::string ROUTE6 = "Route6"; +const std::string VERMILION = "VermilionCity"; +const std::string BIKE_SHOP = "CeruleanCity_BikeShop"; +const std::string CERULEAN_CENTER = "CeruleanCity_PokemonCenter_1F"; +const std::string CERULEAN_MART = "CeruleanCity_Mart"; +const std::string ROUTE10_CENTER = "Route10_PokemonCenter_1F"; +const std::string ROUTE9 = "Route9"; + struct AutoStoryCeladonInput{ std::string name; std::function body; @@ -99,7 +109,7 @@ std::vector maps_after_surge(){ flags.merge(map_flag_set(all, "new_game")); flags.erase("FLAG_HIDE_VERMILION_CITY_OAKS_AIDE"); std::vector maps = overworld_maps(flags); - for (MapObject& object : map_named(maps, StoryTable::ROUTE6).objects){ + for (MapObject& object : map_named(maps, ROUTE6).objects){ if (object.name == "camper" && object.trainer){ object.trainer.reset(); } @@ -124,8 +134,8 @@ const MapObject* object_ahead(const std::vector& maps, const StoryPose& // The row's last route's target. std::optional last_target(const StoryCheckpoint& row){ for (auto step = row.steps.rbegin(); step != row.steps.rend(); ++step){ - if (step->kind == StoryStepKind::ROUTE && step->target){ - return story_pose(*step->target); + if (step->kind == StoryStepKind::ROUTE && step->args.contains("target")){ + return story_pose(Pokemon::pose_of(Pokemon::story_arg(step->args, "target"))); } } return std::nullopt; @@ -140,7 +150,7 @@ UnitTestResult starts_where_ends(const std::string& previous, const std::string& } const std::optional end = last_target(checkpoint(previous)); const StoryCheckpoint& row = checkpoint(id); - const std::optional start = row.start ? story_pose(*row.start) : std::nullopt; + const std::optional start = row.start ? story_pose(Pokemon::pose_of(*row.start)) : std::nullopt; if (!end || !start || start->map != end->map || !(start->tile == end->tile) || start->facing != end->facing){ return "Expected " + id + " to start where " + previous + "'s last walk ends."; } @@ -165,17 +175,17 @@ UnitTestResult test_starts_where_bicycle_ends(){ UnitTestResult test_bike_voucher_row(){ const StoryCheckpoint& row = checkpoint("00.26"); const std::vector maps = maps_after_surge(); - const MapData& city = *std::find_if(maps.begin(), maps.end(), [](const MapData& map){ return map.name == StoryTable::VERMILION; }); + const MapData& city = *std::find_if(maps.begin(), maps.end(), [](const MapData& map){ return map.name == VERMILION; }); if (object_at(city, {25, 7}) == nullptr){ return "Expected Oak's aide on (25, 7) after Lt. Surge."; } - StoryPose at = *story_pose(*row.start); + StoryPose at = *story_pose(Pokemon::pose_of(*row.start)); OverworldSim sim(maps, MapPosition{at.map, at.tile}, *at.facing); std::vector talked_to; for (const StoryStep& step : row.steps){ if (step.kind == StoryStepKind::TALK){ const StoryPose here{sim.state().position.map, sim.state().position.point, sim.state().facing}; - const bool counter = here.map == StoryTable::BIKE_SHOP; + const bool counter = here.map == BIKE_SHOP; const MapObject* person = object_ahead(maps, here, counter ? 2 : 1); if (person == nullptr || (counter && object_ahead(maps, here, 1) != nullptr)){ return std::format("00.26/{}: no one to talk to from {}.", step.name, to_string(sim.state().position)); @@ -197,7 +207,7 @@ UnitTestResult test_bike_voucher_row(){ if (!sim.state().trainers_beaten.empty() || !sim.state().violations.empty()){ return "00.26: a battle or a violation on the way" + (sim.state().violations.empty() ? std::string(".") : ": " + sim.state().violations.back()); } - const MapPosition nurse{StoryTable::CERULEAN_CENTER, {7, 4}}; + const MapPosition nurse{CERULEAN_CENTER, {7, 4}}; if (!(sim.state().position == nurse)){ return "00.26: ended on " + to_string(sim.state().position) + ", not Cerulean's nurse."; } @@ -209,13 +219,17 @@ UnitTestResult test_bike_voucher_row(){ UnitTestResult test_repels_and_escape_ropes(){ const StoryCheckpoint& row = checkpoint("00.26"); const auto step = std::find_if(row.steps.begin(), row.steps.end(), [](const StoryStep& data){ - return parse_mart_variant(data.variant).has_value(); + return data.action == MART_ACTION; }); if (step == row.steps.end()){ return "00.26: expected a Mart step."; } - const MartPlan plan = *parse_mart_variant(step->variant); - if (plan.map != StoryTable::CERULEAN_MART || !plan.money_floor){ + const std::optional parsed = mart_plan_of(step->args); + if (!parsed){ + return "00.26: expected a Mart plan."; + } + const MartPlan& plan = *parsed; + if (plan.map != CERULEAN_MART || !plan.money_floor){ return "00.26: expected the Mart step at Cerulean's Mart, with a money floor."; } const std::optional> buys = plan_mart_buys(mart_stock(plan.map), plan, *plan.money_floor); @@ -244,14 +258,14 @@ UnitTestResult test_repels_and_escape_ropes(){ UnitTestResult test_route10_row(){ const StoryCheckpoint& row = checkpoint("00.27"); const std::vector maps = maps_after_surge(); - StoryPose at = *story_pose(*row.start); + StoryPose at = *story_pose(Pokemon::pose_of(*row.start)); OverworldSim sim(maps, MapPosition{at.map, at.tile}, *at.facing); for (const StoryStep& step : row.steps){ if (const std::string failure = row_step_on_sim(sim, at, step, row.id); !failure.empty()){ return failure; } // A step into a trainer's line ends where the battle after it says. - const bool into_line = step.kind == StoryStepKind::STEP && !step.variant.empty(); + const bool into_line = step.kind == StoryStepKind::STEP && !step.action.empty(); if (!into_line && !(sim.state().position == MapPosition{at.map, at.tile})){ return std::format("00.27/{}: expected {}, on {}.", step.name, to_string(MapPosition{at.map, at.tile}), to_string(sim.state().position)); } @@ -262,7 +276,7 @@ UnitTestResult test_route10_row(){ if (!sim.state().violations.empty()){ return "00.27: a violation on the way: " + sim.state().violations.back(); } - const MapPosition nurse{StoryTable::ROUTE10_CENTER, {7, 4}}; + const MapPosition nurse{ROUTE10_CENTER, {7, 4}}; if (!(sim.state().position == nurse)){ return "00.27: ended on " + to_string(sim.state().position) + ", not Route 10's nurse."; } @@ -272,7 +286,7 @@ UnitTestResult test_route10_row(){ // The next row starts from 00.27's save in Route 10's Center, whose save // card says ROUTE 10: a place of its own, not Route 1's. UnitTestResult test_route10_save_place(){ - if (save_card_place(StoryTable::ROUTE10_CENTER) != "route-10" || save_card_place("Route1") == "route-10"){ + if (save_card_place(ROUTE10_CENTER) != "route-10" || save_card_place("Route1") == "route-10"){ return "Wrong save card place for Route 10's Pokemon Center."; } return true; @@ -301,7 +315,7 @@ std::vector route10_walk(){ return std::vector(first, last + 1); } -const StoryPose ROUTE10_WALK_START{StoryTable::ROUTE9, {70, 8}, Direction::EAST}; +const StoryPose ROUTE10_WALK_START{ROUTE9, {70, 8}, Direction::EAST}; // `steps` from `first` on, on `sim` from `at`, where the table says the // player stands: the failure, or empty once at Route 10's nurse. @@ -310,7 +324,7 @@ std::string route10_walk_rest(OverworldSim& sim, StoryPose at, const std::vector for (size_t c = first; c < steps.size() && failure.empty(); c++){ failure = row_step_on_sim(sim, at, steps[c], "00.27"); } - const MapPosition nurse{StoryTable::ROUTE10_CENTER, {7, 4}}; + const MapPosition nurse{ROUTE10_CENTER, {7, 4}}; if (!failure.empty() || !(sim.state().position == nurse)){ return std::format("ended on {}, not Route 10's nurse; {}", to_string(sim.state().position), failure); } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryChoice.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryChoice.cpp index 7bd64d3949..78137cc345 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryChoice.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryChoice.cpp @@ -11,6 +11,7 @@ #include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" #include "PokemonFRLG_AutoStoryActions.h" #include "PokemonFRLG_AutoStoryChoice.h" +#include "PokemonFRLG_AutoStoryGameArgs.h" namespace PokemonAutomation{ namespace NintendoSwitch{ @@ -50,15 +51,12 @@ const char* choice_end_name(ChoiceEnd end){ } -std::string fossil_variant(Fossil fossil){ - return std::string(FOSSIL_VARIANT_PREFIX) + fossil_name(fossil); -} - -std::optional parse_fossil_variant(std::string_view variant){ - if (!variant.starts_with(FOSSIL_VARIANT_PREFIX)){ +std::optional fossil_of(const Pokemon::StoryActionArgs& args){ + const std::string* name = game_arg(args, "fossil"); + if (name == nullptr){ return std::nullopt; } - return fossil_from_name(variant.substr(FOSSIL_VARIANT_PREFIX.size())); + return fossil_from_name(*name); } Pokemon::StoryStep fossil_step(std::string name, std::string why, Fossil fossil){ @@ -66,7 +64,8 @@ Pokemon::StoryStep fossil_step(std::string name, std::string why, Fossil fossil) step.kind = Pokemon::StoryStepKind::GAME; step.name = std::move(name); step.why = std::move(why); - step.variant = fossil_variant(fossil); + step.action = FOSSIL_ACTION; + step.args = {{"fossil", std::string(fossil_name(fossil))}}; return step; } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryChoice.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryChoice.h index 59443c6675..4bfaff25a8 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryChoice.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryChoice.h @@ -33,7 +33,8 @@ #include "Common/Cpp/TestRunners/UnitTestDatabase.h" #include "NintendoSwitch/Controllers/Procon/NintendoSwitch_ProController.h" #include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h" -#include "Pokemon/AutoStory/Pokemon_StorySteps.h" +#include "Pokemon/AutoStory/Pokemon_StoryStepExecutor.h" +#include "Pokemon/AutoStory/Types/Pokemon_StoryActionSpec.h" #include "Pokemon/Navigation/Pokemon_Grid.h" namespace PokemonAutomation{ @@ -54,13 +55,11 @@ std::optional fossil_from_name(std::string_view name); // Where `fossil` lies on MtMoon_B2F (map.json object_events). Pokemon::TilePos fossil_tile(Fossil fossil); -// The prefix of a GAME step's variant that names the fossil CHOICE. -inline constexpr std::string_view FOSSIL_VARIANT_PREFIX = "fossil "; - -// "fossil helix" or "fossil dome". -std::string fossil_variant(Fossil fossil); -// Parses a fossil CHOICE variant string. -std::optional parse_fossil_variant(std::string_view variant); +// The GAME action of the fossil CHOICE: fossil WORD (required), "helix" +// or "dome". +inline const std::string FOSSIL_ACTION = "fossil"; +// The fossil a FOSSIL_ACTION step's args choose; nothing if it isn't one. +std::optional fossil_of(const Pokemon::StoryActionArgs& args); // The table's CHOICE(fossil) step, the player facing the fossil. Pokemon::StoryStep fossil_step(std::string name, std::string why, Fossil fossil); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryChoice_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryChoice_Tests.cpp index 432ff26b00..9de1685ad4 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryChoice_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryChoice_Tests.cpp @@ -178,15 +178,21 @@ UnitTestResult test_fossil_choice(){ } -UnitTestResult test_fossil_variant(){ - if (fossil_variant(Fossil::HELIX) != "fossil helix" || parse_fossil_variant("fossil dome") != Fossil::DOME){ - return "Expected \"fossil helix\" and \"fossil dome\"."; +UnitTestResult test_fossil_args(){ + const Pokemon::StoryStep step = fossil_step("helix", "", Fossil::HELIX); + if (step.action != FOSSIL_ACTION || fossil_of(step.args) != Fossil::HELIX + || fossil_of({{"fossil", std::string("dome")}}) != Fossil::DOME + ){ + return "Expected the HELIX step and \"dome\" to read back."; } - for (std::string_view bad : {"fossil", "fossil old_amber", "fossil helix dome", "grind level=18"}){ - if (parse_fossil_variant(bad)){ - return "Expected \"" + std::string(bad) + "\" refused."; + for (const std::string& bad : {"", "old_amber", "helix dome"}){ + if (fossil_of({{"fossil", bad}})){ + return "Expected \"" + bad + "\" refused."; } } + if (fossil_of({})){ + return "Expected a step with no fossil refused."; + } // MtMoon_B2F map.json: DOME at (13, 7), HELIX at (14, 7). if (!(fossil_tile(Fossil::DOME) == Pokemon::TilePos{13, 7}) || !(fossil_tile(Fossil::HELIX) == Pokemon::TilePos{14, 7})){ return "The fossils' tiles aren't MtMoon_B2F's."; @@ -203,7 +209,7 @@ const AutoStoryChoiceCase AUTO_STORY_CHOICE_CASES[] = { .expectation = {}, }, { - .input = {"the table's variant", test_fossil_variant}, + .input = {"the step's args", test_fossil_args}, .expectation = {}, }, }; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp index d06a03851a..b6ee0a71ab 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp @@ -22,11 +22,13 @@ #include "PokemonFRLG_AutoStoryCapture.h" #include "PokemonFRLG_AutoStoryEvents.h" #include "PokemonFRLG_AutoStoryGrind.h" +#include "PokemonFRLG_AutoStoryGameArgs.h" #include "PokemonFRLG_AutoStoryScreenEvents.h" #include "PokemonFRLG_AutoStorySummary.h" #include "PokemonFRLG_AutoStoryTable.h" #include "PokemonFRLG_AutoStoryTeachScreens.h" #include "PokemonFRLG_AutoStoryTrashCans.h" +#include "PokemonFRLG_AutoStoryViridianMart.h" #include "PokemonFRLG_AutoStoryWinChance.h" namespace PokemonAutomation{ @@ -58,6 +60,17 @@ Outcome guarded(Body&& body){ } } +// The step's arg `key`, which its action declares. +template +const Type& arg(const StoryStep& step, std::string_view key){ + return Pokemon::story_arg(step.args, key); +} + +// A checkpoint's start as the engine's Pose: nothing for a new game. +std::optional start_pose(const StoryCheckpoint& checkpoint){ + return checkpoint.start ? std::optional(Pokemon::pose_of(*checkpoint.start)) : std::nullopt; +} + const MapData* find_story_map(const std::string& name){ for (const MapData& map : story_maps()){ if (map.name == name){ @@ -85,13 +98,13 @@ std::optional face_a_wall(StoryEnv& env, const MapPosition& position) // The shared route log's arrival line (Pokemon_RouteLog.h), as BDSP's walker // writes it: where the route was walked to. void log_arrival(StoryEnv& env, const std::string& label, const std::string& map, const TilePos& tile){ - env.console.log(Pokemon::ROUTE_LOG_TAG + Pokemon::route_arrived_line(label, {{map, tile}})); + env.console.log(std::string(Pokemon::ROUTE_LOG_TAG) + Pokemon::route_arrived_line(label, {{map, tile}})); } // The walker's check that each leg to a wall ended at it (a diagnostic): // with Thorough checks only, as Fast trusts the walk. WallCheck wall_check(const StoryEnv& env){ - return env.checks == StoryChecks::THOROUGH ? WallCheck::TAP : WallCheck::SKIP; + return checks_screen(env.checks) ? WallCheck::TAP : WallCheck::SKIP; } // Where a ROUTE from `pose` starts: its tile, or nothing for a set of @@ -108,7 +121,7 @@ std::optional route_start(const Pokemon::Pose& pose){ // which places a wild battle seen only after an open leg's hold // (OverworldInterruptSet::make_observer). OverworldInterruptSet walk_interrupts(StoryEnv& env, const StoryStep& step){ - OverworldInterruptSet out = story_interrupts(env.supplies, step.fight_wild, env.checks, env.language); + OverworldInterruptSet out = story_interrupts(env.supplies, arg(step, "fight_wild"), env.checks, env.language); out.make_observer = []() -> std::unique_ptr{ return std::make_unique(); }; @@ -132,9 +145,10 @@ Outcome walk_route(StoryEnv& env, RunState& state, const StoryStep& step, const if (!facing && start){ return Pokemon::outcome_failed("unknown_facing", to_string(*start)); } - const std::optional target = step.target ? story_pose(*step.target) : std::nullopt; + const Pokemon::Pose target_pose = Pokemon::pose_of(arg(step, "target")); + const std::optional target = story_pose(target_pose); if (!target){ - return Pokemon::outcome_failed("bad_target", step.target ? Pokemon::to_string(*step.target) : "none"); + return Pokemon::outcome_failed("bad_target", Pokemon::to_string(target_pose)); } const RouteGoal goal{{target->map, target->tile}, target->facing}; const std::optional> route = plan_story_route(maps, state.pose, facing, goal); @@ -165,7 +179,7 @@ Outcome walk_legs(StoryEnv& env, RunState& state, const StoryStep& step){ if (!facing){ facing = face_a_wall(env, start); } - const std::optional> route = fixed_route(story_maps(), start, step.legs); + const std::optional> route = fixed_route(story_maps(), start, arg>(step, "legs")); if (!facing || !route || route->empty()){ return Pokemon::outcome_failed("bad_legs", to_string(start)); } @@ -179,20 +193,21 @@ Outcome walk_legs(StoryEnv& env, RunState& state, const StoryStep& step){ } Outcome take_step(StoryEnv& env, RunState& state, const StoryStep& step){ + const Direction direction = arg(step, "direction"); int tiles_stepped = 1; - if (step.variant == TRAINER_LINE_VARIANT){ - const std::optional stepped = step_into_line(env.console, env.context, step.direction, facing_of(state.pose), TRAINER_LINE_TILES); + if (step.action == TRAINER_LINE_VARIANT){ + const std::optional stepped = step_into_line(env.console, env.context, direction, facing_of(state.pose), TRAINER_LINE_TILES); if (!stepped){ - return Pokemon::outcome_failed("no_trainer", std::format("{} tiles {}", TRAINER_LINE_TILES, direction_name(step.direction))); + return Pokemon::outcome_failed("no_trainer", std::format("{} tiles {}", TRAINER_LINE_TILES, direction_name(direction))); } env.console.log(std::format("Story: {}: a trainer saw the player after {} tile(s).", step.name, *stepped)); tiles_stepped = *stepped; - }else if (step.variant == TRAINER_WAIT_VARIANT){ - if (!step_into_line(env.console, env.context, step.direction, facing_of(state.pose), 1, TRAINER_WAIT_WATCH)){ - return Pokemon::outcome_failed("no_trainer", std::format("{} s on the tile {}", TRAINER_WAIT_WATCH.count() / 1000, direction_name(step.direction))); + }else if (step.action == TRAINER_WAIT_VARIANT){ + if (!step_into_line(env.console, env.context, direction, facing_of(state.pose), 1, TRAINER_WAIT_WATCH)){ + return Pokemon::outcome_failed("no_trainer", std::format("{} s on the tile {}", TRAINER_WAIT_WATCH.count() / 1000, direction_name(direction))); } }else{ - step_once(env.context, step.direction, facing_of(state.pose)); + step_once(env.context, direction, facing_of(state.pose)); } const std::vector tiles = Pokemon::tiles_of(state.pose); if (tiles.size() != 1){ @@ -200,16 +215,16 @@ Outcome take_step(StoryEnv& env, RunState& state, const StoryStep& step){ } TilePos onto = tiles[0]; for (int c = 0; c < tiles_stepped; c++){ - onto = onto.next(step.direction); + onto = onto.next(direction); } - return Pokemon::outcome_ok(to_pose(StoryPose{state.pose.map, onto, step.direction})); + return Pokemon::outcome_ok(to_pose(StoryPose{state.pose.map, onto, direction})); } // Before a BattleRisk::HIGH battle the story may lose: the sim's win // chance, the HP as the last bar read left it. Why not to fight, if so. std::optional refuse_battle(StoryEnv& env, const StoryStep& step, std::string_view trainer){ const Supplies& supplies = env.supplies; - if (step.may_lose || supplies.risk != BattleRisk::HIGH){ + if (arg(step, "may_lose") || supplies.risk != BattleRisk::HIGH){ return std::nullopt; } const SimItems items{.potions = supplies.potions, .awakenings = supplies.awakenings, .antidotes = supplies.antidotes}; @@ -247,7 +262,7 @@ Outcome battle(StoryEnv& env, const StoryStep& step){ env.supplies.foes.clear(); env.supplies.trainer.clear(); env.supplies.foe_out.reset(); - if (end == BattleEnd::LOST && !step.may_lose){ + if (end == BattleEnd::LOST && !arg(step, "may_lose")){ return Pokemon::outcome_failed("blackout"); } mash_until_overworld(env.console, env.context, SCENE_TIMEOUT); @@ -276,75 +291,9 @@ Outcome get_ready(StoryEnv& env, RunState& state, const StoryStep& step){ return walked; } -// Viridian Mart before the Boulder Badge (pokefirered ViridianCity_Mart_Items): -// POKE BALL, POTION (300), ANTIDOTE (100), PARLYZ HEAL (200). Each item -// the story buys: its row, and where the bag's count is kept. -struct MartItem{ - const char* item; - int row; - int Supplies::* count; - // The name the item list reader reads (read_item_list_name()). - const char* slug; -}; -constexpr MartItem VIRIDIAN_MART_ITEMS[] = { - {.item = "potion", .row = 1, .count = &Supplies::potions, .slug = "potion"}, - {.item = "antidote", .row = 2, .count = &Supplies::antidotes, .slug = "antidote"}, - {.item = "parlyz_heal", .row = 3, .count = &Supplies::parlyz_heals, .slug = "parlyz-heal"}, -}; - -const MartItem* viridian_mart_item(const std::string& name){ - for (const MartItem& item : VIRIDIAN_MART_ITEMS){ - if (name == item.item){ - return &item; - } - } - return nullptr; -} - -Outcome shop(StoryEnv& env, const StoryStep& step){ - const std::optional> orders = viridian_mart_orders(step.items); - if (!orders){ - return Pokemon::outcome_failed("unknown_item", step.name); - } - // 2000 of the 3000 a new game starts with, plus the rival's prize. - buy_items(env.console, env.context, *orders, env.checks, env.language); - for (const Pokemon::StoryItem& item : step.items){ - env.supplies.*viridian_mart_item(item.item)->count += (int)item.quantity; - } - if (env.checks == StoryChecks::FAST){ - return Pokemon::outcome_ok(); - } - // The counts from the bag, not from the orders: a wrong row once bought - // Parlyz Heals for Antidotes unnoticed (console B, 2026-11-01). - const std::vector rows = read_items_pocket(env.console, env.context, env.language); - if (rows.empty()){ - env.console.log("Story: couldn't read the Items pocket; keeping the counts ordered.", COLOR_ORANGE); - return Pokemon::outcome_ok(); - } - for (const std::string& item : set_from_bag(env.supplies, rows)){ - env.console.log(std::format( - "Story: couldn't read how many {} the bag holds; counting {}.", - item, item_count(env.supplies, item) - ), COLOR_ORANGE); - } - return Pokemon::outcome_ok(); -} - } // namespace -std::optional> viridian_mart_orders(const std::vector& items){ - std::vector orders; - for (const Pokemon::StoryItem& wanted : items){ - const MartItem* found = viridian_mart_item(wanted.item); - if (found == nullptr){ - return std::nullopt; - } - orders.push_back(MartOrder{found->row, (int)wanted.quantity, found->slug}); - } - return orders; -} - const RouteCosts& story_route_costs(){ static const RouteCosts COSTS = []{ RouteCosts costs = default_route_costs(); @@ -365,7 +314,7 @@ const std::vector& story_maps(){ } MoveSpeed move_speed(const StoryStep& step){ - return step.variant == RUN_VARIANT ? MoveSpeed::RUN : MoveSpeed::WALK; + return step.action == RUN_VARIANT ? MoveSpeed::RUN : MoveSpeed::WALK; } Pokemon::Pose to_pose(const StoryPose& pose){ @@ -478,9 +427,9 @@ std::optional> fixed_route( Pokemon::Pose paced_pose(const Pokemon::Pose& patch, const StoryStep& step){ std::optional pace; - if (const std::optional grind = parse_grind_variant(step.variant)){ + if (const std::optional grind = step.action == GRIND_ACTION ? grind_plan_of(step.args) : std::nullopt){ pace = grind->pace; - }else if (const std::optional capture = parse_capture_variant(step.variant)){ + }else if (const std::optional capture = step.action == CAPTURE_ACTION ? capture_plan_of(step.args) : std::nullopt){ pace = capture->pace; } const std::vector tiles = Pokemon::tiles_of(patch); @@ -533,11 +482,13 @@ bool walked(StoryEnv& env, RunState& state, const StoryStep& step){ return outcome.succeeded(); } -// A GRIND's trip from the patch to the nurse (`step`'s target) and back +// A GRIND's trip from the patch to the nurse (`step`'s nurse) and back // to `patch`, starting where pacing left the player (`spot`). bool grind_heal_trip(StoryEnv& env, RunState& state, const StoryStep& step, const Pokemon::Pose& patch, const GrindSpot& spot){ std::optional here = story_pose(patch); - if (!here){ + const Pokemon::GridPose* nurse = game_arg(step.args, "nurse"); + const std::optional back = story_pose(patch); + if (!here || !back || nurse == nullptr){ return false; } if (spot.displaced && spot.facing){ @@ -550,7 +501,7 @@ bool grind_heal_trip(StoryEnv& env, RunState& state, const StoryStep& step, cons StoryStep walk; walk.kind = StoryStepKind::ROUTE; walk.name = step.name + "_to_nurse"; - walk.target = step.target; + walk.args = {{"target", *nurse}, {"fight_wild", false}}; if (!walked(env, state, walk)){ return false; } @@ -558,7 +509,7 @@ bool grind_heal_trip(StoryEnv& env, RunState& state, const StoryStep& step, cons // PP too: a grind's battles spend more than its attacks have. healed_by_nurse(env.supplies); walk.name = step.name + "_back_to_patch"; - walk.target = patch; + walk.args["target"] = Pokemon::GridPose{back->map, {back->tile}, back->facing}; return walked(env, state, walk); } @@ -571,7 +522,7 @@ void pace_trainer_battle(StoryEnv& env, RunState& state, const StoryStep& step, StoryStep walk; walk.kind = StoryStepKind::ROUTE; walk.name = step.name + "_back_after_trainer"; - walk.target = patch; + walk.args["target"] = Pokemon::GridPose{patch.map, Pokemon::tiles_of(patch), Pokemon::facing_of(patch)}; if (!walked(env, state, walk)){ OperationFailedExceptionWithScreenshot::fire( ErrorReportMode::SEND_ERROR_REPORT, @@ -582,7 +533,7 @@ void pace_trainer_battle(StoryEnv& env, RunState& state, const StoryStep& step, } // A MART, TEACH, LEVEL, GRIND or fossil step on the console; nothing for -// another variant. +// another action. std::optional run_abilities(StoryEnv& env, RunState& state, const StoryStep& step){ const Pokemon::Pose patch = state.pose; ConsoleMartActions mart(env.console, env.context, env.language, env.supplies); @@ -599,7 +550,7 @@ std::optional run_abilities(StoryEnv& env, RunState& state, const Story ); ConsoleChoiceActions choice(env.console, env.context); StoryAbilities abilities{console_member_reader(env.console, env.context, env.language), mart, teach, grind, choice}; - if (const std::optional plan = parse_grind_check_variant(step.variant)){ + if (const std::optional plan = step.action == GRIND_CHECK_ACTION ? grind_plan_of(step.args) : std::nullopt){ if (grind_reached_already(env.console.logger(), grind, abilities.members, *plan)){ state.flags.insert(step.name); } @@ -608,22 +559,23 @@ std::optional run_abilities(StoryEnv& env, RunState& state, const Story return run_ability_game_step(env.console.logger(), &env.console, step, abilities); } -// CUT_TREE_VARIANT: the tree `step.direction` of the player, cut, and a -// step onto its tile. +// CUT_TREE_VARIANT: the tree in the step's direction, cut, and a step +// onto its tile. Outcome cut_tree(StoryEnv& env, RunState& state, const StoryStep& step){ const std::optional here = story_pose(state.pose); if (!here){ return Pokemon::outcome_failed("no_pose", Pokemon::to_string(state.pose)); } - if (here->facing != step.direction){ + const Direction direction = arg(step, "direction"); + if (here->facing != direction){ // The tree is in the way: a tap only turns the player to it. - face_wall(env.context, step.direction); + face_wall(env.context, direction); } pbf_press_button(env.context, BUTTON_A, 160ms, 800ms); answer_yes_no(env.console, env.context, true, BUTTON_B, YES_NO_TIMEOUT); mash_until_overworld(env.console, env.context, SCENE_TIMEOUT); - step_once(env.context, step.direction, step.direction); - return Pokemon::outcome_ok(to_pose(StoryPose{here->map, here->tile.next(step.direction), step.direction})); + step_once(env.context, direction, direction); + return Pokemon::outcome_ok(to_pose(StoryPose{here->map, here->tile.next(direction), direction})); } // Vermilion Gym's trash cans on the console: a walk to each can's stand @@ -637,13 +589,13 @@ class ConsoleTrashCans{ CanPages check(int can){ const TrashCanStand stand = trash_can_stand(can); const std::optional here = story_pose(m_state.pose); - const Pokemon::Pose target = to_pose(StoryPose{m_state.pose.map, stand.tile, stand.facing}); + const Pokemon::GridPose target{m_state.pose.map, {stand.tile}, stand.facing}; if (!here || !(here->tile == stand.tile) || here->facing != stand.facing){ StoryStep walk = m_step; walk.kind = StoryStepKind::ROUTE; walk.name = m_step.name + "_can" + std::to_string(can); - walk.variant.clear(); - walk.target = target; + walk.action.clear(); + walk.args = {{"target", target}, {"fight_wild", false}}; static const std::vector MAPS = trash_can_maps(story_maps()); const Outcome outcome = walk_route(m_env, m_state, walk, MAPS); if (!outcome.succeeded()){ @@ -752,7 +704,7 @@ ConsoleAction console_action_of(StoryActionId id){ }; case StoryActionId::ANSWER: return [](StoryEnv& env, RunState&, const StoryStep& step){ - answer_yes_no(env.console, env.context, step.yes, BUTTON_B, YES_NO_TIMEOUT); + answer_yes_no(env.console, env.context, arg(step, "yes"), BUTTON_B, YES_NO_TIMEOUT); return Pokemon::outcome_ok(); }; case StoryActionId::MASH: @@ -769,7 +721,7 @@ ConsoleAction console_action_of(StoryActionId id){ return Pokemon::outcome_ok(); }; case StoryActionId::SHOP: - return [](StoryEnv& env, RunState&, const StoryStep& step){ return shop(env, step); }; + return [](StoryEnv& env, RunState&, const StoryStep& step){ return viridian_shop(env, step); }; case StoryActionId::READY: return get_ready; default: @@ -954,9 +906,9 @@ Pokemon::Checkpoint build_checkpoint(const StoryCheckpoint& data, StoryExecutor& // card's place is checked when the save is loaded (check_save_place()), // and the start check compares the screen with the frame kept when the // program last saved there. With none kept, it passes. - Pokemon::Checkpoint checkpoint = Pokemon::build_story_checkpoint(data, executor, env.prepared); + Pokemon::Checkpoint checkpoint = Pokemon::build_story_checkpoint(data, executor, &env.prepared); add_start_check( - checkpoint, data.start, + checkpoint, start_pose(data), [&env, id = data.id]{ return read_console_start(env, id); }, [&env](const std::string& line){ env.console.log(line, COLOR_ORANGE); } ); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.h index 9e089b767c..e025560140 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.h @@ -5,7 +5,7 @@ * The FRLG story as data for the shared story engine * (Pokemon/AutoStory/Pokemon_StoryEvents.h, Pokemon_StorySegments.h). * A checkpoint is a list of the shared StorySteps - * (Pokemon/AutoStory/Pokemon_StorySteps.h), each one kind of event (a + * (Pokemon/AutoStory/Pokemon_StoryStepExecutor.h), each one kind of event (a * route, a talk, text read to its end, a YES/NO, a battle, the nurse, the * Mart); StoryExecutor does each kind on the console, and * make_story_segment() turns the table into engine checkpoints. Routes @@ -29,7 +29,7 @@ #include "Pokemon/AutoStory/Pokemon_StoryActions.h" #include "Pokemon/AutoStory/Pokemon_StoryEvents.h" #include "Pokemon/AutoStory/Pokemon_StorySegments.h" -#include "Pokemon/AutoStory/Pokemon_StorySteps.h" +#include "Pokemon/AutoStory/Pokemon_StoryStepExecutor.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.h" @@ -44,11 +44,11 @@ namespace NintendoSwitch{ namespace PokemonFRLG{ -// Story leg definition imported from Pokemon AutoStory. +// Story leg definition imported from Pokemon AutoStory. using Pokemon::StoryLeg; -// Story step definition imported from Pokemon AutoStory. +// Story step definition imported from Pokemon AutoStory. using Pokemon::StoryStep; -// Story step kind classification imported from Pokemon AutoStory. +// Story step kind classification imported from Pokemon AutoStory. using Pokemon::StoryStepKind; // Where the player stands and faces: the one-tile poses of FRLG's table @@ -69,7 +69,7 @@ inline const std::string RUN_VARIANT = "run"; // (step_until_seen()). The battle after it starts on the trainer's row // whether the walk before ended on its tile or a tile short. inline const std::string TRAINER_LINE_VARIANT = "trainer_line"; -// Maximum tiles to step into a trainer's line of sight. +// Maximum tiles to step into a trainer's line of sight. inline constexpr int TRAINER_LINE_TILES = 3; // The variant of a STEP into the line of a trainer who looks around @@ -176,7 +176,7 @@ const std::vector& story_maps(); // City's harbor). const RouteCosts& story_route_costs(); -// Converts a StoryPose to a general navigation Pose. +// Converts a StoryPose to a general navigation Pose. Pokemon::Pose to_pose(const StoryPose& pose); // `pose` as a StoryPose: nothing unless it is on one tile. std::optional story_pose(const Pokemon::Pose& pose); @@ -239,10 +239,6 @@ std::optional> plan_story_route( // into a sign would read it. std::optional wall_beside(const MapData& map, const TilePos& tile); -// `items` as orders at the Viridian Mart before the Boulder Badge: the -// rows of POKE BALL, POTION, ANTIDOTE, PARLYZ HEAL. Nothing if it does -// not sell one of them. -std::optional> viridian_mart_orders(const std::vector& items); // What the story's events act on. `supplies` are what the bag holds now, @@ -254,7 +250,7 @@ struct StoryEnv{ Supplies saved_supplies; // Whether the game has a save to reload. bool has_save = false; - StoryChecks checks = StoryChecks::THOROUGH; + Pokemon::StoryCheckLevel checks = Pokemon::StoryCheckLevel::DEFAULT; // The game's language, for reading item names. In one the readers have // no names for, the checks fall back to positions and counts. Language language = Language::English; @@ -345,7 +341,7 @@ Pokemon::Segment make_story_segment(const std::vector& checkpoi -} // namespace PokemonFRLG -} // namespace NintendoSwitch -} // namespace PokemonAutomation +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation #endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGameArgs.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGameArgs.cpp new file mode 100644 index 0000000000..84edd1e3de --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGameArgs.cpp @@ -0,0 +1,46 @@ +/* AutoStory Game Args + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include "PokemonFRLG_AutoStoryGameArgs.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +Pokemon::StoryArgSpec required_arg(std::string key, Pokemon::StoryArgType type, std::string why){ + return Pokemon::StoryArgSpec{.key = std::move(key), .type = type, .required = true, .fallback = std::nullopt, .why = std::move(why)}; +} + +Pokemon::StoryArgSpec optional_arg(std::string key, Pokemon::StoryArgType type, Pokemon::StoryArgValue fallback, std::string why){ + return Pokemon::StoryArgSpec{.key = std::move(key), .type = type, .required = false, .fallback = std::move(fallback), .why = std::move(why)}; +} + +Pokemon::StoryArgSpec absent_arg(std::string key, Pokemon::StoryArgType type, std::string why){ + return Pokemon::StoryArgSpec{.key = std::move(key), .type = type, .required = false, .fallback = std::nullopt, .why = std::move(why)}; +} + +std::optional number_arg(const Pokemon::StoryActionArgs& args, std::string_view key, size_t min, size_t max){ + const int64_t* value = game_arg(args, key); + if (value == nullptr || *value < (int64_t)min || *value > (int64_t)max){ + return std::nullopt; + } + return (size_t)*value; +} + +std::optional counted_arg(const Pokemon::StoryActionArgs& args, std::string_view key, size_t max){ + const std::optional value = number_arg(args, key, 1, max); + if (!value){ + return std::nullopt; + } + return *value - 1; +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGameArgs.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGameArgs.h new file mode 100644 index 0000000000..7448f3c813 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGameArgs.h @@ -0,0 +1,57 @@ +/* AutoStory Game Args + * + * From: https://github.com/PokemonAutomation/ + * + * Declaring and reading the args of FRLG's own GAME actions (a PC + * transfer, a capture, a Mart, a TEACH...): each declares its args as a + * Pokemon::StoryActionSpec, the story file gives them, the reader fills in + * the fallbacks, and the step reads them back into its plan. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_AutoStoryGameArgs_H +#define PokemonAutomation_PokemonFRLG_AutoStoryGameArgs_H + +#include +#include +#include +#include +#include "Pokemon/AutoStory/Pokemon_MapUtil.h" +#include "Pokemon/AutoStory/Types/Pokemon_StoryActionArg.h" +#include "Pokemon/AutoStory/Types/Pokemon_StoryActionSpec.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// An arg the action needs. +Pokemon::StoryArgSpec required_arg(std::string key, Pokemon::StoryArgType type, std::string why); +// An arg read as `fallback` when the step leaves it out. +Pokemon::StoryArgSpec optional_arg(std::string key, Pokemon::StoryArgType type, Pokemon::StoryArgValue fallback, std::string why); +// An arg the step may leave out, with no fallback: absent means "none". +Pokemon::StoryArgSpec absent_arg(std::string key, Pokemon::StoryArgType type, std::string why); + +// `args`' value of `key`, or null when it is missing or of another type. +template +const Type* game_arg(const Pokemon::StoryActionArgs& args, std::string_view key); + +template +const Type* game_arg(const Pokemon::StoryActionArgs& args, std::string_view key){ + return Pokemon::value_if_at_it(args, args.find(key)); +} + +// The INTEGER arg `key` when it is from `min` to `max`; nothing if it is +// missing, of another type or out of range. +std::optional number_arg(const Pokemon::StoryActionArgs& args, std::string_view key, size_t min, size_t max); + +// The INTEGER arg `key`, a slot or box counted from 1 to `max` as the game +// shows it, counted from 0; nothing if it is missing or out of range. +std::optional counted_arg(const Pokemon::StoryActionArgs& args, std::string_view key, size_t max); + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGrind.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGrind.cpp index 38f4afba33..d3090796ec 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGrind.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGrind.cpp @@ -5,11 +5,12 @@ */ #include +#include #include #include "CommonFramework/Exceptions/OperationFailedException.h" #include "PokemonFRLG_AutoStoryActions.h" +#include "PokemonFRLG_AutoStoryGameArgs.h" #include "PokemonFRLG_AutoStoryGrind.h" -#include "PokemonFRLG_AutoStoryVariantWords.h" namespace PokemonAutomation{ namespace NintendoSwitch{ @@ -35,104 +36,74 @@ const char* grind_end_name(GrindEnd end){ } -std::string grind_variant(const GrindPlan& plan){ - std::string variant = std::format( - "{}slot={} level={} encounters={} pace={} heal_every={}", - GRIND_VARIANT_PREFIX, plan.member + 1, plan.level, plan.max_encounters, - direction_name(plan.pace), plan.heal_every - ); +Pokemon::StoryActionArgs grind_check_args(const GrindPlan& plan){ + Pokemon::StoryActionArgs args{ + {"slot", int64_t(plan.member + 1)}, + {"level", int64_t(plan.level)}, + {"encounters", int64_t(plan.max_encounters)}, + {"pace", plan.pace}, + {"heal_every", int64_t(plan.heal_every)}, + }; if (!plan.trainer.empty()){ - variant += std::format(" beat={} chance={:.0f}", plan.trainer, 100 * plan.min_chance); + args.emplace("beat", plan.trainer); + args.emplace("chance", int64_t(std::lround(100 * plan.min_chance))); } - return variant; + return args; } -namespace{ - -bool set_grind_word(GrindPlan& plan, std::string_view word){ - const std::optional pair = variant_pair(word); - if (!pair){ - return false; - } - if (pair->key == "beat"){ - plan.trainer = std::string(pair->value); - return !plan.trainer.empty(); - } - if (pair->key == "pace"){ - for (Direction direction : Pokemon::ALL_DIRECTIONS){ - if (pair->value == direction_name(direction)){ - plan.pace = direction; - return true; - } - } - return false; - } - const std::optional number = variant_number(pair->value, 4); - if (!number){ - return false; - } - if (pair->key == "slot" && *number >= 1 && *number <= PARTY_SLOTS){ - plan.member = *number - 1; - }else if (pair->key == "level" && *number >= 2 && *number <= 100){ - plan.level = (unsigned)*number; - }else if (pair->key == "encounters" && *number >= 1){ - plan.max_encounters = *number; - }else if (pair->key == "heal_every"){ - plan.heal_every = *number; - }else if (pair->key == "chance" && *number >= 1 && *number <= 100){ - plan.min_chance = static_cast(*number) / 100; - }else{ - return false; - } - return true; +Pokemon::StoryActionArgs grind_args(const GrindPlan& plan, Pokemon::GridPose nurse){ + Pokemon::StoryActionArgs args = grind_check_args(plan); + args.emplace("nurse", std::move(nurse)); + return args; } -} // namespace - -std::optional parse_grind_variant(std::string_view variant){ - if (!variant.starts_with(GRIND_VARIANT_PREFIX)){ +std::optional grind_plan_of(const Pokemon::StoryActionArgs& args){ + const std::optional member = counted_arg(args, "slot", PARTY_SLOTS); + const std::optional level = number_arg(args, "level", 2, 100); + const std::optional encounters = number_arg(args, "encounters", 1, 9999); + const std::optional heal_every = number_arg(args, "heal_every", 0, 9999); + const Direction* pace = game_arg(args, "pace"); + if (!member || !level || !encounters || !heal_every || pace == nullptr){ return std::nullopt; } - GrindPlan plan; - bool level_seen = false; - bool chance_seen = false; - for (std::string_view word : variant_words(variant.substr(GRIND_VARIANT_PREFIX.size()))){ - if (!set_grind_word(plan, word)){ + GrindPlan plan{ + .member = *member, .level = (unsigned)*level, .max_encounters = *encounters, + .pace = *pace, .heal_every = *heal_every, + }; + if (const std::string* trainer = game_arg(args, "beat")){ + if (trainer->empty()){ return std::nullopt; } - level_seen |= word.starts_with("level="); - chance_seen |= word.starts_with("chance="); + plan.trainer = *trainer; } - // A chance needs a trainer to be against. - if (!level_seen || (chance_seen && plan.trainer.empty())){ - return std::nullopt; + if (args.contains("chance")){ + const std::optional chance = number_arg(args, "chance", 1, 100); + // A chance needs a trainer to be against. + if (!chance || plan.trainer.empty()){ + return std::nullopt; + } + plan.min_chance = static_cast(*chance) / 100; } return plan; } -Pokemon::StoryStep grind_step(std::string name, std::string why, const GrindPlan& plan, Pokemon::Pose nurse){ +Pokemon::StoryStep grind_step(std::string name, std::string why, const GrindPlan& plan, Pokemon::GridPose nurse){ Pokemon::StoryStep step; step.kind = Pokemon::StoryStepKind::GAME; step.name = std::move(name); step.why = std::move(why); - step.variant = grind_variant(plan); - step.target = std::move(nurse); + step.action = GRIND_ACTION; + step.args = grind_args(plan, std::move(nurse)); return step; } -std::optional parse_grind_check_variant(std::string_view variant){ - if (!variant.starts_with(GRIND_CHECK_VARIANT_PREFIX)){ - return std::nullopt; - } - return parse_grind_variant(std::string(GRIND_VARIANT_PREFIX) + std::string(variant.substr(GRIND_CHECK_VARIANT_PREFIX.size()))); -} - Pokemon::StoryStep grind_check_step(std::string name, std::string why, const GrindPlan& plan){ Pokemon::StoryStep step; step.kind = Pokemon::StoryStepKind::GAME; step.name = std::move(name); step.why = std::move(why); - step.variant = std::string(GRIND_CHECK_VARIANT_PREFIX) + grind_variant(plan).substr(GRIND_VARIANT_PREFIX.size()); + step.action = GRIND_CHECK_ACTION; + step.args = grind_check_args(plan); return step; } @@ -342,7 +313,7 @@ std::optional healed_win_chance(PartyMember lead, const SimItems& i ConsoleGrindActions::ConsoleGrindActions( ConsoleHandle& console, ProControllerContext& context, Language language, - Supplies& supplies, StoryChecks checks, HealTrip heal_trip, PaceTrainerBattle trainer_battle + Supplies& supplies, Pokemon::StoryCheckLevel checks, HealTrip heal_trip, PaceTrainerBattle trainer_battle ) : m_console(console) , m_context(context) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGrind.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGrind.h index 34953a85f2..644398ab56 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGrind.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGrind.h @@ -38,7 +38,8 @@ #include "CommonFramework/Language.h" #include "NintendoSwitch/Controllers/Procon/NintendoSwitch_ProController.h" #include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h" -#include "Pokemon/AutoStory/Pokemon_StorySteps.h" +#include "Pokemon/AutoStory/Pokemon_StoryStepExecutor.h" +#include "Pokemon/AutoStory/Types/Pokemon_StoryActionSpec.h" #include "Pokemon/Navigation/Pokemon_Grid.h" #include "PokemonFRLG_AutoStoryBattle.h" #include "PokemonFRLG_AutoStoryBattleData.h" @@ -52,7 +53,7 @@ namespace NintendoSwitch{ namespace PokemonFRLG{ -// Configuration for an auto-story grinding session. +// Configuration for an auto-story grinding session. struct GrindPlan{ // The party slot that grinds: the lead (0) only. size_t member = 0; @@ -72,26 +73,26 @@ struct GrindPlan{ double min_chance = MIN_WIN_CHANCE; }; -// The prefix of a GAME step's variant that names a GRIND step. -inline constexpr std::string_view GRIND_VARIANT_PREFIX = "grind "; - -// `plan` as a variant: "grind slot=1 level=18 encounters=60 pace=east -// heal_every=8", the slot counted from 1, and with a trainer -// " beat=TRAINER_RIVAL_CERULEAN_BULBASAUR chance=70", the chance in -// percent. The step's target is the nurse. -std::string grind_variant(const GrindPlan& plan); -// Parses a grinding plan from a variant string. -std::optional parse_grind_variant(std::string_view variant); +// The GAME action of a GRIND step: slot INTEGER (required, from 1); +// level INTEGER (required, 2-100); encounters INTEGER (60); pace +// DIRECTION (east); heal_every INTEGER (0); beat WORD and chance INTEGER +// (optional), the trainer and the win chance in percent; nurse GRID_POSE +// (required), where the step heals. +inline const std::string GRIND_ACTION = "grind"; +// `plan` and `nurse` as its action's args. +Pokemon::StoryActionArgs grind_args(const GrindPlan& plan, Pokemon::GridPose nurse); +// The plan a GRIND_ACTION step's args give; nothing if one is out of +// range, or a chance has no trainer to be against. +std::optional grind_plan_of(const Pokemon::StoryActionArgs& args); // The table's GRIND step: `nurse` is where the player faces the nurse. -Pokemon::StoryStep grind_step(std::string name, std::string why, const GrindPlan& plan, Pokemon::Pose nurse); +Pokemon::StoryStep grind_step(std::string name, std::string why, const GrindPlan& plan, Pokemon::GridPose nurse); -// The prefix of a GAME step's variant that checks a GRIND step's plan -// before the walk out to its patch, e.g. "grind_check slot=1 level=32 -// ...", the rest as grind_variant()'s. -inline constexpr std::string_view GRIND_CHECK_VARIANT_PREFIX = "grind_check "; -// Parses a grind check variant string into its GrindPlan. -std::optional parse_grind_check_variant(std::string_view variant); +// The GAME action that checks a GRIND step's plan before the walk out to +// its patch: GRIND_ACTION's args but the nurse. +inline const std::string GRIND_CHECK_ACTION = "grind_check"; +// `plan` as GRIND_CHECK_ACTION's args; grind_plan_of() reads them back. +Pokemon::StoryActionArgs grind_check_args(const GrindPlan& plan); // The table's check before the walk out to a GRIND step's patch: when the // lead already has what `plan` grinds for, the step sets a run flag named @@ -99,7 +100,7 @@ std::optional parse_grind_check_variant(std::string_view variant); Pokemon::StoryStep grind_check_step(std::string name, std::string why, const GrindPlan& plan); -// The outcome of an individual grinding battle. +// The outcome of an individual grinding battle. enum class GrindFight{ // The battle ended with the overworld back and the lead standing, // won or run from. @@ -133,7 +134,7 @@ class GrindActions{ virtual std::optional win_chance(const MemberInfo& member, std::string_view trainer) = 0; }; -// How a grinding session concluded. +// How a grinding session concluded. enum class GrindEnd{ // The level, or the win chance, reached. REACHED, @@ -151,10 +152,10 @@ enum class GrindEnd{ REFUSED, FAILED, }; -// The human-readable name of a grind end outcome. +// The human-readable name of a grind end outcome. const char* grind_end_name(GrindEnd end); -// The summary result of a grinding session. +// The summary result of a grinding session. struct GrindResult{ GrindEnd end = GrindEnd::FAILED; size_t encounters = 0; @@ -200,7 +201,7 @@ class ConsoleGrindActions : public GrindActions{ ConsoleGrindActions( ConsoleHandle& console, ProControllerContext& context, Language language, - Supplies& supplies, StoryChecks checks, HealTrip heal_trip, PaceTrainerBattle trainer_battle + Supplies& supplies, Pokemon::StoryCheckLevel checks, HealTrip heal_trip, PaceTrainerBattle trainer_battle ); virtual bool find_encounter(Pokemon::Direction pace) override; @@ -217,7 +218,7 @@ class ConsoleGrindActions : public GrindActions{ ProControllerContext& m_context; Language m_language; Supplies& m_supplies; - StoryChecks m_checks; + Pokemon::StoryCheckLevel m_checks; ConsoleCaptureActions m_encounters; HealTrip m_heal_trip; PaceTrainerBattle m_trainer_battle; @@ -225,12 +226,12 @@ class ConsoleGrindActions : public GrindActions{ }; -// Register auto-story grind unit tests. +// Register auto-story grind unit tests. void add_tests_AutoStoryGrind(UnitTestDatabase& database); -} // namespace PokemonFRLG -} // namespace NintendoSwitch -} // namespace PokemonAutomation +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation #endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGrind_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGrind_Tests.cpp index 963f819dfd..337c6f8ed9 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGrind_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGrind_Tests.cpp @@ -17,6 +17,7 @@ #include "Common/Cpp/Exceptions.h" #include "Common/Cpp/TestRunners/UnitTest.h" #include "PokemonFRLG_AutoStoryBattleSim.h" +#include "PokemonFRLG_AutoStoryGameArgs.h" #include "PokemonFRLG_AutoStoryGrind.h" namespace PokemonAutomation{ @@ -129,35 +130,35 @@ class FakePatch : public GrindActions{ }; -struct AutoStoryGrindInput{ - std::string name; - std::function body; -}; - -struct AutoStoryGrindExpectation{ -}; - -struct AutoStoryGrindCase{ - AutoStoryGrindInput input; - AutoStoryGrindExpectation expectation; -}; - +struct AutoStoryGrindInput{ + std::string name; + std::function body; +}; + +struct AutoStoryGrindExpectation{ +}; + +struct AutoStoryGrindCase{ + AutoStoryGrindInput input; + AutoStoryGrindExpectation expectation; +}; + class Test_AutoStoryGrind : public UnitTest{ public: - explicit Test_AutoStoryGrind(AutoStoryGrindCase test_case) - : UnitTest("PokemonFRLG::AutoStoryGrind - " + test_case.input.name) - , m_case(std::move(test_case)) + explicit Test_AutoStoryGrind(AutoStoryGrindCase test_case) + : UnitTest("PokemonFRLG::AutoStoryGrind - " + test_case.input.name) + , m_case(std::move(test_case)) {} virtual UnitTestResult run(Logger&, CancellableScope&) const override{ try{ - return m_case.input.body(); + return m_case.input.body(); }catch (Exception& e){ return std::string(e.name()) + ": " + e.message(); } } private: - AutoStoryGrindCase m_case; + AutoStoryGrindCase m_case; }; @@ -432,41 +433,55 @@ UnitTestResult test_console_party(){ } -UnitTestResult test_grind_variant(){ +// A GridPose for the nurse the args carry. +const Pokemon::GridPose NURSE{"Route4_PokemonCenter_1F", {{7, 4}}, Pokemon::Direction::NORTH}; + +UnitTestResult test_grind_args(){ GrindPlan plan = squirtle_to(18); plan.max_encounters = 60; plan.pace = Pokemon::Direction::NORTH; plan.heal_every = 8; - const std::string variant = grind_variant(plan); - if (variant != "grind slot=1 level=18 encounters=60 pace=north heal_every=8"){ - return "Unexpected variant \"" + variant + "\"."; - } - const std::optional back = parse_grind_variant(variant); + const Pokemon::StoryActionArgs args = grind_args(plan, NURSE); + const std::optional back = grind_plan_of(args); if (!back || back->level != 18 || back->max_encounters != 60 || back->pace != Pokemon::Direction::NORTH - || back->heal_every != 8 || back->member != 0 + || back->heal_every != 8 || back->member != 0 || !back->trainer.empty() || args.contains("chance") ){ - return "\"" + variant + "\" didn't read back as its plan."; + return "The level-18 plan didn't read back from its args."; } GrindPlan rival = beat_rival(30); rival.max_encounters = 100; rival.pace = Pokemon::Direction::WEST; - const std::string rival_variant = grind_variant(rival); - if (rival_variant != "grind slot=1 level=30 encounters=100 pace=west heal_every=0 beat=TRAINER_RIVAL_CERULEAN_BULBASAUR chance=50"){ - return "Unexpected variant \"" + rival_variant + "\"."; + Pokemon::StoryActionArgs rival_args = grind_args(rival, NURSE); + const int64_t* chance = game_arg(rival_args, "chance"); + const std::string* beat = game_arg(rival_args, "beat"); + if (chance == nullptr || *chance != 50 || beat == nullptr || *beat != RIVAL){ + return "Expected the rival's plan to carry beat and chance=50."; } - const std::optional rival_back = parse_grind_variant(rival_variant + " chance=75"); + rival_args["chance"] = int64_t(75); + const std::optional rival_back = grind_plan_of(rival_args); if (!rival_back || rival_back->trainer != RIVAL || rival_back->level != 30 || rival_back->min_chance != 0.75){ - return "\"" + rival_variant + " chance=75\" didn't read back as its plan."; + return "The rival's plan with chance=75 didn't read back."; } - for (std::string_view bad : { - "grind", "grind slot=1", "grind slot=1 level=101", "grind slot=7 level=18", "grind level=18 pace=up", - "grind level=18 encounters=0", "capture rattata", "grind level=30 beat=", "grind level=30 chance=70", - "grind level=30 beat=TRAINER_X chance=0", "grind level=30 beat=TRAINER_X chance=101", - }){ - if (parse_grind_variant(bad)){ - return "Expected \"" + std::string(bad) + "\" refused."; + const std::vector> bad_args{ + {"level", int64_t(101)}, + {"slot", int64_t(7)}, + {"encounters", int64_t(0)}, + {"beat", std::string("")}, + {"chance", int64_t(0)}, + {"chance", int64_t(101)}, + }; + for (const auto& [key, value] : bad_args){ + Pokemon::StoryActionArgs bad = rival_args; + bad[key] = value; + if (grind_plan_of(bad)){ + return "Expected a bad " + key + " refused."; } } + Pokemon::StoryActionArgs no_trainer = rival_args; + no_trainer.erase("beat"); + if (grind_plan_of(no_trainer)){ + return "Expected a chance with no trainer refused."; + } return true; } @@ -487,9 +502,9 @@ UnitTestResult test_grind_reached_already(){ } } const Pokemon::StoryStep check = grind_check_step("rival_winnable", "", beat_rival(30)); - const std::optional back = parse_grind_check_variant(check.variant); - if (!back || back->trainer != RIVAL || back->level != 30 || parse_grind_variant(check.variant)){ - return "\"" + check.variant + "\" didn't read back as its plan, or read as a GRIND step."; + const std::optional back = grind_plan_of(check.args); + if (check.action != GRIND_CHECK_ACTION || !back || back->trainer != RIVAL || back->level != 30 || check.args.contains("nurse")){ + return "The check's args didn't read back as its plan, or had a nurse."; } return true; } @@ -498,38 +513,38 @@ UnitTestResult test_grind_reached_already(){ -const AutoStoryGrindCase AUTO_STORY_GRIND_CASES[] = { - { - .input = {"grinding on a fake patch", test_grind}, - .expectation = {}, - }, - { - .input = {"the table's variant", test_grind_variant}, - .expectation = {}, - }, - { - .input = {"the level cap's message", test_grind_cap_message}, - .expectation = {}, - }, - { - .input = {"the lead the sim plays is the one read", test_lead_as_read}, - .expectation = {}, - }, - { - .input = {"console B's party is fought at Lv22 against the Cerulean rival", test_console_party}, - .expectation = {}, - }, +const AutoStoryGrindCase AUTO_STORY_GRIND_CASES[] = { + { + .input = {"grinding on a fake patch", test_grind}, + .expectation = {}, + }, + { + .input = {"the step's args", test_grind_args}, + .expectation = {}, + }, + { + .input = {"the level cap's message", test_grind_cap_message}, + .expectation = {}, + }, + { + .input = {"the lead the sim plays is the one read", test_lead_as_read}, + .expectation = {}, + }, + { + .input = {"console B's party is fought at Lv22 against the Cerulean rival", test_console_party}, + .expectation = {}, + }, {.input = {"reached already: no walk out to the patch", test_grind_reached_already}, .expectation = {}}, -}; - +}; + void add_tests_AutoStoryGrind(UnitTestDatabase& database){ - for (const auto& item : AUTO_STORY_GRIND_CASES){ - database.add(item); - } + for (const auto& item : AUTO_STORY_GRIND_CASES){ + database.add(item); + } } -} // namespace PokemonFRLG -} // namespace NintendoSwitch -} // namespace PokemonAutomation +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItems_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItems_Tests.cpp index 8a141637d0..611eefa34b 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItems_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItems_Tests.cpp @@ -42,36 +42,36 @@ namespace PokemonFRLG{ namespace{ -struct AutoStoryItemsInput{ - std::string name; - UnitTestResult (*body)(Logger&); -}; - -struct AutoStoryItemsExpectation{ - const char* description; -}; - -struct AutoStoryItemsTestCase{ - AutoStoryItemsInput input; - AutoStoryItemsExpectation expectation; -}; - +struct AutoStoryItemsInput{ + std::string name; + UnitTestResult (*body)(Logger&); +}; + +struct AutoStoryItemsExpectation{ + const char* description; +}; + +struct AutoStoryItemsTestCase{ + AutoStoryItemsInput input; + AutoStoryItemsExpectation expectation; +}; + class Test_AutoStoryItems : public UnitTest{ public: - explicit Test_AutoStoryItems(AutoStoryItemsTestCase scenario) - : UnitTest("PokemonFRLG::AutoStoryItems - " + scenario.input.name) - , m_scenario(std::move(scenario)) + explicit Test_AutoStoryItems(AutoStoryItemsTestCase scenario) + : UnitTest("PokemonFRLG::AutoStoryItems - " + scenario.input.name) + , m_scenario(std::move(scenario)) {} virtual UnitTestResult run(Logger& logger, CancellableScope&) const override{ try{ - return m_scenario.input.body(logger); + return m_scenario.input.body(logger); }catch (Exception& e){ return std::string(e.name()) + ": " + e.message(); } } private: - AutoStoryItemsTestCase m_scenario; + AutoStoryItemsTestCase m_scenario; }; @@ -328,7 +328,7 @@ UnitTestResult test_late_battle_placed(Logger&){ script.encounters = {{.grass_step = 1, .seen_late = true}}; OverworldSim sim(maps, leg->start, leg->step.direction, script); Supplies supplies; - const OverworldInterruptSet story = story_interrupts(supplies, false, StoryChecks::FAST, Language::English); + const OverworldInterruptSet story = story_interrupts(supplies, false, Pokemon::StoryCheckLevel::FAST, Language::English); OverworldSimWalker walker(sim, {}, story); const StepOutcome outcome = walker.calls().walk(leg->step, leg->step.direction); const int walked = tiles_walked(maps, *leg, sim.state().position); @@ -511,9 +511,9 @@ const AutoStoryItemsTestCase AUTO_STORY_ITEMS_CASES[] = { void add_tests_AutoStoryItems(UnitTestDatabase& database){ - for (const auto& scenario : AUTO_STORY_ITEMS_CASES){ - database.add(scenario); - } + for (const auto& scenario : AUTO_STORY_ITEMS_CASES){ + database.add(scenario); + } // "Wild CHANSEY appeared!" with its HP box, and Mt. Moon B2F's corridor // after "Got away safely!", whose black lower half reads as the battle's // text box (console B, 2026-11-03: 9 minutes of A and B there). @@ -547,6 +547,6 @@ void add_tests_AutoStoryItems(UnitTestDatabase& database){ -} // namespace PokemonFRLG -} // namespace NintendoSwitch -} // namespace PokemonAutomation +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMart.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMart.cpp index 937ae6c217..c851b25266 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMart.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMart.cpp @@ -12,8 +12,8 @@ #include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" #include "VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_ItemListReader.h" #include "PokemonFRLG_AutoStoryActions.h" +#include "PokemonFRLG_AutoStoryGameArgs.h" #include "PokemonFRLG_AutoStoryMart.h" -#include "PokemonFRLG_AutoStoryVariantWords.h" namespace PokemonAutomation{ namespace NintendoSwitch{ @@ -26,6 +26,8 @@ namespace{ // The quantity box's most (shop.c Task_BuyHowManyDialogueInit). constexpr size_t MAX_QUANTITY = 99; +// pokefirered: MAX_MONEY. +constexpr size_t MAX_MONEY = 999999; // Prices from pokefirered src/data/items.json. constexpr MartStockItem POKE_BALL{"poke-ball", 200}; @@ -79,25 +81,6 @@ std::optional stock_row(const std::vector& stock, std::st return std::nullopt; } -// Sets one "key=value" of a Mart variant into `plan`. False if it can't. -bool set_mart_word(MartPlan& plan, std::string_view word){ - const std::optional pair = variant_pair(word); - const std::optional number = pair ? variant_number(pair->value) : std::nullopt; - if (!number){ - return false; - } - if (pair->key == "budget"){ - plan.budget = *number; - }else if (pair->key == "floor"){ - plan.money_floor = *number; - }else if (*number >= 1 && *number <= MAX_QUANTITY && stock_row(mart_stock(plan.map), pair->key)){ - plan.lines.push_back({std::string(pair->key), *number}); - }else{ - return false; - } - return true; -} - } // namespace @@ -118,34 +101,39 @@ const char* mart_end_name(MartEnd end){ } -std::string mart_variant(const MartPlan& plan){ - std::string variant = std::format("{}{} budget={}", MART_VARIANT_PREFIX, plan.map, plan.budget); - if (plan.money_floor){ - variant += std::format(" floor={}", *plan.money_floor); - } +Pokemon::StoryActionArgs mart_args(const MartPlan& plan){ + std::vector items; for (const MartLine& line : plan.lines){ - variant += std::format(" {}={}", line.item, line.quantity); + items.push_back({line.item, line.quantity}); } - return variant; + Pokemon::StoryActionArgs args{ + {"map", plan.map}, {"budget", int64_t(plan.budget)}, {"items", std::move(items)}, + }; + if (plan.money_floor){ + args.emplace("floor", int64_t(*plan.money_floor)); + } + return args; } -std::optional parse_mart_variant(std::string_view variant){ - if (!variant.starts_with(MART_VARIANT_PREFIX)){ - return std::nullopt; - } - const std::vector words = variant_words(variant.substr(MART_VARIANT_PREFIX.size())); - if (words.empty() || mart_stock(words[0]).empty()){ +std::optional mart_plan_of(const Pokemon::StoryActionArgs& args){ + const std::string* map = game_arg(args, "map"); + const std::optional budget = number_arg(args, "budget", 0, MAX_MONEY); + const std::vector* items = game_arg>(args, "items"); + if (map == nullptr || mart_stock(*map).empty() || !budget || items == nullptr || items->empty()){ return std::nullopt; } - MartPlan plan; - plan.map = std::string(words[0]); - for (size_t c = 1; c < words.size(); c++){ - if (!set_mart_word(plan, words[c])){ + MartPlan plan{.map = *map, .budget = *budget}; + if (args.contains("floor")){ + plan.money_floor = number_arg(args, "floor", 0, MAX_MONEY); + if (!plan.money_floor){ return std::nullopt; } } - if (plan.lines.empty()){ - return std::nullopt; + for (const Pokemon::StoryItem& item : *items){ + if (item.quantity < 1 || item.quantity > MAX_QUANTITY || !stock_row(mart_stock(plan.map), item.item)){ + return std::nullopt; + } + plan.lines.push_back({item.item, item.quantity}); } return plan; } @@ -155,7 +143,8 @@ Pokemon::StoryStep mart_step(std::string name, std::string why, const MartPlan& step.kind = Pokemon::StoryStepKind::GAME; step.name = std::move(name); step.why = std::move(why); - step.variant = mart_variant(plan); + step.action = MART_ACTION; + step.args = mart_args(plan); step.once_per_save = true; return step; } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMart.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMart.h index 70b137b0ec..2bdbd1bc91 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMart.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMart.h @@ -46,7 +46,8 @@ #include "CommonFramework/Language.h" #include "NintendoSwitch/Controllers/Procon/NintendoSwitch_ProController.h" #include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h" -#include "Pokemon/AutoStory/Pokemon_StorySteps.h" +#include "Pokemon/AutoStory/Pokemon_StoryStepExecutor.h" +#include "Pokemon/AutoStory/Types/Pokemon_StoryActionSpec.h" #include "PokemonFRLG_AutoStoryBattle.h" namespace PokemonAutomation{ @@ -84,15 +85,15 @@ struct MartPlan{ std::optional money_floor = std::nullopt; }; -// The prefix of a GAME step's variant that names a Mart step. -inline constexpr std::string_view MART_VARIANT_PREFIX = "mart "; - -// `plan` as a variant: "mart PewterCity_Mart budget=2000 floor=2400 -// potion=5 repel=3", the lines in order. -std::string mart_variant(const MartPlan& plan); -// A variant from mart_variant(); nothing if it isn't one, has no line, or +// The GAME action of a Mart step: map WORD (required), the Mart's map; +// budget INTEGER (required); floor INTEGER (optional), the money floor; +// items ITEMS (required), the lines in order. +inline const std::string MART_ACTION = "mart"; +// `plan` as its action's args. +Pokemon::StoryActionArgs mart_args(const MartPlan& plan); +// The plan a MART_ACTION step's args give; nothing if it has no line or // names an item its Mart doesn't sell. -std::optional parse_mart_variant(std::string_view variant); +std::optional mart_plan_of(const Pokemon::StoryActionArgs& args); // The table's Mart step, once per save (StoryStep::once_per_save): a // retry from the same save skips it when it had nothing to buy. @@ -121,11 +122,11 @@ struct QuantityPresses{ size_t right = 0; size_t up = 0; }; -// Calculates D-pad presses needed to select a purchase quantity. +// Calculates D-pad presses needed to select a purchase quantity. QuantityPresses quantity_presses(size_t quantity); -// The outcome of attempting to buy an item at the Mart. +// The outcome of attempting to buy an item at the Mart. enum class PurchaseEnd{ // "Here you are!": bought, back at the list. BOUGHT, @@ -160,7 +161,7 @@ class MartActions{ virtual bool leave() = 0; }; -// How a Mart shopping trip concluded. +// How a Mart shopping trip concluded. enum class MartEnd{ DONE, // The plan bought nothing: the money (or its floor) doesn't cover one @@ -170,10 +171,10 @@ enum class MartEnd{ NO_MONEY_READ, FAILED, }; -// The human-readable name of a Mart outcome. +// The human-readable name of a Mart outcome. const char* mart_end_name(MartEnd end); -// The summary result of a Mart shopping session. +// The summary result of a Mart shopping session. struct MartResult{ MartEnd end = MartEnd::FAILED; std::vector bought = {}; @@ -185,7 +186,7 @@ struct MartResult{ // Facing the clerk: buys as `plan` says, then back to the overworld. MartResult run_mart(Logger& logger, MartActions& actions, const MartPlan& plan); -// Formats a log message summarizing the Mart shopping result. +// Formats a log message summarizing the Mart shopping result. std::string mart_message(const MartPlan& plan, const MartResult& result); @@ -222,12 +223,12 @@ class ConsoleMartActions : public MartActions{ }; -// Register auto-story Mart unit tests. +// Register auto-story Mart unit tests. void add_tests_AutoStoryMart(UnitTestDatabase& database); -} // namespace PokemonFRLG -} // namespace NintendoSwitch -} // namespace PokemonAutomation +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation #endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMart_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMart_Tests.cpp index 53e24da076..a431608910 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMart_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMart_Tests.cpp @@ -124,35 +124,35 @@ class FakeMart : public MartActions{ }; -struct AutoStoryMartInput{ - std::string name; - std::function body; -}; - -struct AutoStoryMartExpectation{ -}; - -struct AutoStoryMartCase{ - AutoStoryMartInput input; - AutoStoryMartExpectation expectation; -}; - +struct AutoStoryMartInput{ + std::string name; + std::function body; +}; + +struct AutoStoryMartExpectation{ +}; + +struct AutoStoryMartCase{ + AutoStoryMartInput input; + AutoStoryMartExpectation expectation; +}; + class Test_AutoStoryMart : public UnitTest{ public: - explicit Test_AutoStoryMart(AutoStoryMartCase test_case) - : UnitTest("PokemonFRLG::AutoStoryMart - " + test_case.input.name) - , m_case(std::move(test_case)) + explicit Test_AutoStoryMart(AutoStoryMartCase test_case) + : UnitTest("PokemonFRLG::AutoStoryMart - " + test_case.input.name) + , m_case(std::move(test_case)) {} virtual UnitTestResult run(Logger&, CancellableScope&) const override{ try{ - return m_case.input.body(); + return m_case.input.body(); }catch (Exception& e){ return std::string(e.name()) + ": " + e.message(); } } private: - AutoStoryMartCase m_case; + AutoStoryMartCase m_case; }; @@ -335,25 +335,27 @@ UnitTestResult test_quantity_presses(){ } -UnitTestResult test_mart_variant(){ +UnitTestResult test_mart_args(){ const MartPlan plan = pewter_plan(2000, {{"potion", 5}, {"repel", 3}}, 2400); - const std::string variant = mart_variant(plan); - if (variant != "mart PewterCity_Mart budget=2000 floor=2400 potion=5 repel=3"){ - return "Unexpected variant \"" + variant + "\"."; - } - const std::optional back = parse_mart_variant(variant); + const Pokemon::StoryActionArgs args = mart_args(plan); + const std::optional back = mart_plan_of(args); if (!back || back->map != plan.map || back->budget != 2000 || back->money_floor != plan.money_floor || back->lines.size() != 2 || back->lines[1].item != "repel" || back->lines[1].quantity != 3 ){ - return "\"" + variant + "\" didn't read back as its plan."; + return "The Pewter plan didn't read back from its args."; } - for (std::string_view bad : { - "mart", "mart PewterCity_Mart budget=2000", "mart Nowhere_Mart potion=1", - "mart ViridianCity_Mart repel=1", "mart PewterCity_Mart potion=0", "mart PewterCity_Mart potion=100", - "mart PewterCity_Mart potion", "teach hm03 surf slot=1", - }){ - if (parse_mart_variant(bad)){ - return "Expected \"" + std::string(bad) + "\" refused."; + const std::vector> bad_args{ + {"items", std::vector{}}, + {"map", std::string("Nowhere_Mart")}, + {"map", std::string("ViridianCity_Mart")}, + {"items", std::vector{{"potion", 0}}}, + {"items", std::vector{{"potion", 100}}}, + }; + for (const auto& [key, value] : bad_args){ + Pokemon::StoryActionArgs bad = args; + bad[key] = value; + if (mart_plan_of(bad)){ + return "Expected a bad " + key + " refused."; } } return true; @@ -396,40 +398,40 @@ UnitTestResult test_count_supplies(){ return true; } -} // namespace - - -const AutoStoryMartCase AUTO_STORY_MART_CASES[] = { - { - .input = {"buy lists on a fake Mart", test_mart_buys}, - .expectation = {}, - }, - { - .input = {"quantity presses", test_quantity_presses}, - .expectation = {}, - }, - { - .input = {"the table's variant", test_mart_variant}, - .expectation = {}, - }, - { - .input = {"Mart stocks", test_mart_stock}, - .expectation = {}, - }, - { - .input = {"bought supplies counted", test_count_supplies}, - .expectation = {}, - }, -}; - +} // namespace + + +const AutoStoryMartCase AUTO_STORY_MART_CASES[] = { + { + .input = {"buy lists on a fake Mart", test_mart_buys}, + .expectation = {}, + }, + { + .input = {"quantity presses", test_quantity_presses}, + .expectation = {}, + }, + { + .input = {"the step's args", test_mart_args}, + .expectation = {}, + }, + { + .input = {"Mart stocks", test_mart_stock}, + .expectation = {}, + }, + { + .input = {"bought supplies counted", test_count_supplies}, + .expectation = {}, + }, +}; + void add_tests_AutoStoryMart(UnitTestDatabase& database){ - for (const auto& item : AUTO_STORY_MART_CASES){ - database.add(item); - } + for (const auto& item : AUTO_STORY_MART_CASES){ + database.add(item); + } } -} // namespace PokemonFRLG -} // namespace NintendoSwitch -} // namespace PokemonAutomation +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMember.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMember.cpp index 6d3f71dd1e..bb4a4b3eb2 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMember.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMember.cpp @@ -5,9 +5,9 @@ */ #include +#include "PokemonFRLG_AutoStoryGameArgs.h" #include "PokemonFRLG_AutoStoryMember.h" #include "PokemonFRLG_AutoStorySummary.h" -#include "PokemonFRLG_AutoStoryVariantWords.h" namespace PokemonAutomation{ namespace NintendoSwitch{ @@ -30,37 +30,17 @@ MemberReader console_member_reader(ConsoleHandle& console, ProControllerContext& } -std::string level_variant(const LevelCheck& check){ - return std::format("{}slot={} min={}", LEVEL_VARIANT_PREFIX, check.slot + 1, check.level); +Pokemon::StoryActionArgs level_args(const LevelCheck& check){ + return {{"slot", int64_t(check.slot + 1)}, {"min", int64_t(check.level)}}; } -std::optional parse_level_variant(std::string_view variant){ - if (!variant.starts_with(LEVEL_VARIANT_PREFIX)){ +std::optional level_check_of(const Pokemon::StoryActionArgs& args){ + const std::optional slot = counted_arg(args, "slot", PARTY_SLOTS); + const std::optional level = number_arg(args, "min", 1, 100); + if (!slot || !level){ return std::nullopt; } - LevelCheck check; - bool slot_seen = false; - bool level_seen = false; - for (std::string_view word : variant_words(variant.substr(LEVEL_VARIANT_PREFIX.size()))){ - const std::optional pair = variant_pair(word); - const std::optional number = pair ? variant_number(pair->value, 3) : std::nullopt; - if (!number){ - return std::nullopt; - } - if (pair->key == "slot" && *number >= 1 && *number <= PARTY_SLOTS){ - check.slot = *number - 1; - slot_seen = true; - }else if (pair->key == "min" && *number >= 1 && *number <= 100){ - check.level = (unsigned)*number; - level_seen = true; - }else{ - return std::nullopt; - } - } - if (!slot_seen || !level_seen){ - return std::nullopt; - } - return check; + return LevelCheck{.slot = *slot, .level = (unsigned)*level}; } Pokemon::StoryStep level_step(std::string name, std::string why, const LevelCheck& check){ @@ -68,7 +48,8 @@ Pokemon::StoryStep level_step(std::string name, std::string why, const LevelChec step.kind = Pokemon::StoryStepKind::GAME; step.name = std::move(name); step.why = std::move(why); - step.variant = level_variant(check); + step.action = LEVEL_ACTION; + step.args = level_args(check); return step; } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMember.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMember.h index 937c4962f7..0c681a9afd 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMember.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMember.h @@ -28,7 +28,8 @@ #include "CommonFramework/Language.h" #include "NintendoSwitch/Controllers/Procon/NintendoSwitch_ProController.h" #include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h" -#include "Pokemon/AutoStory/Pokemon_StorySteps.h" +#include "Pokemon/AutoStory/Pokemon_StoryStepExecutor.h" +#include "Pokemon/AutoStory/Types/Pokemon_StoryActionSpec.h" #include "PokemonFRLG_AutoStoryDamage.h" namespace PokemonAutomation{ @@ -72,13 +73,13 @@ struct LevelCheck{ unsigned level = 1; }; -// The prefix of a GAME step's variant that names a LEVEL step. -inline constexpr std::string_view LEVEL_VARIANT_PREFIX = "level "; - -// `check` as a variant: "level slot=1 min=16", the slot counted from 1. -std::string level_variant(const LevelCheck& check); -// A variant from level_variant(); nothing if it isn't one. -std::optional parse_level_variant(std::string_view variant); +// The GAME action of a LEVEL step: slot INTEGER (required, from 1), min +// INTEGER (required, 1-100). +inline const std::string LEVEL_ACTION = "level"; +// `check` as its action's args. +Pokemon::StoryActionArgs level_args(const LevelCheck& check); +// The check a LEVEL_ACTION step's args give; nothing if one is out of range. +std::optional level_check_of(const Pokemon::StoryActionArgs& args); // The table's LEVEL step. Pokemon::StoryStep level_step(std::string name, std::string why, const LevelCheck& check); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPcStorage.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPcStorage.cpp index 380cdaed9a..9424d87f51 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPcStorage.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPcStorage.cpp @@ -9,6 +9,7 @@ #include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" #include "VideoGames/PokemonFRLG/PokemonFRLG_Navigation.h" #include "PokemonFRLG_AutoStoryActions.h" +#include "PokemonFRLG_AutoStoryGameArgs.h" #include "PokemonFRLG_AutoStoryPcStorage.h" namespace PokemonAutomation{ @@ -30,86 +31,62 @@ constexpr size_t STORAGE_MENU_ROWS = 5; // A second look at a frame that reads as the overworld. constexpr Milliseconds OVERWORLD_CONFIRM = 800ms; -std::vector split_words(std::string_view text){ - std::vector words; - while (!text.empty()){ - const size_t space = text.find(' '); - const std::string_view word = text.substr(0, space); - if (!word.empty()){ - words.push_back(word); - } - if (space == std::string_view::npos){ - break; - } - text.remove_prefix(space + 1); - } - return words; -} - -// "key=N" with N from 1 to `max`, as N - 1. -std::optional counted_value(std::string_view word, std::string_view key, size_t max){ - if (!word.starts_with(key) || word.size() <= key.size() + 1 || word[key.size()] != '='){ - return std::nullopt; - } - size_t value = 0; - for (char c : word.substr(key.size() + 1)){ - if (c < '0' || c > '9' || value > max){ - return std::nullopt; - } - value = value * 10 + size_t(c - '0'); - } - if (value < 1 || value > max){ - return std::nullopt; +// "deposit slot=2 box=1" or "withdraw box=1 slot=7", for the log. +std::string pc_transfer_text(const PcTransfer& transfer){ + if (transfer.action == PcAction::DEPOSIT){ + return std::format( + "deposit slot={} box={}{}", transfer.party_slot + 1, transfer.box + 1, + transfer.if_missing == PcMissing::SKIP ? " if_present" : "" + ); } - return value - 1; + return std::format("withdraw box={} slot={}", transfer.box + 1, transfer.box_slot + 1); } } // namespace -std::string pc_variant(const PcTransfer& transfer){ +Pokemon::StoryActionArgs pc_args(const PcTransfer& transfer){ if (transfer.action == PcAction::DEPOSIT){ - return std::format( - "{}deposit slot={} box={}{}", PC_VARIANT_PREFIX, transfer.party_slot + 1, transfer.box + 1, - transfer.if_missing == PcMissing::SKIP ? " if_present" : "" - ); - } - return std::format("{}withdraw box={} slot={}", PC_VARIANT_PREFIX, transfer.box + 1, transfer.box_slot + 1); + return { + {"do", std::string("deposit")}, + {"slot", int64_t(transfer.party_slot + 1)}, + {"box", int64_t(transfer.box + 1)}, + {"if_present", transfer.if_missing == PcMissing::SKIP}, + }; + } + return { + {"do", std::string("withdraw")}, + {"slot", int64_t(transfer.box_slot + 1)}, + {"box", int64_t(transfer.box + 1)}, + {"if_present", false}, + }; } -std::optional parse_pc_variant(std::string_view variant){ - if (!variant.starts_with(PC_VARIANT_PREFIX)){ +std::optional pc_transfer_of(const Pokemon::StoryActionArgs& args){ + const std::string* action = game_arg(args, "do"); + const std::optional box = counted_arg(args, "box", BOX_COUNT); + if (action == nullptr || !box){ return std::nullopt; } - std::vector words = split_words(variant.substr(PC_VARIANT_PREFIX.size())); - PcTransfer transfer; - if (words.size() == 4 && words[0] == "deposit" && words[3] == "if_present"){ - transfer.if_missing = PcMissing::SKIP; - words.pop_back(); - } - if (words.size() != 3){ - return std::nullopt; + PcTransfer transfer{.box = *box}; + if (*action == "deposit"){ + const std::optional slot = counted_arg(args, "slot", PARTY_SIZE); + const bool* if_present = game_arg(args, "if_present"); + if (!slot){ + return std::nullopt; + } + transfer.party_slot = *slot; + if (if_present != nullptr && *if_present){ + transfer.if_missing = PcMissing::SKIP; + } + return transfer; } - std::optional slot; - std::optional box; - if (words[0] == "deposit"){ - transfer.action = PcAction::DEPOSIT; - slot = counted_value(words[1], "slot", PARTY_SIZE); - box = counted_value(words[2], "box", BOX_COUNT); - }else if (words[0] == "withdraw"){ - transfer.action = PcAction::WITHDRAW; - box = counted_value(words[1], "box", BOX_COUNT); - slot = counted_value(words[2], "slot", BOX_SLOTS); - } - if (!slot || !box){ + const std::optional slot = counted_arg(args, "slot", BOX_SLOTS); + if (*action != "withdraw" || !slot){ return std::nullopt; } - transfer.box = *box; - if (transfer.action == PcAction::DEPOSIT){ - transfer.party_slot = *slot; - }else{ - transfer.box_slot = *slot; - } + transfer.action = PcAction::WITHDRAW; + transfer.box_slot = *slot; return transfer; } @@ -317,7 +294,7 @@ PcDecision PcStorageDialog::on_box_chooser(const PcView& view){ PcResult run_pc_transfer(Logger& logger, PcStorageActions& actions, const PcTransfer& transfer){ - const std::string name = pc_variant(transfer); + const std::string name = pc_transfer_text(transfer); const std::vector party = actions.read_party(); if (transfer.action == PcAction::DEPOSIT && transfer.if_missing == PcMissing::SKIP && transfer.party_slot >= party.size()){ logger.log(std::format("PC: skipped \"{}\": the party has {} Pokemon.", name, party.size())); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPcStorage.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPcStorage.h index 453c78b1d8..139bb82ca0 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPcStorage.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPcStorage.h @@ -49,6 +49,7 @@ #include #include "Common/Cpp/Logging/AbstractLogger.h" #include "Common/Cpp/TestRunners/UnitTestDatabase.h" +#include "Pokemon/AutoStory/Types/Pokemon_StoryActionSpec.h" #include "NintendoSwitch/Controllers/Procon/NintendoSwitch_ProController.h" #include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h" #include "VideoGames/PokemonFRLG/Inference/Box/PokemonFRLG_PcScreenReader.h" @@ -84,16 +85,17 @@ struct PcTransfer{ PcMissing if_missing = PcMissing::REFUSE; }; -// The prefix of a GAME step's variant that names a PC step. -inline constexpr std::string_view PC_VARIANT_PREFIX = "pc "; - -// `transfer` as a GAME step's variant: "pc deposit slot=2 box=1" or -// "pc withdraw box=1 slot=7", slots and boxes counted from 1 as the game -// shows them; a deposit with PcMissing::SKIP ends in " if_present". -std::string pc_variant(const PcTransfer& transfer); -// A variant from pc_variant(); nothing if `variant` isn't one, or names a -// slot or box the game hasn't got. -std::optional parse_pc_variant(std::string_view variant); +// The GAME action of a PC step, slots and boxes counted from 1 as the game +// shows them: do WORD (required), "deposit" or "withdraw"; slot INTEGER +// (required), the party slot (1-6) of a deposit or the box slot (1-30) +// of a withdrawal; box INTEGER (required, 1-14); if_present BOOLEAN +// (false): a deposit skipped when the party hasn't got the slot. +inline const std::string PC_ACTION = "pc"; +// `transfer` as its action's args. +Pokemon::StoryActionArgs pc_args(const PcTransfer& transfer); +// The transfer a PC_ACTION step's args give; nothing if they name a slot +// or box the game hasn't got. +std::optional pc_transfer_of(const Pokemon::StoryActionArgs& args); // A party member as far as a PC step needs to know. diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPcStorage_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPcStorage_Tests.cpp index c3af11e750..926a5a78d1 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPcStorage_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPcStorage_Tests.cpp @@ -516,32 +516,37 @@ UnitTestResult test_pc_dialog_screens(){ } -// The table's variant, both ways, and the variants it refuses. -UnitTestResult test_pc_variant(){ +// The step's args, both ways, and the args it refuses. +UnitTestResult test_pc_args(){ const std::vector transfers = { {.action = PcAction::DEPOSIT, .party_slot = 1, .box = 0}, {.action = PcAction::WITHDRAW, .box = 13, .box_slot = 29}, {.action = PcAction::DEPOSIT, .party_slot = 1, .box = 0, .if_missing = PcMissing::SKIP}, }; - for (const PcTransfer& transfer : transfers){ - const std::string variant = pc_variant(transfer); - const std::optional back = parse_pc_variant(variant); + for (size_t c = 0; c < transfers.size(); c++){ + const PcTransfer& transfer = transfers[c]; + const std::optional back = pc_transfer_of(pc_args(transfer)); if (!back || back->action != transfer.action || back->box != transfer.box || back->party_slot != transfer.party_slot || back->box_slot != transfer.box_slot || back->if_missing != transfer.if_missing ){ - return "\"" + variant + "\" didn't read back as the transfer it was made from."; + return std::format("Transfer {} didn't read back from its args.", c + 1); } } - if (pc_variant(transfers[0]) != "pc deposit slot=2 box=1"){ - return "Expected \"pc deposit slot=2 box=1\", got \"" + pc_variant(transfers[0]) + "\"."; - } - for (std::string_view bad : { - "pc", "pc deposit", "pc deposit slot=7 box=1", "pc deposit slot=0 box=1", "pc deposit slot=2 box=15", - "pc withdraw box=1 slot=31", "pc release slot=1 box=1", "pc deposit box=1 slot=2", "capture rattata", - }){ - if (parse_pc_variant(bad)){ - return "Expected \"" + std::string(bad) + "\" refused."; + const auto args = [](std::string action, int64_t slot, int64_t box){ + return Pokemon::StoryActionArgs{{"do", std::move(action)}, {"slot", slot}, {"box", box}}; + }; + const std::vector bad_args{ + {}, + args("deposit", 7, 1), + args("deposit", 0, 1), + args("deposit", 2, 15), + args("withdraw", 31, 1), + args("release", 1, 1), + }; + for (const Pokemon::StoryActionArgs& bad : bad_args){ + if (pc_transfer_of(bad)){ + return "Expected a missing or out-of-range arg refused."; } } return true; @@ -560,7 +565,7 @@ const AutoStoryPcStorageCase AUTO_STORY_PC_STORAGE_CASES[] = { .expectation = {}, }, { - .input = {"the table's variant", test_pc_variant}, + .input = {"the step's args", test_pc_args}, .expectation = {}, }, }; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRngLoop.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRngLoop.cpp index 4ecb06c609..1b810ac2cd 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRngLoop.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRngLoop.cpp @@ -160,7 +160,7 @@ StoryRunPlan rows_after_gift_rng( throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "No checkpoint after the Magikarp salesman."); } const StoryCheckpoint& row = checkpoints[salesman_row + 1]; - if (row.steps.empty() || row.steps.front().variant != LEAVE_GIFT_SUMMARY){ + if (row.steps.empty() || row.steps.front().action != LEAVE_GIFT_SUMMARY){ throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, row.id + " doesn't start by leaving the gift's summary."); } StoryRunPlan plan; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRngLoop_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRngLoop_Tests.cpp index ce3ab7c091..a7839aff1d 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRngLoop_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRngLoop_Tests.cpp @@ -199,7 +199,7 @@ UnitTestResult test_rows_after_magikarp(){ const size_t salesman_row = row_index("00.12"); const StoryCheckpoint& salesman = checkpoints[salesman_row]; const StoryCheckpoint& after = checkpoints[salesman_row + 1]; - const std::optional start = after.start ? story_pose(*after.start) : std::nullopt; + const std::optional start = after.start ? story_pose(Pokemon::pose_of(*after.start)) : std::nullopt; if (salesman.handoff != StoryHandoff::GIFT_RNG || !after.live_start || !start || start->map != "Route4_PokemonCenter_1F" || !(start->tile == TilePos{2, 3}) || start->facing != Direction::WEST ){ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRowSim.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRowSim.cpp index 791fe18e85..fa86f58335 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRowSim.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRowSim.cpp @@ -15,6 +15,7 @@ #include "Pokemon/AutoStory/Pokemon_TilePose.h" #include "PokemonFRLG_AutoStoryActions.h" #include "PokemonFRLG_AutoStoryRowSim.h" +#include "PokemonFRLG_AutoStoryViridianMart.h" namespace PokemonAutomation{ namespace NintendoSwitch{ @@ -235,7 +236,7 @@ Outcome StoryMapsSim::legs(const Pokemon::Pose& pose, const StoryStep& step) con if (!at.error.empty()){ return Pokemon::outcome_failed("no_pose", at.error); } - const std::optional> route = fixed_route(story_maps(), at.position, step.legs); + const std::optional> route = fixed_route(story_maps(), at.position, Pokemon::story_arg>(step.args, "legs")); if (!route || route->empty()){ return Pokemon::outcome_failed("bad_legs", to_string(at.position)); } @@ -249,14 +250,15 @@ Outcome StoryMapsSim::step_ahead(const Pokemon::Pose& pose, const StoryStep& ste if (!at){ return Pokemon::outcome_failed("no_pose", Pokemon::to_string(pose)); } + const Direction direction = Pokemon::story_arg(step.args, "direction"); const MapData* map = map_named(at->map); - if (step.variant != TRAINER_LINE_VARIANT || map == nullptr){ - return Pokemon::outcome_ok(to_pose(StoryPose{at->map, at->tile.next(step.direction), step.direction})); + if (step.action != TRAINER_LINE_VARIANT || map == nullptr){ + return Pokemon::outcome_ok(to_pose(StoryPose{at->map, at->tile.next(direction), direction})); } TilePos onto = at->tile; const std::optional stepped = step_until_seen( TRAINER_LINE_TILES, - [&]{ onto = onto.next(step.direction); }, + [&]{ onto = onto.next(direction); }, [&]{ return std::any_of(map->objects.begin(), map->objects.end(), [&](const MapObject& object){ return object.trainer && trainer_may_see(*map, object, onto); @@ -266,15 +268,16 @@ Outcome StoryMapsSim::step_ahead(const Pokemon::Pose& pose, const StoryStep& ste if (!stepped){ return Pokemon::outcome_failed("no_trainer", to_string(MapPosition{at->map, onto})); } - return Pokemon::outcome_ok(to_pose(StoryPose{at->map, onto, step.direction})); + return Pokemon::outcome_ok(to_pose(StoryPose{at->map, onto, direction})); } // The Viridian Mart's list as the game shows it. After a purchase the // cursor stays on the row bought (console B, 2026-11-01), so each // order moves it from there, as buy_items() does since ad5d40885. Outcome StoryMapsSim::shop(const StoryStep& step){ + const std::vector& items = Pokemon::story_arg>(step.args, "items"); static const std::vector LIST{"poke_ball", "potion", "antidote", "parlyz_heal", "cancel"}; - const std::optional> orders = viridian_mart_orders(step.items); + const std::optional> orders = viridian_mart_orders(items); if (!orders){ return Pokemon::outcome_failed("unknown_item", step.name); } @@ -286,8 +289,8 @@ Outcome StoryMapsSim::shop(const StoryStep& step){ if (cursor < 0 || cursor >= (int)LIST.size() || LIST[cursor] == "cancel"){ return Pokemon::outcome_failed("mart_cancel", std::format("order {} ends on row {}", c + 1, cursor + 1)); } - if (LIST[cursor] != step.items[c].item){ - return Pokemon::outcome_failed("wrong_item", std::format("{} instead of {}", LIST[cursor], step.items[c].item)); + if (LIST[cursor] != items[c].item){ + return Pokemon::outcome_failed("wrong_item", std::format("{} instead of {}", LIST[cursor], items[c].item)); } m_bag[LIST[cursor]] += order.quantity; } @@ -298,7 +301,7 @@ Outcome StoryMapsSim::walk_to(const Pokemon::Pose& pose, const StoryStep& step) if (Pokemon::tiles_of(pose).size() > 1){ // From the tiles a pacing step leaves: the route must plan, and // test_routes_after_pacing() walks it on the sim from each. - const std::optional target = story_pose(*step.target); + const std::optional target = story_pose(Pokemon::pose_of(Pokemon::story_arg(step.args, "target"))); const RouteGoal goal{{target->map, target->tile}, target->facing}; const std::optional> route = plan_story_route(story_maps(), pose, std::nullopt, goal); if (!route || route->empty()){ @@ -310,7 +313,7 @@ Outcome StoryMapsSim::walk_to(const Pokemon::Pose& pose, const StoryStep& step) if (!at.error.empty()){ return Pokemon::outcome_failed("no_pose", at.error); } - const std::optional target = story_pose(*step.target); + const std::optional target = story_pose(Pokemon::pose_of(Pokemon::story_arg(step.args, "target"))); const RouteGoal goal{{target->map, target->tile}, target->facing}; const std::optional> route = plan_overworld_route( story_maps(), at.position, goal, story_route_costs(), at.facing @@ -335,9 +338,9 @@ Outcome StoryMapsSim::walk_to(const Pokemon::Pose& pose, const StoryStep& step) std::optional> walked_route(const StoryPose& at, const StoryStep& step){ const MapPosition start{at.map, at.tile}; if (step.kind == StoryStepKind::LEGS){ - return fixed_route(story_maps(), start, step.legs); + return fixed_route(story_maps(), start, Pokemon::story_arg>(step.args, "legs")); } - const std::optional target = story_pose(*step.target); + const std::optional target = story_pose(Pokemon::pose_of(Pokemon::story_arg(step.args, "target"))); const RouteGoal goal{{target->map, target->tile}, target->facing}; return plan_overworld_route(story_maps(), start, goal, story_route_costs(), at.facing); } @@ -396,43 +399,46 @@ std::string OverworldStepSim::walk(const StoryStep& step){ // a step one tap at a time, or for a step into a trainer's line by // step_until_seen(), each watched for the trainer. std::string OverworldStepSim::step_ahead(const StoryStep& step){ - if (step.variant.empty() && step.pose_after){ + if (step.action.empty() && step.pose_after){ return step_onto(step); } - const auto tap = [this, &step]{ - if (m_sim.state().facing != step.direction){ - m_sim.tap(step.direction); + const Direction direction = Pokemon::story_arg(step.args, "direction"); + const auto tap = [this, direction]{ + if (m_sim.state().facing != direction){ + m_sim.tap(direction); } - m_sim.tap(step.direction); + m_sim.tap(direction); }; const auto seen = [this]{ return m_sim.watch({SimWatcher::MESSAGE, SimWatcher::BATTLE_SCREEN}, TRAINER_LINE_WATCH).has_value(); }; - const int tiles = step.variant == TRAINER_LINE_VARIANT ? TRAINER_LINE_TILES : 1; + const int tiles = step.action == TRAINER_LINE_VARIANT ? TRAINER_LINE_TILES : 1; return step_until_seen(tiles, tap, seen) ? "" : "no trainer saw the player."; } // A hop() or step_onto(): one step, ending where the table says. std::string OverworldStepSim::step_onto(const StoryStep& step){ - if (m_sim.state().facing != step.direction){ - m_sim.tap(step.direction); + const Direction direction = Pokemon::story_arg(step.args, "direction"); + if (m_sim.state().facing != direction){ + m_sim.tap(direction); } - m_sim.tap(step.direction); - m_at = *story_pose(*step.pose_after); + m_sim.tap(direction); + m_at = *story_pose(Pokemon::pose_of(*step.pose_after)); return m_sim.state().position == MapPosition{m_at.map, m_at.tile} ? "" : "expected to end on " + to_string(MapPosition{m_at.map, m_at.tile}) + "."; } // A CUT_TREE_VARIANT step: turned to the tree, cut, and a step onto its // tile. std::string OverworldStepSim::cut(const StoryStep& step){ - if (m_sim.state().facing != step.direction){ - m_sim.tap(step.direction); + const Direction direction = Pokemon::story_arg(step.args, "direction"); + if (m_sim.state().facing != direction){ + m_sim.tap(direction); } if (!m_sim.cut_tree()){ return "no tree to cut."; } - m_sim.tap(step.direction); - m_at = StoryPose{m_at.map, m_at.tile.next(step.direction), step.direction}; + m_sim.tap(direction); + m_at = StoryPose{m_at.map, m_at.tile.next(direction), direction}; if (!(m_sim.state().position == MapPosition{m_at.map, m_at.tile})){ return "expected to step onto the tree's tile " + to_string(MapPosition{m_at.map, m_at.tile}) + "."; } @@ -445,7 +451,7 @@ std::string OverworldStepSim::battle(const StoryStep& step){ if (!m_sim.close_message() || m_sim.handle_battle(SimBattleChoice::FIGHT) != SimBattleEnd::ENDED){ return "no_battle."; } - m_at = *story_pose(*step.pose_after); + m_at = *story_pose(Pokemon::pose_of(*step.pose_after)); if (!(m_sim.state().position == MapPosition{m_at.map, m_at.tile})){ return "expected " + to_string(MapPosition{m_at.map, m_at.tile}) + "."; } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows_Tests.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows_Tests.h new file mode 100644 index 0000000000..2d07d000b6 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows_Tests.h @@ -0,0 +1,31 @@ +/* AutoStory Row Tests + * + * From: https://github.com/PokemonAutomation/ + * + * Registration of the tests that run story rows on the overworld sim, + * one file per stretch of the story. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_AutoStoryRows_Tests_H +#define PokemonAutomation_PokemonFRLG_AutoStoryRows_Tests_H + +#include "Common/Cpp/TestRunners/UnitTestDatabase.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// Rows 00.21 and 00.22 on the overworld sim (PokemonFRLG_AutoStoryVermilion_Tests.cpp). +void add_tests_AutoStoryVermilion(UnitTestDatabase& database); +// Rows 00.23 to 00.25 on the overworld sim (PokemonFRLG_AutoStoryVermilionGym_Tests.cpp). +void add_tests_AutoStoryVermilionGym(UnitTestDatabase& database); +// Rows from 00.26 on on the overworld sim (PokemonFRLG_AutoStoryCeladon_Tests.cpp). +void add_tests_AutoStoryCeladon(UnitTestDatabase& database); + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRunPlan_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRunPlan_Tests.cpp index 39230fefbc..1bdca6cf89 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRunPlan_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRunPlan_Tests.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include "Common/Cpp/Exceptions.h" #include "Common/Cpp/TestRunners/UnitTest.h" @@ -302,13 +303,13 @@ UnitTestResult test_starter_rows_joined(){ return "Expected 00.04 \"Squirtle, then the rival's battle\": " + expected_steps + "; got " + row.id + " \"" + row.title + "\": " + step_names(row); } - const std::optional start = story_pose(*row.start); + const std::optional start = story_pose(Pokemon::pose_of(*row.start)); if (!start || start->map != "PalletTown_ProfessorOaksLab" || !(start->tile == TilePos{6, 4}) || row.menu != StartMenu::BEFORE_POKEDEX){ return "Expected the joined 00.04 to start at the table (6, 4) and save with the starter's START menu."; } // Split, 00.04 saves under the ball facing it, before the starter. const StoryCheckpoint& to_ball = checkpoints[row_index("00.04")]; - const std::optional ball = story_pose(*checkpoints[row_index("00.04b")].start); + const std::optional ball = story_pose(Pokemon::pose_of(*checkpoints[row_index("00.04b")].start)); if (to_ball.handoff != StoryHandoff::STARTER_RNG || to_ball.menu != StartMenu::BEFORE_POKEMON || !ball || !(ball->tile == TilePos{9, 5}) || ball->facing != Direction::NORTH ){ @@ -344,6 +345,40 @@ size_t find_step(const std::vector& steps, size_t from, const std::fu return steps.size(); } +// `step`'s pose arg `key`, or nothing. +std::optional pose_arg(const StoryStep& step, std::string_view key){ + const Pokemon::GridPose* pose = Pokemon::value_if_at_it(step.args, step.args.find(key)); + return pose == nullptr ? std::nullopt : std::optional(Pokemon::pose_of(*pose)); +} + +// `step`'s pose arg `key` as a StoryPose, or nothing. +std::optional story_pose_arg(const StoryStep& step, std::string_view key){ + const std::optional pose = pose_arg(step, key); + return pose ? story_pose(*pose) : std::nullopt; +} + +// `step`'s MART, TEACH or GRIND plan, or nothing when it is another step. +std::optional mart_of(const StoryStep& step){ + return step.action == MART_ACTION ? mart_plan_of(step.args) : std::nullopt; +} +std::optional teach_of(const StoryStep& step){ + return step.action == TEACH_ACTION ? teach_plan_of(step.args) : std::nullopt; +} +std::optional grind_of(const StoryStep& step){ + return step.action == GRIND_ACTION ? grind_plan_of(step.args) : std::nullopt; +} + +// The GRIND at `grind`'s patch, the target of the route right before it, +// and its nurse; nothing without either. +std::optional> grind_trip(const std::vector& steps, size_t grind){ + const std::optional patch = grind == 0 || grind >= steps.size() ? std::nullopt : pose_arg(steps[grind - 1], "target"); + const std::optional nurse = grind >= steps.size() ? std::nullopt : pose_arg(steps[grind], "nurse"); + if (!patch || !nurse){ + return std::nullopt; + } + return std::pair{*patch, *nurse}; +} + // Whether a route plans from `from` to `to` (ending facing as `to` does). bool plans(const Pokemon::Pose& from, const Pokemon::Pose& to){ const std::optional start = story_pose(from); @@ -367,28 +402,28 @@ bool plans(const Pokemon::Pose& from, const Pokemon::Pose& to){ UnitTestResult test_cerulean_mart_and_grind(){ const StoryCheckpoint& row = story_checkpoints()[row_index("00.15")]; const std::vector& steps = row.steps; - const std::optional start = row.start ? story_pose(*row.start) : std::nullopt; + const std::optional start = row.start ? story_pose(Pokemon::pose_of(*row.start)) : std::nullopt; if (!start || start->map != "CeruleanCity_PokemonCenter_1F"){ return "00.15: expected it to start in Cerulean's Center."; } - const std::optional teach = steps.empty() ? std::nullopt : parse_teach_variant(steps[0].variant); + const std::optional teach = steps.empty() ? std::nullopt : teach_of(steps[0]); if (!teach || teach->item != "tm03" || teach->move != "water-pulse" || teach->member != 0 || teach->forget_move != "tail-whip"){ return "00.15: expected it to start with TM03 Water Pulse over the lead's Tail Whip."; } const size_t mart = find_step(steps, 0, [](const StoryStep& step){ - const std::optional plan = parse_mart_variant(step.variant); + const std::optional plan = mart_of(step); return plan && plan->map == "CeruleanCity_Mart" && !plan->lines.empty() && plan->lines[0].item == "potion"; }); const std::optional rival = story_trainer("CeruleanCity", "rival_cerulean"); const size_t grind = find_step(steps, mart, [&](const StoryStep& step){ - const std::optional plan = parse_grind_variant(step.variant); + const std::optional plan = grind_of(step); return plan && plan->member == 0 && rival && plan->trainer == *rival && plan->min_chance == MIN_WIN_CHANCE && plan->level > 25; }); if (mart == steps.size() || grind == steps.size()){ return "00.15: expected a Cerulean Mart step buying Potions, then a GRIND of the lead until the rival is 50%, capped above Lv25."; } - const MartPlan plan = *parse_mart_variant(steps[mart].variant); + const MartPlan plan = *mart_of(steps[mart]); const std::optional> buys = plan.money_floor ? plan_mart_buys(mart_stock(plan.map), plan, *plan.money_floor) : std::nullopt; @@ -398,15 +433,15 @@ UnitTestResult test_cerulean_mart_and_grind(){ if (!awakenings){ return "00.15: expected the Mart step to buy 2 or more Awakenings at its money floor."; } - const std::optional clerk = mart > 0 && steps[mart - 1].target ? story_pose(*steps[mart - 1].target) : std::nullopt; + const std::optional clerk = mart > 0 ? story_pose_arg(steps[mart - 1], "target") : std::nullopt; if (!clerk || clerk->map != "CeruleanCity_Mart"){ return "00.15: expected the Mart step right after a route to the clerk."; } - if (grind == 0 || !steps[grind - 1].target || !steps[grind].target){ + const auto trip = grind_trip(steps, grind); + if (!trip){ return "00.15: expected the GRIND right after a route to its patch, with the nurse as its target."; } - const Pokemon::Pose& patch = *steps[grind - 1].target; - const Pokemon::Pose& nurse = *steps[grind].target; + const auto& [patch, nurse] = *trip; const std::optional nurse_pose = story_pose(nurse); if (!nurse_pose || nurse_pose->map != "CeruleanCity_PokemonCenter_1F" || !plans(patch, nurse) || !plans(nurse, patch)){ return "00.15: expected the GRIND's trips to Cerulean's nurse and back to plan."; @@ -424,7 +459,7 @@ UnitTestResult test_cerulean_rival_row(){ const std::vector& checkpoints = story_checkpoints(); const size_t index = row_index("00.15b"); const StoryCheckpoint& rival = checkpoints[index]; - const std::optional start = rival.start ? story_pose(*rival.start) : std::nullopt; + const std::optional start = rival.start ? story_pose(Pokemon::pose_of(*rival.start)) : std::nullopt; if (!start || rival.live_start || start->map != "CeruleanCity" || !(start->tile == TilePos{23, 7}) || save_card_place(start->map).empty() ){ @@ -437,7 +472,7 @@ UnitTestResult test_cerulean_rival_row(){ if (battles != " rival_cerulean" || rival.steps.size() != 3 || rival.steps[1].name != "rival_trigger"){ return "00.15b: expected a TEACH, the step onto his trigger and his battle; its battles:" + battles; } - const std::optional teach = parse_teach_variant(rival.steps[0].variant); + const std::optional teach = teach_of(rival.steps[0]); if (rival.steps[0].kind != StoryStepKind::GAME || !teach || teach->item != "tm03" || teach->move != "water-pulse" || teach->member != 0 || teach->forget_move != "tail-whip" ){ @@ -445,7 +480,7 @@ UnitTestResult test_cerulean_rival_row(){ } const StoryCheckpoint& before = checkpoints[index - 1]; const size_t n = before.steps.size(); - const std::optional end = n > 0 && before.steps[n - 1].target ? story_pose(*before.steps[n - 1].target) : std::nullopt; + const std::optional end = n > 0 ? story_pose_arg(before.steps[n - 1], "target") : std::nullopt; if (before.id != "00.15" || n < 2 || before.steps[n - 2].kind != StoryStepKind::HEAL || !end || end->map != start->map || !(end->tile == start->tile) ){ @@ -482,13 +517,13 @@ UnitTestResult test_misty_rows(){ } const std::vector& steps = gym.steps; const size_t mart = find_step(steps, 0, [](const StoryStep& step){ - const std::optional plan = parse_mart_variant(step.variant); + const std::optional plan = mart_of(step); return plan && plan->map == "CeruleanCity_Mart" && !plan->lines.empty() && plan->lines[0].item == "potion"; }); if (mart == steps.size() || !battle_names(gym).empty()){ return "00.14b: expected a Cerulean Mart step buying Potions and no battle; its battles:" + battle_names(gym); } - const std::optional start = misty.start ? story_pose(*misty.start) : std::nullopt; + const std::optional start = misty.start ? story_pose(Pokemon::pose_of(*misty.start)) : std::nullopt; if (!start || misty.live_start || start->map != "CeruleanCity_Gym" || !(start->tile == TilePos{9, 7}) || save_card_place(start->map).empty() ){ @@ -499,12 +534,12 @@ UnitTestResult test_misty_rows(){ ){ return "00.14c: expected a walk beside Misty, the talk and her battle, the only one; its battles:" + battle_names(misty); } - const std::optional beside = misty.steps[0].target ? story_pose(*misty.steps[0].target) : std::nullopt; + const std::optional beside = story_pose_arg(misty.steps[0], "target"); if (!beside || !(beside->tile == TilePos{9, 6}) || beside->facing != Direction::WEST){ return "00.14c: expected the talk from (9, 6), facing Misty (8, 6)."; } const size_t teach = find_step(misty.steps, 0, [](const StoryStep& step){ - const std::optional plan = parse_teach_variant(step.variant); + const std::optional plan = teach_of(step); return plan && plan->item == "tm03" && plan->move == "water-pulse" && plan->member == 0 && plan->forget_move == "tail-whip"; }); if (teach == misty.steps.size()){ @@ -523,7 +558,7 @@ UnitTestResult test_misty_grind_order(){ const std::vector& steps = story_checkpoints()[row_index("00.14b")].steps; std::optional plan; const size_t mart = find_step(steps, 0, [&](const StoryStep& step){ - plan = parse_mart_variant(step.variant); + plan = mart_of(step); return plan && plan->map == "CeruleanCity_Mart"; }); if (mart == steps.size() || plan->lines.size() < 2 || plan->lines[0].item != "potion" || plan->lines[1].item != "super-potion" @@ -536,16 +571,16 @@ UnitTestResult test_misty_grind_order(){ return "00.14b: expected the money floor to buy 2 or more Potions and a Super Potion."; } const size_t grind = find_step(steps, mart, [](const StoryStep& step){ - const std::optional grind_plan = parse_grind_variant(step.variant); + const std::optional grind_plan = grind_of(step); return grind_plan && grind_plan->member == 0 && grind_plan->level >= 23; }); - if (grind == steps.size() || !steps[grind - 1].target || !steps[grind].target){ + const auto trip = grind_trip(steps, grind); + if (!trip){ return "00.14b: expected a GRIND of the lead to Lv23 after the Mart, right after a route to its patch, the nurse its target."; } - const std::optional patch = story_pose(*steps[grind - 1].target); - const std::optional nurse = story_pose(*steps[grind].target); + const std::optional patch = story_pose(trip->first), nurse = story_pose(trip->second); if (!patch || patch->map != "Route4" || !nurse || nurse->map != "CeruleanCity_PokemonCenter_1F" - || !plans(*steps[grind - 1].target, *steps[grind].target) || !plans(*steps[grind].target, *steps[grind - 1].target) + || !plans(trip->first, trip->second) || !plans(trip->second, trip->first) ){ return "00.14b: expected the GRIND on Route 4, its trips to Cerulean's nurse and back planning."; } @@ -553,7 +588,7 @@ UnitTestResult test_misty_grind_order(){ return step.name == "heal_cerulean"; }); const size_t gym = find_step(steps, grind + 1, [](const StoryStep& step){ - const std::optional pose = step.target ? story_pose(*step.target) : std::nullopt; + const std::optional pose = story_pose_arg(step, "target"); return pose && pose->map == "CeruleanCity_Gym"; }); if (heal == steps.size() || gym == steps.size() || heal > gym){ @@ -561,7 +596,7 @@ UnitTestResult test_misty_grind_order(){ } StoryPose end; for (const StoryStep& step : steps){ - const std::optional pose = step.target ? story_pose(*step.target) : std::nullopt; + const std::optional pose = story_pose_arg(step, "target"); end = pose ? *pose : end; } if (end.map != "CeruleanCity_Gym"){ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySimulation_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySimulation_Tests.cpp index 6685da4ef9..1cf76ebc65 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySimulation_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySimulation_Tests.cpp @@ -27,7 +27,7 @@ #include "Common/Cpp/Exceptions.h" #include "Common/Cpp/TestRunners/UnitTest.h" #include "Pokemon/AutoStory/Pokemon_StorySegments.h" -#include "Pokemon/AutoStory/Pokemon_StorySteps.h" +#include "Pokemon/AutoStory/Pokemon_StoryStepExecutor.h" #include "Pokemon/AutoStory/Pokemon_TilePose.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h" @@ -36,7 +36,6 @@ #include "PokemonFRLG_AutoStoryEvents.h" #include "PokemonFRLG_AutoStoryPaceSim.h" #include "PokemonFRLG_AutoStoryRowSim.h" -#include "Data/JsonParser.h" #include "PokemonFRLG_AutoStoryStepTable.h" #include "PokemonFRLG_AutoStoryTable.h" @@ -58,6 +57,21 @@ std::string joined(const std::vector& lines){ return text; } +// A checkpoint's start as the engine's Pose: nothing for a new game. +std::optional start_pose(const StoryCheckpoint& checkpoint){ + return checkpoint.start ? std::optional(Pokemon::pose_of(*checkpoint.start)) : std::nullopt; +} + +// The table's checkpoint `id`; throws if it has none. +const StoryCheckpoint& checkpoint_row(std::string_view id){ + const std::vector& rows = story_checkpoints(); + const auto row = std::find_if(rows.begin(), rows.end(), [id](const StoryCheckpoint& data){ return data.id == id; }); + if (row == rows.end()){ + throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "No checkpoint " + std::string(id) + "."); + } + return *row; +} + // The story on the story maps (StoryMapsSim), with a trace of what ran // and steps told to fail. class FakeGame : public StoryMapsSim{ @@ -112,9 +126,7 @@ struct Simulation{ std::vector> saves; Pokemon::SegmentPolicy policy; - // A language no reader supports, so a step that needed text would show. Pokemon::SegmentReport run(const Pokemon::SegmentRange& range){ - game.set_language(Language::Japanese); Pokemon::Segment segment; segment.id = "00"; for (const StoryCheckpoint& data : rows){ @@ -122,7 +134,7 @@ struct Simulation{ .id = data.id, .title = data.title, .saves = true, .build = [this, &data]{ Pokemon::Checkpoint checkpoint = Pokemon::build_story_checkpoint(data, game); - add_start_pose_check(checkpoint, data.start, [this]{ return game.save_stands; }, [this](const std::string& line){ lines.push_back(line); }); + add_start_pose_check(checkpoint, start_pose(data), [this]{ return game.save_stands; }, [this](const std::string& line){ lines.push_back(line); }); return checkpoint; }, }); @@ -164,38 +176,38 @@ struct Simulation{ }; -struct AutoStorySimulationInput{ - std::string name; - UnitTestResult (*body)(); - // A body that logs, run instead of `body` if given. - UnitTestResult (*logged)(Logger&) = {}; -}; - -struct AutoStorySimulationExpectation{ - std::string description; -}; - -struct AutoStorySimulationTestCase{ - AutoStorySimulationInput input; - AutoStorySimulationExpectation expectation; -}; - +struct AutoStorySimulationInput{ + std::string name; + UnitTestResult (*body)(); + // A body that logs, run instead of `body` if given. + UnitTestResult (*logged)(Logger&) = {}; +}; + +struct AutoStorySimulationExpectation{ + std::string description; +}; + +struct AutoStorySimulationTestCase{ + AutoStorySimulationInput input; + AutoStorySimulationExpectation expectation; +}; + class Test_AutoStorySimulation : public UnitTest{ public: - explicit Test_AutoStorySimulation(AutoStorySimulationTestCase scenario) - : UnitTest("PokemonFRLG::AutoStory - Simulation: " + scenario.input.name) - , m_scenario(std::move(scenario)) + explicit Test_AutoStorySimulation(AutoStorySimulationTestCase scenario) + : UnitTest("PokemonFRLG::AutoStory - Simulation: " + scenario.input.name) + , m_scenario(std::move(scenario)) {} virtual UnitTestResult run(Logger& logger, CancellableScope&) const override{ try{ - return m_scenario.input.logged ? m_scenario.input.logged(logger) : m_scenario.input.body(); + return m_scenario.input.logged ? m_scenario.input.logged(logger) : m_scenario.input.body(); }catch (Exception& e){ return std::string(e.name()) + ": " + e.message(); } } private: - AutoStorySimulationTestCase m_scenario; + AutoStorySimulationTestCase m_scenario; }; @@ -215,13 +227,13 @@ UnitTestResult test_whole_story(){ // Each checkpoint starts where the save before it stands. for (size_t c = 1; c < sim.rows.size(); c++){ const StoryCheckpoint& data = sim.rows[c]; - const std::optional start = story_pose(*data.start); + const std::optional start = story_pose(*start_pose(data)); const std::optional saved = story_pose(sim.saves[c - 1].second); const bool same = start && saved && start->map == saved->map && start->tile == saved->tile && (!start->facing || start->facing == saved->facing); if (!same){ return std::format("{} starts at {}, but {} saved at {}.", data.id, - Pokemon::to_string(*data.start), sim.saves[c - 1].first, Pokemon::to_string(sim.saves[c - 1].second)); + Pokemon::to_string(*start_pose(data)), sim.saves[c - 1].first, Pokemon::to_string(sim.saves[c - 1].second)); } } if (report.one_shot_passes() != report.checkpoints_run){ @@ -349,12 +361,13 @@ std::string walk_on_sim(OverworldSim& sim, StoryPose& at, const StoryStep& step) open_end = last.action == RouteAction::WALK && !last.to_wall && !last.warps; at = StoryPose{last.end.map, last.end.point, last.facing_after}; }else if (step.kind == StoryStepKind::STEP){ - if (sim.state().facing != step.direction){ - sim.tap(step.direction); + const Direction direction = Pokemon::story_arg(step.args, "direction"); + if (sim.state().facing != direction){ + sim.tap(direction); } - sim.tap(step.direction); + sim.tap(direction); sim.watch({SimWatcher::MESSAGE}, std::chrono::milliseconds(2000)); - at = *story_pose(*step.pose_after); + at = *story_pose(Pokemon::pose_of(*step.pose_after)); } if (!open_end && !(sim.state().position == MapPosition{at.map, at.tile})){ return where + "expected " + to_string(MapPosition{at.map, at.tile}) + ", but on " + to_string(sim.state().position) + "."; @@ -370,17 +383,13 @@ std::string walk_on_sim(OverworldSim& sim, StoryPose& at, const StoryStep& step) // foot of Route 4's ledge, the row's walks on the sim reach the nurse // with that leg whole or a tile short. UnitTestResult test_cerulean_entry_short(){ - const std::vector& rows = story_checkpoints(); - const auto row = std::find_if(rows.begin(), rows.end(), [](const StoryCheckpoint& data){ return data.id == "00.14"; }); - if (row == rows.end()){ - return "No checkpoint 00.14."; - } + const StoryCheckpoint* row = &checkpoint_row("00.14"); const auto hop = std::find_if(row->steps.begin(), row->steps.end(), [](const StoryStep& step){ return step.name == "ledge_hop"; }); if (hop == row->steps.end() || !hop->pose_after){ return "00.14: no ledge_hop."; } for (int short_by : {0, 1}){ - StoryPose at = *story_pose(*hop->pose_after); + StoryPose at = *story_pose(Pokemon::pose_of(*hop->pose_after)); SimScript script; script.short_holds[1] = short_by; OverworldSim sim(story_maps(), MapPosition{at.map, at.tile}, *at.facing, script); @@ -401,17 +410,13 @@ UnitTestResult test_cerulean_entry_short(){ // end, whole or a tile short, the five trainers are met and beaten on // the sim, each battle on the trainer's row. UnitTestResult test_nugget_bridge_short(){ - const std::vector& rows = story_checkpoints(); - const auto row = std::find_if(rows.begin(), rows.end(), [](const StoryCheckpoint& data){ return data.id == "00.16"; }); - if (row == rows.end()){ - return "No checkpoint 00.16."; - } + const StoryCheckpoint* row = &checkpoint_row("00.16"); const auto walk = std::find_if(row->steps.begin(), row->steps.end(), [](const StoryStep& step){ return step.name == "below_cale_line"; }); - if (walk == row->steps.end() || !walk->target){ + if (walk == row->steps.end() || !walk->args.contains("target")){ return "No step 00.16/below_cale_line."; } for (int short_by : {0, 1}){ - StoryPose at = *story_pose(*walk->target); + StoryPose at = *story_pose(Pokemon::pose_of(Pokemon::story_arg(walk->args, "target"))); OverworldSim sim(story_maps(), MapPosition{at.map, {at.tile.x, at.tile.y + short_by}}, Direction::NORTH); for (auto step = walk + 1; step != row->steps.end() && step->kind != StoryStepKind::READY; ++step){ const std::string failure = row_step_on_sim(sim, at, *step, "00.16"); @@ -432,12 +437,8 @@ UnitTestResult test_nugget_bridge_short(){ // they may look, so Youngster Dan sees the player on (20, 4), walks up // to (21, 4) and is fought there, off the way on. UnitTestResult test_route25_trainers(){ - const std::vector& rows = story_checkpoints(); - const auto row = std::find_if(rows.begin(), rows.end(), [](const StoryCheckpoint& data){ return data.id == "00.17"; }); - if (row == rows.end()){ - return "No checkpoint 00.17."; - } - StoryPose at = *story_pose(*row->start); + const StoryCheckpoint* row = &checkpoint_row("00.17"); + StoryPose at = *story_pose(Pokemon::pose_of(*row->start)); OverworldSim sim(story_maps(), MapPosition{at.map, at.tile}, *at.facing); for (const StoryStep& step : row->steps){ const std::string failure = row_step_on_sim(sim, at, step, "00.17"); @@ -485,12 +486,8 @@ std::vector maps_bridge_beaten(){ } UnitTestResult test_oddish_walks(){ - const std::vector& rows = story_checkpoints(); - const auto row = std::find_if(rows.begin(), rows.end(), [](const StoryCheckpoint& data){ return data.id == "00.20"; }); - if (row == rows.end()){ - return "No checkpoint 00.20."; - } - StoryPose at = *story_pose(*row->start); + const StoryCheckpoint* row = &checkpoint_row("00.20"); + StoryPose at = *story_pose(Pokemon::pose_of(*row->start)); OverworldSim sim(maps_bridge_beaten(), MapPosition{at.map, at.tile}, *at.facing); const std::map ends{ {"mart_clerk", {"CeruleanCity_Mart", {4, 3}}}, @@ -532,6 +529,12 @@ std::string walk_paced_route(OverworldSim& sim, const std::vector& ro return failure.empty() ? "" : label + ": " + failure + " On " + to_string(sim.state().position) + "."; } +// A ROUTE's target as a pose, or nothing for another step. +std::optional target_of(const StoryStep& step){ + const Pokemon::GridPose* target = Pokemon::value_if_at_it(step.args, step.args.find("target")); + return target == nullptr ? std::nullopt : std::optional(Pokemon::pose_of(*target)); +} + // Console B, 2026-11-03 (row 00.20, run m61): the Oddish's battle came // on the pace's far step, so the capture left the player on (3, 19), not // the table's (4, 19). The walk back planned from (4, 19) went a column @@ -547,18 +550,14 @@ std::string walk_paced_route(OverworldSim& sim, const std::vector& ro // stopped. From the Mart, the walk to the patch on the sim keeps out of // his sight with the leg west whole or a tile short. UnitTestResult test_oddish_patch_west_short(){ - const std::vector& rows = story_checkpoints(); - const auto row = std::find_if(rows.begin(), rows.end(), [](const StoryCheckpoint& data){ return data.id == "00.20"; }); - if (row == rows.end()){ - return "No checkpoint 00.20."; - } + const StoryCheckpoint* row = &checkpoint_row("00.20"); const auto mart = std::find_if(row->steps.begin(), row->steps.end(), [](const StoryStep& step){ return step.name == "mart_clerk"; }); const auto patch = std::find_if(row->steps.begin(), row->steps.end(), [](const StoryStep& step){ return step.name == "oddish_patch"; }); - if (mart == row->steps.end() || patch == row->steps.end() || !mart->target || !patch->target){ + if (mart == row->steps.end() || patch == row->steps.end() || !target_of(*mart) || !target_of(*patch)){ return "00.20: no mart_clerk or oddish_patch."; } for (int short_by : {0, 1}){ - StoryPose at = *story_pose(*mart->target); + StoryPose at = *story_pose(*target_of(*mart)); SimScript script; // Holds from the Mart: south, west, north, east, north, east, north // over the bridge, then the 8th, west from the bridge's head. @@ -572,7 +571,7 @@ UnitTestResult test_oddish_patch_west_short(){ if (!sim.state().trainers_beaten.empty()){ return label + "a trainer saw the player, on " + to_string(sim.state().position) + "."; } - const StoryPose end = *story_pose(*patch->target); + const StoryPose end = *story_pose(*target_of(*patch)); if (!(sim.state().position == MapPosition{end.map, end.tile})){ return label + "ended on " + to_string(sim.state().position) + ", not " + to_string(MapPosition{end.map, end.tile}) + "."; } @@ -581,17 +580,13 @@ UnitTestResult test_oddish_patch_west_short(){ } UnitTestResult test_oddish_battle_on_far_step(){ - const std::vector& rows = story_checkpoints(); - const auto row = std::find_if(rows.begin(), rows.end(), [](const StoryCheckpoint& data){ return data.id == "00.20"; }); - if (row == rows.end()){ - return "No checkpoint 00.20."; - } + const StoryCheckpoint* row = &checkpoint_row("00.20"); const auto capture = std::find_if(row->steps.begin(), row->steps.end(), [](const StoryStep& step){ return step.name == "catch_oddish"; }); - if (capture == row->steps.end() || capture + 1 == row->steps.end() || !(capture + 1)->target){ + if (capture == row->steps.end() || capture + 1 == row->steps.end() || !target_of(*(capture + 1))){ return "00.20: no catch_oddish with a route after it."; } const auto patch = std::find_if(row->steps.begin(), capture, [](const StoryStep& step){ return step.name == "oddish_patch"; }); - if (patch == capture || !patch->target){ + if (patch == capture || !target_of(*patch)){ return "00.20: no oddish_patch before catch_oddish."; } // The sim starts on the patch (3, 19): grass step 1 is the pace's far @@ -599,7 +594,7 @@ UnitTestResult test_oddish_battle_on_far_step(){ for (int grass_step : {1, 2}){ SimScript script; script.encounters.push_back(SimEncounter{.grass_step = grass_step}); - const StoryPose start = *story_pose(*patch->target); + const StoryPose start = *story_pose(*target_of(*patch)); OverworldSim sim(maps_bridge_beaten(), MapPosition{start.map, start.tile}, Direction::SOUTH, script); const std::string label = std::format("Battle on grass step {}: ", grass_step); QuietLogger logger; @@ -608,9 +603,9 @@ UnitTestResult test_oddish_battle_on_far_step(){ return label + "no wild battle on the pace."; } const StoryStep& back = *(capture + 1); - StoryPose at = *story_pose(*back.target); + StoryPose at = *story_pose(*target_of(back)); const std::optional> route = plan_story_route( - story_maps(), paced_pose(*patch->target, *capture), std::nullopt, RouteGoal{{at.map, at.tile}, at.facing} + story_maps(), paced_pose(*target_of(*patch), *capture), std::nullopt, RouteGoal{{at.map, at.tile}, at.facing} ); if (!route){ return label + "no route from the capture's tiles."; @@ -635,16 +630,16 @@ UnitTestResult test_oddish_battle_on_far_step(){ // after it: nothing if not; else the route, planned from the pace's two // tiles (paced_pose()), walked on the sim from each: the failure, or empty. std::optional route_after_pacing(const StoryCheckpoint& row, size_t c){ - if (c == 0 || c + 1 >= row.steps.size() || row.steps[c + 1].kind != StoryStepKind::ROUTE || !row.steps[c - 1].target){ + if (c == 0 || c + 1 >= row.steps.size() || row.steps[c + 1].kind != StoryStepKind::ROUTE || !target_of(row.steps[c - 1])){ return std::nullopt; } const StoryStep& next = row.steps[c + 1]; - const Pokemon::Pose paced = paced_pose(*row.steps[c - 1].target, row.steps[c]); + const Pokemon::Pose paced = paced_pose(*target_of(row.steps[c - 1]), row.steps[c]); const std::vector tiles = Pokemon::tiles_of(paced); if (tiles.size() < 2){ return std::nullopt; } - const StoryPose end = *story_pose(*next.target); + const StoryPose end = *story_pose(*target_of(next)); const std::optional> route = plan_story_route( story_maps(), paced, std::nullopt, RouteGoal{{end.map, end.tile}, end.facing} ); @@ -690,16 +685,12 @@ UnitTestResult test_routes_after_pacing(){ // Kick tutor (50, 3), then on to above the ledge (93, 8). Each walk ends // where the table says, and no trainer sees the player on the way. UnitTestResult test_mega_kick_tutor_walks(){ - const std::vector& rows = story_checkpoints(); - const auto row = std::find_if(rows.begin(), rows.end(), [](const StoryCheckpoint& data){ return data.id == "00.14"; }); - if (row == rows.end()){ - return "No checkpoint 00.14."; - } + const StoryCheckpoint* row = &checkpoint_row("00.14"); const auto ledge = std::find_if(row->steps.begin(), row->steps.end(), [](const StoryStep& step){ return step.name == "above_ledge"; }); if (ledge == row->steps.end()){ return "00.14: no above_ledge."; } - StoryPose at = *story_pose(*row->start); + StoryPose at = *story_pose(Pokemon::pose_of(*row->start)); OverworldSim sim(story_maps(), MapPosition{at.map, at.tile}, *at.facing); bool at_tutor = false; for (auto step = row->steps.begin(); step != ledge + 1; ++step){ @@ -735,11 +726,7 @@ UnitTestResult test_mega_kick_tutor_walks(){ // didn't warp from (6, 9)), the row's walks after the ticket end each // where the table says and leave on Route 25's (51, 5). UnitTestResult test_out_of_bill_cottage(){ - const std::vector& rows = story_checkpoints(); - const auto row = std::find_if(rows.begin(), rows.end(), [](const StoryCheckpoint& data){ return data.id == "00.18"; }); - if (row == rows.end()){ - return "No checkpoint 00.18."; - } + const StoryCheckpoint* row = &checkpoint_row("00.18"); const auto ticket = std::find_if(row->steps.begin(), row->steps.end(), [](const StoryStep& step){ return step.name == "ss_ticket"; }); if (ticket == row->steps.end() || !ticket->pose_after){ return "00.18: no ss_ticket."; @@ -757,7 +744,7 @@ UnitTestResult test_out_of_bill_cottage(){ } std::erase_if(map.warps, [](const MapWarp& warp){ return warp.x != 7; }); } - StoryPose at = *story_pose(*ticket->pose_after); + StoryPose at = *story_pose(Pokemon::pose_of(*ticket->pose_after)); OverworldSim sim(maps, MapPosition{at.map, at.tile}, *at.facing); for (auto step = ticket + 1; step != row->steps.end(); ++step){ if (step->kind != StoryStepKind::ROUTE && step->kind != StoryStepKind::LEGS){ @@ -781,40 +768,6 @@ UnitTestResult test_out_of_bill_cottage(){ } -// 00.05 as the table authors it and as the data file built into the -// program (StoryData/frlg-parcel-00.05.json, the export tool's capture of -// that row): the loaded row builds the same events, and run against the -// fake game walks the same route, leaves the same trace and saves in the -// same place. -UnitTestResult test_data_row_parity(){ - const std::vector& table = story_checkpoints(); - const auto authored = std::find_if(table.begin(), table.end(), [](const StoryCheckpoint& row){ return row.id == "00.05"; }); - if (authored == table.end()){ - return "Expected row 00.05 in the table."; - } - const StoryCheckpoint loaded = load_story_checkpoint("frlg-parcel-00.05"); - FakeGame describer; - const std::string authored_events = Pokemon::describe(Pokemon::build_story_checkpoint(*authored, describer)); - const std::string loaded_events = Pokemon::describe(Pokemon::build_story_checkpoint(loaded, describer)); - if (authored_events != loaded_events){ - return "Expected the same events from the table and the data:\n" + authored_events + "\n" + loaded_events; - } - Simulation from_table; - from_table.rows = {*authored}; - Simulation from_data; - from_data.rows = {loaded}; - const bool completed = from_table.run({}).completed && from_data.run({}).completed; - if (!completed || from_table.game.trace != from_data.game.trace || from_table.lines != from_data.lines){ - return "Expected the same run from the table and the data:" + joined(from_table.game.trace) + joined(from_data.game.trace); - } - if (from_table.saves.size() != 1 || from_data.saves.size() != 1 - || Pokemon::to_string(from_table.saves[0].second) != Pokemon::to_string(from_data.saves[0].second) - ){ - return "Expected both runs to save once, in the same place:" + joined(from_table.lines) + joined(from_data.lines); - } - return true; -} - // Someone talks to the player before every step (StorySimKnobs:: // dialog_before): cleared between steps, the whole story still passes; // left up, as before the executor looked, a walk fails on it. @@ -866,7 +819,6 @@ UnitTestResult test_dialogs_at_random(Logger& logger){ const AutoStorySimulationTestCase AUTO_STORY_SIMULATION_CASES[] = { - {.input = {.name = "00.05 loaded row parity", .body = test_data_row_parity}, .expectation = {.description = "loaded row preserves events, trace and save pose"}}, {.input = {.name = "new game to Brock, in order, each start where the last save stood", .body = test_whole_story}, .expectation = {.description = "runs full story progression from new game through Brock gym"}}, {.input = {.name = "the steps it stubs need the console", .body = nullptr, .logged = test_stubbed_steps_need_the_console}, .expectation = {.description = "stubs each needs-console step of the whole story and plays the rest"}}, {.input = {.name = "start and end checkpoints", .body = test_start_and_end}, .expectation = {.description = "executes segment bounded by start and end checkpoints"}}, @@ -899,6 +851,6 @@ void add_tests_AutoStorySimulation(UnitTestDatabase& database){ -} // namespace PokemonFRLG -} // namespace NintendoSwitch -} // namespace PokemonAutomation +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepInterrupts.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepInterrupts.h index d1d3e5d32a..a396b790c7 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepInterrupts.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepInterrupts.h @@ -32,7 +32,7 @@ #include "Pokemon/AutoStory/Pokemon_ScreenEvents.h" #include "Pokemon/AutoStory/Pokemon_StoryActions.h" #include "Pokemon/AutoStory/Pokemon_StoryInterrupts.h" -#include "Pokemon/AutoStory/Pokemon_StorySteps.h" +#include "Pokemon/AutoStory/Pokemon_StoryStepExecutor.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.h" #include "PokemonFRLG_AutoStoryScreenEvents.h" diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepTable.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepTable.cpp index 3781630bd9..4217a619e6 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepTable.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepTable.cpp @@ -4,8 +4,17 @@ * */ +#include #include "Common/Cpp/Exceptions.h" +#include "PokemonFRLG_AutoStoryCapture.h" +#include "PokemonFRLG_AutoStoryChoice.h" #include "PokemonFRLG_AutoStoryEvents.h" +#include "PokemonFRLG_AutoStoryGameArgs.h" +#include "PokemonFRLG_AutoStoryGrind.h" +#include "PokemonFRLG_AutoStoryMart.h" +#include "PokemonFRLG_AutoStoryMember.h" +#include "PokemonFRLG_AutoStoryPcStorage.h" +#include "PokemonFRLG_AutoStoryTeach.h" #include "PokemonFRLG_AutoStoryStepTable.h" #include "PokemonFRLG_AutoStoryTrashCans.h" @@ -62,10 +71,140 @@ const std::vector& story_action_rows(){ return ROWS; } +namespace{ + +using Pokemon::StoryArgType; +using Pokemon::Direction; + +// PC_ACTION's args (pc_args()). +Pokemon::StoryActionSpec pc_action_spec(){ + return {.kind = StoryStepKind::GAME, .name = PC_ACTION, .args = { + required_arg("do", StoryArgType::WORD, "\"deposit\" or \"withdraw\""), + required_arg("slot", StoryArgType::INTEGER, "the party slot to deposit, or the box slot to withdraw, from 1"), + required_arg("box", StoryArgType::INTEGER, "the box, from 1; a withdrawal's must be the one the PC shows"), + optional_arg("if_present", StoryArgType::BOOLEAN, false, "skip a deposit when the party hasn't got the slot"), + }}; +} + +Pokemon::StoryActionSpec capture_action_spec(){ + return {.kind = StoryStepKind::GAME, .name = CAPTURE_ACTION, .args = { + required_arg("species", StoryArgType::WORD, "the species' slug, e.g. \"rattata\""), + optional_arg("catches", StoryArgType::INTEGER, int64_t(1), "how many to catch"), + optional_arg("encounters", StoryArgType::INTEGER, int64_t(20), "wild battles before the step gives up"), + optional_arg("balls", StoryArgType::INTEGER, int64_t(5), "Poke Balls thrown before the step gives up"), + optional_arg("pace", StoryArgType::DIRECTION, Direction::EAST, "the way the player steps to look for a battle"), + absent_arg("move", StoryArgType::INTEGER, "the FIGHT list's move that weakens the target, from 1; none: only balls"), + optional_arg("turns", StoryArgType::INTEGER, int64_t(2), "the most turns spent weakening each target"), + }}; +} + +Pokemon::StoryActionSpec fossil_action_spec(){ + return {.kind = StoryStepKind::GAME, .name = FOSSIL_ACTION, .args = { + required_arg("fossil", Pokemon::StoryArgType::WORD, "\"helix\" or \"dome\""), + }}; +} + +Pokemon::StoryActionSpec level_action_spec(){ + return {.kind = StoryStepKind::GAME, .name = LEVEL_ACTION, .args = { + required_arg("slot", StoryArgType::INTEGER, "the party slot, from 1"), + required_arg("min", StoryArgType::INTEGER, "the level it must have"), + }}; +} + +Pokemon::StoryActionSpec mart_action_spec(){ + return {.kind = StoryStepKind::GAME, .name = MART_ACTION, .args = { + required_arg("map", StoryArgType::WORD, "the Mart's map, for its stock"), + required_arg("budget", StoryArgType::INTEGER, "the most the step spends"), + absent_arg("floor", StoryArgType::INTEGER, "the least money the player has here, when the money box can't be read"), + required_arg("items", StoryArgType::ITEMS, "what to buy, in priority order"), + }}; +} + +Pokemon::StoryActionSpec teach_action_spec(){ + return {.kind = StoryStepKind::GAME, .name = TEACH_ACTION, .args = { + required_arg("item", StoryArgType::WORD, "the TM or HM, e.g. \"hm03\""), + required_arg("move", StoryArgType::WORD, "the move it holds, e.g. \"surf\""), + required_arg("slot", StoryArgType::INTEGER, "the party slot, from 1"), + absent_arg("forget", StoryArgType::WORD, "the move to forget when it knows four"), + absent_arg("forget_slot", StoryArgType::INTEGER, "the move slot to forget, from 1, when no move is named"), + }}; +} + +Pokemon::StoryActionSpec grind_action_spec(){ + return {.kind = StoryStepKind::GAME, .name = GRIND_ACTION, .args = { + required_arg("slot", StoryArgType::INTEGER, "the party slot that grinds, from 1"), + required_arg("level", StoryArgType::INTEGER, "the level to reach; with a trainer, the cap"), + optional_arg("encounters", StoryArgType::INTEGER, int64_t(60), "wild battles before the step gives up"), + optional_arg("pace", StoryArgType::DIRECTION, Direction::EAST, "the way the player steps to look for a battle"), + optional_arg("heal_every", StoryArgType::INTEGER, int64_t(0), "battles between visits to the nurse; 0: only when hurt"), + absent_arg("beat", StoryArgType::WORD, "the next boss's trainer: grind until the sim's win chance is enough"), + absent_arg("chance", StoryArgType::INTEGER, "the win chance against it, in percent"), + required_arg("nurse", StoryArgType::GRID_POSE, "where the step heals"), + }}; +} + +// GRIND_CHECK_ACTION's args: GRIND_ACTION's but the nurse. +Pokemon::StoryActionSpec grind_check_action_spec(){ + Pokemon::StoryActionSpec spec = grind_action_spec(); + spec.name = GRIND_CHECK_ACTION; + std::erase_if(spec.args, [](const Pokemon::StoryArgSpec& arg){ return arg.key == "nurse"; }); + return spec; +} + +} // namespace + +std::span story_action_specs(){ + static const std::vector SPECS = []{ + const std::span builtin = Pokemon::builtin_story_actions(); + std::vector specs(builtin.begin(), builtin.end()); + for (StoryStepKind kind : {StoryStepKind::ROUTE, StoryStepKind::LEGS}){ + Pokemon::StoryActionSpec run = *Pokemon::find_story_action(builtin, kind, ""); + run.name = "run"; + specs.push_back(std::move(run)); + } + for (const std::string& name : {TRAINER_LINE_VARIANT, TRAINER_WAIT_VARIANT}){ + Pokemon::StoryActionSpec step = *Pokemon::find_story_action(builtin, StoryStepKind::STEP, ""); + step.name = name; + specs.push_back(std::move(step)); + } + specs.push_back({.kind = StoryStepKind::GAME, .name = CLOSE_TRAINER_CARD, .args = {}}); + specs.push_back({.kind = StoryStepKind::GAME, .name = LEAVE_GIFT_SUMMARY, .args = {}}); + specs.push_back({.kind = StoryStepKind::GAME, .name = CUT_TREE_VARIANT, .args = { + required_arg("direction", StoryArgType::DIRECTION, "the way to the tree, which the step then walks onto"), + }}); + specs.push_back({.kind = StoryStepKind::GAME, .name = TRASH_CANS_VARIANT, .args = {}}); + for (Pokemon::StoryActionSpec spec : { + pc_action_spec(), capture_action_spec(), fossil_action_spec(), level_action_spec(), + mart_action_spec(), teach_action_spec(), grind_action_spec(), grind_check_action_spec(), + }){ + specs.push_back(std::move(spec)); + } + return specs; + }(); + return SPECS; +} + Pokemon::StoryActionTable make_story_action_table(const StoryActionBinding& bind){ Pokemon::StoryActionTable table; for (const StoryActionRow& row : story_action_rows()){ - table.add(row.kind, row.variant, bind(row.id)); + Pokemon::StoryAction action = bind(row.id); + if (const Pokemon::StoryActionSpec* spec = Pokemon::find_story_action(story_action_specs(), row.kind, row.variant)){ + action.args = spec->args; + } + table.add(row.kind, row.variant, std::move(action)); + } + // FRLG's GAME actions without a row of their own: the GAME row's + // action, with each one's args. + for (const Pokemon::StoryActionSpec& spec : story_action_specs()){ + const bool has_row = std::ranges::any_of(story_action_rows(), [&](const StoryActionRow& row){ + return row.kind == spec.kind && row.variant == spec.name; + }); + if (spec.kind != StoryStepKind::GAME || spec.name.empty() || has_row){ + continue; + } + Pokemon::StoryAction action = bind(StoryActionId::GAME); + action.args = spec.args; + table.add(StoryStepKind::GAME, spec.name, std::move(action)); } return table; } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepTable.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepTable.h index 515bc5c3ce..f9aba85bd3 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepTable.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepTable.h @@ -14,11 +14,13 @@ #define PokemonAutomation_PokemonFRLG_AutoStoryStepTable_H #include +#include #include #include #include "Common/Cpp/TestRunners/UnitTestDatabase.h" +#include "Pokemon/AutoStory/Pokemon_BuiltinStoryActions.h" #include "Pokemon/AutoStory/Pokemon_StoryActions.h" -#include "Pokemon/AutoStory/Pokemon_StorySteps.h" +#include "Pokemon/AutoStory/Pokemon_StoryStepExecutor.h" namespace PokemonAutomation{ namespace NintendoSwitch{ @@ -68,9 +70,22 @@ struct StoryActionRow{ // Every row. TRAIN and SAVE have none: FRLG's story doesn't use them. const std::vector& story_action_rows(); +// The actions FRLG's steps name, with the args each takes: the built-in +// ones (Pokemon_BuiltinStoryActions.h), then a ROUTE and a LEGS named +// "run" (RUN_VARIANT), which take the same args and run with B held, +// STEPs named "trainer_line" (TRAINER_LINE_VARIANT) and "trainer_wait" +// (TRAINER_WAIT_VARIANT), then FRLG's GAME actions: closing the Trainer +// Card or the Gift RNG summary, cutting a tree, the trash cans, a PC +// transfer, a capture, the fossil, a LEVEL check, a Mart, a TEACH and a +// GRIND, each with the args it declares. +// A story file is read against these. +std::span story_action_specs(); + // How one binding (the console, a test) does each action. using StoryActionBinding = std::function; -// The rows as a table, each with `bind`'s action for its id. +// The rows as a table, each with `bind`'s action for its id and its +// spec's args, and each of FRLG's GAME actions with the GAME row's action +// and its own args. Pokemon::StoryActionTable make_story_action_table(const StoryActionBinding& bind); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepTable_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepTable_Tests.cpp index 33302b794b..585e9138f8 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepTable_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepTable_Tests.cpp @@ -40,16 +40,16 @@ const StoryStepKind ALL_KINDS[] = { // The action StoryExecutor::game() ran for a GAME `step` before the table. StoryActionId old_game_dispatch(const StoryStep& step){ - if (step.variant == CLOSE_TRAINER_CARD){ + if (step.action == CLOSE_TRAINER_CARD){ return StoryActionId::CLOSE_TRAINER_CARD; } - if (step.variant == LEAVE_GIFT_SUMMARY){ + if (step.action == LEAVE_GIFT_SUMMARY){ return StoryActionId::LEAVE_GIFT_SUMMARY; } - if (step.variant == CUT_TREE_VARIANT){ + if (step.action == CUT_TREE_VARIANT){ return StoryActionId::CUT_TREE; } - if (step.variant == TRASH_CANS_VARIANT){ + if (step.action == TRASH_CANS_VARIANT){ return StoryActionId::TRASH_CANS; } return StoryActionId::GAME; @@ -117,7 +117,7 @@ std::string parity_error(FakeGame& game, const StoryStep& step){ std::vector trace; const Pokemon::Outcome outcome = game.run(step, trace); const std::optional expected = old_dispatch(step); - const std::string label = std::format("{} '{}' ({})", Pokemon::story_step_kind_name(step.kind), step.variant, step.name); + const std::string label = std::format("{} '{}' ({})", Pokemon::story_step_kind_name(step.kind), step.action, step.name); if (!expected){ if (!trace.empty() || outcome.failure != "unsupported_step"){ return label + ": expected unsupported, ran " + (trace.empty() ? outcome.failure : trace[0]); @@ -148,7 +148,7 @@ std::vector every_kind_and_variant(){ StoryStep step; step.kind = kind; step.name = "synthetic"; - step.variant = variant; + step.action = variant; steps.push_back(std::move(step)); } } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp index 3f88fe03e1..82b2aab8a0 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp @@ -4,14 +4,16 @@ * */ -#include "PokemonFRLG_AutoStoryCapture.h" -#include "Data/JsonParser.h" -#include "PokemonFRLG_AutoStoryChoice.h" -#include "PokemonFRLG_AutoStoryGrind.h" +#include +#include +#include "Common/Cpp/Exceptions.h" +#include "Common/Cpp/Json/JsonArray.h" +#include "Common/Cpp/Json/JsonObject.h" +#include "Pokemon/AutoStory/Data/Pokemon_AuthoredCheckpointJson.h" #include "PokemonFRLG_AutoStoryMart.h" -#include "PokemonFRLG_AutoStoryPcStorage.h" +#include "PokemonFRLG_AutoStoryParty.h" +#include "PokemonFRLG_AutoStoryStepTable.h" #include "PokemonFRLG_AutoStoryTable.h" -#include "PokemonFRLG_AutoStoryTableSteps.h" #include "PokemonFRLG_AutoStoryTeach.h" namespace PokemonAutomation{ @@ -21,778 +23,163 @@ namespace PokemonFRLG{ namespace{ -using namespace StoryTable; - - -StoryCheckpoint new_game(){ - StoryCheckpoint checkpoint = row("00.01", "new game to the bedroom", std::nullopt, {}, StartMenu::BEFORE_POKEMON, { - // new_game.c: the bedroom at (6, 6), facing the TV. - new_game_intro(at(BEDROOM, 6, 6, NORTH), "Oak's speech, BOY, the player's name (default if none is set), rival GREEN"), - options_step(), - }); - checkpoint.handoff = StoryHandoff::SID_HELPER; - return checkpoint; -} - -// SID Helper confirms the name, finishes the intro and reads the Trainer -// Card from the START menu, without moving the player or saving. -StoryCheckpoint after_sid_helper(){ - StoryCheckpoint checkpoint = row("00.01b", "after SID Helper: close the Trainer Card, save in the bedroom", at(BEDROOM, 6, 6, NORTH), {}, StartMenu::BEFORE_POKEMON, { - game_step(CLOSE_TRAINER_CARD, at(BEDROOM, 6, 6, NORTH), "the Trainer Card SID Helper left open, or HOME"), - options_step(), - }); - checkpoint.live_start = true; - return checkpoint; -} - -StoryCheckpoint leave_house(){ - return row("00.02", "bedroom to Pallet Town", at(BEDROOM, 6, 6, NORTH), {}, StartMenu::BEFORE_POKEMON, { - route("front_door", at(PALLET, 6, 8), "down the stairs and out of the house"), - }); -} - -StoryCheckpoint oaks_trigger(){ - return row("00.03", "Oak stops the player and walks them to the lab", at(PALLET, 6, 8, SOUTH), {}, StartMenu::BEFORE_POKEMON, { - route("below_oaks_trigger", at(PALLET, 12, 2, NORTH), "below the north exit, short of Oak's trigger at (12, 1)"), - step_into("oaks_trigger", NORTH, "the trigger: \"Don't go out!\""), - // PlayerEnter walks the player up 8 tiles from the lab's door. - scene("to_the_lab", at(LAB, 6, 4, NORTH), "Oak walks the player into the lab; the scene ends at the table"), - }); -} - -// Starter RNG starts from a save south of the table, facing the ball. -StoryCheckpoint to_starter_ball(){ - StoryCheckpoint checkpoint = row("00.04", "to Squirtle's ball, south of the table", at(LAB, 6, 4, NORTH), {}, StartMenu::BEFORE_POKEMON, { - route("below_squirtle", at(LAB, 9, 5, NORTH), "under Squirtle's ball (9, 4)"), - }); - checkpoint.handoff = StoryHandoff::STARTER_RNG; - return checkpoint; -} - -StoryCheckpoint starter(){ - return row("00.04b", "Squirtle, then the rival's battle", at(LAB, 9, 5, NORTH), {}, StartMenu::BEFORE_POKEDEX, { - talk("squirtle_ball", "\"So, you want the WATER POKEMON SQUIRTLE?\""), - answer("choose_squirtle", true, "take Squirtle"), - answer("no_nickname", false, "\"give a nickname?\" NO"), - scene("rival_takes_bulbasaur", at(LAB, 9, 5, NORTH), "the rival picks his ball; the player still faces the table (console B, 2026-11-01)"), - route("above_rival_trigger", at(LAB, 7, 7, SOUTH), "short of the rival's trigger row 8"), - step_into("rival_trigger", SOUTH, "\"Wait, let's check out our POKEMON!\""), - // The rival leaves; PlayerWatchRivalExitAfterBattleRight ends facing down. - battle("rival_battle", at(LAB, 7, 8, SOUTH), true, "the tutorial battle; losing goes on too"), - }); -} - -// TODO: Load an ordered series of authored checkpoints together and construct -// a partial story table, instead of loading one file in each row factory. -StoryCheckpoint parcel(){ - return load_authored_checkpoint("frlg-parcel-00.05.plan"); -} - -StoryCheckpoint pokedex(){ - return row("00.06", "Oak's Parcel to the Pokedex", at(VIRIDIAN_MART, 4, 3, WEST), {}, StartMenu::FULL, { - route("below_oak", at(LAB, 6, 4, NORTH), "back down Route 1 to Oak"), - talk("give_parcel", "Oak takes the parcel"), - scene("pokedex_scene", at(LAB, 6, 4, SOUTH), "the rival comes in, Pokedexes from the desk; the player ends facing south (console B, 2026-11-01)"), - }); -} - -StoryCheckpoint shopping(){ - return row("00.07", "Viridian shopping, then into Viridian Forest", at(LAB, 6, 4, SOUTH), {}, StartMenu::FULL, { - route("mart_clerk", at(VIRIDIAN_MART, 4, 3, WEST), "Route 1 again"), - // 2000 of the 3000 a new game starts with, plus the rival's prize. - shop("potions_and_antidotes", {{"potion", 5}, {"antidote", 3}, {"parlyz_heal", 1}}, "5 Potions, 3 Antidotes, 1 Parlyz Heal"), - route("viridian_nurse", at(VIRIDIAN_CENTER, 7, 4, NORTH), "heal before the forest"), - heal("heal_viridian"), - route("below_old_man_trigger", at(VIRIDIAN, 20, 9, NORTH), "short of the tutorial trigger (20, 8)"), - step_into("old_man_trigger", NORTH, "the old man's catching tutorial can't be walked around"), - // TutorialTriggerLeft turns the player right, to the old man. - scene("old_man_tutorial", at(VIRIDIAN, 20, 8, EAST), "about 60 lines and his demo battle; TEACHY TV"), - // After his demo the old man stands east of the player, beside (20, 8), where - // the map doesn't have him: "east 2" from there didn't move, and the walk north - // ended under Route 2's ledge in column 8 (console B, 2026-11-01). Go north first. - route("past_old_man", at(VIRIDIAN, 20, 5, NORTH), "north along column 20, clear of the old man"), - // The gate's north warp lands on the forest's exit mat (29, 62), facing - // north. The save there keeps a forest failure from going back to Pallet. - route("forest_entrance", at(FOREST, 29, 62, NORTH), "Route 2 and the south gate, running from wild battles"), - }); -} - -StoryCheckpoint forest(){ - // The supplies bought in 00.07. - return row("00.08", "Viridian Forest to Pewter Center", at(FOREST, 29, 62, NORTH), {5, 3, 1}, StartMenu::FULL, { - // Wild battles are fought for EXP. Straight up the east side from the - // entrance, each leg ending on a wall (the Boy at (45, 58) stops the - // east one). Rick (47, 45) sees (42..46, 45), so the last leg meets - // his battle and is held on to its wall after it. The by-hand run's - // detour west to (13, 46) and back is dropped. - legs("forest_east", {{EAST, 1}, {NORTH, 4}, {EAST, 14}, {NORTH, 15}}, "up the east side to (44, 43)", WildBattles::FIGHT), - route("forest_north", at(FOREST, 39, 25), "north part", WildBattles::FIGHT), - // To the gate by legs that end on walls, which the walker holds again - // after a battle instead of estimating where it stopped: planned - // routes with open legs lost the player in the north of the forest - // (console B, 2026-11-01). The two 1-tile legs are single steps. - legs("forest_exit", { - {NORTH, 10}, {WEST, 12}, {SOUTH, 10}, {WEST, 6}, {NORTH, 20}, - {SOUTH, 1}, {WEST, 10}, {SOUTH, 27}, {WEST, 8}, {NORTH, 20}, {EAST, 1}, - }, "walls all the way to the gate's column", WildBattles::FIGHT), - route("forest_gate", at(FOREST_GATE, 7, 10, NORTH), "north onto the exit, arriving on the gate's mat", WildBattles::FIGHT), - // Out of the forest, wild battles are run from; trainers are still fought. - route("pewter_nurse", at(PEWTER_CENTER, 7, 4, NORTH), "Route 2 north to Pewter's Center"), - heal("heal_pewter"), - }); -} - -StoryCheckpoint brock(){ - // The by-hand save: 2 Potions and 1 Antidote left after the forest. - return row("00.09", "Pewter Gym: Camper Liam, then Brock", at(PEWTER_CENTER, 7, 4, NORTH), {2, 1}, StartMenu::FULL, { - // Camper Liam (3, 8) always faces east (MOVEMENT_TYPE_FACE_RIGHT, sight - // 4) and sees (4..7, 8): walking north up column 6 from the door, - // the step onto (6, 8) starts his battle. He walks up to the player, - // who stays put and keeps facing north (FRLG doesn't turn the player - // to a trainer). That step is taken on its own, so no leg is cut. - route("below_liam_line", at(GYM, 6, 9, NORTH), "in by the door, up column 6 to below Liam's row"), - step_into("liam_line", NORTH, "onto (6, 8), in Liam's line"), - battle("camper_liam", at(GYM, 6, 8, NORTH), false, "Geodude and Sandshrew; EXP before Brock"), - // On to Brock unless red HP or a status is left that no item cures. - ready("ready_for_brock", at(PEWTER_CENTER, 7, 4, NORTH), "items for a status or low HP; the nurse only if they can't"), - route("before_brock", at(GYM, 6, 6, NORTH), "below Brock (6, 5); Liam, beaten, stands at (5, 8)"), - talk("challenge_brock", "Brock's speech"), - battle("brock", at(GYM, 6, 6, NORTH), false, "Geodude and Onix, with Bubble; Boulder Badge and TM39"), - }); -} - -StoryCheckpoint running_shoes(){ - return row("00.10", "Pewter: the Running Shoes from Oak's aide", at(GYM, 6, 6, NORTH), after_brock(), StartMenu::FULL, { - // Brock's win sets VAR_MAP_SCENE_PEWTER_CITY to 1 and shows the aide at - // (46, 20); his triggers are (46, 21..23) (PewterCity map.json). The - // Gym guide's triggers at (42..43, 21..23) need the scene at 0. - route("before_aide_trigger", at(PEWTER, 45, 21, EAST), "out of the Gym, east along row 21, short of the top trigger"), - step_into("aide_trigger", EAST, "onto (46, 21), below the aide"), - // RunningShoesAideTriggerTop: the aide talks from (46, 20), no YES/NO; - // the player only turns up. He walks off and is removed; FLAG_SYS_B_DASH - // is set (console B, 2026-11-02: about 20 B presses to the overworld). - scene("shoes_from_aide", at(PEWTER, 46, 21, NORTH), "\"Oh, PLAYER!\" ... the Running Shoes; ends facing north"), - // Where the by-hand walk stopped to start 00.11 (console B, 2026-11-02). - route("below_pewter_center", at(PEWTER, 17, 26, SOUTH), "west along row 21 and down to below the Pokemon Center's door (17, 25)"), - }); -} - -// Route 3's trainers (Route3 map.json): the way east meets three of them. -// Bug Catcher Colton (12, 6) faces east, sight 3: the only way north past -// the row 7 ledges is the gap at x 14..15, below his line. Youngster Ben -// (17, 4) faces south, sight 2, so the way east keeps to row 3 past him. -// Bug Catcher Greg (25, 4) faces south, sight 2, over the way east along -// row 5. Bug Catcher James (32, 6) faces east, sight 4, over the way down -// at x 35..36. The others are kept out of: Lass Janice (19, 9) sees west -// along row 9 to x 14, Lass Sally (30, 3) west along row 3 to x 25, and -// Youngster Calvin (29, 10) west along row 10. Each line is stepped into on -// its own, so no leg is cut; the trainer walks up to the player, who stays -// put facing the way they stepped. -StoryCheckpoint route3(){ - return row("00.11", "Pewter Center, then Route 3's trainers", at(PEWTER, 17, 26, SOUTH), after_brock(), StartMenu::FULL, { - running(route("pewter_nurse", at(PEWTER_CENTER, 7, 4, NORTH), "in by the door below the player")), - heal("heal_pewter"), - // Up from row 9 west of Janice's line, which ends at x 14. - running(route("west_of_janice_line", at(ROUTE3, 13, 8), "out of Pewter by row 21, east into Route 3, short of Janice's line")), - running(legs("below_colton_line", {{EAST, 1}, {NORTH, 1}}, "to (14, 7), in the ledges' gap")), - step_into("colton_line", NORTH, "onto (14, 6), in Colton's line"), - battle("bug_catcher_colton", at(ROUTE3, 14, 6, NORTH), false, "his Bug Pokemon; Colton stops at (13, 6)"), - running(legs("past_ben", {{NORTH, 3}, {EAST, 4}, {SOUTH, 2}, {EAST, 6}}, "up to row 3 above Ben, down at x 18 east of his line, to (24, 5)")), - step_into("greg_line", EAST, "onto (25, 5), below Greg"), - battle("bug_catcher_greg", at(ROUTE3, 25, 5, EAST), false, "his Bug Pokemon; Greg is already next to the player"), - running(legs("above_james_line", {{EAST, 11}}, "along row 5 to the wall at (36, 5)")), - step_into("james_line", SOUTH, "onto (36, 6), at the end of James's line"), - battle("bug_catcher_james", at(ROUTE3, 36, 6, SOUTH), false, "his Bug Pokemon; James stops at (35, 6)"), - // Saved here, the trainers behind, so a failure on the way to Route 4 - // doesn't fight them again. - running(legs("save_spot", {{SOUTH, 2}}, "down to (36, 8), beside the wall east of it")), - }); -} - -// Route 3's north exit (x 68..75) joins Route 4 (offset 60) at x 8..15, up -// which column 12 leads to the Pokemon Center's door (12, 5). Lass Robin -// (40, 11) wanders up and down at x 40, looking north and south, sight 3. -// Rock above (y <= 8) and grass below (y >= 12) leave every way east -// across her column at y 9..11, so whether she sees the player depends on -// her facing. The walk watches for her after the leg along row 9, which -// crosses her sight on (40, 9) only; if she saw the player, her message -// goes to story_interrupts(), which fight her, and the route goes on from -// (40, 9) (run_route(); console B, 2026-11-02, she stopped the player -// there and spoke after the leg's short watch). -StoryCheckpoint magikarp_salesman(){ - StoryCheckpoint checkpoint = row("00.12", "Route 3 and 4 to the Magikarp salesman", at(ROUTE3, 36, 8, SOUTH), after_brock(), StartMenu::FULL, { - running(route("route4_nurse", at(ROUTE4_CENTER, 7, 4, NORTH), "east over Route 3, off the grass, north into Route 4 and its Pokemon Center")), - heal("heal_route4"), - // Gift RNG starts from a save facing the salesman (1, 3). - running(route("before_salesman", at(ROUTE4_CENTER, 2, 3, WEST), "beside the Magikarp salesman, facing him")), - }); - checkpoint.handoff = StoryHandoff::GIFT_RNG; - return checkpoint; -} - -// Gift RNG buys the Magikarp (500 of the money 00.12 brings) without -// moving the player and leaves its summary open, or HOME. This saves the -// shiny where 00.12 ended. A run started here with Gift RNG's handoff on -// loads the save beside the salesman and runs Gift RNG first. -StoryCheckpoint after_gift_rng(){ - StoryCheckpoint checkpoint = row("00.12b", "after Gift RNG: save with the Magikarp", at(ROUTE4_CENTER, 2, 3, WEST), after_brock(), StartMenu::FULL, { - game_step(LEAVE_GIFT_SUMMARY, at(ROUTE4_CENTER, 2, 3, WEST), "the Magikarp's summary Gift RNG left open, or HOME"), - }); - checkpoint.live_start = true; - return checkpoint; +// The wire names of the START menus. +StartMenu read_start_menu(std::string_view name, std::string_view source){ + if (name == "before_pokemon"){ + return StartMenu::BEFORE_POKEMON; + } + if (name == "before_pokedex"){ + return StartMenu::BEFORE_POKEDEX; + } + if (name == "full"){ + return StartMenu::FULL; + } + throw ParseException(std::format("{}: unknown START menu {}", source, name)); +} + +// The wire names of the handoffs. +StoryHandoff read_handoff(std::string_view name, std::string_view source){ + if (name == "sid_helper"){ + return StoryHandoff::SID_HELPER; + } + if (name == "starter_rng"){ + return StoryHandoff::STARTER_RNG; + } + if (name == "gift_rng"){ + return StoryHandoff::GIFT_RNG; + } + throw ParseException(std::format("{}: unknown handoff {}", source, name)); +} + +// `object`'s fields, each of which must be one of `keys`. +void only_fields(const JsonObject& object, std::initializer_list keys, std::string_view source){ + for (const auto& [key, unused] : object){ + bool known = false; + for (std::string_view allowed : keys){ + known |= key == allowed; + } + if (!known){ + throw ParseException(std::format("{}: unsupported execution field {}", source, key)); + } + } +} + +int read_count(const JsonObject& object, const std::string& key, std::string_view source){ + const JsonValue* value = object.get_value(key); + if (value == nullptr){ + return 0; + } + const int64_t count = value->to_integer_throw(std::string(source)); + if (count < 0 || count > 999){ + throw ParseException(std::format("{}: {} out of range", source, key)); + } + return (int)count; +} + +Supplies read_supplies(const JsonObject& execution, std::string_view source){ + Supplies supplies; + if (const JsonObject* items = execution.get_object("supplies")){ + only_fields(*items, {"potions", "antidotes", "parlyz_heals"}, source); + supplies.potions = read_count(*items, "potions", source); + supplies.antidotes = read_count(*items, "antidotes", source); + supplies.parlyz_heals = read_count(*items, "parlyz_heals", source); + } + if (const std::string* lead = execution.get_string("lead")){ + if (*lead != "after_brock"){ + throw ParseException(std::format("{}: unknown lead {}", source, *lead)); + } + supplies.lead = story_lead_after_brock(); + }else if (execution.get_value("lead") != nullptr){ + throw ParseException(std::format("{}: lead must be a string", source)); + } + return supplies; +} + +// The keys of the notes: "checkpoint" or a step's id, each a list of lines. +std::set read_note_keys(const JsonObject& execution, std::string_view source){ + std::set keys; + const JsonValue* notes = execution.get_value("notes"); + if (notes == nullptr){ + return keys; + } + for (const auto& [key, lines] : notes->to_object_throw(std::string(source))){ + for (const JsonValue& line : lines.to_array_throw(std::string(source))){ + line.to_string_throw(std::string(source)); + } + keys.insert(key); + } + return keys; +} + +// The file without its "metadata", which the shared reader doesn't take +// (yet): {"phase": testing, verification or reproduction}, how far the +// checkpoint is trusted to save (the engine's save policy reads it). +JsonValue without_metadata(const JsonValue& value, std::string_view source){ + JsonObject stripped; + for (const auto& [key, field] : value.to_object_throw(std::string(source))){ + if (key != "metadata"){ + stripped[key] = field.clone(); + continue; + } + const JsonObject& metadata = field.to_object_throw(std::string(source)); + for (const auto& [metadata_key, unused] : metadata){ + if (metadata_key != "phase"){ + throw ParseException(std::format("{}: unsupported metadata field {}", source, metadata_key)); + } + } + const std::string& phase = metadata.get_string_throw("phase", std::string(source)); + if (phase != "testing" && phase != "verification" && phase != "reproduction"){ + throw ParseException(std::format("{}: unknown phase {}", source, phase)); + } + } + return JsonValue(std::move(stripped)); } -// The Magikarp goes to BOX 1 at the Center's PC (11, 1), so Mt. Moon is -// fought with the starter alone (console B, 2026-11-02: done by hand and -// saved at (11, 2), facing the PC, where this row ends). The wandering -// boy (4..6, 3..5) is walked around. The Magikarp comes from Gift RNG: -// with Gift RNG off the party is the starter alone, and the deposit is -// skipped. -StoryCheckpoint magikarp_to_box(){ - return row("00.12c", "Route 4 Center: the Magikarp into BOX 1", at(ROUTE4_CENTER, 2, 3, WEST), after_brock(), StartMenu::FULL, { - running(route("pc_front", at(ROUTE4_CENTER, 11, 2, NORTH), "below the PC (11, 1), facing it")), - pc_step("magikarp_to_box", "DEPOSIT the party's second slot into BOX 1, if it has one", PcTransfer{ - .action = PcAction::DEPOSIT, .party_slot = 1, .box = 0, .if_missing = PcMissing::SKIP, - }), - }); -} - -// Mt. Moon (pokefirered data/maps/MtMoon_1F, _B1F, _B2F). Every floor tile -// of the cave has wild encounters, which are run from, so its legs end on -// walls, ladders or someone standing still, which the walker holds again -// after a battle; the few open ones are short. The way through: up 1F's -// middle and west side, its north-west ladder, B1F's west ladder down to -// B2F's south-east, round B2F's south edge to its west, north past -// Miguel and the fossils, and the ladder up to B1F's east end, which -// leads out to Route 4 east of the mountain. -// - 1F's trainers are walked around: Youngster Josh (13, 17) sees east -// along row 17 to x 17, so the way west into the west room is down -// column 18 and up column 11; Lass Miriam walks round (32..33, 4..5), -// sight 2, so the way east keeps to row 9 and columns 38 and 40; Hiker -// Marcos wanders (5..9, 8..12) and sees one tile, so the way north is -// column 11 and row 3. -// - The Moon Stone ball (3, 2) on 1F (FLAG_HIDE_MT_MOON_1F_MOON_STONE) is -// a few tiles off the way to the ladder (5, 6). -// - The Grunt at (37, 21) on B2F looks around (sight 3) over the only way -// east round B2F. His room is crossed on legs to walls, at one tile of -// his sight each, (37, 22) and (40, 21); if he looks the player's way, -// he walks up beside the leg, story_interrupts() fights him, and the -// leg is held on to its wall. -// - The Grunt at (12, 20) faces south (sight 2) over (12, 21..22), across -// rows 21..22, the only way north to Miguel: stepped into from the -// west, he is next to the player and doesn't walk. -// - Super Nerd Miguel (13, 11) battles on the step onto (14, 11) -// (MtMoon_B2F_EventScript_MiguelTrigger, VAR_MAP_SCENE_MT_MOON_B2F 0), -// then "We'll each take one!" -// - The fossils: DOME (13, 7), HELIX (14, 7). After the HELIX, Miguel -// walks up to (13, 8) and takes the DOME, which opens the gap north. -// The save is on Route 4: the save card's places don't include Mt. Moon. -StoryCheckpoint mt_moon(){ - return row("00.13", "Mt. Moon: a Moon Stone, a Rocket, Miguel and the Helix Fossil", at(ROUTE4_CENTER, 11, 2, NORTH), after_brock(), StartMenu::FULL, { - running(route("route4_nurse", at(ROUTE4_CENTER, 7, 4, NORTH), "the nurse, below the counter")), - heal("heal_route4"), - running(route("mt_moon_entrance", at(MT_MOON_1F, 18, 37, NORTH), "out of the Center, west into Mt. Moon")), - running(legs("mt_moon_1f", { - {NORTH, 12}, {EAST, 8}, {NORTH, 12}, {EAST, 3}, {SOUTH, 1}, {EAST, 9}, - {NORTH, 1}, {EAST, 2}, {NORTH, 4}, {WEST, 24}, {EAST, 2}, {SOUTH, 12}, - {WEST, 7}, {NORTH, 18}, {WEST, 9}, {EAST, 1}, - }, "up the middle, east of Miriam, west along row 9, down column 18 past Josh, up column 11 past Marcos, to (3, 3)")), - running(route("below_moon_stone", at(MT_MOON_1F, 3, 3, NORTH), "facing the Moon Stone (3, 2)")), - talk("moon_stone_ball", "A on the item ball"), - // No reader for the text yet: the scene's end is the overworld. - scene("found_moon_stone", at(MT_MOON_1F, 3, 3, NORTH), "\" found a MOON STONE!\", then the pocket line; the ball is gone"), - running(route("b2f_ladder_foot", at(MT_MOON_B2F, 26, 21, EAST), "1F's ladder (5, 6), down B1F's west side to its ladder (22, 18), onto B2F")), - running(legs("b2f_south", { - {NORTH, 4}, {EAST, 8}, {WEST, 2}, {SOUTH, 5}, {EAST, 8}, {NORTH, 3}, {WEST, 1}, {NORTH, 5}, - {EAST, 7}, {SOUTH, 14}, {WEST, 9}, {SOUTH, 10}, {WEST, 29}, {EAST, 3}, {NORTH, 17}, - }, "through the Grunt's room at (37, 21), round the south edge, up column 11 to (11, 21)")), - step_into("grunt_line", EAST, "onto (12, 21), below the Grunt at (12, 20)"), - battle("rocket_grunt", at(MT_MOON_B2F, 12, 21, EAST), false, "Rattata and Zubat, Lv13"), - ready("ready_for_miguel", at(ROUTE4_CENTER, 7, 4, NORTH), "items for a status or low HP; the nurse, back through the cave, only if they can't"), - // Up column 13 to Miguel, who stops the leg on (13, 12), then east - // to the wall: the tile below his trigger. - running(legs("below_miguel_trigger", {{EAST, 1}, {NORTH, 9}, {EAST, 1}}, "to (14, 12), below Miguel's trigger (14, 11)")), - step_into("miguel_trigger", NORTH, "onto (14, 11), beside Miguel"), - battle("super_nerd_miguel", at(MT_MOON_B2F, 14, 11, NORTH), false, "Grimer, Voltorb and Koffing, Lv12; \"We'll each take one!\""), - running(legs("below_helix_fossil", {{NORTH, 3}}, "up column 14 to the HELIX FOSSIL (14, 7)")), - fossil_step("helix_fossil", "the HELIX FOSSIL; Miguel takes the DOME FOSSIL", Fossil::HELIX), - // The maps keep the fossils, which the game removes after the - // choice: the step onto the HELIX's tile is taken on its own. - step_into("helix_gap", NORTH, "onto (14, 7), where the HELIX FOSSIL lay"), - running(route("route4_east", at(ROUTE4, 32, 6, SOUTH), "west to B2F's ladder (5, 10), up to B1F, east to its exit onto Route 4")), - }); -} - -// Route 4 east of Mt. Moon (Route4 map.json) joins Cerulean City at its -// east end (x 107; Route 4's row 3 is the city's row 13). Its upper road -// (rows 2..8) reaches the city only by water: the way on by land is down -// the ledge row 9 at x 90..96 to the lower road (rows 10..12), which -// joins the city's rows 20..22. Lass Crissy (75, 3) faces east, sight 4, -// over row 3 from x 76 to 79; the way east keeps out of her line and off -// the grass south of the road (75..87, 11..17). -// -// On the way, the Mega Kick tutor (Black Belt (50, 3), facing west, -// Route4_EventScript_MegaKickTutor) stands in a pen (46..51, 2..4) north -// of the road, beside the Mega Punch tutor (47, 3); the pen opens south -// only on (48, 5) and (49, 5), the rest of row 5 ledges out of it. From -// Mt. Moon's exit the walk goes east and up into the pen to (50, 4), -// below the tutor, and Mega Kick takes Withdraw's slot. Cerulean can't -// be walked back to Route 4's upper road without Surf, so it is now or -// much later. -// -// The open leg east across the city's edge ended a tile short on the -// console (2026-11-03: on (6, 20), not (7, 20)), and no hold to a wall -// in the city's west end finds the player from there: the next hold -// south met the fence on (6, 23) and the walk went on a column off. So -// the entry ends on (9, 20), and only legs to walls follow: north up -// column 9 (or 8, a tile short) to row 12, west to (8, 12), east to -// (30, 12) beside the policeman (31, 12), south to (30, 17), west to -// (25, 17), and down the ledge row 18 to (25, 19), a few tiles from the -// door (22, 19). The way keeps out of the boy's (16, 18..24) and the -// balding man's (8..10, 22..24) wander boxes. -StoryCheckpoint route4_to_cerulean(){ - const TeachPlan mega_kick{.item = std::string(TEACH_TUTOR), .move = "mega-kick", .member = 0, .forget_move = "withdraw"}; - return row("00.14", "Route 4: Mega Kick from its tutor, then east to Cerulean's Pokemon Center", at(ROUTE4, 32, 6, SOUTH), after_brock(), StartMenu::FULL, { - running(route("mega_kick_tutor", at(ROUTE4, 50, 4, NORTH), "east and up through (48, 5) into the tutors' pen, below the Mega Kick tutor (50, 3)")), - teach_step("teach_mega_kick", "the tutor's Mega Kick in place of Withdraw, unless the lead knows it", mega_kick), - running(route("above_ledge", at(ROUTE4, 93, 8, SOUTH), "east along Route 4's upper road to above the ledge row 9")), - hop("ledge_hop", SOUTH, at(ROUTE4, 93, 10, SOUTH), "down the ledge (93, 9) to the lower road"), - running(route("cerulean_entry", at(CERULEAN, 9, 20, EAST), "east into Cerulean City, to (9, 20) below column 9")), - running(legs("above_city_ledge", {{NORTH, 8}, {WEST, 1}, {EAST, 22}, {SOUTH, 5}, {WEST, 5}}, "to walls: (9, 12), (8, 12), (30, 12), (30, 17), (25, 17)")), - hop("city_ledge_hop", SOUTH, at(CERULEAN, 25, 19, SOUTH), "down the ledge (25, 18)"), - running(route("cerulean_nurse", at(CERULEAN_CENTER, 7, 4, NORTH), "west along row 20 to the Pokemon Center's door (22, 19)")), - heal("heal_cerulean"), - }); -} - -// Cerulean Gym (pokefirered CeruleanCity_Gym map.json and scripts.inc): -// a pool with walkways. Misty (8, 6) stands on a platform (7..9, 6) above -// row 7. Picnicker Diana (4, 7) faces east, sight 4, over (5..8, 7), so -// misty_front (8, 7) is in her line; Swimmer Luis (10, 12) in the water -// faces west, sight 1, over (9, 12), on column 9 north of the door. No -// gym trainer has to be fought for Misty, so neither is: from the door up -// column 9 to row 13 (a route there, so the planner's walk to a wall -// doesn't run on past it through (9, 12)), west to (4, 13), and to walls -// round the pool's west and north sides, (4, 10), (12, 10), (12, 7), then -// west to (9, 7), the tile below the platform's east end, out of Diana's -// line. 00.14c steps up onto (9, 6) and talks to Misty from beside her. -// -// Misty beat a Lv20 Wartortle (console B, run m51), so first a GRIND to -// Lv23 on 00.15's patch. Gen 3 numbers (pokefirered: her mons have IV 0; -// Wartortle taken at IV 15, no EVs): Starmie Lv21 has 56 HP, Atk 36, SpA -// 47, SpD 40. Bite is Dark, special in Gen 3, no STAB, x2 on Psychic: at -// Lv23 (SpA 39) it does 23..28, three hits (two on top rolls); at Lv20, -// 20..24. Her Swift (physical, 60) does 9..11 to a Lv23 Wartortle (about -// 67 HP, Def 45) and Water Pulse (STAB, resisted) 8..10: 6 or more hits, -// though m51 saw about 20 a turn. Her Recover (28) and Super Potion undo -// a Bite, so the margin is in Bite's damage. -// -// The Mart comes before the GRIND: its wild battles are fought only with -// 2 or more Potions, and 00.14's save has none (m51 met Misty with only -// the 5 this row bought). 5 Potions (row 3, 300 each), then up to 3 Super -// Potions (row 2, 700), last so they take the Items pocket's last row; -// the battle doesn't use them yet. The money box can't be read, so the -// floor stands for it, and a floor above the money fails the step (the -// quantity box wraps). Prizes (pokefirered: 4 x last level x the class's -// factor) from a new game's 3000, less Viridian's 2000 and the Magikarp's -// 500: Liam 220, Brock 1400, Route 3's bug catchers 360, the Mt. Moon -// grunt 416 and Miguel 288 (the first rival's 80 only if won), at least -// 3184 here. Floor and budget 3000: 5 Potions and 2 Super Potions, 2900. -// Misty's 2100 (4 x 21 x 25) then leaves 00.15 its floor of 1500. Then the -// nurse, and the save before Misty, so her battle is its own checkpoint, -// 00.14c, verified and retried from it. 00.15's GRIND then fights -// until the sim beats the Cerulean rival often enough. -StoryCheckpoint cerulean_gym(){ - const MartPlan supplies{ - .map = CERULEAN_MART, - .lines = {{.item = "potion", .quantity = 5}, {.item = "super-potion", .quantity = 3}}, - .budget = 3000, - .money_floor = 3000, - }; - const GrindPlan to_lv23{.member = 0, .level = 23, .max_encounters = 100, .pace = WEST, .heal_every = 0}; - return row("00.14b", "Cerulean: Potions, a GRIND to Lv23, then into the Gym, saved below Misty's platform", at(CERULEAN_CENTER, 7, 4, NORTH), after_brock(), StartMenu::FULL, { - running(route("mart_clerk", at(CERULEAN_MART, 4, 3, WEST), "out of the Center to the Mart's clerk")), - mart_step("buy_potions", "5 Potions for the GRIND's wild battles, then Super Potions as the money allows", supplies), - running(route("grind_patch", at(ROUTE4, 86, 16, WEST), "west out of the city along Route 4's lower road onto its grass's east edge")), - grind_step("grind_to_lv23", "wild battles until the lead is Lv23, where Bite takes Starmie in three", to_lv23, at(CERULEAN_CENTER, 7, 4, NORTH)), - running(route("cerulean_nurse", at(CERULEAN_CENTER, 7, 4, NORTH), "back to the Center: Misty's battle starts at full HP and PP")), - heal("heal_cerulean"), - running(route("gym_below_luis", at(CERULEAN_GYM, 9, 13), "into the Gym, up column 9 to row 13, short of Luis's (9, 12)")), - running(legs("gym_west_walkway", {{WEST, 5}}, "west to the wall (4, 13)")), - running(legs("below_misty_platform", {{NORTH, 3}, {EAST, 8}, {NORTH, 3}, {WEST, 3}}, "walls (4, 10), (12, 10), (12, 7), then to (9, 7), out of Diana's line")), - }); -} - -// Misty (TRAINER_LEADER_MISTY: Staryu Lv18, Starmie Lv21), talked to from -// (9, 6), beside her on the platform. Her win text runs on to the CASCADE -// BADGE, TM03 (Water Pulse) and its explanation, all read with the -// battle's. Bite is chosen against her party (Starmie is Water/Psychic). -// Back to the nurse round the pool's west side, out of Luis's line; then -// Water Pulse in place of Tail Whip, last, at the Center, from the bag's -// TM CASE. Ends where 00.15 starts. -StoryCheckpoint misty(){ - const TeachPlan water_pulse{.item = "tm03", .move = "water-pulse", .member = 0, .forget_move = "tail-whip"}; - return row("00.14c", "Cerulean Gym: Misty, then Water Pulse", at(CERULEAN_GYM, 9, 7, WEST), after_brock(), StartMenu::FULL, { - running(route("beside_misty", at(CERULEAN_GYM, 9, 6, WEST), "up onto (9, 6), facing Misty (8, 6)")), - talk("challenge_misty", "Misty's speech"), - battle("misty", at(CERULEAN_GYM, 9, 6, WEST), false, "Staryu and Starmie, with Bite; CASCADE BADGE and TM03"), - running(legs("gym_way_out", {{SOUTH, 1}, {EAST, 3}, {SOUTH, 3}, {WEST, 8}, {SOUTH, 3}, {EAST, 5}}, "walls (12, 7), (12, 10), (4, 10), (4, 13), (9, 13), round Luis's (9, 12)")), - running(route("cerulean_nurse", at(CERULEAN_CENTER, 7, 4, NORTH), "down column 9 out of the Gym, to the Center")), - heal("heal_cerulean"), - teach_step("teach_water_pulse", "TM03 Water Pulse in place of Tail Whip", water_pulse), - }); -} - -// Before the rival north of Cerulean (cerulean_rival()), from the -// Center: first TM03 Water Pulse over Tail Whip, if the lead doesn't know -// it yet, so the GRIND's sim plays it (a run without TM03 from Misty -// skips the step). Then 3 Potions at the Mart -// (CeruleanCity_Mart_Items: POTION is row 3, 300 each; Mt. Moon's -// trainers leave well over the floor) and 2 Awakenings (row 6, 250 each; -// pokefirered items.json) for the rival's Bulbasaur's Sleep Powder -// (console B, m56: asleep at 34/65 HP, it fainted two turns later with -// 15 Potions), 1400 of the floor's 1500. Then a GRIND on Route 4's grass -// east of Mt. Moon (75..86, 11..17; Spearow, Rattata, Ekans and Mankey -// around Lv10, about 80 EXP each), healing at the Center, until the -// battle sim beats the rival 00.15b fights 50% or more: the win chance -// his battle refuses below. Console B's Wartortle (Lv22, 65 HP, Water -// Pulse) is about 42% there and 62% at Lv23; Lv28 (about 88%, some 120 -// battles from Lv22) is the cap. Then the nurse, and the save on (23, 7), -// the tile below his trigger: his battle is its own checkpoint, 00.15b, -// verified and retried from this save. -StoryCheckpoint cerulean_grind(){ - const TeachPlan water_pulse{.item = "tm03", .move = "water-pulse", .member = 0, .forget_move = "tail-whip"}; - const MartPlan potions{ - .map = CERULEAN_MART, - .lines = {{.item = "potion", .quantity = 3}, {.item = "awakening", .quantity = 2}}, - .budget = 1500, - .money_floor = 1500, - }; - const GrindPlan for_rival{ - .member = 0, .level = 28, .max_encounters = 150, .pace = WEST, .heal_every = 0, - .trainer = std::string(story_trainer(CERULEAN, "rival_cerulean").value_or("")), .min_chance = MIN_WIN_CHANCE, - }; - return row("00.15", "Cerulean: Water Pulse, Potions, a GRIND until the rival is winnable, then saved below his trigger", at(CERULEAN_CENTER, 7, 4, NORTH), after_brock(), StartMenu::FULL, { - teach_step("teach_water_pulse", "TM03 Water Pulse in place of Tail Whip, unless the lead knows it or there is no TM03", water_pulse), - running(route("mart_clerk", at(CERULEAN_MART, 4, 3, WEST), "out of the Center to the Mart's clerk")), - mart_step("buy_potions", "3 Potions: the GRIND fights wild battles only with 2 or more; 2 Awakenings for the rival's Sleep Powder", potions), - running(route("grind_patch", at(ROUTE4, 86, 16, WEST), "west out of the city along Route 4's lower road onto its grass's east edge")), - grind_step("grind_for_rival", "wild battles until the sim beats the rival 50% or more, Lv28 at most; the nurse when hurt or low on PP", for_rival, at(CERULEAN_CENTER, 7, 4, NORTH)), - running(route("cerulean_nurse", at(CERULEAN_CENTER, 7, 4, NORTH), "back to the Center: the rival's battle starts at full HP and PP")), - heal("heal_cerulean"), - running(route("below_rival_trigger", at(CERULEAN, 23, 7, NORTH), "out of the Center, north up to (23, 7), short of the trigger row 6")), - }); -} - -// The rival north of Cerulean (CeruleanCity scripts.inc): the only way -// north to Nugget Bridge is columns 22..24, and a step onto row 6 there -// (CeruleanCity_EventScript_RivalTrigger*, VAR_MAP_SCENE_CERULEAN_CITY_RIVAL -// 0) brings him down to the player. From the middle, (23, 6), he stops -// at (23, 5); after the battle he walks round the player and off south, -// and the player, turning to watch him, ends facing south. His FAME -// CHECKER's text is read to the overworld with the battle's. For a player -// who took Squirtle he has Pidgeotto Lv17, Abra Lv16, Rattata Lv15 and -// Bulbasaur Lv18 (sParty_RivalCeruleanBulbasaur), whose Vine Whip and -// Sleep Powder are the danger. The row starts from 00.15's save below the -// trigger, and saves after him. First TM03 Water Pulse over Tail Whip (from -// the bag, where the player stands), if the lead doesn't know it yet: -// console B's save (2026-11-03) is past Misty's TEACH, which failed there. -// Where she taught it, the step reads the moves and does nothing. -StoryCheckpoint cerulean_rival(){ - const TeachPlan water_pulse{.item = "tm03", .move = "water-pulse", .member = 0, .forget_move = "tail-whip"}; - return row("00.15b", "Cerulean: Water Pulse if not known, then the rival north of the city", at(CERULEAN, 23, 7, NORTH), after_brock(), StartMenu::FULL, { - teach_step("teach_water_pulse", "TM03 Water Pulse in place of Tail Whip, unless the lead knows it", water_pulse), - step_into("rival_trigger", NORTH, "onto (23, 6), the middle trigger: \"Yo! !\""), - battle("rival_cerulean", at(CERULEAN, 23, 6, SOUTH), false, "Pidgeotto, Abra, Rattata and Bulbasaur; then the FAME CHECKER"), - }); -} - -// Nugget Bridge (Route24 map.json) is x 10..12 from row 32 north to row -// 16, the city's columns 22..24 (offset 12). Its five trainers stand on -// it facing across, sight 2, so each line crosses the middle column 11 -// on the trainer's row: Bug Catcher Cale (12, 31), Lass Ali (10, 28), -// Youngster Timmy (12, 25), Lass Reli (10, 22) and Camper Ethan (12, 19). -// Each is fought on the step onto their row, beside them: they don't -// walk, and the player keeps facing north. Two tiles separate the rows, -// walked as one short leg; the step onto a row goes on a tile at a time -// until the trainer sees the player (into_line()), as the open leg onto -// the bridge ended a tile short twice on console B (2026-11-03), on -// (11, 33), and one step left the player out of Cale's sight. Then the -// Rocket (12, 15): the step onto (11, 15) -// (Route24_EventScript_RocketTriggerRight, VAR_MAP_SCENE_ROUTE24 0) gives -// the NUGGET, "join Team Rocket", and his battle; he only turns, and the -// player turns east to him. Camper Shane (5, 21) looks north from the -// west bank, off the way. -StoryCheckpoint nugget_bridge(){ - return row("00.16", "Nugget Bridge: the nurse, five trainers and the Rocket", at(CERULEAN, 23, 6, SOUTH), after_brock(), StartMenu::FULL, { - running(route("cerulean_nurse", at(CERULEAN_CENTER, 7, 4, NORTH), "back to the Center after the rival, before Nugget Bridge")), - heal("heal_cerulean"), - running(route("below_cale_line", at(ROUTE24, 11, 32, NORTH), "out of the Center, north past the rival's row onto the bridge, below Cale's row")), - into_line("cale_line", NORTH, "onto (11, 31), beside Cale"), - battle("bug_catcher_cale", at(ROUTE24, 11, 31, NORTH), false, "his Bug Pokemon"), - running(legs("below_ali_line", {{NORTH, 2}}, "up to (11, 29)")), - into_line("ali_line", NORTH, "onto (11, 28), beside Ali"), - battle("lass_ali", at(ROUTE24, 11, 28, NORTH), false, "her Pokemon"), - running(legs("below_timmy_line", {{NORTH, 2}}, "up to (11, 26)")), - into_line("timmy_line", NORTH, "onto (11, 25), beside Timmy"), - battle("youngster_timmy", at(ROUTE24, 11, 25, NORTH), false, "his Pokemon"), - running(legs("below_reli_line", {{NORTH, 2}}, "up to (11, 23)")), - into_line("reli_line", NORTH, "onto (11, 22), beside Reli"), - battle("lass_reli", at(ROUTE24, 11, 22, NORTH), false, "her Pokemon"), - running(legs("below_ethan_line", {{NORTH, 2}}, "up to (11, 20)")), - into_line("ethan_line", NORTH, "onto (11, 19), beside Ethan"), - battle("camper_ethan", at(ROUTE24, 11, 19, NORTH), false, "his Pokemon"), - // A route, not legs: the nurse may have been needed. - ready("ready_for_rocket", at(CERULEAN_CENTER, 7, 4, NORTH), "items for a status or low HP; the nurse only if they can't"), - running(route("below_rocket_trigger", at(ROUTE24, 11, 16, NORTH), "up the bridge to below the Rocket's trigger (11, 15)")), - step_into("rocket_trigger", NORTH, "onto (11, 15), beside the Rocket"), - battle("rocket_grunt", at(ROUTE24, 11, 15, EAST), false, "the NUGGET, then Ekans and Zubat, Lv15"), - }); -} - -// Route 24 north of Nugget Bridge (Route24 map.json) joins Route 25 by -// its rows 7..9; the ledges on Route 25's row 6 (x 0..9) leave the way -// north at x 12..13. Route 25 (Route25 map.json, scripts.inc) to Bill's -// Sea Cottage door (51, 4): of its nine trainers, four can't be walked -// around. -// - Hiker Franklin (11, 4) faces east, sight 4, over (12..15, 4), and -// Hiker Wayne (17, 7) east over (18..19, 7): the only ways east past -// x 15. Franklin is fought, from (15, 5) on the step onto (15, 4), the -// end of his line: he walks up to (14, 4). -// - Youngster Joey (18, 2) faces south over (18, 3..4): the way keeps -// off column 18, south round Wayne to (19, 6) and up to (19, 4). -// - Youngster Dan (22, 4) looks around, sight 2, over the only way east, -// (20..21, 4). On (20, 4), a one-tile leg, he may see the player and -// walk up to (21, 4); so the way goes north from there to row 2, east, -// and down column 23 past him to (23, 5), off every tile he may walk -// up to. Where his sight is crossed, the leg ends on a wall or is one -// tile; if he looks the player's way, story_interrupts() fight him. -// - Picnicker Kelsey (22, 8) faces east over (23..24, 8), across the -// only way on: fought on the step onto (24, 8); she walks up to (23, 8). -// - Hiker Nob (27, 9) faces north over (27, 6..8), Camper Flint (28, 4) -// south over (28, 5..7): every way east crosses one. Nob is fought on -// the step onto (27, 8), beside him; the way on keeps off Flint's -// column, by one-tile legs and legs to walls. -// - Youngster Chad (36, 4) walks up and down column 36 (rows 2..7), so -// he may see any tile of it down to row 9. The way crosses his column -// on row 9, a leg to the water at (42, 9), where he can only walk up -// beside it. -// - Lass Haley (42, 5) faces south over (42, 6..8), the only way east of -// x 42: fought on the step onto (42, 8); she walks up to (42, 7). -// The row saves inside the Sea Cottage, which the save card names -// ROUTE 25. -StoryCheckpoint route25(){ - return row("00.17", "Route 24 and 25 to Bill's Sea Cottage: Franklin, Kelsey, Nob and Haley", at(ROUTE24, 11, 15, EAST), after_brock(), StartMenu::FULL, { - running(route("below_franklin_line", at(ROUTE25, 15, 5, NORTH), "north off Nugget Bridge, east into Route 25, round its ledges to (15, 5), below the end of Franklin's line")), - into_line("franklin_line", NORTH, "onto (15, 4), at the end of Franklin's line"), - battle("hiker_franklin", at(ROUTE25, 15, 4, NORTH), false, "Machop and Geodude, Lv15; Franklin stops at (14, 4)"), - running(legs("west_of_dan", {{EAST, 2}, {SOUTH, 2}, {EAST, 2}, {NORTH, 2}}, "to (17, 4), short of Joey's (18, 4); round Wayne (17, 7) to (19, 6); up to (19, 4)")), - running(legs("round_dan", { - {EAST, 1}, {NORTH, 2}, {EAST, 4}, {WEST, 1}, {SOUTH, 3}, {EAST, 1}, {SOUTH, 2}, - }, "onto (20, 4); up to (20, 2), east to (24, 2), down column 23 past Dan to (23, 5), to (24, 7) above Kelsey's line")), - into_line("kelsey_line", SOUTH, "onto (24, 8), at the end of Kelsey's line"), - battle("picnicker_kelsey", at(ROUTE25, 24, 8, SOUTH), false, "Nidoran M and Nidoran F, Lv15; Kelsey stops at (23, 8)"), - running(legs("west_of_nob_line", {{EAST, 2}}, "along row 8 to (26, 8)")), - into_line("nob_line", EAST, "onto (27, 8), above Nob"), - battle("hiker_nob", at(ROUTE25, 27, 8, EAST), false, "three Geodude and a Machop, Lv13"), - running(legs("below_haley_line", { - {EAST, 1}, {SOUTH, 1}, {EAST, 1}, {NORTH, 3}, {EAST, 5}, {SOUTH, 3}, {EAST, 8}, - }, "below Flint's column to (29, 9), up to (29, 6), east to (34, 6), down to (34, 9), east along row 9 past Chad's column to the water, (42, 9)")), - into_line("haley_line", NORTH, "onto (42, 8), at the end of Haley's line"), - battle("lass_haley", at(ROUTE25, 42, 8, NORTH), false, "Oddish, Pidgey and Oddish, Lv13; Haley stops at (42, 7)"), - running(route("sea_cottage", at(SEA_COTTAGE, 7, 8, NORTH), "east along row 8, up column 51 into the Sea Cottage (51, 4), a step in from its mat")), - }); -} - -// Bill's Sea Cottage (Route25_SeaCottage scripts.inc). Bill is the -// Clefairy at (10, 6) (FLAG_HELPED_BILL_IN_SEA_COTTAGE unset): talked to -// from (10, 7), below him, he asks "Help me out!" (YES/NO; NO goes on the -// same), says to run the Cell Separation on the PC, and walks up into -// the right teleporter (10, 3); with the player facing north he walks -// straight up. The PC (4, 5) answers only from the south, (4, 6). Its -// scene: the teleporters run, Bill comes out of the left one (3, 3) and -// walks to (7, 6) (BillWalkToMiddleOfRoom); the player isn't moved. -// Talked to from (6, 6), Bill gives the S.S. TICKET, no YES/NO, and goes -// on about the S.S. ANNE (FLAG_GOT_SS_TICKET, which also hides Nugget -// Bridge's Rocket). Out by the mat (7, 9); the door puts the player on -// (51, 5), facing south. The maps keep Bill at (7, 5), but after his -// scene he stands on (7, 6), in the way from (6, 6) to the mat (console -// B, 2026-11-03), so the walk out goes around him to (7, 8) first. -StoryCheckpoint bill(){ - return row("00.18", "Bill's Sea Cottage: the Cell Separator and the S.S. Ticket", at(SEA_COTTAGE, 7, 8, NORTH), after_brock(), StartMenu::FULL, { - running(route("below_bill_clefairy", at(SEA_COTTAGE, 10, 7, NORTH), "below the Clefairy (10, 6), facing it")), - talk("bill_clefairy", "\"Hiya! I'm a POKEMON... ...No I'm not!\" ... \"Help me out!\""), - answer("help_bill", true, "YES: \"run the Cell Separation on the PC\""), - scene("bill_into_teleporter", at(SEA_COTTAGE, 10, 7, NORTH), "the Clefairy walks up into the right teleporter"), - running(route("pc_front", at(SEA_COTTAGE, 4, 6, NORTH), "below the PC (4, 5), facing it")), - talk("cell_separator", "the PC: \" initiated the TELEPORTER's CELL SEPARATOR!\""), - scene("bill_comes_out", at(SEA_COTTAGE, 4, 6, NORTH), "the teleporters run; Bill comes out of the left one and walks to (7, 6)"), - running(legs("beside_bill", {{EAST, 2}}, "to (6, 6), west of Bill, facing him")), - talk("thank_bill", "\"Thanks, bud! ... take this\""), - scene("ss_ticket", at(SEA_COTTAGE, 6, 6, EAST), "the S.S. TICKET; \"... the S.S. ANNE ... go instead\""), - running(legs("around_bill", {{SOUTH, 2}, {EAST, 1}}, "to (7, 8), above the mat; Bill stands on (7, 6) after his scene")), - running(route("out_of_cottage", at(ROUTE25, 51, 5, SOUTH), "down to the mat and out; the door puts the player below it")), - }); -} +} // namespace -// Back to Cerulean by Route 25's south path (Route25 map.json): from -// below the cottage down column 51 to row 12, west along row 12 and row -// 11 into Route 24 (x 14..23, row 11), and down its column 14..16 east -// of Nugget Bridge to Cerulean's north edge (x 26..28, offset 12). No -// trainer stands on it. Cerulean's row 1 there is a ledge (26..28, 1), -// hopped south from (27, 0); then on into the city to the Pokemon Center. -StoryCheckpoint back_to_cerulean(){ - return row("00.19", "Route 25's south path back to Cerulean's Pokemon Center", at(ROUTE25, 51, 5, SOUTH), after_brock(), StartMenu::FULL, { - running(route("above_cerulean_ledge", at(CERULEAN, 27, 0, SOUTH), "Route 25's south path west, Route 24 east of the bridge south, to above Cerulean's ledge (27, 1)")), - hop("cerulean_ledge_hop", SOUTH, at(CERULEAN, 27, 2, SOUTH), "down the ledge (27, 1)"), - running(route("cerulean_nurse", at(CERULEAN_CENTER, 7, 4, NORTH), "into the city to the Pokemon Center")), - heal("heal_cerulean"), - }); -} -// Stopgap for console B's save, which caught nothing on Route 1. A new -// playthrough should instead catch a Rattata on Route 1 or 22 early, as -// its Cut user and spare member, and drop this row (and its walk over -// Nugget Bridge and back). -// -// An Oddish for HM01 Cut, and a second member behind the lead -// (docs/design/AutoStory-FRLG-FutureEvents.md, "Console B run choices"). -// Route 24's grass (Route24 map.json: x 3..5, rows 19..31, west of Nugget -// Bridge) is the nearest to the Center with Oddish: FireRed's -// sRoute24_FireRed (pokefirered wild_encounters.json) has it in 25% of -// battles, Lv12..14, as Route 25's grass; Routes 5 and 6 aren't on the -// story's maps yet. Up the bridge, whose trainers 00.16 beat, west along -// rows 10..15 to the cliff (3, 15) and down column 3 to the grass's first -// row, (3, 19); the step paces east to (4, 19) and back. Camper Shane -// (5, 21) faces north, sight 5, over (5, 16..20): column 5 is kept off. -// The leg west ends on the cliff, not open: on console B (m63) an open -// leg west to (4, 15) ended a tile short, and the walk down column 5 -// came into Shane's sight. -// -// First 7 Poke Balls at the Mart (row 1, 200 each; the bag isn't read, so -// the step buys them whatever the bag holds). The floor, from 00.15's -// 1500 less its 1400: the rival's 288 (4 x 18 x 4), the Rocket's 480 (4 -// x 15 x 8), Franklin's 540 and Nob's 468 (hikers, 9) alone make 1876 -// (pokefirered gTrainerMoneyTable). An Oddish at full HP (catch rate 255) -// stays in a Poke Ball about 1 time in 3 (Gen 3: a = 85, four shakes of -// 0.76), so 7 balls catch it about 94% of the time; the step throws 7 at -// most, in 30 battles (none an Oddish: 0.02%). Nothing weakens it: the HP -// bar isn't read on the console yet. -// -// The Oddish joins the party second. Battles keep the lead in -// (PokemonFRLG_AutoStoryBattleDecisions.h): the Oddish is sent only when -// the lead faints in a trainer's battle, which counts as lost. Back to -// the nurse, and the save in the Center. -StoryCheckpoint oddish(){ - const MartPlan balls{ - .map = CERULEAN_MART, - .lines = {{.item = "poke-ball", .quantity = 7}}, - .budget = 1400, - .money_floor = 1500, +StoryCheckpoint read_story_checkpoint_file(const JsonValue& value, std::string_view source){ + StoryCheckpoint checkpoint; + std::set note_keys; + const Pokemon::ExecutionReader read_execution = [&](const JsonObject& execution, std::string_view where){ + only_fields(execution, {"menu", "supplies", "lead", "handoff", "live_start", "notes"}, where); + checkpoint.menu = read_start_menu(execution.get_string_throw("menu", std::string(where)), where); + checkpoint.supplies = read_supplies(execution, where); + if (execution.get_value("handoff") != nullptr){ + checkpoint.handoff = read_handoff(execution.get_string_throw("handoff", std::string(where)), where); + } + if (execution.get_value("live_start") != nullptr){ + checkpoint.live_start = execution.get_boolean_throw("live_start", std::string(where)); + } + note_keys = read_note_keys(execution, where); }; - const CapturePlan catch_oddish{.species = "oddish", .catches = 1, .max_encounters = 30, .max_balls = 7, .pace = EAST}; - return row("00.20", "Route 24's grass: an Oddish for Cut, then the Center", at(CERULEAN_CENTER, 7, 4, NORTH), after_brock(), StartMenu::FULL, { - running(route("mart_clerk", at(CERULEAN_MART, 4, 3, WEST), "out of the Center to the Mart's clerk")), - mart_step("buy_poke_balls", "7 Poke Balls for the Oddish", balls), - running(route("oddish_patch", at(ROUTE24, 3, 19), "north over Nugget Bridge, west to the cliff and down column 3 onto the grass's first row, out of Shane's column 5")), - capture_step("catch_oddish", "wild battles until an Oddish, then Poke Balls; any other species is run from", catch_oddish), - running(route("cerulean_nurse", at(CERULEAN_CENTER, 7, 4, NORTH), "back over the bridge to the Center")), - heal("heal_cerulean"), - }); -} - -// Cerulean's only way south without Cut (CeruleanCity map.json, -// scripts.inc) is through the burgled house (30, 11), whose door the -// policeman leaves once the S.S. TICKET is had, out of the hole in its -// back wall into the yard (31, 8). The Rocket there (33, 6) stops the -// player on (33, 5) or (33, 7) (CeruleanCity_EventScript_GruntTrigger*): -// from (32, 7), the step east onto (33, 7) turns the player to him; -// Machop and Drowzee, Lv17, then TM28 Dig, and he is gone. Then east -// round the yard, down to the city's south edge by the path along its -// east side (39..40, 20..31), down Route 5's east side to the -// Underground Path's north house (31, 31), through its tunnel and out of -// the south house onto Route 6, below its door (19, 14). Route 6: -// - Bug Catcher Keigo (3, 16) faces east, sight 5, over the middle path -// (4..8, 16); Bug Catcher Elijah (20, 25) faces west, sight 3, over -// the east path (17..19, 25). The way goes down column 15, through the -// grass to the wall (15, 33), out of both lines; the open leg west to -// it, a tile short, leaves the player on column 16, out of them too. -// - Camper Ricky and Picnicker Nancy (12..13, 21) battle only when -// talked to. -// - Picnicker Isabelle (13, 32) and Camper Jeff (13, 33) face west, sight -// 3, over (10..12, 32) and (10..12, 33); the only way south, (10..12, -// 34), is from Jeff's row. Up to (15, 31), west to the wall (7, 31), -// down to the wall (7, 33), east: Jeff is fought on the step onto -// (10, 33) and walks up to (11, 33). Isabelle's row is kept off. -// Then down into Vermilion City (offset 12) to its Pokemon Center. -StoryCheckpoint to_vermilion(){ - return row("00.21", "The Cerulean Rocket, Route 5, the Underground Path and Route 6 to Vermilion's Pokemon Center: Jeff", at(CERULEAN_CENTER, 7, 4, NORTH), after_brock(), StartMenu::FULL, { - running(route("west_of_rocket", at(CERULEAN, 32, 7, EAST), "through the burgled house and out of the hole in its back wall, west of the Rocket (33, 6)")), - step_into("rocket_trigger", EAST, "onto (33, 7), below the Rocket"), - battle("rocket_grunt", at(CERULEAN, 33, 7, NORTH), false, "Machop and Drowzee, Lv17; TM28 Dig"), - running(route("route6_column15", at(ROUTE6, 15, 14), "round the yard and down Cerulean's east side, Route 5 into the Underground Path, through it onto Route 6, west to column 15")), - running(legs("round_keigo_and_elijah", { - {SOUTH, 19}, {NORTH, 1}, {NORTH, 1}, {WEST, 8}, {SOUTH, 2}, {EAST, 2}, - }, "down column 15 to the wall (15, 33); up to (15, 31), west to the wall (7, 31), down to the wall (7, 33), east to (9, 33)")), - into_line("jeff_line", EAST, "onto (10, 33), in Jeff's line"), - battle("camper_jeff", at(ROUTE6, 10, 33, EAST), false, "Spearow and Raticate, Lv16; Jeff stops at (11, 33)"), - running(route("vermilion_nurse", at(VERMILION_CENTER, 7, 4, NORTH), "down Route 6's south path into Vermilion City, to the Pokemon Center")), - heal("heal_vermilion"), - }); -} - -// The S.S. Anne (VermilionCity, SSAnne_* scripts.inc). The step onto -// (23, 33) (VermilionCity_EventScript_CheckTicket) has the sailor (24, 33) -// ask for a ticket; the S.S. TICKET (00.18) is shown and the player turns -// east to him. Then onto the pier (23, 34), along the gangway, through -// 1F, by legs off its cabins' doormats on row 10, which planned routes -// cross, and up its stairs (3, 8) to 2F. The step onto (30, 6), below the -// Captain's door (30, 2) (SSAnne_2F_Corridor_EventScript_RivalTriggerLeft), -// brings the rival out and down to (30, 5); the player keeps facing -// north, and after the battle he walks round the player and off. For a -// player who took Squirtle: Pidgeotto Lv19, Raticate Lv16, Kadabra Lv18, -// Ivysaur Lv20. The ship's trainers are in its cabins and on its deck, -// off the way. The Captain (5, 4) faces up; talked to from (5, 5) he is -// rubbed on the back and gives HM01 (VAR_MAP_SCENE_VERMILION_CITY 1). -// Back out through 1F's door (19, 1): on the gangway the ship sails -// (SSAnne_Exterior_ExitSSAnne), the player is put on (23, 34) and walked -// up to (23, 32) (VermilionCity_EventScript_ExitSSAnne). Cut is taught -// later, to the Oddish. -StoryCheckpoint ss_anne(){ - return row("00.22", "The S.S. Anne: the rival, HM01 Cut from the Captain, back to Vermilion's Pokemon Center", at(VERMILION_CENTER, 7, 4, NORTH), after_brock(), StartMenu::FULL, { - running(route("above_ticket_check", at(VERMILION, 23, 32, SOUTH), "out of the Center down to the harbor, above the ticket check (23, 33)")), - step_into("ticket_check", SOUTH, "onto (23, 33): \"Do you have a ticket?\""), - scene("show_ss_ticket", at(VERMILION, 23, 33, EAST), "the S.S. TICKET; the player turns to the sailor"), - running(route("aboard", at(SS_ANNE_1F, 19, 2, SOUTH), "onto the pier, along the gangway and in by 1F's door, a step below it")), - running(legs("past_the_cabins", {{SOUTH, 8}, {NORTH, 1}, {WEST, 6}, {NORTH, 1}}, "to the wall (19, 10), up a step, west to the worker (12, 9), up a step to (13, 8): off the cabins' mats on row 10")), - running(route("below_rival_trigger", at(SS_ANNE_2F, 30, 7, NORTH), "west along 1F, up the stairs (3, 8) and along 2F below the Captain's door")), - step_into("rival_trigger", NORTH, "onto (30, 6): the rival comes out of the Captain's door"), - battle("rival_ss_anne", at(SS_ANNE_2F, 30, 6, NORTH), false, "Pidgeotto, Raticate, Kadabra and Ivysaur"), - running(route("behind_captain", at(CAPTAINS_OFFICE, 5, 5, NORTH), "into the Captain's office, behind the Captain (5, 4)")), - talk("captain", "\"Ooargh... I feel hideous... Urrp! Seasick...\""), - scene("hm01_cut", at(CAPTAINS_OFFICE, 5, 5, NORTH), "the player rubs his back; HM01, and what Cut does"), - running(route("off_2f", at(SS_ANNE_1F, 13, 8), "back along 2F, down the stairs and east along 1F's row 8")), - running(legs("round_the_sailor", {{EAST, 4}, {SOUTH, 1}, {EAST, 2}}, "to the sailor (18, 8), down a step, east to (19, 9): off the cabins' mats on row 10")), - running(route("below_ship_door", at(SS_ANNE_1F, 19, 2, NORTH), "up below the door to the gangway")), - step_into("off_the_ship", NORTH, "out onto the gangway"), - scene("ss_anne_sails", at(VERMILION, 23, 32, NORTH), "the ship sails; the player is walked off the pier to (23, 32)"), - running(route("vermilion_nurse", at(VERMILION_CENTER, 7, 4, NORTH), "back to the Pokemon Center")), - heal("heal_vermilion"), - }); + static_cast(checkpoint) = Pokemon::read_authored_checkpoint( + without_metadata(value, source), "frlg", source, read_execution, story_action_specs() + ); + for (const std::string& key : note_keys){ + bool found = key == "checkpoint"; + for (const StoryStep& step : checkpoint.steps){ + found |= step.name == key; + } + if (!found){ + throw ParseException(std::format("{}: notes for unknown step {}", source, key)); + } + } + // A Mart spends money and a TEACH a TM: once per save. + for (StoryStep& step : checkpoint.steps){ + step.once_per_save = step.action == MART_ACTION || step.action == TEACH_ACTION; + } + return checkpoint; } -} // namespace - - - const std::vector& story_checkpoints(){ - static const std::vector checkpoints{ - new_game(), after_sid_helper(), leave_house(), oaks_trigger(), to_starter_ball(), starter(), parcel(), pokedex(), shopping(), forest(), brock(), - running_shoes(), route3(), magikarp_salesman(), after_gift_rng(), magikarp_to_box(), mt_moon(), - route4_to_cerulean(), cerulean_gym(), misty(), cerulean_grind(), cerulean_rival(), nugget_bridge(), - route25(), bill(), back_to_cerulean(), oddish(), to_vermilion(), ss_anne(), - vermilion_gym(), to_lt_surge(), lt_surge(), bike_voucher(), route10_center(), - }; + static const std::vector checkpoints = []{ + std::vector result; + for (const auto& [name, text] : autostory_checkpoint_json()){ + result.push_back(read_story_checkpoint_file(parse_json(text), name)); + } + return result; + }(); return checkpoints; } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h index 2778f00eb5..ec960d1f99 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h @@ -10,12 +10,38 @@ * saved at its end. After 00.10 every route and leg runs. Taken from a by-hand run on * console B (2026-11-01) and the pokefirered map scripts. * + * Each checkpoint is an authored JSON file in StoryData/ + * (frlg-.plan.json, format pokesim-authored-checkpoint/1): the shared + * checkpoint, its steps each an action with args, read against FRLG's + * actions (story_action_specs()), and FRLG's execution object: + * + * "menu" before_pokemon, before_pokedex or full: the START menu + * at its end (StoryCheckpoint::menu); + * "supplies" optional: {"potions", "antidotes", "parlyz_heals"} at + * its start, for a run that loads its save; + * "lead" optional: "after_brock", the starter as the story left + * it by Brock (story_lead_after_brock()); + * "handoff" optional: sid_helper, starter_rng or gift_rng, the RNG program + * the user may run there (StoryCheckpoint::handoff); + * "live_start" optional, true: it starts from the game as another + * program left it (StoryCheckpoint::live_start); + * "notes" optional: {"checkpoint" or a step's id: [lines]}, the + * reasons behind a step that a reader of the file needs. + * The program doesn't read them. + * + * Beside "execution", "metadata": {"phase": testing, verification or + * reproduction}: how far the checkpoint is trusted. + * */ #ifndef PokemonAutomation_PokemonFRLG_AutoStoryTable_H #define PokemonAutomation_PokemonFRLG_AutoStoryTable_H +#include +#include +#include #include +#include "Common/Cpp/Json/JsonValue.h" #include "Common/Cpp/TestRunners/UnitTestDatabase.h" #include "PokemonFRLG_AutoStoryEvents.h" @@ -24,8 +50,17 @@ namespace NintendoSwitch{ namespace PokemonFRLG{ -// Checkpoints 00.01 to 00.25, in order, with 00.01b, the way back in after -// SID Helper, after 00.01, 00.04 split in two at Squirtle's ball for +// (name, JSON text) of each file in StoryData/, sorted by name. +// Generated at build time (SerialPrograms/cmake/EmbedTextFiles.cmake). +const std::vector>& autostory_checkpoint_json(); + +// The checkpoint of an authored FRLG file. Throws ParseException when +// the file is malformed, names an action FRLG doesn't have, gives an +// action args it doesn't take, or has notes for a step it doesn't have. +StoryCheckpoint read_story_checkpoint_file(const JsonValue& value, std::string_view source); + +// Checkpoints 00.01 to 00.27, in order: every file in StoryData/. With +// 00.01b, the way back in after SID Helper, after 00.01, 00.04 split in two at Squirtle's ball for // Starter RNG: 00.04 and 00.04b, 00.12b, the way back in after Gift RNG, // after 00.12, 00.12c, the Magikarp put in BOX 1, after it, 00.14b and // 00.14c, Cerulean Gym to a save below Misty's platform and Misty alone @@ -40,12 +75,6 @@ void add_tests_AutoStory(UnitTestDatabase& database); void add_tests_AutoStoryRunPlan(UnitTestDatabase& database); // The table run end to end against a fake game (PokemonFRLG_AutoStorySimulation_Tests.cpp). void add_tests_AutoStorySimulation(UnitTestDatabase& database); -// Rows 00.21 and 00.22 on the overworld sim (PokemonFRLG_AutoStoryVermilion_Tests.cpp). -void add_tests_AutoStoryVermilion(UnitTestDatabase& database); -// Rows 00.23 to 00.25 on the overworld sim (PokemonFRLG_AutoStoryVermilionGym_Tests.cpp). -void add_tests_AutoStoryVermilionGym(UnitTestDatabase& database); -// Rows from 00.26 on on the overworld sim (PokemonFRLG_AutoStoryCeladon_Tests.cpp). -void add_tests_AutoStoryCeladon(UnitTestDatabase& database); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableCeladon.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableCeladon.cpp deleted file mode 100644 index 6406c1e857..0000000000 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableCeladon.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/* AutoStory Table: to Celadon - * - * From: https://github.com/PokemonAutomation/ - * - * Rows from 00.26 on, after the THUNDERBADGE: the BICYCLE, and the way - * east and south to Celadon City. - * - */ - -#include "PokemonFRLG_AutoStoryMart.h" -#include "PokemonFRLG_AutoStoryTableSteps.h" - -namespace PokemonAutomation{ -namespace NintendoSwitch{ -namespace PokemonFRLG{ -namespace StoryTable{ - - -// The BIKE VOUCHER and the BICYCLE, from Vermilion's Center to -// Cerulean's (pokeguy 43:50 to 45:00). -// - The Pokemon Fan Club (VermilionCity_PokemonFanClub map.json, -// scripts.inc), in by Vermilion's (12, 17): the chairman (5, 4) sits -// above a table (5..6, 5..6) with the worker (6, 4) east of him, so he -// is talked to from (4, 4), west of him. "Did you come to hear about -// my POKEMON?" YES: his story, then the BIKE VOUCHER -// (FLAG_GOT_BIKE_VOUCHER). Oak's aide stands on Vermilion's (25, 7) -// since Lt. Surge, where the story's maps don't have him: the way -// planned from the Center's door goes east along his row 7, so the -// walk goes down to the water (14, 10) first, as 00.25 came up from -// it. From the Fan Club, up to (22, 10) first, so that the way on to -// Route 6 goes up column 22, west of him, not round by column 27. -// - Route 6 north, the trainers as 00.21 left them: Jeff (13, 33) -// beaten, Isabelle (13, 32) and Elijah (20, 25) not. As in 00.24, onto -// Jeff's row, west to the wall (7, 33) and up to row 31, above -// Isabelle's line; then east along row 31 to the wall (17, 31) and up -// column 16, west of Elijah's line (17..19, 25) and east of Keigo's -// (4..8, 16), to the ledge (16, 11). The first three legs are 00.24's, -// walked on console B; the two after end on walls, which the walker -// holds again after a wild battle in the grass. -// - The Underground Path north, Route 5's sides, which have no trainer, -// and Cerulean's south edge, whose way into the city without the -// burgled house is the tree (26, 32) (pokeguy 44:42). -// - The Bike Shop (CeruleanCity_BikeShop), in by (13, 28): the clerk -// (9, 3) is across the counter (8, 3), talked to from (7, 3). With the -// voucher he gives the BICYCLE (FLAG_GOT_BICYCLE) with no YES/NO; it -// isn't registered or ridden yet. -// - The Mart: 5 Repels (row 9, 350 each) and 2 Escape Ropes (row 8, -// 550 each; pokefirered items.json), 2850 in all. Console B had about -// 9000 after Lt. Surge (2026-11-03); the floor of 6000 leaves 3000 or -// more after them. -// - The nurse, and the save in Cerulean's Center. -StoryCheckpoint bike_voucher(){ - const MartPlan repels{ - .map = CERULEAN_MART, - .lines = {{.item = "repel", .quantity = 5}, {.item = "escape-rope", .quantity = 2}}, - .budget = 2850, - .money_floor = 6000, - }; - return row("00.26", "The BIKE VOUCHER from the Fan Club, back north to Cerulean, the BICYCLE, Repels and Escape Ropes", at(VERMILION_CENTER, 7, 4, NORTH), after_brock(), StartMenu::FULL, { - running(route("below_center", at(VERMILION, 14, 10), "out of the Center, down to the water (14, 10): off Oak's aide's row 7")), - running(route("beside_chairman", at(FAN_CLUB, 4, 4, EAST), "east along row 10, down to the Fan Club's door (12, 17), in, and up its west side beside the chairman (5, 4)")), - talk("chairman", "\"I chair the POKEMON Fan Club!\" ... \"Did you come to hear about my POKEMON?\""), - answer("hear_story", true, "YES: his story"), - scene("bike_voucher", at(FAN_CLUB, 4, 4, EAST), "the story of his Rapidash; the BIKE VOUCHER"), - running(route("west_of_oaks_aide", at(VERMILION, 22, 10), "out of the Fan Club, east along row 18 and up column 22 to (22, 10)")), - running(route("route6_south_path", at(ROUTE6, 11, 34, NORTH), "up column 22 west of Oak's aide (25, 7), out of the city onto Route 6's path, below Jeff's row")), - running(legs("round_isabelle_and_elijah", {{NORTH, 1}, {WEST, 4}, {NORTH, 2}, {EAST, 9}, {NORTH, 19}}, "onto Jeff's row (11, 33), west to the wall (7, 33), up to (7, 31), east along row 31 to the wall (16, 31), up column 16 to the ledge (16, 12): out of Isabelle's and Elijah's lines")), - running(route("below_cerulean_tree", at(CERULEAN, 26, 33, NORTH), "the Underground Path north, up Route 5's side into Cerulean, below the tree (26, 32)")), - cut_tree("cut_cerulean_tree", at(CERULEAN, 26, 32, NORTH), "the tree; a step onto its tile"), - running(route("bike_clerk", at(BIKE_SHOP, 7, 3, EAST), "west into the Bike Shop (13, 28), across the counter from the clerk (9, 3)")), - talk("talk_bike_clerk", "\"Oh, that's... A BIKE VOUCHER!\""), - scene("bicycle", at(BIKE_SHOP, 7, 3, EAST), "the voucher exchanged for a BICYCLE"), - running(route("mart_clerk", at(CERULEAN_MART, 4, 3, WEST), "out of the Bike Shop to the Mart's clerk")), - mart_step("buy_repels", "5 Repels and 2 Escape Ropes, 2850 at most", repels), - running(route("cerulean_nurse", at(CERULEAN_CENTER, 7, 4, NORTH), "out of the Mart to the Center")), - heal("heal_cerulean"), - }); -} - -// East out of Cerulean over Route 9 to Route 10's Pokemon Center -// (pokeguy 45:12 to 47:27), on foot: the Bicycle isn't registered yet. -// - Cerulean (CeruleanCity map.json): the way east, column 39..40 up -// from row 33 to rows 18..19 and out of the city's east edge, is -// reached from the city only through the tree (26, 32), grown back -// since 00.26 (its flag is a FLAG_TEMP), or the burgled house. Cut -// from above. Route 9 joins the city's rows 18..19 by its rows 8..9 -// (offset -10); its tree (2, 8) (FLAG_TEMP_12) closes them, (2, 9) -// being rock: cut from (1, 8), west of it. -// - Route 9 (Route9 map.json, scripts.inc), its ledges all facing south. -// Of its nine trainers, three can't be walked around, as in pokeguy's -// run, where Jeremy happened to look away: -// - Picnicker Alicia (14, 10) faces west, sight 3, over (11..13, 10), -// the only tiles above the ledge row 11 the way west goes down by: -// fought on the step onto (11, 10); she walks up to (12, 10). Then -// down the ledge (11, 11). -// - Hiker Jeremy (20, 17) looks north and west (FACE_UP_AND_LEFT), -// sight 4: north over (20, 13..16), every way east of column 19 -// below the rocks of row 12. Fought on (20, 13), waiting for him to -// look north (TRAINER_WAIT_VARIANT); he walks up to (20, 14). -// - Bug Catcher Conner (49, 7) faces east, sight 3, over (50..52, 7): -// the way north from row 13 is column 52 alone (the ledges of row -// 11 face south), and row 7 is the way onto the ridge. Fought on the -// step onto (52, 7); he walks up to (51, 7). -// - Hiker Brice wanders row 2 (50..56), looking west and east, sight -// 1, over (49..57, 2), and the way up from the ledges of row 4 is -// (50..51, 4) below him. The leg up column 51 ends on row 3 if he -// stands at (51, 2), else it goes on to (51, 1) past him, and he may -// see the player there; either way the legs to walls after it meet -// on (48, 1): west to the rock (48, 3) or (48, 1), up to (48, 1). -// Row 1 is clear of his sight; east along it to the rock (64, 1) -// and down column 64 past the hidden Rare Candy (63, 2), not picked -// up. A held leg down to (64, 3) would hop the ledge (64, 4) and go -// on, so the last tile is one step, then the hop. -// - Picnicker Caitlin (60, 9) faces east over (61..64, 9): the way to -// Route 10 goes along row 8, above her line, by legs to (70, 8), a -// tile short of the edge. Camper Chris (26, 7), -// Bug Catcher Brent (26, 1), Camper Drew (36, 6) and Hiker Alan (61, -// 16) are off the way; TM40 (12, 17) is left. -// - Route 10 (Route10 map.json) joins Route 9's rows 8..10 by its own; -// its north part, down to the Center's door (13, 20), has no trainer -// on the way and its grass is walked round. The trees west of the -// door (10, 20..26) stay. The walk there ends its open legs where a -// tile of error can't reach a blocker, and finds its place again on -// walls (console B, 2026-11-09, two runs "no fade" at the door): the -// step onto Route 10 is not always held up, so the player may stand a -// tile further east, and the leg along row 11 holds to the wall -// (17, 11) instead of ending on (16, 11) by count. The 12 tiles down -// column 16 may end a tile short or long: from rows 22..29 a tile west -// and up to the Center's wall (15, 20) all end on (15, 21). West along -// row 21 to the wall (9, 21) ends on (10, 21), three west of the -// door's column: the only count no wall after it checks. -// - The nurse, and the save in Route 10's Center: the save card names -// ROUTE 10. -StoryCheckpoint route10_center(){ - return row("00.27", "East over Route 9 to Route 10's Pokemon Center: the two trees, Alicia, Jeremy and Conner", at(CERULEAN_CENTER, 7, 4, NORTH), after_brock(), StartMenu::FULL, { - running(route("above_cerulean_tree", at(CERULEAN, 26, 31, SOUTH), "out of the Center, south through the city to above the tree (26, 32), grown back")), - cut_tree("cut_cerulean_tree", at(CERULEAN, 26, 32, SOUTH), "the tree; a step onto its tile"), - running(route("west_of_route9_tree", at(ROUTE9, 1, 8, EAST), "down to row 33, east and up column 39 or 40 to row 18, east out of the city onto Route 9, west of its tree (2, 8)")), - cut_tree("cut_route9_tree", at(ROUTE9, 2, 8, EAST), "Route 9's tree; a step onto its tile"), - running(route("above_alicia_line", at(ROUTE9, 11, 9, SOUTH), "east to (11, 9), above the west end of Alicia's line")), - into_line("alicia_line", SOUTH, "onto (11, 10), in Alicia's line: she walks up to (12, 10)"), - battle("picnicker_alicia", at(ROUTE9, 11, 10, EAST), false, "Oddish, Bellsprout, Oddish and Bellsprout, Lv18"), - hop("alicia_ledge_hop", SOUTH, at(ROUTE9, 11, 12, SOUTH), "down the ledge (11, 11)"), - running(route("west_of_jeremy_sight", at(ROUTE9, 19, 13, EAST), "down to row 13 and east along it to (19, 13), west of Jeremy's north line")), - into_sight("jeremy_sight", EAST, "onto (20, 13), four above Jeremy (20, 17): when he looks north he walks up to (20, 14)"), - battle("hiker_jeremy", at(ROUTE9, 20, 13, SOUTH), false, "Machop and Onix, Lv20"), - running(route("below_conner_line", at(ROUTE9, 52, 8, NORTH), "east along row 13 and up column 52 to (52, 8), below the east end of Conner's line")), - into_line("conner_line", NORTH, "onto (52, 7), the end of Conner's line: he walks up to (51, 7)"), - battle("bug_catcher_conner", at(ROUTE9, 52, 7, WEST), false, "Caterpie, Weedle and Venonat, Lv20"), - running(legs("round_brice", {{NORTH, 2}, {WEST, 1}, {NORTH, 2}, {WEST, 3}, {NORTH, 2}, {EAST, 16}, {SOUTH, 1}}, "up to the ledge (52, 4), up column 51 to Brice's row, west to the rock (48, 3) (or (48, 1)), up to (48, 1), east along row 1 to the rock (64, 1), down to (64, 2)")), - step_onto("above_east_ledge", SOUTH, at(ROUTE9, 64, 3, SOUTH), "onto (64, 3), above the ledge (64, 4)"), - hop("east_ledge_hop", SOUTH, at(ROUTE9, 64, 5, SOUTH), "down the ledge (64, 4)"), - running(legs("above_caitlin_line", {{SOUTH, 3}, {EAST, 6}}, "down column 64 to row 8, east along it to (70, 8): above Caitlin's line (61..64, 9)")), - running(route("route10_ledge_end", at(ROUTE10, 17, 11, EAST), "east onto Route 10, down to row 11 west of the grass and east along it to the wall (17, 11), above the fence post (17, 12)")), - running(legs("below_center_door", {{WEST, 1}, {SOUTH, 12}, {WEST, 1}, {NORTH, 2}, {WEST, 5}, {EAST, 3}}, "into the ledge's gap (16, 11), down column 16 to row 23, a tile west, up to the Center's wall (15, 21), west along row 21 to the wall (10, 21), east to (13, 21), below the door")), - running(route("route10_nurse", at(ROUTE10_CENTER, 7, 4, NORTH), "up onto the Center's door (13, 20), to the nurse")), - heal("heal_route10"), - }); -} - - -} // namespace StoryTable -} // namespace PokemonFRLG -} // namespace NintendoSwitch -} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableSteps.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableSteps.cpp deleted file mode 100644 index acd9a79de8..0000000000 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableSteps.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/* AutoStory Table Steps - * - * From: https://github.com/PokemonAutomation/ - * - */ - -#include "PokemonFRLG_AutoStoryTableSteps.h" - -namespace PokemonAutomation{ -namespace NintendoSwitch{ -namespace PokemonFRLG{ -namespace StoryTable{ - - -Pokemon::Pose at(const char* map, int x, int y, std::optional facing){ - return to_pose(StoryPose{map, {x, y}, facing}); -} - -StoryCheckpoint row( - std::string id, std::string title, std::optional start, - Supplies supplies, StartMenu menu, std::vector steps -){ - StoryCheckpoint checkpoint; - checkpoint.id = std::move(id); - checkpoint.title = std::move(title); - checkpoint.start = std::move(start); - checkpoint.steps = std::move(steps); - checkpoint.supplies = supplies; - checkpoint.menu = menu; - return checkpoint; -} - -Supplies after_brock(){ - Supplies supplies; - supplies.lead = story_lead_after_brock(); - return supplies; -} - -StoryStep make(StoryStepKind kind, std::string name, std::string why){ - StoryStep step; - step.kind = kind; - step.name = std::move(name); - step.why = std::move(why); - return step; -} - -StoryStep route(std::string name, Pokemon::Pose target, std::string why, WildBattles wild){ - StoryStep step = make(StoryStepKind::ROUTE, std::move(name), std::move(why)); - step.target = std::move(target); - step.fight_wild = wild == WildBattles::FIGHT; - return step; -} - -StoryStep step_into(std::string name, Direction direction, std::string why){ - StoryStep step = make(StoryStepKind::STEP, std::move(name), std::move(why)); - step.direction = direction; - return step; -} - -StoryStep into_line(std::string name, Direction direction, std::string why){ - StoryStep step = step_into(std::move(name), direction, std::move(why)); - step.variant = TRAINER_LINE_VARIANT; - return step; -} - -StoryStep hop(std::string name, Direction direction, Pokemon::Pose landing, std::string why){ - StoryStep step = step_into(std::move(name), direction, std::move(why)); - step.pose_after = std::move(landing); - return step; -} - -StoryStep step_onto(std::string name, Direction direction, Pokemon::Pose tile, std::string why){ - return hop(std::move(name), direction, std::move(tile), std::move(why)); -} - -StoryStep answer(std::string name, bool yes, std::string why){ - StoryStep step = make(StoryStepKind::ANSWER, std::move(name), std::move(why)); - step.yes = yes; - return step; -} - -StoryStep scene(std::string name, std::optional pose_after, std::string why){ - StoryStep step = make(StoryStepKind::MASH, std::move(name), std::move(why)); - step.pose_after = std::move(pose_after); - return step; -} - -StoryStep battle(std::string name, Pokemon::Pose pose_after, bool may_lose, std::string why){ - StoryStep step = make(StoryStepKind::BATTLE, std::move(name), std::move(why)); - step.pose_after = std::move(pose_after); - step.may_lose = may_lose; - return step; -} - -StoryStep legs(std::string name, std::vector legs, std::string why, WildBattles wild){ - StoryStep step = make(StoryStepKind::LEGS, std::move(name), std::move(why)); - step.legs = std::move(legs); - step.fight_wild = wild == WildBattles::FIGHT; - return step; -} - -StoryStep running(StoryStep step){ - step.variant = RUN_VARIANT; - return step; -} - -StoryStep new_game_intro(Pokemon::Pose pose_after, std::string why){ - StoryStep step = make(StoryStepKind::NEW_GAME, "intro", std::move(why)); - step.pose_after = std::move(pose_after); - return step; -} - -StoryStep talk(std::string name, std::string why){ - return make(StoryStepKind::TALK, std::move(name), std::move(why)); -} - -StoryStep ready(std::string name, Pokemon::Pose nurse, std::string why){ - StoryStep step = make(StoryStepKind::READY, std::move(name), std::move(why)); - step.target = std::move(nurse); - return step; -} - -StoryStep heal(std::string name){ - return make(StoryStepKind::HEAL, std::move(name), "full HP"); -} - -StoryStep shop(std::string name, std::vector items, std::string why){ - StoryStep step = make(StoryStepKind::SHOP, std::move(name), std::move(why)); - step.items = std::move(items); - return step; -} - -StoryStep game_step(std::string variant, Pokemon::Pose pose_after, std::string why){ - StoryStep step = make(StoryStepKind::GAME, variant, std::move(why)); - step.variant = std::move(variant); - step.pose_after = std::move(pose_after); - return step; -} - -StoryStep options_step(){ - return make(StoryStepKind::OPTIONS, "options", "fast text; no switch prompt between a trainer's Pokemon"); -} -StoryStep into_sight(std::string name, Direction direction, std::string why){ - StoryStep step = step_into(std::move(name), direction, std::move(why)); - step.variant = TRAINER_WAIT_VARIANT; - return step; -} - -StoryStep cut_tree(std::string name, Pokemon::Pose tree, std::string why){ - StoryStep step = make(StoryStepKind::GAME, std::move(name), std::move(why)); - step.variant = CUT_TREE_VARIANT; - step.direction = facing_of(tree).value_or(Direction::NORTH); - step.pose_after = std::move(tree); - return step; -} - - - -} // namespace StoryTable -} // namespace PokemonFRLG -} // namespace NintendoSwitch -} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableSteps.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableSteps.h deleted file mode 100644 index 8775379b84..0000000000 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableSteps.h +++ /dev/null @@ -1,197 +0,0 @@ -/* AutoStory Table Steps - * - * From: https://github.com/PokemonAutomation/ - * - * What the story table (PokemonFRLG_AutoStoryTable.h) is written in: the - * maps' names and the functions that make its rows and steps, shared by - * the files its rows are in. - * - */ - -#ifndef PokemonAutomation_PokemonFRLG_AutoStoryTableSteps_H -#define PokemonAutomation_PokemonFRLG_AutoStoryTableSteps_H - -#include -#include -#include -#include "PokemonFRLG_AutoStoryEvents.h" - -namespace PokemonAutomation{ -namespace NintendoSwitch{ -namespace PokemonFRLG{ -namespace StoryTable{ - - -// Cardinal direction: North. -inline constexpr Direction NORTH = Direction::NORTH; -// Cardinal direction: South. -inline constexpr Direction SOUTH = Direction::SOUTH; -// Cardinal direction: East. -inline constexpr Direction EAST = Direction::EAST; -// Cardinal direction: West. -inline constexpr Direction WEST = Direction::WEST; - -// Pallet Town player's bedroom map. -inline constexpr const char* BEDROOM = "PalletTown_PlayersHouse_2F"; -// Pallet Town overworld map. -inline constexpr const char* PALLET = "PalletTown"; -// Professor Oak's lab map. -inline constexpr const char* LAB = "PalletTown_ProfessorOaksLab"; -// Viridian City overworld map. -inline constexpr const char* VIRIDIAN = "ViridianCity"; -// Viridian City Mart map. -inline constexpr const char* VIRIDIAN_MART = "ViridianCity_Mart"; -// Viridian City Pokemon Center map. -inline constexpr const char* VIRIDIAN_CENTER = "ViridianCity_PokemonCenter_1F"; -// Viridian Forest overworld map. -inline constexpr const char* FOREST = "ViridianForest"; -// Viridian Forest North Entrance gate map. -inline constexpr const char* FOREST_GATE = "Route2_ViridianForest_NorthEntrance"; -// Pewter City overworld map. -inline constexpr const char* PEWTER = "PewterCity"; -// Pewter City Pokemon Center map. -inline constexpr const char* PEWTER_CENTER = "PewterCity_PokemonCenter_1F"; -// Pewter City Gym map. -inline constexpr const char* GYM = "PewterCity_Gym"; -// Route 3 overworld map. -inline constexpr const char* ROUTE3 = "Route3"; -// Route 4 overworld map. -inline constexpr const char* ROUTE4 = "Route4"; -// Route 4 Pokemon Center map. -inline constexpr const char* ROUTE4_CENTER = "Route4_PokemonCenter_1F"; -// Mt. Moon 1F map. -inline constexpr const char* MT_MOON_1F = "MtMoon_1F"; -// Mt. Moon B2F map. -inline constexpr const char* MT_MOON_B2F = "MtMoon_B2F"; -// Cerulean City overworld map. -inline constexpr const char* CERULEAN = "CeruleanCity"; -// Cerulean City Pokemon Center map. -inline constexpr const char* CERULEAN_CENTER = "CeruleanCity_PokemonCenter_1F"; -// Cerulean City Mart map. -inline constexpr const char* CERULEAN_MART = "CeruleanCity_Mart"; -// Cerulean City Gym map. -inline constexpr const char* CERULEAN_GYM = "CeruleanCity_Gym"; -// Route 24 overworld map. -inline constexpr const char* ROUTE24 = "Route24"; -// Route 25 overworld map. -inline constexpr const char* ROUTE25 = "Route25"; -// Bill's Sea Cottage map. -inline constexpr const char* SEA_COTTAGE = "Route25_SeaCottage"; -// Route 6 overworld map. -inline constexpr const char* ROUTE6 = "Route6"; -// Vermilion City overworld map. -inline constexpr const char* VERMILION = "VermilionCity"; -// Vermilion City Pokemon Center map. -inline constexpr const char* VERMILION_CENTER = "VermilionCity_PokemonCenter_1F"; -// Vermilion City Gym map. -inline constexpr const char* VERMILION_GYM = "VermilionCity_Gym"; -// S.S. Anne 1F corridor map. -inline constexpr const char* SS_ANNE_1F = "SSAnne_1F_Corridor"; -// S.S. Anne 2F corridor map. -inline constexpr const char* SS_ANNE_2F = "SSAnne_2F_Corridor"; -// Captain's Office map. -inline constexpr const char* CAPTAINS_OFFICE = "SSAnne_CaptainsOffice"; -// Vermilion City Pokemon Fan Club map. -inline constexpr const char* FAN_CLUB = "VermilionCity_PokemonFanClub"; -// Cerulean City Bike Shop map. -inline constexpr const char* BIKE_SHOP = "CeruleanCity_BikeShop"; -// Route 9 overworld map. -inline constexpr const char* ROUTE9 = "Route9"; -// Route 10 overworld map. -inline constexpr const char* ROUTE10 = "Route10"; -// Route 10 Pokemon Center map. -inline constexpr const char* ROUTE10_CENTER = "Route10_PokemonCenter_1F"; - -// Constructs pose at map coordinates. -Pokemon::Pose at(const char* map, int x, int y, std::optional facing = std::nullopt); - -// Constructs story checkpoint row. -StoryCheckpoint row( - std::string id, std::string title, std::optional start, - Supplies supplies, StartMenu menu, std::vector steps -); - -// At the rows after Brock: no items counted, the starter with the moves -// the story gave it by Lv13. A run that loads a save reads the moves off -// the lead's summary instead (read_lead_moves()), so a save whose moves -// differ from these (console B, 2026-11-02: Water Gun where Tackle was) -// is fought with the moves it has. -Supplies after_brock(); - -// What a walk does about wild Pokemon: runs, or fights them for EXP. -enum class WildBattles{ - RUN, - FIGHT, -}; - -// Constructs a story step of given kind. -StoryStep make(StoryStepKind kind, std::string name, std::string why); -// Constructs a route navigation step. -StoryStep route(std::string name, Pokemon::Pose target, std::string why, WildBattles wild = WildBattles::RUN); -// Constructs a single directional movement step. -StoryStep step_into(std::string name, Direction direction, std::string why); -// A step `direction` into a trainer's line, a tile at a time until the -// trainer sees the player (TRAINER_LINE_VARIANT): the battle after it -// starts whether the walk before ended on its tile or a tile short. -StoryStep into_line(std::string name, Direction direction, std::string why); -// A step `direction` into the line of a trainer who looks around -// (TRAINER_WAIT_VARIANT), then a wait until they turn to the player: the -// battle after it starts on that tile. -StoryStep into_sight(std::string name, Direction direction, std::string why); -// A step the way a ledge faces, from the tile before it: the player hops -// it and lands on `landing`, two tiles on. Planned routes never hop a -// ledge (they hold into walls, and a held ledge hops), so where the only -// way on is down a ledge the table takes it as this one step. -StoryStep hop(std::string name, Direction direction, Pokemon::Pose landing, std::string why); -// One step `direction` onto `tile`, the next one, where a walk's hold -// would go on: onto the tile before a ledge, which a held leg hops. -StoryStep step_onto(std::string name, Direction direction, Pokemon::Pose tile, std::string why); -// Constructs a dialog answer step. -StoryStep answer(std::string name, bool yes, std::string why); -// Constructs an in-game cutscene or dialog interaction step. -StoryStep scene(std::string name, std::optional pose_after, std::string why); -// Constructs a trainer or boss battle step. -StoryStep battle(std::string name, Pokemon::Pose pose_after, bool may_lose, std::string why); -// Constructs a fixed multi-leg route step. -StoryStep legs(std::string name, std::vector legs, std::string why, WildBattles wild = WildBattles::RUN); -// `step`, a ROUTE or LEGS, run with B held: from the Running Shoes on. -// Indoors, where the game doesn't let the player run, it walks. -StoryStep running(StoryStep step); -// Constructs new game introduction sequence step. -StoryStep new_game_intro(Pokemon::Pose pose_after, std::string why); -// Constructs an NPC dialog interaction step. -StoryStep talk(std::string name, std::string why); -// Constructs checkpoint preparation and recovery step. -StoryStep ready(std::string name, Pokemon::Pose nurse, std::string why); -// Constructs a Pokemon Center healing sequence step. -StoryStep heal(std::string name); -// Constructs a Poke Mart shopping step. -StoryStep shop(std::string name, std::vector items, std::string why); -// Constructs an internal engine gameplay automation step. -StoryStep game_step(std::string variant, Pokemon::Pose pose_after, std::string why); -// Constructs game settings configuration step. -StoryStep options_step(); -// Cuts the tree the player faces (CUT_TREE_VARIANT) and steps onto its -// tile, `tree`, facing the way the step goes. -StoryStep cut_tree(std::string name, Pokemon::Pose tree, std::string why); - - -// Rows in files of their own (PokemonFRLG_AutoStoryTableVermilionGym.cpp, -// PokemonFRLG_AutoStoryTableCeladon.cpp). -StoryCheckpoint vermilion_gym(); -// Route navigation step towards Lt. Surge battle. -StoryCheckpoint to_lt_surge(); -// Lt. Surge gym leader battle checkpoint. -StoryCheckpoint lt_surge(); -// Bike Voucher retrieval checkpoint in Vermilion City Fan Club. -StoryCheckpoint bike_voucher(); -// Route 10 Pokemon Center navigation checkpoint. -StoryCheckpoint route10_center(); - - - -} // namespace StoryTable -} // namespace PokemonFRLG -} // namespace NintendoSwitch -} // namespace PokemonAutomation -#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableVermilionGym.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableVermilionGym.cpp deleted file mode 100644 index 6c8f3d653f..0000000000 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableVermilionGym.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/* AutoStory Table: Vermilion Gym - * - * From: https://github.com/PokemonAutomation/ - * - * Rows 00.23 to 00.25: HM01 Cut to the Oddish, the tree before Vermilion - * Gym, its three trainers and its trash cans, then Lt. Surge from a save - * in front of him. - * - * The gym (VermilionCity_Gym map.json, scripts.inc), 11 x 20, entered on - * (5, 19): the cans on rows 10, 12 and 14 at x 1, 3, 5, 7, 9 - * (PokemonFRLG_AutoStoryTrashCans.h), the beams across rows 6 and 7 that - * the two switches turn off, Lt. Surge (5, 2) facing down above them. Its - * trainers, sight 3: - * - Sailor Dwayne (8, 13) and Engineer Baily (2, 11) look around - * (MOVEMENT_TYPE_LOOK_AROUND): between them they see across rows 11 and - * 13 and down columns 2 and 8, so no way from the door to the cans - * keeps out of their sight. Each is fought from the second tile of his - * line, stepped onto from beside it, out of sight, and waited on there - * until he turns to the player (TRAINER_WAIT_VARIANT): Dwayne from - * (8, 15), stepped onto from (7, 15), Baily from (2, 13), from (3, 13). - * Each walks up a tile, Dwayne to (8, 14), Baily to (2, 12), and stays - * there while the player is in the gym. - * - Gentleman Tucker (7, 8) faces west over (4..6, 8): fought on the step - * up from (5, 9) onto (5, 8); he walks up to (6, 8). - * The cans' stands, on rows 9, 11 and 13 above each, are clear of where - * the three stand after their battles. Leaving the gym puts them back - * where the map has them, beaten, and grows the tree back. - * - */ - -#include "PokemonFRLG_AutoStoryBattleData.h" -#include "PokemonFRLG_AutoStoryGrind.h" -#include "PokemonFRLG_AutoStoryTableSteps.h" -#include "PokemonFRLG_AutoStoryTeach.h" -#include "PokemonFRLG_AutoStoryTrashCans.h" - -namespace PokemonAutomation{ -namespace NintendoSwitch{ -namespace PokemonFRLG{ -namespace StoryTable{ - - -namespace{ - -// The search for the switches (PokemonFRLG_AutoStoryTrashCans.h). It -// ends at the last can's stand, which the step's Outcome says. -StoryStep trash_cans(std::string name, std::string why){ - StoryStep step = make(StoryStepKind::GAME, std::move(name), std::move(why)); - step.variant = TRASH_CANS_VARIANT; - return step; -} - -// `step`, skipped when the run flag `flag` is set. -StoryStep unless(const char* flag, StoryStep step){ - step.skip_if.emplace_back(flag); - return step; -} - -} // namespace - - -// HM01 Cut, from the S.S. Anne (00.22), to the Oddish (00.20), second in -// the party: a wild Oddish of Lv12 to 14 knows 2 or 3 moves (Absorb, -// Sweet Scent, Poison Powder at 14), so it has room. TM28 Dig, from the -// Cerulean Rocket (00.21), to the lead in place of Withdraw: Ground, twice -// as strong on Lt. Surge's three, it takes the sim's chance against him -// for a Lv28 Wartortle with 14 Potions from 6% to 47%. Vermilion's tree -// (19, 24) (EventScript_CutTree) is the only way into the gym's yard, -// row 24 being walls but for it; the gym's door is (14, 25). In the gym, -// the trainers as above, then the trash cans until the door opens; out, -// the tree cut again from below, and back to the nurse. -StoryCheckpoint vermilion_gym(){ - const TeachPlan cut{.item = "hm01", .move = "cut", .member = 1}; - const TeachPlan dig{.item = "tm28", .move = "dig", .member = 0, .forget_move = "withdraw"}; - return row("00.23", "Vermilion Gym: Cut and Dig, the tree, Dwayne, Baily and Tucker, the trash cans", at(VERMILION_CENTER, 7, 4, NORTH), after_brock(), StartMenu::FULL, { - teach_step("teach_cut", "HM01 Cut to the Oddish, second in the party, unless it knows it", cut), - teach_step("teach_dig", "TM28 Dig in place of Withdraw, for Lt. Surge, unless the lead knows it or there is no TM28", dig), - running(route("above_gym_tree", at(VERMILION, 19, 23, SOUTH), "out of the Center, south through the city to above the tree (19, 24)")), - cut_tree("cut_gym_tree", at(VERMILION, 19, 24, SOUTH), "the Oddish cuts the tree; a step onto its tile"), - running(route("gym_door", at(VERMILION_GYM, 5, 19, NORTH), "down into the yard and in by the gym's door (14, 25)")), - running(legs("west_of_dwayne_line", {{NORTH, 4}, {EAST, 2}}, "up column 5 to the can (5, 14), east to (7, 15): out of Dwayne's and Baily's sight")), - into_sight("dwayne_sight", EAST, "onto (8, 15), two below Dwayne (8, 13): he turns to the player and walks up to (8, 14)"), - battle("sailor_dwayne", at(VERMILION_GYM, 8, 15, NORTH), false, "two Pikachu, Lv21"), - running(legs("east_of_baily_line", {{WEST, 4}, {NORTH, 2}, {WEST, 1}}, "west along row 15 to (4, 15), up to (4, 13), west to (3, 13): out of Baily's sight")), - into_sight("baily_sight", WEST, "onto (2, 13), two below Baily (2, 11): he turns to the player and walks up to (2, 12)"), - battle("engineer_baily", at(VERMILION_GYM, 2, 13, NORTH), false, "Voltorb and Magnemite, Lv21"), - running(legs("below_tucker_line", {{EAST, 2}, {NORTH, 4}, {EAST, 1}}, "east to (4, 13), up column 4 past Baily's row to (4, 9), east to (5, 9): below Tucker's line, not on it")), - into_line("tucker_line", NORTH, "onto (5, 8), in Tucker's line: he walks up to (6, 8)"), - battle("gentleman_tucker", at(VERMILION_GYM, 5, 8, EAST), false, "Pikachu, Lv23"), - trash_cans("trash_cans", "the cans until both locks open; a wrong second can resets them"), - running(route("below_gym_tree", at(VERMILION, 19, 25, NORTH), "out of the gym, east to below the tree, grown back")), - cut_tree("cut_tree_out", at(VERMILION, 19, 24, NORTH), "the tree again; a step onto its tile"), - running(route("vermilion_nurse", at(VERMILION_CENTER, 7, 4, NORTH), "north through the city to the Pokemon Center")), - heal("heal_vermilion"), - }); -} - -// Wild battles on Route 6 until the sim beats Lt. Surge half the time: -// with Dig, 47% at Lv28 and 51% at Lv29, so a lead the gym's trainers -// have brought to Lv29 passes at once, and a Lv28 one after a level. The grass nearest the city is Route 6's -// south patch (13..16, 30..33); Picnicker Isabelle (13, 32) faces west -// over (10..12, 32), on the way north from the city, so the walk goes -// along Jeff's row 33 (he is beaten) to the wall (7, 33), up to row 31 -// and east along it onto the patch's west edge, (13, 31), above -// Isabelle, out of her line. Back to the nurse the same way. -// All that is skipped when the lead, read in the Center, passes already. -// Then the tree, the gym, whose trainers stand where the map has them, -// beaten, and whose beams stay off (FLAG_FOUND_BOTH_VERMILION_GYM_SWITCHES): -// up column 5 to below Lt. Surge, and saved there. -StoryCheckpoint to_lt_surge(){ - constexpr const char* SURGE_WINNABLE = "surge_winnable"; - const GrindPlan for_surge{ - .member = 0, .level = 32, .max_encounters = 150, .pace = EAST, .heal_every = 0, - .trainer = std::string(story_trainer(VERMILION_GYM, "lt_surge").value_or("")), .min_chance = MIN_WIN_CHANCE, - }; - return row("00.24", "Route 6's grass until Lt. Surge is winnable, then through the open beams to him", at(VERMILION_CENTER, 7, 4, NORTH), after_brock(), StartMenu::FULL, { - grind_check_step(SURGE_WINNABLE, "the lead as it is: if the sim beats Lt. Surge 50% or more already, no trip to Route 6", for_surge), - unless(SURGE_WINNABLE, running(route("route6_south_path", at(ROUTE6, 11, 34, NORTH), "out of the Center, north out of the city onto Route 6's path, below Jeff's row"))), - unless(SURGE_WINNABLE, running(legs("round_isabelle_line", {{NORTH, 1}, {WEST, 4}, {NORTH, 2}, {EAST, 5}, {EAST, 1}}, "onto Jeff's row (11, 33), west to the wall (7, 33), up to (7, 31), east along row 31 to (12, 31) and a step onto the grass, (13, 31): out of Isabelle's line"))), - unless(SURGE_WINNABLE, grind_step("grind_for_surge", "wild battles until the sim beats Lt. Surge 50% or more, Lv32 at most; the nurse when hurt or low on PP", for_surge, at(VERMILION_CENTER, 7, 4, NORTH))), - unless(SURGE_WINNABLE, running(route("west_on_row_31", at(ROUTE6, 7, 31), "west along row 31, out of the grass, to the wall (7, 31)"))), - unless(SURGE_WINNABLE, running(legs("down_to_jeff_row", {{SOUTH, 2}, {EAST, 4}}, "down to the wall (7, 33), east along Jeff's row to (11, 33): out of Isabelle's line"))), - unless(SURGE_WINNABLE, running(route("vermilion_nurse", at(VERMILION_CENTER, 7, 4, NORTH), "south into the city to the Pokemon Center"))), - unless(SURGE_WINNABLE, heal("heal_vermilion")), - running(route("above_gym_tree", at(VERMILION, 19, 23, SOUTH), "out of the Center, south through the city to above the tree (19, 24)")), - cut_tree("cut_gym_tree", at(VERMILION, 19, 24, SOUTH), "the tree; a step onto its tile"), - running(route("below_lt_surge", at(VERMILION_GYM, 5, 3, NORTH), "into the gym, up round the cans and through the beams, off, to below Surge (5, 2)")), - }); -} - -// Lt. Surge (5, 2), talked to from below, from the save in front of him: -// Voltorb Lv21, Pikachu Lv18 and Raichu Lv24, Shock Wave and Thunder -// Wave, a Super Potion and a Full Heal (sParty_LeaderLtSurge); then the -// THUNDERBADGE and TM34, read to the overworld with the battle's text. -// Out, the tree, and the nurse. Surge's win also puts Oak's aide on -// Vermilion City's (25, 7) (VermilionCity_Gym_EventScript_ShowOaksAide), -// where he stays until talked to; the story's maps don't have him. The -// way to the nurse along row 7 runs into him (console B, 2026-11-03: the -// leg west stopped beside him and the step into the Center's door went -// into a house), so it goes along row 10 to the water instead, clear of -// him, and up column 14 from there. -StoryCheckpoint lt_surge(){ - return row("00.25", "Vermilion Gym: Lt. Surge, the THUNDERBADGE, then the Center", at(VERMILION_GYM, 5, 3, NORTH), after_brock(), StartMenu::FULL, { - talk("challenge_lt_surge", "\"Hey, kid! What do you think you're doing here?\""), - battle("lt_surge", at(VERMILION_GYM, 5, 3, NORTH), false, "Voltorb, Pikachu and Raichu; THUNDERBADGE and TM34"), - running(route("below_gym_tree", at(VERMILION, 19, 25, NORTH), "down through the beams, out of the gym, east to below the tree, grown back")), - cut_tree("cut_tree_out", at(VERMILION, 19, 24, NORTH), "the tree; a step onto its tile"), - running(route("below_oaks_aide", at(VERMILION, 14, 10), "north through the city and west along row 10 to the water, (14, 10): off Oak's aide's row 7")), - running(route("vermilion_nurse", at(VERMILION_CENTER, 7, 4, NORTH), "up to the Pokemon Center")), - heal("heal_vermilion"), - }); -} - - -} // namespace StoryTable -} // namespace PokemonFRLG -} // namespace NintendoSwitch -} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTeach.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTeach.cpp index fb487e8f09..36d386f34d 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTeach.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTeach.cpp @@ -6,8 +6,8 @@ #include #include +#include "PokemonFRLG_AutoStoryGameArgs.h" #include "PokemonFRLG_AutoStoryTeach.h" -#include "PokemonFRLG_AutoStoryVariantWords.h" namespace PokemonAutomation{ namespace NintendoSwitch{ @@ -37,64 +37,46 @@ const char* teach_end_name(TeachEnd end){ } -std::string teach_variant(const TeachPlan& plan){ - std::string variant = std::format("{}{} {} slot={}", TEACH_VARIANT_PREFIX, plan.item, plan.move, plan.member + 1); - if (!plan.forget_move.empty()){ - variant += " forget=" + plan.forget_move; - }else if (plan.forget_slot){ - variant += std::format(" forget_slot={}", *plan.forget_slot + 1); - } - return variant; -} - namespace{ bool is_tm_or_hm(std::string_view item){ return item.size() == 4 && (item.starts_with("tm") || item.starts_with("hm")) - && variant_number(item.substr(2), 2).has_value(); -} - -bool set_teach_word(TeachPlan& plan, std::string_view word){ - const std::optional pair = variant_pair(word); - if (!pair){ - return false; - } - if (pair->key == "forget" && !pair->value.empty()){ - plan.forget_move = std::string(pair->value); - return true; - } - const std::optional number = variant_number(pair->value, 1); - if (pair->key == "slot" && number && *number >= 1 && *number <= PARTY_SLOTS){ - plan.member = *number - 1; - return true; - } - if (pair->key == "forget_slot" && number && *number >= 1 && *number <= MOVE_SLOTS){ - plan.forget_slot = *number - 1; - return true; - } - return false; + && item[2] >= '0' && item[2] <= '9' && item[3] >= '0' && item[3] <= '9'; } } // namespace -std::optional parse_teach_variant(std::string_view variant){ - if (!variant.starts_with(TEACH_VARIANT_PREFIX)){ - return std::nullopt; +Pokemon::StoryActionArgs teach_args(const TeachPlan& plan){ + Pokemon::StoryActionArgs args{ + {"item", plan.item}, {"move", plan.move}, {"slot", int64_t(plan.member + 1)}, + }; + if (!plan.forget_move.empty()){ + args.emplace("forget", plan.forget_move); + }else if (plan.forget_slot){ + args.emplace("forget_slot", int64_t(*plan.forget_slot + 1)); } - const std::vector words = variant_words(variant.substr(TEACH_VARIANT_PREFIX.size())); - if (words.size() < 3 || !(is_tm_or_hm(words[0]) || words[0] == TEACH_TUTOR) || variant_pair(words[1])){ + return args; +} + +std::optional teach_plan_of(const Pokemon::StoryActionArgs& args){ + const std::string* item = game_arg(args, "item"); + const std::string* move = game_arg(args, "move"); + const std::optional member = counted_arg(args, "slot", PARTY_SLOTS); + if (item == nullptr || !(is_tm_or_hm(*item) || *item == TEACH_TUTOR) || move == nullptr || move->empty() || !member){ return std::nullopt; } - TeachPlan plan{.item = std::string(words[0]), .move = std::string(words[1])}; - bool slot_seen = false; - for (size_t c = 2; c < words.size(); c++){ - if (!set_teach_word(plan, words[c])){ + TeachPlan plan{.item = *item, .move = *move, .member = *member}; + if (const std::string* forget = game_arg(args, "forget")){ + if (forget->empty()){ return std::nullopt; } - slot_seen |= words[c].starts_with("slot="); + plan.forget_move = *forget; } - if (!slot_seen){ - return std::nullopt; + if (args.contains("forget_slot")){ + plan.forget_slot = counted_arg(args, "forget_slot", MOVE_SLOTS); + if (!plan.forget_slot){ + return std::nullopt; + } } return plan; } @@ -104,7 +86,8 @@ Pokemon::StoryStep teach_step(std::string name, std::string why, const TeachPlan step.kind = Pokemon::StoryStepKind::GAME; step.name = std::move(name); step.why = std::move(why); - step.variant = teach_variant(plan); + step.action = TEACH_ACTION; + step.args = teach_args(plan); step.once_per_save = true; return step; } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTeach.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTeach.h index 614a3c725d..ac166fd82b 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTeach.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTeach.h @@ -55,7 +55,8 @@ #include #include "Common/Cpp/Logging/AbstractLogger.h" #include "Common/Cpp/TestRunners/UnitTestDatabase.h" -#include "Pokemon/AutoStory/Pokemon_StorySteps.h" +#include "Pokemon/AutoStory/Pokemon_StoryStepExecutor.h" +#include "Pokemon/AutoStory/Types/Pokemon_StoryActionSpec.h" #include "PokemonFRLG_AutoStoryMember.h" namespace PokemonAutomation{ @@ -84,14 +85,16 @@ inline constexpr std::string_view TEACH_TUTOR = "tutor"; // Whether `move` is an HM's, which the game won't let a Pokemon forget. bool is_hm_move(std::string_view move); -// The prefix of a GAME step's variant that names a TEACH step. -inline constexpr std::string_view TEACH_VARIANT_PREFIX = "teach "; - -// `plan` as a variant: "teach hm03 surf slot=1 forget=tail-whip" or -// "... forget_slot=2", slots counted from 1, no forget when it has room. -std::string teach_variant(const TeachPlan& plan); -// Parses a move teaching plan from a variant string. -std::optional parse_teach_variant(std::string_view variant); +// The GAME action of a TEACH step: item WORD (required), the TM or HM, +// e.g. "hm03"; move WORD (required), e.g. "surf"; slot INTEGER +// (required, from 1); forget WORD or forget_slot INTEGER (from 1) +// (optional): the move to forget when it knows four. +inline const std::string TEACH_ACTION = "teach"; +// `plan` as its action's args. +Pokemon::StoryActionArgs teach_args(const TeachPlan& plan); +// The plan a TEACH_ACTION step's args give; nothing if the item isn't a +// TM or HM or a slot is out of range. +std::optional teach_plan_of(const Pokemon::StoryActionArgs& args); // The table's TEACH step, once per save (StoryStep::once_per_save): a // retry from the same save skips it when the lead knew the move or there @@ -107,7 +110,7 @@ struct TeachDecision{ // It knows the move already: nothing to do. bool already_known = false; }; -// Determines which move slot to overwrite given current moves. +// Determines which move slot to overwrite given current moves. TeachDecision decide_teach(const TeachPlan& plan, const std::vector& moves); @@ -121,7 +124,7 @@ enum class TeachPrompt{ FAILED, }; -// The outcome of attempting to forget a move. +// The outcome of attempting to forget a move. enum class ForgetEnd{ LEARNED, // "HM moves can't be forgotten now.": back on the moves page. @@ -160,7 +163,7 @@ class TeachActions{ virtual void dump_screen(std::string_view label) = 0; }; -// How a move teaching sequence concluded. +// How a move teaching sequence concluded. enum class TeachEnd{ LEARNED, ALREADY_KNOWN, @@ -172,10 +175,10 @@ enum class TeachEnd{ NO_ITEM, FAILED, }; -// The human-readable name of a teach outcome. +// The human-readable name of a teach outcome. const char* teach_end_name(TeachEnd end); -// The summary result of a move teaching operation. +// The summary result of a move teaching operation. struct TeachResult{ TeachEnd end = TeachEnd::FAILED; // The move forgotten, if any. @@ -187,16 +190,16 @@ struct TeachResult{ // the overworld, and reads the member again to confirm. TeachResult run_teach(Logger& logger, TeachActions& actions, const MemberReader& reader, const TeachPlan& plan); -// Formats a log message summarizing the move teaching result. +// Formats a log message summarizing the move teaching result. std::string teach_message(const TeachPlan& plan, const TeachResult& result); -// Register auto-story move teaching unit tests. +// Register auto-story move teaching unit tests. void add_tests_AutoStoryTeach(UnitTestDatabase& database); -} // namespace PokemonFRLG -} // namespace NintendoSwitch -} // namespace PokemonAutomation +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation #endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTeach_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTeach_Tests.cpp index 202e979a0b..1e777bbf88 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTeach_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTeach_Tests.cpp @@ -166,35 +166,35 @@ MemberReader reader_of(FakeTeachGame& game){ } -struct AutoStoryTeachInput{ - std::string name; - std::function body; -}; - -struct AutoStoryTeachExpectation{ -}; - -struct AutoStoryTeachCase{ - AutoStoryTeachInput input; - AutoStoryTeachExpectation expectation; -}; - +struct AutoStoryTeachInput{ + std::string name; + std::function body; +}; + +struct AutoStoryTeachExpectation{ +}; + +struct AutoStoryTeachCase{ + AutoStoryTeachInput input; + AutoStoryTeachExpectation expectation; +}; + class Test_AutoStoryTeach : public UnitTest{ public: - explicit Test_AutoStoryTeach(AutoStoryTeachCase test_case) - : UnitTest("PokemonFRLG::AutoStoryTeach - " + test_case.input.name) - , m_case(std::move(test_case)) + explicit Test_AutoStoryTeach(AutoStoryTeachCase test_case) + : UnitTest("PokemonFRLG::AutoStoryTeach - " + test_case.input.name) + , m_case(std::move(test_case)) {} virtual UnitTestResult run(Logger&, CancellableScope&) const override{ try{ - return m_case.input.body(); + return m_case.input.body(); }catch (Exception& e){ return std::string(e.name()) + ": " + e.message(); } } private: - AutoStoryTeachCase m_case; + AutoStoryTeachCase m_case; }; @@ -375,62 +375,67 @@ UnitTestResult test_tm_used_up(){ } -UnitTestResult test_teach_variant(){ +UnitTestResult test_teach_args(){ const TeachPlan plan{.item = "hm03", .move = "surf", .member = 0, .forget_move = "tail-whip"}; - const std::string variant = teach_variant(plan); - if (variant != "teach hm03 surf slot=1 forget=tail-whip"){ - return "Unexpected variant \"" + variant + "\"."; - } - const std::optional back = parse_teach_variant(variant); + const Pokemon::StoryActionArgs args = teach_args(plan); + const std::optional back = teach_plan_of(args); if (!back || back->item != "hm03" || back->move != "surf" || back->member != 0 || back->forget_move != "tail-whip"){ - return "\"" + variant + "\" didn't read back as its plan."; + return "The Surf plan didn't read back from its args."; } - const std::optional by_slot = parse_teach_variant("teach tm28 dig slot=2 forget_slot=4"); + const std::optional by_slot = teach_plan_of({ + {"item", std::string("tm28")}, {"move", std::string("dig")}, {"slot", int64_t(2)}, {"forget_slot", int64_t(4)}, + }); if (!by_slot || by_slot->member != 1 || by_slot->forget_slot != 3u){ - return "\"teach tm28 dig slot=2 forget_slot=4\" didn't read back."; + return "Dig into slot 2, forgetting move 4, didn't read back."; } - const std::optional tutor = parse_teach_variant("teach tutor mega-kick slot=1 forget=withdraw"); + const std::optional tutor = teach_plan_of(teach_args({.item = std::string(TEACH_TUTOR), .move = "mega-kick", .member = 0, .forget_move = "withdraw"})); if (!tutor || tutor->item != TEACH_TUTOR || tutor->move != "mega-kick" || tutor->forget_move != "withdraw"){ - return "\"teach tutor mega-kick slot=1 forget=withdraw\" didn't read back."; + return "The tutor's Mega Kick didn't read back from its args."; } - for (std::string_view bad : { - "teach", "teach hm03 surf", "teach potion surf slot=1", "teach hm03 surf slot=7", "teach tutors mega-kick slot=1", - "teach hm03 surf slot=1 forget_slot=5", "teach hm03 slot=1", "mart PewterCity_Mart potion=1", - }){ - if (parse_teach_variant(bad)){ - return "Expected \"" + std::string(bad) + "\" refused."; + const std::vector> bad_args{ + {"item", std::string("potion")}, + {"item", std::string("tutors")}, + {"slot", int64_t(7)}, + {"forget_slot", int64_t(5)}, + {"move", std::string("")}, + }; + for (const auto& [key, value] : bad_args){ + Pokemon::StoryActionArgs bad = args; + bad[key] = value; + if (teach_plan_of(bad)){ + return "Expected a bad " + key + " refused."; } } return true; } -} // namespace - - -const AutoStoryTeachCase AUTO_STORY_TEACH_CASES[] = { - { - .input = {"TMs and HMs on a fake party", test_teach}, - .expectation = {}, - }, - { - .input = {"a TM is used up, an HM kept", test_tm_used_up}, - .expectation = {}, - }, - { - .input = {"the table's variant", test_teach_variant}, - .expectation = {}, - }, -}; - +} // namespace + + +const AutoStoryTeachCase AUTO_STORY_TEACH_CASES[] = { + { + .input = {"TMs and HMs on a fake party", test_teach}, + .expectation = {}, + }, + { + .input = {"a TM is used up, an HM kept", test_tm_used_up}, + .expectation = {}, + }, + { + .input = {"the step's args", test_teach_args}, + .expectation = {}, + }, +}; + void add_tests_AutoStoryTeach(UnitTestDatabase& database){ - for (const auto& item : AUTO_STORY_TEACH_CASES){ - database.add(item); - } + for (const auto& item : AUTO_STORY_TEACH_CASES){ + database.add(item); + } add_tests_AutoStoryTeachScreens(database); } -} // namespace PokemonFRLG -} // namespace NintendoSwitch -} // namespace PokemonAutomation +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVariantWords.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVariantWords.cpp deleted file mode 100644 index 975658f892..0000000000 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVariantWords.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* AutoStory Variant Words - * - * From: https://github.com/PokemonAutomation/ - * - */ - -#include "PokemonFRLG_AutoStoryVariantWords.h" - -namespace PokemonAutomation{ -namespace NintendoSwitch{ -namespace PokemonFRLG{ - - -std::vector variant_words(std::string_view text){ - std::vector words; - while (!text.empty()){ - const size_t space = text.find(' '); - const std::string_view word = text.substr(0, space); - if (!word.empty()){ - words.push_back(word); - } - if (space == std::string_view::npos){ - break; - } - text.remove_prefix(space + 1); - } - return words; -} - -std::optional variant_pair(std::string_view word){ - const size_t equals = word.find('='); - if (equals == std::string_view::npos || equals == 0){ - return std::nullopt; - } - return VariantPair{word.substr(0, equals), word.substr(equals + 1)}; -} - -std::optional variant_number(std::string_view text, size_t max_digits){ - if (text.empty() || text.size() > max_digits){ - return std::nullopt; - } - size_t value = 0; - for (char c : text){ - if (c < '0' || c > '9'){ - return std::nullopt; - } - value = value * 10 + size_t(c - '0'); - } - return value; -} - - - -} // namespace PokemonFRLG -} // namespace NintendoSwitch -} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVariantWords.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVariantWords.h deleted file mode 100644 index 3618657a27..0000000000 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVariantWords.h +++ /dev/null @@ -1,44 +0,0 @@ -/* AutoStory Variant Words - * - * From: https://github.com/PokemonAutomation/ - * - * Reading a GAME step's variant: words split on spaces, "key=value" - * pairs, and small numbers. The table writes variants such as - * "mart PewterCity_Mart budget=2000 potion=5"; the steps read them back. - * - */ - -#ifndef PokemonAutomation_PokemonFRLG_AutoStoryVariantWords_H -#define PokemonAutomation_PokemonFRLG_AutoStoryVariantWords_H - -#include -#include -#include -#include - -namespace PokemonAutomation{ -namespace NintendoSwitch{ -namespace PokemonFRLG{ - - -// `text`'s words, split on spaces, empty words dropped. -std::vector variant_words(std::string_view text); - -// A word "key=value" as its two halves; nothing without an '='. -struct VariantPair{ - std::string_view key; - std::string_view value; -}; -// Splits a variant word into a key-value pair separated by "=". -std::optional variant_pair(std::string_view word); - -// `text` as a number of up to `max_digits` decimal digits; nothing if it -// isn't one. -std::optional variant_number(std::string_view text, size_t max_digits = 6); - - - -} // namespace PokemonFRLG -} // namespace NintendoSwitch -} // namespace PokemonAutomation -#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVermilionGym_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVermilionGym_Tests.cpp index b59faf6d75..ae79696202 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVermilionGym_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVermilionGym_Tests.cpp @@ -2,7 +2,7 @@ * * From: https://github.com/PokemonAutomation/ * - * Rows 00.23 to 00.25 (PokemonFRLG_AutoStoryTableVermilionGym.cpp) on the + * Rows 00.23 to 00.25 (StoryData/frlg-00.23..25.plan.json) on the * overworld sim: the tree cut on the way in and out, the gym's three * trainers fought where the table says, the trash can search walking * between the cans clear of where the trainers stand after their battles @@ -30,8 +30,8 @@ #include "PokemonFRLG_AutoStoryGrind.h" #include "PokemonFRLG_AutoStoryParty.h" #include "PokemonFRLG_AutoStoryRowSim.h" +#include "PokemonFRLG_AutoStoryRows_Tests.h" #include "PokemonFRLG_AutoStoryTable.h" -#include "PokemonFRLG_AutoStoryTableSteps.h" #include "PokemonFRLG_AutoStoryTrashCans.h" #include "PokemonFRLG_AutoStoryWinChance.h" @@ -79,7 +79,10 @@ class Test_AutoStoryVermilionGym : public UnitTest{ AutoStoryVermilionGymCase m_case; }; -const char* const GYM = StoryTable::VERMILION_GYM; +const std::string GYM = "VermilionCity_Gym"; +const std::string ROUTE6 = "Route6"; +const std::string VERMILION = "VermilionCity"; +const std::string VERMILION_CENTER = "VermilionCity_PokemonCenter_1F"; const StoryCheckpoint& checkpoint(std::string_view id){ const std::vector& rows = story_checkpoints(); @@ -121,7 +124,7 @@ std::vector maps_after_gym(std::vector maps = story_maps()){ for (MapObject& object : map_named(maps, GYM).objects){ object.trainer.reset(); } - for (MapObject& object : map_named(maps, StoryTable::ROUTE6).objects){ + for (MapObject& object : map_named(maps, ROUTE6).objects){ if (object.name == "camper" && object.trainer){ object.trainer.reset(); } @@ -173,7 +176,7 @@ std::string walk_to_stand(OverworldSim& sim, StoryPose& at, int can){ // the GRIND and the talks the sim hasn't got pass. std::string gym_step_on_sim(OverworldSim& sim, StoryPose& at, const StoryStep& step, const std::string& id){ if (step.kind == StoryStepKind::BATTLE && step.name == "lt_surge"){ - at = *story_pose(*step.pose_after); + at = *story_pose(Pokemon::pose_of(*step.pose_after)); return ""; } return row_step_on_sim(sim, at, step, id); @@ -235,7 +238,7 @@ std::string run_gym_steps(OverworldSim& sim, StoryPose& at, size_t first, size_t const StoryCheckpoint& row = checkpoint("00.23"); for (size_t c = first; c < last; c++){ const StoryStep& step = row.steps[c]; - if (step.variant == TRASH_CANS_VARIANT){ + if (step.action == TRASH_CANS_VARIANT){ QuietLogger logger; SimGym gym(sim, at, draws); const TrashCanResult result = run_trash_cans(logger, [&](int can){ return gym.check(can); }); @@ -259,7 +262,7 @@ std::string run_gym_steps(OverworldSim& sim, StoryPose& at, size_t first, size_t UnitTestResult test_gym_row(){ const StoryCheckpoint& row = checkpoint("00.23"); for (const std::vector& draws : {std::vector{{3, 4}}, std::vector{{3, 8}, {13, 14}}}){ - StoryPose at = *story_pose(*row.start); + StoryPose at = *story_pose(Pokemon::pose_of(*row.start)); OverworldSim sim(story_maps(), MapPosition{at.map, at.tile}, *at.facing); if (const std::string failure = run_gym_steps(sim, at, 0, row.steps.size(), draws); !failure.empty()){ return failure + " Beat" + beaten_list(sim) + "."; @@ -268,7 +271,7 @@ UnitTestResult test_gym_row(){ if (sim.state().trainers_beaten != expected || !sim.state().violations.empty()){ return "00.23: expected Dwayne, Baily and Tucker beaten and no violation; beat" + beaten_list(sim) + "."; } - if (!(sim.state().position == MapPosition{StoryTable::VERMILION_CENTER, {7, 4}})){ + if (!(sim.state().position == MapPosition{VERMILION_CENTER, {7, 4}})){ return "00.23: expected to end at Vermilion's nurse, not " + to_string(sim.state().position) + "."; } } @@ -280,7 +283,7 @@ UnitTestResult test_gym_row(){ // every other stand, and the way out to the nurse from every stand. UnitTestResult test_cans_from_everywhere(){ const StoryCheckpoint& row = checkpoint("00.23"); - StoryPose at = *story_pose(*row.start); + StoryPose at = *story_pose(Pokemon::pose_of(*row.start)); OverworldSim sim(story_maps(), MapPosition{at.map, at.tile}, *at.facing); const size_t cans = step_index(row, "trash_cans"); if (const std::string failure = run_gym_steps(sim, at, 0, cans, {}); !failure.empty()){ @@ -306,7 +309,7 @@ UnitTestResult test_cans_from_everywhere(){ if (const std::string failure = run_gym_steps(out, here, cans + 1, row.steps.size(), {}); !failure.empty()){ return std::format("Out from can {}: ", from) + failure; } - if (!(out.state().position == MapPosition{StoryTable::VERMILION_CENTER, {7, 4}}) || !out.state().violations.empty()){ + if (!(out.state().position == MapPosition{VERMILION_CENTER, {7, 4}}) || !out.state().violations.empty()){ return std::format("Out from can {}: expected the nurse and no violation, on {}.", from, to_string(out.state().position)); } } @@ -316,20 +319,20 @@ UnitTestResult test_cans_from_everywhere(){ // The tree shuts the gym's yard: no way from above it to the door. UnitTestResult test_tree_shuts_the_yard(){ const RouteGoal door{{GYM, {5, 19}}, std::nullopt}; - if (plan_overworld_route(story_maps(), MapPosition{StoryTable::VERMILION, {19, 23}}, door, story_route_costs(), Direction::SOUTH)){ + if (plan_overworld_route(story_maps(), MapPosition{VERMILION, {19, 23}}, door, story_route_costs(), Direction::SOUTH)){ return "Planned a way into the gym past the uncut tree (19, 24)."; } - if (!plan_overworld_route(story_maps(), MapPosition{StoryTable::VERMILION, {19, 24}}, door, story_route_costs(), Direction::SOUTH)){ + if (!plan_overworld_route(story_maps(), MapPosition{VERMILION, {19, 24}}, door, story_route_costs(), Direction::SOUTH)){ return "No way from the tree's tile to the gym."; } // The sim: no step onto the tree; cut, it's gone; a warp grows it back. - OverworldSim sim(story_maps(), MapPosition{StoryTable::VERMILION, {19, 23}}, Direction::SOUTH); + OverworldSim sim(story_maps(), MapPosition{VERMILION, {19, 23}}, Direction::SOUTH); sim.tap(Direction::SOUTH); - if (!(sim.state().position == MapPosition{StoryTable::VERMILION, {19, 23}}) || !sim.cut_tree()){ + if (!(sim.state().position == MapPosition{VERMILION, {19, 23}}) || !sim.cut_tree()){ return "Expected the tree to stop the player, then be cut."; } sim.tap(Direction::SOUTH); - if (!(sim.state().position == MapPosition{StoryTable::VERMILION, {19, 24}})){ + if (!(sim.state().position == MapPosition{VERMILION, {19, 24}})){ return "Expected a step onto the cut tree's tile."; } return true; @@ -341,7 +344,7 @@ UnitTestResult test_tree_shuts_the_yard(){ UnitTestResult test_to_surge_and_out(){ for (const char* id : {"00.24", "00.25"}){ const StoryCheckpoint& row = checkpoint(id); - StoryPose at = *story_pose(*row.start); + StoryPose at = *story_pose(Pokemon::pose_of(*row.start)); OverworldSim sim(maps_after_gym(), MapPosition{at.map, at.tile}, *at.facing); for (const StoryStep& step : row.steps){ if (const std::string failure = gym_step_on_sim(sim, at, step, row.id); !failure.empty()){ @@ -351,12 +354,12 @@ UnitTestResult test_to_surge_and_out(){ if (!sim.state().trainers_beaten.empty() || !sim.state().violations.empty()){ return std::string(id) + ": a battle or a violation on the way."; } - const MapPosition end = std::string(id) == "00.24" ? MapPosition{GYM, {5, 3}} : MapPosition{StoryTable::VERMILION_CENTER, {7, 4}}; + const MapPosition end = std::string(id) == "00.24" ? MapPosition{GYM, {5, 3}} : MapPosition{VERMILION_CENTER, {7, 4}}; if (!(sim.state().position == end)){ return std::string(id) + ": ended on " + to_string(sim.state().position) + ", not " + to_string(end) + "."; } } - const StoryPose next = *story_pose(*checkpoint("00.25").start); + const StoryPose next = *story_pose(Pokemon::pose_of(*checkpoint("00.25").start)); if (!(next.tile == TilePos{5, 3}) || next.map != GYM){ return "00.25 doesn't start where 00.24 ends."; } @@ -371,18 +374,18 @@ UnitTestResult test_to_surge_and_out(){ UnitTestResult test_out_past_oaks_aide(){ const StoryCheckpoint& row = checkpoint("00.25"); const std::vector maps = maps_after_surge(); - const MapData& city = *std::find_if(maps.begin(), maps.end(), [](const MapData& map){ return map.name == StoryTable::VERMILION; }); + const MapData& city = *std::find_if(maps.begin(), maps.end(), [](const MapData& map){ return map.name == VERMILION; }); if (object_at(city, {25, 7}) == nullptr){ return "Expected Oak's aide on (25, 7) after Lt. Surge."; } - StoryPose at = *story_pose(*row.start); + StoryPose at = *story_pose(Pokemon::pose_of(*row.start)); OverworldSim sim(maps, MapPosition{at.map, at.tile}, *at.facing); for (const StoryStep& step : row.steps){ if (const std::string failure = gym_step_on_sim(sim, at, step, row.id); !failure.empty()){ return failure; } } - const MapPosition nurse{StoryTable::VERMILION_CENTER, {7, 4}}; + const MapPosition nurse{VERMILION_CENTER, {7, 4}}; if (!sim.state().violations.empty() || !(sim.state().position == nurse)){ return "Expected the nurse reached past Oak's aide; on " + to_string(sim.state().position) + (sim.state().violations.empty() ? "." : ", " + sim.state().violations.back()); } @@ -496,10 +499,10 @@ UnitTestResult test_surge_dig_two_turns(){ UnitTestResult test_surge_winnable_skips_grind(){ const StoryCheckpoint& row = checkpoint("00.24"); const StoryStep& check = row.steps.front(); - if (!parse_grind_check_variant(check.variant)){ + if (check.action != GRIND_CHECK_ACTION || !grind_plan_of(check.args)){ return "Expected 00.24 to start with the grind's check, not " + check.name + "."; } - StoryPose at = *story_pose(*row.start); + StoryPose at = *story_pose(Pokemon::pose_of(*row.start)); OverworldSim sim(maps_after_gym(), MapPosition{at.map, at.tile}, *at.facing); std::vector skipped; for (const StoryStep& step : row.steps){ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVermilion_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVermilion_Tests.cpp index 14ca17705a..835d15a2a0 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVermilion_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVermilion_Tests.cpp @@ -20,6 +20,7 @@ #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h" #include "PokemonFRLG_AutoStoryEvents.h" #include "PokemonFRLG_AutoStoryRowSim.h" +#include "PokemonFRLG_AutoStoryRows_Tests.h" #include "PokemonFRLG_AutoStoryTable.h" namespace PokemonAutomation{ @@ -114,7 +115,7 @@ UnitTestResult test_route6_jeff_only(){ if (row == nullptr){ return "No checkpoint 00.21."; } - StoryPose at = *story_pose(*row->start); + StoryPose at = *story_pose(Pokemon::pose_of(*row->start)); OverworldSim house(story_maps(), MapPosition{at.map, at.tile}, *at.facing); const size_t rocket = step_index(*row, "rocket_trigger"); for (size_t c = 0; c < rocket; c++){ @@ -126,13 +127,13 @@ UnitTestResult test_route6_jeff_only(){ return "00.21: expected to reach (32, 7) west of the Rocket, meeting no one, not " + to_string(house.state().position) + "."; } const size_t battle = step_index(*row, "rocket_grunt"); - const StoryPose after_rocket = *story_pose(*row->steps[battle].pose_after); + const StoryPose after_rocket = *story_pose(Pokemon::pose_of(*row->steps[battle].pose_after)); OverworldSim whole(story_maps(), MapPosition{after_rocket.map, after_rocket.tile}, *after_rocket.facing); if (const std::string failure = run_to_vermilion(whole, after_rocket, *row, battle + 1); !failure.empty()){ return "From the Rocket: " + failure; } const size_t walk = step_index(*row, "route6_column15"); - const StoryPose column = *story_pose(*row->steps[walk].target); + const StoryPose column = *story_pose(Pokemon::pose_of(Pokemon::story_arg(row->steps[walk].args, "target"))); OverworldSim sim(story_maps(), MapPosition{column.map, {column.tile.x + 1, column.tile.y}}, Direction::WEST); if (const std::string failure = run_to_vermilion(sim, column, *row, walk + 1); !failure.empty()){ return "A tile short: " + failure; @@ -157,10 +158,10 @@ bool steps_onto(const std::vector& route, MapPosition start, const st // Where the table says the player stands after `step` from `at`. StoryPose pose_after(const StoryPose& at, const StoryStep& step){ if (step.pose_after){ - return *story_pose(*step.pose_after); + return *story_pose(Pokemon::pose_of(*step.pose_after)); } if (step.kind == StoryStepKind::STEP){ - return StoryPose{at.map, at.tile.next(step.direction), step.direction}; + return StoryPose{at.map, at.tile.next(Pokemon::story_arg(step.args, "direction")), Pokemon::story_arg(step.args, "direction")}; } return at; } @@ -175,7 +176,7 @@ UnitTestResult test_ss_anne_walks(){ if (row == nullptr){ return "No checkpoint 00.22."; } - StoryPose at = *story_pose(*row->start); + StoryPose at = *story_pose(Pokemon::pose_of(*row->start)); bool before_rival = true; for (const StoryStep& step : row->steps){ if (step.kind != StoryStepKind::ROUTE && step.kind != StoryStepKind::LEGS){ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryViridianMart.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryViridianMart.cpp new file mode 100644 index 0000000000..0c02e86a0d --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryViridianMart.cpp @@ -0,0 +1,94 @@ +/* AutoStory Viridian Mart + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include +#include "Pokemon/AutoStory/Pokemon_BuiltinStoryActions.h" +#include "PokemonFRLG_AutoStoryActions.h" +#include "PokemonFRLG_AutoStoryBattle.h" +#include "PokemonFRLG_AutoStoryViridianMart.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +namespace{ + +// Viridian Mart before the Boulder Badge (pokefirered ViridianCity_Mart_Items): +// POKE BALL, POTION (300), ANTIDOTE (100), PARLYZ HEAL (200). Each item +// the story buys: its row, and where the bag's count is kept. +struct MartItem{ + std::string_view item; + int row; + int Supplies::* count; + // The name the item list reader reads (read_item_list_name()). + std::string_view slug; +}; +constexpr MartItem VIRIDIAN_MART_ITEMS[] = { + {.item = "potion", .row = 1, .count = &Supplies::potions, .slug = "potion"}, + {.item = "antidote", .row = 2, .count = &Supplies::antidotes, .slug = "antidote"}, + {.item = "parlyz_heal", .row = 3, .count = &Supplies::parlyz_heals, .slug = "parlyz-heal"}, +}; + +const MartItem* viridian_mart_item(const std::string& name){ + for (const MartItem& item : VIRIDIAN_MART_ITEMS){ + if (name == item.item){ + return &item; + } + } + return nullptr; +} + +} // namespace + + +Pokemon::Outcome viridian_shop(StoryEnv& env, const StoryStep& step){ + const std::optional> orders = viridian_mart_orders(Pokemon::story_arg>(step.args, "items")); + if (!orders){ + return Pokemon::outcome_failed("unknown_item", step.name); + } + // 2000 of the 3000 a new game starts with, plus the rival's prize. + buy_items(env.console, env.context, *orders, env.checks, env.language); + for (const Pokemon::StoryItem& item : Pokemon::story_arg>(step.args, "items")){ + env.supplies.*viridian_mart_item(item.item)->count += (int)item.quantity; + } + if (!checks_screen(env.checks)){ + return Pokemon::outcome_ok(); + } + // The counts from the bag, not from the orders: a wrong row once bought + // Parlyz Heals for Antidotes unnoticed (console B, 2026-11-01). + const std::vector rows = read_items_pocket(env.console, env.context, env.language); + if (rows.empty()){ + env.console.log("Story: couldn't read the Items pocket; keeping the counts ordered.", COLOR_ORANGE); + return Pokemon::outcome_ok(); + } + for (const std::string& item : set_from_bag(env.supplies, rows)){ + env.console.log(std::format( + "Story: couldn't read how many {} the bag holds; counting {}.", + item, item_count(env.supplies, item) + ), COLOR_ORANGE); + } + return Pokemon::outcome_ok(); +} + +std::optional> viridian_mart_orders(const std::vector& items){ + std::vector orders; + for (const Pokemon::StoryItem& wanted : items){ + const MartItem* found = viridian_mart_item(wanted.item); + if (found == nullptr){ + return std::nullopt; + } + orders.push_back(MartOrder{found->row, (int)wanted.quantity, found->slug.data()}); + } + return orders; +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryViridianMart.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryViridianMart.h new file mode 100644 index 0000000000..6582d62ecb --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryViridianMart.h @@ -0,0 +1,36 @@ +/* AutoStory Viridian Mart + * + * From: https://github.com/PokemonAutomation/ + * + * The SHOP step: Viridian Mart before the Boulder Badge, whose rows the + * story knows, and the bag's counts read back after it. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_AutoStoryViridianMart_H +#define PokemonAutomation_PokemonFRLG_AutoStoryViridianMart_H + +#include +#include +#include "PokemonFRLG_AutoStoryActions.h" +#include "PokemonFRLG_AutoStoryEvents.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// `items` as orders at the Viridian Mart before the Boulder Badge: the +// rows of POKE BALL, POTION, ANTIDOTE, PARLYZ HEAL. Nothing if it does +// not sell one of them. +std::optional> viridian_mart_orders(const std::vector& items); + +// A SHOP step: its "items" bought at the Viridian Mart, counted into +// `env.supplies`, and with Thorough checks the counts read from the bag. +Pokemon::Outcome viridian_shop(StoryEnv& env, const StoryStep& step); + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp index 4512a610ac..640c85548a 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp @@ -89,7 +89,8 @@ std::string describe(const StoryPose& pose){ } // A table pose as a StoryPose; FRLG's table has one-tile poses only. -StoryPose one_tile(const Pokemon::Pose& pose){ +StoryPose one_tile(const Pokemon::GridPose& grid_pose){ + const Pokemon::Pose pose = Pokemon::pose_of(grid_pose); const std::optional ret = story_pose(pose); if (!ret){ throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "Not a one-tile pose: " + Pokemon::to_string(pose)); @@ -143,7 +144,7 @@ UnitTestResult check_held_legs(const std::string& name, const std::vector> route = fixed_route(story_maps(), MapPosition{pose.map, pose.tile}, step.legs); + const std::optional> route = fixed_route(story_maps(), MapPosition{pose.map, pose.tile}, Pokemon::story_arg>(step.args, "legs")); if (!route || route->empty()){ return step.name + ": the legs can't be walked from " + describe(pose) + "."; } @@ -168,10 +169,7 @@ UnitTestResult check_route(StoryPose& pose, const StoryStep& step){ return step.name + ": the facing is unknown at " + describe(pose) + " and no wall is beside it."; } } - if (!step.target){ - return step.name + ": no target."; - } - const StoryPose target = one_tile(*step.target); + const StoryPose target = one_tile(Pokemon::story_arg(step.args, "target")); const RouteGoal goal{{target.map, target.tile}, target.facing}; const std::optional> route = plan_overworld_route(story_maps(), start, goal, default_route_costs(), facing); if (!route){ @@ -219,7 +217,8 @@ UnitTestResult check_checkpoint(const StoryCheckpoint& checkpoint, StoryPose& po return checkpoint.id + " " + result.message; } }else if (step.kind == StoryStepKind::STEP){ - pose = StoryPose{pose.map, pose.tile.next(step.direction), step.direction}; + const Direction direction = Pokemon::story_arg(step.args, "direction"); + pose = StoryPose{pose.map, pose.tile.next(direction), direction}; } if (step.pose_after){ pose = one_tile(*step.pose_after); @@ -399,13 +398,14 @@ const MapObject* trainer_seeing(const MapData& map, const TilePos& tile, const s // last. TilePos step_end(const StoryPose& pose, const StoryStep& step, const std::set& beaten){ const MapData* map = find_map_named(pose.map); - if (step.variant != TRAINER_LINE_VARIANT || map == nullptr){ - return pose.tile.next(step.direction); + const Direction direction = Pokemon::story_arg(step.args, "direction"); + if (step.action != TRAINER_LINE_VARIANT || map == nullptr){ + return pose.tile.next(direction); } TilePos tile = pose.tile; step_until_seen( TRAINER_LINE_TILES, - [&]{ tile = tile.next(step.direction); }, + [&]{ tile = tile.next(direction); }, [&]{ return trainer_seeing(*map, tile, beaten, false) != nullptr; } ); return tile; @@ -431,11 +431,11 @@ std::vector legs_walked(const StoryPose& pose, const StoryStep& step) const MapPosition start{pose.map, pose.tile}; std::optional> route; if (step.kind == StoryStepKind::LEGS){ - route = fixed_route(story_maps(), start, step.legs); - }else if (step.target){ + route = fixed_route(story_maps(), start, Pokemon::story_arg>(step.args, "legs")); + }else if (step.args.contains("target")){ const MapData* map = find_map_named(pose.map); const std::optional facing = pose.facing ? pose.facing : map ? wall_beside(*map, pose.tile) : std::nullopt; - const StoryPose target = one_tile(*step.target); + const StoryPose target = one_tile(Pokemon::story_arg(step.args, "target")); route = plan_overworld_route(story_maps(), start, RouteGoal{{target.map, target.tile}, target.facing}, story_route_costs(), facing); } return route ? *route : std::vector{}; @@ -549,7 +549,7 @@ UnitTestResult advance(StoryPose& pose, const StoryStep& step){ return check_legs(pose, step); } if (step.kind == StoryStepKind::STEP){ - pose = StoryPose{pose.map, step_end(pose, step, {}), step.direction}; + pose = StoryPose{pose.map, step_end(pose, step, {}), Pokemon::story_arg(step.args, "direction")}; } if (step.pose_after){ pose = one_tile(*step.pose_after); @@ -566,10 +566,10 @@ UnitTestResult check_lines(const StoryCheckpoint& checkpoint, std::set{}){ - const StoryPose end = to_patch ? one_tile(*step.target) : StoryPose{}; + const StoryPose end = to_patch ? one_tile(Pokemon::story_arg(step.args, "target")) : StoryPose{}; const bool patch = to_patch && tile.map == end.map && tile.point == end.tile; if (const std::string problem = tile_problem(tile, beaten); !problem.empty() && !((patch || grass_held(pose, step)) && problem.starts_with("in the grass"))){ return where + problem; @@ -583,7 +583,7 @@ UnitTestResult check_lines(const StoryCheckpoint& checkpoint, std::setstart); for (const StoryStep& step : checkpoint->steps){ const std::string where = c.checkpoint + "/" + step.name + ": "; - if (step.name == c.step && step.kind == StoryStepKind::STEP && onto == MapPosition{pose.map, pose.tile.next(step.direction)}){ + if (step.name == c.step && step.kind == StoryStepKind::STEP && onto == MapPosition{pose.map, pose.tile.next(Pokemon::story_arg(step.args, "direction"))}){ return true; } if (step.name == c.step){ @@ -913,7 +913,7 @@ UnitTestResult test_magikarp_deposit_skippable(){ continue; } for (const StoryStep& step : checkpoint.steps){ - const std::optional transfer = parse_pc_variant(step.variant); + const std::optional transfer = step.action == PC_ACTION ? pc_transfer_of(step.args) : std::nullopt; if (transfer && transfer->party_slot == 1 && transfer->if_missing == PcMissing::SKIP){ return true; } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/README.md b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/README.md deleted file mode 100644 index 55a5b23722..0000000000 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/README.md +++ /dev/null @@ -1,27 +0,0 @@ -# FRLG authored checkpoint pilot - -`frlg-parcel-00.05.plan.json` is the production definition of checkpoint `00.05`. The story table loads it with `load_authored_checkpoint()`: there is no second C++ Parcel event list. Its `pokesim-authored-checkpoint/1` contract contains the common checkpoint plus FRLG executor configuration (`execution.menu`). It has no export revision, bookkeeping snapshot, or claimed observation. - -The same file is checked into PokemonSimulation at `data/story/parcel-pilot/frlg-parcel-00.05.plan.json`; the paired CI check compares its exact bytes and runs the existing seven replay scenarios there. The schema is `schemas/authored-checkpoint.schema.json`, referencing `story-checkpoint.schema.json`. - -## The two gates - -1. Native tests load the actual table entry through JSON, run the existing engine/fake-game simulator, and compare its events/trace/save pose with the captured pre-migration checkpoint. Existing full-story progression tests also use the JSON-backed table entry. Unsupported fields/menu values and malformed common actions are rejected. -2. PokemonSimulation loads the same authored file with explicit map/action bindings and scripted evidence, then asserts the seven scenarios, including the full successful semantic action sequence and interruption/failure cases. It does not import the native supplies snapshot as requirements. - -`frlg-parcel-00.05.json` is the old table-export fixture used for migration regression checks only. Its provenance and snapshot fields are not part of the authored plan. It can be removed once the native expectations are independent of the capture. - -## Semantics - -- Checkpoint fields are ordered `id`, `title`, `start`, `events`; each event has an expanded block beginning with `id`, `kind`. -- `start` is the assumed checkpoint/save pose, not a localization observation. -- `declared_after` preserves the current scene executor’s author-declared arrival fallback. It is not independent evidence of position or Parcel receipt. Real door/scene verification remains a separate executor change. -- `execution.menu` configures the existing FRLG save implementation. Inventory, party and battle bookkeeping keep their existing native initialization; they are neither asserted preconditions nor observations. -- This first contract makes no new inventory/party requirements. Add explicit requirements only when an action depends on them, with supported verification/assumption semantics on both sides. Relevant prior progress is not proof of a complete execution history. -- The simulator’s map pins, scene evidence and stop/no-save policy live in the binding and cases, not in the authored checkpoint. Python replay is a model check; native fake-game execution checks integration, not live timing/detector correctness. - -No console is required for either gate. - -## Native JSON code - -`Pokemon/AutoStory/Pokemon_AuthoredCheckpointJson.*` owns the common authored envelope, checkpoint codec delegation, and embedded-resource lookup. `../Data/JsonParser.*` validates FRLG execution settings and retains the legacy capture reader. `JsonWriter.*` is retained for migration comparisons and export diagnostics; production authored loading does not depend on it. `Json_Tests.*` keeps the codec tests beside those sources. Once migration expectations are independent of the old capture, remove the legacy reader, writer, and `LegacyJsonFormat.h`; retain the authored parser. diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.01.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.01.plan.json new file mode 100644 index 0000000000..638b71fa29 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.01.plan.json @@ -0,0 +1,30 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.01", + "title": "new game to the bedroom", + "events": [ + { + "id": "intro", + "kind": "new_game", + "declared_after": {"map": "PalletTown_PlayersHouse_2F", "tiles": [[6, 6]], "facing": "north"}, + "why": "Oak's speech, BOY, the player's name (default if none is set), rival GREEN" + }, + { + "id": "options", + "kind": "options", + "why": "fast text; no switch prompt between a trainer's Pokemon" + } + ] + }, + "execution": { + "menu": "before_pokemon", + "handoff": "sid_helper", + "notes": { + "intro": [ + "new_game.c: the bedroom at (6, 6), facing the TV." + ] + } + } +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.01b.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.01b.plan.json new file mode 100644 index 0000000000..fba9b09f08 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.01b.plan.json @@ -0,0 +1,32 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.01b", + "title": "after SID Helper: close the Trainer Card, save in the bedroom", + "start": {"map": "PalletTown_PlayersHouse_2F", "tiles": [[6, 6]], "facing": "north"}, + "events": [ + { + "id": "close_trainer_card", + "kind": "game_action", + "action": "close_trainer_card", + "declared_after": {"map": "PalletTown_PlayersHouse_2F", "tiles": [[6, 6]], "facing": "north"}, + "why": "the Trainer Card SID Helper left open, or HOME" + }, + { + "id": "options", + "kind": "options", + "why": "fast text; no switch prompt between a trainer's Pokemon" + } + ] + }, + "execution": { + "menu": "before_pokemon", + "live_start": true, + "notes": { + "checkpoint": [ + "SID Helper confirms the name, finishes the intro and reads the Trainer Card from the START menu, without moving the player or saving." + ] + } + } +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.02.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.02.plan.json new file mode 100644 index 0000000000..2f09e7db16 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.02.plan.json @@ -0,0 +1,22 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.02", + "title": "bedroom to Pallet Town", + "start": {"map": "PalletTown_PlayersHouse_2F", "tiles": [[6, 6]], "facing": "north"}, + "events": [ + { + "id": "front_door", + "kind": "route", + "args": { + "target": {"map": "PalletTown", "tiles": [[6, 8]]} + }, + "why": "down the stairs and out of the house" + } + ] + }, + "execution": { + "menu": "before_pokemon" + } +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.03.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.03.plan.json new file mode 100644 index 0000000000..b44478b878 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.03.plan.json @@ -0,0 +1,41 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.03", + "title": "Oak stops the player and walks them to the lab", + "start": {"map": "PalletTown", "tiles": [[6, 8]], "facing": "south"}, + "events": [ + { + "id": "below_oaks_trigger", + "kind": "route", + "args": { + "target": {"map": "PalletTown", "tiles": [[12, 2]], "facing": "north"} + }, + "why": "below the north exit, short of Oak's trigger at (12, 1)" + }, + { + "id": "oaks_trigger", + "kind": "step", + "args": { + "direction": "north" + }, + "why": "the trigger: \"Don't go out!\"" + }, + { + "id": "to_the_lab", + "kind": "scene", + "declared_after": {"map": "PalletTown_ProfessorOaksLab", "tiles": [[6, 4]], "facing": "north"}, + "why": "Oak walks the player into the lab; the scene ends at the table" + } + ] + }, + "execution": { + "menu": "before_pokemon", + "notes": { + "to_the_lab": [ + "PlayerEnter walks the player up 8 tiles from the lab's door." + ] + } + } +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.04.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.04.plan.json new file mode 100644 index 0000000000..e56a583371 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.04.plan.json @@ -0,0 +1,28 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.04", + "title": "to Squirtle's ball, south of the table", + "start": {"map": "PalletTown_ProfessorOaksLab", "tiles": [[6, 4]], "facing": "north"}, + "events": [ + { + "id": "below_squirtle", + "kind": "route", + "args": { + "target": {"map": "PalletTown_ProfessorOaksLab", "tiles": [[9, 5]], "facing": "north"} + }, + "why": "under Squirtle's ball (9, 4)" + } + ] + }, + "execution": { + "menu": "before_pokemon", + "handoff": "starter_rng", + "notes": { + "checkpoint": [ + "Starter RNG starts from a save south of the table, facing the ball." + ] + } + } +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.04b.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.04b.plan.json new file mode 100644 index 0000000000..08af2bfd81 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.04b.plan.json @@ -0,0 +1,68 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.04b", + "title": "Squirtle, then the rival's battle", + "start": {"map": "PalletTown_ProfessorOaksLab", "tiles": [[9, 5]], "facing": "north"}, + "events": [ + { + "id": "squirtle_ball", + "kind": "talk", + "why": "\"So, you want the WATER POKEMON SQUIRTLE?\"" + }, + { + "id": "choose_squirtle", + "kind": "answer", + "why": "take Squirtle" + }, + { + "id": "no_nickname", + "kind": "answer", + "args": { + "yes": false + }, + "why": "\"give a nickname?\" NO" + }, + { + "id": "rival_takes_bulbasaur", + "kind": "scene", + "declared_after": {"map": "PalletTown_ProfessorOaksLab", "tiles": [[9, 5]], "facing": "north"}, + "why": "the rival picks his ball; the player still faces the table (console B, 2026-11-01)" + }, + { + "id": "above_rival_trigger", + "kind": "route", + "args": { + "target": {"map": "PalletTown_ProfessorOaksLab", "tiles": [[7, 7]], "facing": "south"} + }, + "why": "short of the rival's trigger row 8" + }, + { + "id": "rival_trigger", + "kind": "step", + "args": { + "direction": "south" + }, + "why": "\"Wait, let's check out our POKEMON!\"" + }, + { + "id": "rival_battle", + "kind": "battle", + "args": { + "may_lose": true + }, + "declared_after": {"map": "PalletTown_ProfessorOaksLab", "tiles": [[7, 8]], "facing": "south"}, + "why": "the tutorial battle; losing goes on too" + } + ] + }, + "execution": { + "menu": "before_pokedex", + "notes": { + "rival_battle": [ + "The rival leaves; PlayerWatchRivalExitAfterBattleRight ends facing down." + ] + } + } +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.05.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.05.plan.json new file mode 100644 index 0000000000..d3923d0565 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.05.plan.json @@ -0,0 +1,41 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.05", + "title": "Route 1 to Viridian Mart: Oak's Parcel", + "start": {"map": "PalletTown_ProfessorOaksLab", "tiles": [[7, 8]], "facing": "south"}, + "events": [ + { + "id": "below_mart_door", + "kind": "route", + "args": { + "target": {"map": "ViridianCity", "tiles": [[36, 20]], "facing": "north"} + }, + "why": "Route 1, running from wild battles" + }, + { + "id": "mart_door", + "kind": "step", + "args": { + "direction": "north" + }, + "why": "the clerk's scene starts on entering" + }, + { + "id": "parcel_from_clerk", + "kind": "scene", + "declared_after": {"map": "ViridianCity_Mart", "tiles": [[4, 3]], "facing": "west"}, + "why": "the clerk gives OAK'S PARCEL" + } + ] + }, + "execution": { + "menu": "before_pokedex", + "notes": { + "parcel_from_clerk": [ + "ApproachCounter: up 4 from the mat, then faces the clerk." + ] + } + } +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.06.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.06.plan.json new file mode 100644 index 0000000000..431917879d --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.06.plan.json @@ -0,0 +1,33 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.06", + "title": "Oak's Parcel to the Pokedex", + "start": {"map": "ViridianCity_Mart", "tiles": [[4, 3]], "facing": "west"}, + "events": [ + { + "id": "below_oak", + "kind": "route", + "args": { + "target": {"map": "PalletTown_ProfessorOaksLab", "tiles": [[6, 4]], "facing": "north"} + }, + "why": "back down Route 1 to Oak" + }, + { + "id": "give_parcel", + "kind": "talk", + "why": "Oak takes the parcel" + }, + { + "id": "pokedex_scene", + "kind": "scene", + "declared_after": {"map": "PalletTown_ProfessorOaksLab", "tiles": [[6, 4]], "facing": "south"}, + "why": "the rival comes in, Pokedexes from the desk; the player ends facing south (console B, 2026-11-01)" + } + ] + }, + "execution": { + "menu": "full" + } +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.07.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.07.plan.json new file mode 100644 index 0000000000..4abe1885aa --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.07.plan.json @@ -0,0 +1,95 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.07", + "title": "Viridian shopping, then into Viridian Forest", + "start": {"map": "PalletTown_ProfessorOaksLab", "tiles": [[6, 4]], "facing": "south"}, + "events": [ + { + "id": "mart_clerk", + "kind": "route", + "args": { + "target": {"map": "ViridianCity_Mart", "tiles": [[4, 3]], "facing": "west"} + }, + "why": "Route 1 again" + }, + { + "id": "potions_and_antidotes", + "kind": "shop", + "args": { + "items": [{"item": "potion", "quantity": 5}, {"item": "antidote", "quantity": 3}, {"item": "parlyz_heal", "quantity": 1}] + }, + "why": "5 Potions, 3 Antidotes, 1 Parlyz Heal" + }, + { + "id": "viridian_nurse", + "kind": "route", + "args": { + "target": {"map": "ViridianCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"} + }, + "why": "heal before the forest" + }, + { + "id": "heal_viridian", + "kind": "heal", + "why": "full HP" + }, + { + "id": "below_old_man_trigger", + "kind": "route", + "args": { + "target": {"map": "ViridianCity", "tiles": [[20, 9]], "facing": "north"} + }, + "why": "short of the tutorial trigger (20, 8)" + }, + { + "id": "old_man_trigger", + "kind": "step", + "args": { + "direction": "north" + }, + "why": "the old man's catching tutorial can't be walked around" + }, + { + "id": "old_man_tutorial", + "kind": "scene", + "declared_after": {"map": "ViridianCity", "tiles": [[20, 8]], "facing": "east"}, + "why": "about 60 lines and his demo battle; TEACHY TV" + }, + { + "id": "past_old_man", + "kind": "route", + "args": { + "target": {"map": "ViridianCity", "tiles": [[20, 5]], "facing": "north"} + }, + "why": "north along column 20, clear of the old man" + }, + { + "id": "forest_entrance", + "kind": "route", + "args": { + "target": {"map": "ViridianForest", "tiles": [[29, 62]], "facing": "north"} + }, + "why": "Route 2 and the south gate, running from wild battles" + } + ] + }, + "execution": { + "menu": "full", + "notes": { + "potions_and_antidotes": [ + "2000 of the 3000 a new game starts with, plus the rival's prize." + ], + "old_man_tutorial": [ + "TutorialTriggerLeft turns the player right, to the old man." + ], + "past_old_man": [ + "After his demo the old man stands east of the player, beside (20, 8), where the map doesn't have him: \"east 2\" from there didn't move, and the walk north ended under Route 2's ledge in column 8 (console B, 2026-11-01). Go north first." + ], + "forest_entrance": [ + "The gate's north warp lands on the forest's exit mat (29, 62), facing north. The save there keeps a forest failure from going back to Pallet." + ] + } + } +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.08.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.08.plan.json new file mode 100644 index 0000000000..c02e6e877f --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.08.plan.json @@ -0,0 +1,82 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.08", + "title": "Viridian Forest to Pewter Center", + "start": {"map": "ViridianForest", "tiles": [[29, 62]], "facing": "north"}, + "events": [ + { + "id": "forest_east", + "kind": "legs", + "args": { + "legs": [{"direction": "east", "tiles": 1}, {"direction": "north", "tiles": 4}, {"direction": "east", "tiles": 14}, {"direction": "north", "tiles": 15}], + "fight_wild": true + }, + "why": "up the east side to (44, 43)" + }, + { + "id": "forest_north", + "kind": "route", + "args": { + "target": {"map": "ViridianForest", "tiles": [[39, 25]]}, + "fight_wild": true + }, + "why": "north part" + }, + { + "id": "forest_exit", + "kind": "legs", + "args": { + "legs": [{"direction": "north", "tiles": 10}, {"direction": "west", "tiles": 12}, {"direction": "south", "tiles": 10}, {"direction": "west", "tiles": 6}, {"direction": "north", "tiles": 20}, {"direction": "south", "tiles": 1}, {"direction": "west", "tiles": 10}, {"direction": "south", "tiles": 27}, {"direction": "west", "tiles": 8}, {"direction": "north", "tiles": 20}, {"direction": "east", "tiles": 1}], + "fight_wild": true + }, + "why": "walls all the way to the gate's column" + }, + { + "id": "forest_gate", + "kind": "route", + "args": { + "target": {"map": "Route2_ViridianForest_NorthEntrance", "tiles": [[7, 10]], "facing": "north"}, + "fight_wild": true + }, + "why": "north onto the exit, arriving on the gate's mat" + }, + { + "id": "pewter_nurse", + "kind": "route", + "args": { + "target": {"map": "PewterCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"} + }, + "why": "Route 2 north to Pewter's Center" + }, + { + "id": "heal_pewter", + "kind": "heal", + "why": "full HP" + } + ] + }, + "execution": { + "menu": "full", + "supplies": { + "potions": 5, + "antidotes": 3, + "parlyz_heals": 1 + }, + "notes": { + "checkpoint": [ + "The supplies bought in 00.07." + ], + "forest_east": [ + "Wild battles are fought for EXP. Straight up the east side from the entrance, each leg ending on a wall (the Boy at (45, 58) stops the east one). Rick (47, 45) sees (42..46, 45), so the last leg meets his battle and is held on to its wall after it. The by-hand run's detour west to (13, 46) and back is dropped." + ], + "forest_exit": [ + "To the gate by legs that end on walls, which the walker holds again after a battle instead of estimating where it stopped: planned routes with open legs lost the player in the north of the forest (console B, 2026-11-01). The two 1-tile legs are single steps." + ], + "pewter_nurse": [ + "Out of the forest, wild battles are run from; trainers are still fought." + ] + } + } +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.09.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.09.plan.json new file mode 100644 index 0000000000..28b36cc3e4 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.09.plan.json @@ -0,0 +1,79 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.09", + "title": "Pewter Gym: Camper Liam, then Brock", + "start": {"map": "PewterCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"}, + "events": [ + { + "id": "below_liam_line", + "kind": "route", + "args": { + "target": {"map": "PewterCity_Gym", "tiles": [[6, 9]], "facing": "north"} + }, + "why": "in by the door, up column 6 to below Liam's row" + }, + { + "id": "liam_line", + "kind": "step", + "args": { + "direction": "north" + }, + "why": "onto (6, 8), in Liam's line" + }, + { + "id": "camper_liam", + "kind": "battle", + "declared_after": {"map": "PewterCity_Gym", "tiles": [[6, 8]], "facing": "north"}, + "why": "Geodude and Sandshrew; EXP before Brock" + }, + { + "id": "ready_for_brock", + "kind": "ready", + "args": { + "target": {"map": "PewterCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"} + }, + "why": "items for a status or low HP; the nurse only if they can't" + }, + { + "id": "before_brock", + "kind": "route", + "args": { + "target": {"map": "PewterCity_Gym", "tiles": [[6, 6]], "facing": "north"} + }, + "why": "below Brock (6, 5); Liam, beaten, stands at (5, 8)" + }, + { + "id": "challenge_brock", + "kind": "talk", + "why": "Brock's speech" + }, + { + "id": "brock", + "kind": "battle", + "declared_after": {"map": "PewterCity_Gym", "tiles": [[6, 6]], "facing": "north"}, + "why": "Geodude and Onix, with Bubble; Boulder Badge and TM39" + } + ] + }, + "execution": { + "menu": "full", + "supplies": { + "potions": 2, + "antidotes": 1, + "parlyz_heals": 0 + }, + "notes": { + "checkpoint": [ + "The by-hand save: 2 Potions and 1 Antidote left after the forest." + ], + "below_liam_line": [ + "Camper Liam (3, 8) always faces east (MOVEMENT_TYPE_FACE_RIGHT, sight 4) and sees (4..7, 8): walking north up column 6 from the door, the step onto (6, 8) starts his battle. He walks up to the player, who stays put and keeps facing north (FRLG doesn't turn the player to a trainer). That step is taken on its own, so no leg is cut." + ], + "ready_for_brock": [ + "On to Brock unless red HP or a status is left that no item cures." + ] + } + } +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.10.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.10.plan.json new file mode 100644 index 0000000000..8687203adb --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.10.plan.json @@ -0,0 +1,60 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.10", + "title": "Pewter: the Running Shoes from Oak's aide", + "start": {"map": "PewterCity_Gym", "tiles": [[6, 6]], "facing": "north"}, + "events": [ + { + "id": "before_aide_trigger", + "kind": "route", + "args": { + "target": {"map": "PewterCity", "tiles": [[45, 21]], "facing": "east"} + }, + "why": "out of the Gym, east along row 21, short of the top trigger" + }, + { + "id": "aide_trigger", + "kind": "step", + "args": { + "direction": "east" + }, + "why": "onto (46, 21), below the aide" + }, + { + "id": "shoes_from_aide", + "kind": "scene", + "declared_after": {"map": "PewterCity", "tiles": [[46, 21]], "facing": "north"}, + "why": "\"Oh, PLAYER!\" ... the Running Shoes; ends facing north" + }, + { + "id": "below_pewter_center", + "kind": "route", + "args": { + "target": {"map": "PewterCity", "tiles": [[17, 26]], "facing": "south"} + }, + "why": "west along row 21 and down to below the Pokemon Center's door (17, 25)" + } + ] + }, + "execution": { + "menu": "full", + "lead": "after_brock", + "notes": { + "checkpoint": [ + "At the rows after Brock: no items counted, the starter with the moves the story gave it by Lv13. A run that loads a save reads the moves off the lead's summary instead (read_lead_moves()), so a save whose moves differ from these (console B, 2026-11-02: Water Gun where Tackle was) is fought with the moves it has." + ], + "before_aide_trigger": [ + "Brock's win sets VAR_MAP_SCENE_PEWTER_CITY to 1 and shows the aide at (46, 20); his triggers are (46, 21..23) (PewterCity map.json). The Gym guide's triggers at (42..43, 21..23) need the scene at 0." + ], + "shoes_from_aide": [ + "RunningShoesAideTriggerTop: the aide talks from (46, 20), no YES/NO; the player only turns up. He walks off and is removed; FLAG_SYS_B_DASH is set (console B, 2026-11-02: about 20 B presses to the overworld)." + ], + "below_pewter_center": [ + "Where the by-hand walk stopped to start 00.11 (console B, 2026-11-02)." + ] + } + }, + "metadata": {"phase": "testing"} +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.11.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.11.plan.json new file mode 100644 index 0000000000..ab4cbf00e3 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.11.plan.json @@ -0,0 +1,128 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.11", + "title": "Pewter Center, then Route 3's trainers", + "start": {"map": "PewterCity", "tiles": [[17, 26]], "facing": "south"}, + "events": [ + { + "id": "pewter_nurse", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "PewterCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"} + }, + "why": "in by the door below the player" + }, + { + "id": "heal_pewter", + "kind": "heal", + "why": "full HP" + }, + { + "id": "west_of_janice_line", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "Route3", "tiles": [[13, 8]]} + }, + "why": "out of Pewter by row 21, east into Route 3, short of Janice's line" + }, + { + "id": "below_colton_line", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "east", "tiles": 1}, {"direction": "north", "tiles": 1}] + }, + "why": "to (14, 7), in the ledges' gap" + }, + { + "id": "colton_line", + "kind": "step", + "args": { + "direction": "north" + }, + "why": "onto (14, 6), in Colton's line" + }, + { + "id": "bug_catcher_colton", + "kind": "battle", + "declared_after": {"map": "Route3", "tiles": [[14, 6]], "facing": "north"}, + "why": "his Bug Pokemon; Colton stops at (13, 6)" + }, + { + "id": "past_ben", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "north", "tiles": 3}, {"direction": "east", "tiles": 4}, {"direction": "south", "tiles": 2}, {"direction": "east", "tiles": 6}] + }, + "why": "up to row 3 above Ben, down at x 18 east of his line, to (24, 5)" + }, + { + "id": "greg_line", + "kind": "step", + "args": { + "direction": "east" + }, + "why": "onto (25, 5), below Greg" + }, + { + "id": "bug_catcher_greg", + "kind": "battle", + "declared_after": {"map": "Route3", "tiles": [[25, 5]], "facing": "east"}, + "why": "his Bug Pokemon; Greg is already next to the player" + }, + { + "id": "above_james_line", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "east", "tiles": 11}] + }, + "why": "along row 5 to the wall at (36, 5)" + }, + { + "id": "james_line", + "kind": "step", + "args": { + "direction": "south" + }, + "why": "onto (36, 6), at the end of James's line" + }, + { + "id": "bug_catcher_james", + "kind": "battle", + "declared_after": {"map": "Route3", "tiles": [[36, 6]], "facing": "south"}, + "why": "his Bug Pokemon; James stops at (35, 6)" + }, + { + "id": "save_spot", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "south", "tiles": 2}] + }, + "why": "down to (36, 8), beside the wall east of it" + } + ] + }, + "execution": { + "menu": "full", + "lead": "after_brock", + "notes": { + "checkpoint": [ + "Route 3's trainers (Route3 map.json): the way east meets three of them. Bug Catcher Colton (12, 6) faces east, sight 3: the only way north past the row 7 ledges is the gap at x 14..15, below his line. Youngster Ben (17, 4) faces south, sight 2, so the way east keeps to row 3 past him. Bug Catcher Greg (25, 4) faces south, sight 2, over the way east along row 5. Bug Catcher James (32, 6) faces east, sight 4, over the way down at x 35..36. The others are kept out of: Lass Janice (19, 9) sees west along row 9 to x 14, Lass Sally (30, 3) west along row 3 to x 25, and Youngster Calvin (29, 10) west along row 10. Each line is stepped into on its own, so no leg is cut; the trainer walks up to the player, who stays put facing the way they stepped." + ], + "west_of_janice_line": [ + "Up from row 9 west of Janice's line, which ends at x 14." + ], + "save_spot": [ + "Saved here, the trainers behind, so a failure on the way to Route 4 doesn't fight them again." + ] + } + }, + "metadata": {"phase": "testing"} +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.12.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.12.plan.json new file mode 100644 index 0000000000..de54d42cfa --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.12.plan.json @@ -0,0 +1,48 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.12", + "title": "Route 3 and 4 to the Magikarp salesman", + "start": {"map": "Route3", "tiles": [[36, 8]], "facing": "south"}, + "events": [ + { + "id": "route4_nurse", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "Route4_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"} + }, + "why": "east over Route 3, off the grass, north into Route 4 and its Pokemon Center" + }, + { + "id": "heal_route4", + "kind": "heal", + "why": "full HP" + }, + { + "id": "before_salesman", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "Route4_PokemonCenter_1F", "tiles": [[2, 3]], "facing": "west"} + }, + "why": "beside the Magikarp salesman, facing him" + } + ] + }, + "execution": { + "menu": "full", + "lead": "after_brock", + "handoff": "gift_rng", + "notes": { + "checkpoint": [ + "Route 3's north exit (x 68..75) joins Route 4 (offset 60) at x 8..15, up which column 12 leads to the Pokemon Center's door (12, 5). Lass Robin (40, 11) wanders up and down at x 40, looking north and south, sight 3. Rock above (y <= 8) and grass below (y >= 12) leave every way east across her column at y 9..11, so whether she sees the player depends on her facing. The walk watches for her after the leg along row 9, which crosses her sight on (40, 9) only; if she saw the player, her message goes to story_interrupts(), which fight her, and the route goes on from (40, 9) (run_route(); console B, 2026-11-02, she stopped the player there and spoke after the leg's short watch)." + ], + "before_salesman": [ + "Gift RNG starts from a save facing the salesman (1, 3)." + ] + } + }, + "metadata": {"phase": "testing"} +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.12b.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.12b.plan.json new file mode 100644 index 0000000000..f3150745d3 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.12b.plan.json @@ -0,0 +1,29 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.12b", + "title": "after Gift RNG: save with the Magikarp", + "start": {"map": "Route4_PokemonCenter_1F", "tiles": [[2, 3]], "facing": "west"}, + "events": [ + { + "id": "leave_gift_summary", + "kind": "game_action", + "action": "leave_gift_summary", + "declared_after": {"map": "Route4_PokemonCenter_1F", "tiles": [[2, 3]], "facing": "west"}, + "why": "the Magikarp's summary Gift RNG left open, or HOME" + } + ] + }, + "execution": { + "menu": "full", + "lead": "after_brock", + "live_start": true, + "notes": { + "checkpoint": [ + "Gift RNG buys the Magikarp (500 of the money 00.12 brings) without moving the player and leaves its summary open, or HOME. This saves the shiny where 00.12 ended. A run started here with Gift RNG's handoff on loads the save beside the salesman and runs Gift RNG first." + ] + } + }, + "metadata": {"phase": "testing"} +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.12c.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.12c.plan.json new file mode 100644 index 0000000000..e6e3c76ae2 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.12c.plan.json @@ -0,0 +1,42 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.12c", + "title": "Route 4 Center: the Magikarp into BOX 1", + "start": {"map": "Route4_PokemonCenter_1F", "tiles": [[2, 3]], "facing": "west"}, + "events": [ + { + "id": "pc_front", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "Route4_PokemonCenter_1F", "tiles": [[11, 2]], "facing": "north"} + }, + "why": "below the PC (11, 1), facing it" + }, + { + "id": "magikarp_to_box", + "kind": "game_action", + "action": "pc", + "args": { + "do": "deposit", + "slot": 2, + "box": 1, + "if_present": true + }, + "why": "DEPOSIT the party's second slot into BOX 1, if it has one" + } + ] + }, + "execution": { + "menu": "full", + "lead": "after_brock", + "notes": { + "checkpoint": [ + "The Magikarp goes to BOX 1 at the Center's PC (11, 1), so Mt. Moon is fought with the starter alone (console B, 2026-11-02: done by hand and saved at (11, 2), facing the PC, where this row ends). The wandering boy (4..6, 3..5) is walked around. The Magikarp comes from Gift RNG: with Gift RNG off the party is the starter alone, and the deposit is skipped." + ] + } + }, + "metadata": {"phase": "testing"} +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.13.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.13.plan.json new file mode 100644 index 0000000000..6736d01d43 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.13.plan.json @@ -0,0 +1,187 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.13", + "title": "Mt. Moon: a Moon Stone, a Rocket, Miguel and the Helix Fossil", + "start": {"map": "Route4_PokemonCenter_1F", "tiles": [[11, 2]], "facing": "north"}, + "events": [ + { + "id": "route4_nurse", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "Route4_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"} + }, + "why": "the nurse, below the counter" + }, + { + "id": "heal_route4", + "kind": "heal", + "why": "full HP" + }, + { + "id": "mt_moon_entrance", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "MtMoon_1F", "tiles": [[18, 37]], "facing": "north"} + }, + "why": "out of the Center, west into Mt. Moon" + }, + { + "id": "mt_moon_1f", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "north", "tiles": 12}, {"direction": "east", "tiles": 8}, {"direction": "north", "tiles": 12}, {"direction": "east", "tiles": 3}, {"direction": "south", "tiles": 1}, {"direction": "east", "tiles": 9}, {"direction": "north", "tiles": 1}, {"direction": "east", "tiles": 2}, {"direction": "north", "tiles": 4}, {"direction": "west", "tiles": 24}, {"direction": "east", "tiles": 2}, {"direction": "south", "tiles": 12}, {"direction": "west", "tiles": 7}, {"direction": "north", "tiles": 18}, {"direction": "west", "tiles": 9}, {"direction": "east", "tiles": 1}] + }, + "why": "up the middle, east of Miriam, west along row 9, down column 18 past Josh, up column 11 past Marcos, to (3, 3)" + }, + { + "id": "below_moon_stone", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "MtMoon_1F", "tiles": [[3, 3]], "facing": "north"} + }, + "why": "facing the Moon Stone (3, 2)" + }, + { + "id": "moon_stone_ball", + "kind": "talk", + "why": "A on the item ball" + }, + { + "id": "found_moon_stone", + "kind": "scene", + "declared_after": {"map": "MtMoon_1F", "tiles": [[3, 3]], "facing": "north"}, + "why": "\" found a MOON STONE!\", then the pocket line; the ball is gone" + }, + { + "id": "b2f_ladder_foot", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "MtMoon_B2F", "tiles": [[26, 21]], "facing": "east"} + }, + "why": "1F's ladder (5, 6), down B1F's west side to its ladder (22, 18), onto B2F" + }, + { + "id": "b2f_south", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "north", "tiles": 4}, {"direction": "east", "tiles": 8}, {"direction": "west", "tiles": 2}, {"direction": "south", "tiles": 5}, {"direction": "east", "tiles": 8}, {"direction": "north", "tiles": 3}, {"direction": "west", "tiles": 1}, {"direction": "north", "tiles": 5}, {"direction": "east", "tiles": 7}, {"direction": "south", "tiles": 14}, {"direction": "west", "tiles": 9}, {"direction": "south", "tiles": 10}, {"direction": "west", "tiles": 29}, {"direction": "east", "tiles": 3}, {"direction": "north", "tiles": 17}] + }, + "why": "through the Grunt's room at (37, 21), round the south edge, up column 11 to (11, 21)" + }, + { + "id": "grunt_line", + "kind": "step", + "args": { + "direction": "east" + }, + "why": "onto (12, 21), below the Grunt at (12, 20)" + }, + { + "id": "rocket_grunt", + "kind": "battle", + "declared_after": {"map": "MtMoon_B2F", "tiles": [[12, 21]], "facing": "east"}, + "why": "Rattata and Zubat, Lv13" + }, + { + "id": "ready_for_miguel", + "kind": "ready", + "args": { + "target": {"map": "Route4_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"} + }, + "why": "items for a status or low HP; the nurse, back through the cave, only if they can't" + }, + { + "id": "below_miguel_trigger", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "east", "tiles": 1}, {"direction": "north", "tiles": 9}, {"direction": "east", "tiles": 1}] + }, + "why": "to (14, 12), below Miguel's trigger (14, 11)" + }, + { + "id": "miguel_trigger", + "kind": "step", + "args": { + "direction": "north" + }, + "why": "onto (14, 11), beside Miguel" + }, + { + "id": "super_nerd_miguel", + "kind": "battle", + "declared_after": {"map": "MtMoon_B2F", "tiles": [[14, 11]], "facing": "north"}, + "why": "Grimer, Voltorb and Koffing, Lv12; \"We'll each take one!\"" + }, + { + "id": "below_helix_fossil", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "north", "tiles": 3}] + }, + "why": "up column 14 to the HELIX FOSSIL (14, 7)" + }, + { + "id": "helix_fossil", + "kind": "game_action", + "action": "fossil", + "args": { + "fossil": "helix" + }, + "why": "the HELIX FOSSIL; Miguel takes the DOME FOSSIL" + }, + { + "id": "helix_gap", + "kind": "step", + "args": { + "direction": "north" + }, + "why": "onto (14, 7), where the HELIX FOSSIL lay" + }, + { + "id": "route4_east", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "Route4", "tiles": [[32, 6]], "facing": "south"} + }, + "why": "west to B2F's ladder (5, 10), up to B1F, east to its exit onto Route 4" + } + ] + }, + "execution": { + "menu": "full", + "lead": "after_brock", + "notes": { + "checkpoint": [ + "Mt. Moon (pokefirered data/maps/MtMoon_1F, _B1F, _B2F). Every floor tile of the cave has wild encounters, which are run from, so its legs end on walls, ladders or someone standing still, which the walker holds again after a battle; the few open ones are short. The way through: up 1F's middle and west side, its north-west ladder, B1F's west ladder down to B2F's south-east, round B2F's south edge to its west, north past Miguel and the fossils, and the ladder up to B1F's east end, which leads out to Route 4 east of the mountain.", + "1F's trainers are walked around: Youngster Josh (13, 17) sees east along row 17 to x 17, so the way west into the west room is down column 18 and up column 11; Lass Miriam walks round (32..33, 4..5), sight 2, so the way east keeps to row 9 and columns 38 and 40; Hiker Marcos wanders (5..9, 8..12) and sees one tile, so the way north is column 11 and row 3.", + "The Moon Stone ball (3, 2) on 1F (FLAG_HIDE_MT_MOON_1F_MOON_STONE) is a few tiles off the way to the ladder (5, 6).", + "The Grunt at (37, 21) on B2F looks around (sight 3) over the only way east round B2F. His room is crossed on legs to walls, at one tile of his sight each, (37, 22) and (40, 21); if he looks the player's way, he walks up beside the leg, story_interrupts() fights him, and the leg is held on to its wall.", + "The Grunt at (12, 20) faces south (sight 2) over (12, 21..22), across rows 21..22, the only way north to Miguel: stepped into from the west, he is next to the player and doesn't walk.", + "Super Nerd Miguel (13, 11) battles on the step onto (14, 11) (MtMoon_B2F_EventScript_MiguelTrigger, VAR_MAP_SCENE_MT_MOON_B2F 0), then \"We'll each take one!\"", + "The fossils: DOME (13, 7), HELIX (14, 7). After the HELIX, Miguel walks up to (13, 8) and takes the DOME, which opens the gap north.", + "The save is on Route 4: the save card's places don't include Mt. Moon." + ], + "found_moon_stone": [ + "No reader for the text yet: the scene's end is the overworld." + ], + "below_miguel_trigger": [ + "Up column 13 to Miguel, who stops the leg on (13, 12), then east to the wall: the tile below his trigger." + ], + "helix_gap": [ + "The maps keep the fossils, which the game removes after the choice: the step onto the HELIX's tile is taken on its own." + ] + } + }, + "metadata": {"phase": "testing"} +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.14.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.14.plan.json new file mode 100644 index 0000000000..db055712e4 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.14.plan.json @@ -0,0 +1,111 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.14", + "title": "Route 4: Mega Kick from its tutor, then east to Cerulean's Pokemon Center", + "start": {"map": "Route4", "tiles": [[32, 6]], "facing": "south"}, + "events": [ + { + "id": "mega_kick_tutor", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "Route4", "tiles": [[50, 4]], "facing": "north"} + }, + "why": "east and up through (48, 5) into the tutors' pen, below the Mega Kick tutor (50, 3)" + }, + { + "id": "teach_mega_kick", + "kind": "game_action", + "action": "teach", + "args": { + "item": "tutor", + "move": "mega-kick", + "slot": 1, + "forget": "withdraw" + }, + "why": "the tutor's Mega Kick in place of Withdraw, unless the lead knows it" + }, + { + "id": "above_ledge", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "Route4", "tiles": [[93, 8]], "facing": "south"} + }, + "why": "east along Route 4's upper road to above the ledge row 9" + }, + { + "id": "ledge_hop", + "kind": "step", + "args": { + "direction": "south" + }, + "declared_after": {"map": "Route4", "tiles": [[93, 10]], "facing": "south"}, + "why": "down the ledge (93, 9) to the lower road" + }, + { + "id": "cerulean_entry", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "CeruleanCity", "tiles": [[9, 20]], "facing": "east"} + }, + "why": "east into Cerulean City, to (9, 20) below column 9" + }, + { + "id": "above_city_ledge", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "north", "tiles": 8}, {"direction": "west", "tiles": 1}, {"direction": "east", "tiles": 22}, {"direction": "south", "tiles": 5}, {"direction": "west", "tiles": 5}] + }, + "why": "to walls: (9, 12), (8, 12), (30, 12), (30, 17), (25, 17)" + }, + { + "id": "city_ledge_hop", + "kind": "step", + "args": { + "direction": "south" + }, + "declared_after": {"map": "CeruleanCity", "tiles": [[25, 19]], "facing": "south"}, + "why": "down the ledge (25, 18)" + }, + { + "id": "cerulean_nurse", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "CeruleanCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"} + }, + "why": "west along row 20 to the Pokemon Center's door (22, 19)" + }, + { + "id": "heal_cerulean", + "kind": "heal", + "why": "full HP" + } + ] + }, + "execution": { + "menu": "full", + "lead": "after_brock", + "notes": { + "checkpoint": [ + "Route 4 east of Mt. Moon (Route4 map.json) joins Cerulean City at its east end (x 107; Route 4's row 3 is the city's row 13). Its upper road (rows 2..8) reaches the city only by water: the way on by land is down the ledge row 9 at x 90..96 to the lower road (rows 10..12), which joins the city's rows 20..22. Lass Crissy (75, 3) faces east, sight 4, over row 3 from x 76 to 79; the way east keeps out of her line and off the grass south of the road (75..87, 11..17).", + "A ledge is taken as one step the way it faces, from the tile before it: the player hops it and lands two tiles on. Planned routes never hop a ledge (they hold into walls, and a held ledge hops), so where the only way on is down a ledge the row takes it as this one step." + ], + "mega_kick_tutor": [ + "The Mega Kick tutor (Black Belt (50, 3), facing west, Route4_EventScript_MegaKickTutor) stands in a pen (46..51, 2..4) north of the road, beside the Mega Punch tutor (47, 3); the pen opens south only on (48, 5) and (49, 5), the rest of row 5 ledges out of it. From Mt. Moon's exit the walk goes east and up into the pen to (50, 4), below the tutor, and Mega Kick takes Withdraw's slot. Cerulean can't be walked back to Route 4's upper road without Surf, so it is now or much later." + ], + "cerulean_entry": [ + "The open leg east across the city's edge ended a tile short on the console (2026-11-03: on (6, 20), not (7, 20)), and no hold to a wall in the city's west end finds the player from there: the next hold south met the fence on (6, 23) and the walk went on a column off. So the entry ends on (9, 20), and only legs to walls follow." + ], + "above_city_ledge": [ + "North up column 9 (or 8, a tile short) to row 12, west to (8, 12), east to (30, 12) beside the policeman (31, 12), south to (30, 17), west to (25, 17). The way keeps out of the boy's (16, 18..24) and the balding man's (8..10, 22..24) wander boxes." + ] + } + }, + "metadata": {"phase": "testing"} +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.14b.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.14b.plan.json new file mode 100644 index 0000000000..40e06f9bf6 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.14b.plan.json @@ -0,0 +1,108 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.14b", + "title": "Cerulean: Potions, a GRIND to Lv23, then into the Gym, saved below Misty's platform", + "start": {"map": "CeruleanCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"}, + "events": [ + { + "id": "mart_clerk", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "CeruleanCity_Mart", "tiles": [[4, 3]], "facing": "west"} + }, + "why": "out of the Center to the Mart's clerk" + }, + { + "id": "buy_potions", + "kind": "game_action", + "action": "mart", + "args": { + "map": "CeruleanCity_Mart", + "budget": 3000, + "items": [{"item": "potion", "quantity": 5}, {"item": "super-potion", "quantity": 3}], + "floor": 3000 + }, + "why": "5 Potions for the GRIND's wild battles, then Super Potions as the money allows" + }, + { + "id": "grind_patch", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "Route4", "tiles": [[86, 16]], "facing": "west"} + }, + "why": "west out of the city along Route 4's lower road onto its grass's east edge" + }, + { + "id": "grind_to_lv23", + "kind": "game_action", + "action": "grind", + "args": { + "slot": 1, + "level": 23, + "encounters": 100, + "pace": "west", + "heal_every": 0, + "nurse": {"map": "CeruleanCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"} + }, + "why": "wild battles until the lead is Lv23, where Bite takes Starmie in three" + }, + { + "id": "cerulean_nurse", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "CeruleanCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"} + }, + "why": "back to the Center: Misty's battle starts at full HP and PP" + }, + { + "id": "heal_cerulean", + "kind": "heal", + "why": "full HP" + }, + { + "id": "gym_below_luis", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "CeruleanCity_Gym", "tiles": [[9, 13]]} + }, + "why": "into the Gym, up column 9 to row 13, short of Luis's (9, 12)" + }, + { + "id": "gym_west_walkway", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "west", "tiles": 5}] + }, + "why": "west to the wall (4, 13)" + }, + { + "id": "below_misty_platform", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "north", "tiles": 3}, {"direction": "east", "tiles": 8}, {"direction": "north", "tiles": 3}, {"direction": "west", "tiles": 3}] + }, + "why": "walls (4, 10), (12, 10), (12, 7), then to (9, 7), out of Diana's line" + } + ] + }, + "execution": { + "menu": "full", + "lead": "after_brock", + "notes": { + "checkpoint": [ + "Cerulean Gym (pokefirered CeruleanCity_Gym map.json and scripts.inc): a pool with walkways. Misty (8, 6) stands on a platform (7..9, 6) above row 7. Picnicker Diana (4, 7) faces east, sight 4, over (5..8, 7), so misty_front (8, 7) is in her line; Swimmer Luis (10, 12) in the water faces west, sight 1, over (9, 12), on column 9 north of the door. No gym trainer has to be fought for Misty, so neither is: from the door up column 9 to row 13 (a route there, so the planner's walk to a wall doesn't run on past it through (9, 12)), west to (4, 13), and to walls round the pool's west and north sides, (4, 10), (12, 10), (12, 7), then west to (9, 7), the tile below the platform's east end, out of Diana's line. 00.14c steps up onto (9, 6) and talks to Misty from beside her.", + "Misty beat a Lv20 Wartortle (console B, run m51), so first a GRIND to Lv23 on 00.15's patch. Gen 3 numbers (pokefirered: her mons have IV 0; Wartortle taken at IV 15, no EVs): Starmie Lv21 has 56 HP, Atk 36, SpA 47, SpD 40. Bite is Dark, special in Gen 3, no STAB, x2 on Psychic: at Lv23 (SpA 39) it does 23..28, three hits (two on top rolls); at Lv20, 20..24. Her Swift (physical, 60) does 9..11 to a Lv23 Wartortle (about 67 HP, Def 45) and Water Pulse (STAB, resisted) 8..10: 6 or more hits, though m51 saw about 20 a turn. Her Recover (28) and Super Potion undo a Bite, so the margin is in Bite's damage.", + "The Mart comes before the GRIND: its wild battles are fought only with 2 or more Potions, and 00.14's save has none (m51 met Misty with only the 5 this row bought). 5 Potions (row 3, 300 each), then up to 3 Super Potions (row 2, 700), last so they take the Items pocket's last row; the battle doesn't use them yet. The money box can't be read, so the floor stands for it, and a floor above the money fails the step (the quantity box wraps). Prizes (pokefirered: 4 x last level x the class's factor) from a new game's 3000, less Viridian's 2000 and the Magikarp's 500: Liam 220, Brock 1400, Route 3's bug catchers 360, the Mt. Moon grunt 416 and Miguel 288 (the first rival's 80 only if won), at least 3184 here. Floor and budget 3000: 5 Potions and 2 Super Potions, 2900. Misty's 2100 (4 x 21 x 25) then leaves 00.15 its floor of 1500. Then the nurse, and the save before Misty, so her battle is its own checkpoint, 00.14c, verified and retried from it. 00.15's GRIND then fights until the sim beats the Cerulean rival often enough." + ] + } + }, + "metadata": {"phase": "testing"} +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.14c.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.14c.plan.json new file mode 100644 index 0000000000..ba41100ff0 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.14c.plan.json @@ -0,0 +1,76 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.14c", + "title": "Cerulean Gym: Misty, then Water Pulse", + "start": {"map": "CeruleanCity_Gym", "tiles": [[9, 7]], "facing": "west"}, + "events": [ + { + "id": "beside_misty", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "CeruleanCity_Gym", "tiles": [[9, 6]], "facing": "west"} + }, + "why": "up onto (9, 6), facing Misty (8, 6)" + }, + { + "id": "challenge_misty", + "kind": "talk", + "why": "Misty's speech" + }, + { + "id": "misty", + "kind": "battle", + "declared_after": {"map": "CeruleanCity_Gym", "tiles": [[9, 6]], "facing": "west"}, + "why": "Staryu and Starmie, with Bite; CASCADE BADGE and TM03" + }, + { + "id": "gym_way_out", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "south", "tiles": 1}, {"direction": "east", "tiles": 3}, {"direction": "south", "tiles": 3}, {"direction": "west", "tiles": 8}, {"direction": "south", "tiles": 3}, {"direction": "east", "tiles": 5}] + }, + "why": "walls (12, 7), (12, 10), (4, 10), (4, 13), (9, 13), round Luis's (9, 12)" + }, + { + "id": "cerulean_nurse", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "CeruleanCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"} + }, + "why": "down column 9 out of the Gym, to the Center" + }, + { + "id": "heal_cerulean", + "kind": "heal", + "why": "full HP" + }, + { + "id": "teach_water_pulse", + "kind": "game_action", + "action": "teach", + "args": { + "item": "tm03", + "move": "water-pulse", + "slot": 1, + "forget": "tail-whip" + }, + "why": "TM03 Water Pulse in place of Tail Whip" + } + ] + }, + "execution": { + "menu": "full", + "lead": "after_brock", + "notes": { + "checkpoint": [ + "Misty (TRAINER_LEADER_MISTY: Staryu Lv18, Starmie Lv21), talked to from (9, 6), beside her on the platform. Her win text runs on to the CASCADE BADGE, TM03 (Water Pulse) and its explanation, all read with the battle's. Bite is chosen against her party (Starmie is Water/Psychic). Back to the nurse round the pool's west side, out of Luis's line; then Water Pulse in place of Tail Whip, last, at the Center, from the bag's TM CASE. Ends where 00.15 starts." + ] + } + }, + "metadata": {"phase": "testing"} +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.15.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.15.plan.json new file mode 100644 index 0000000000..a0d816d3af --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.15.plan.json @@ -0,0 +1,102 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.15", + "title": "Cerulean: Water Pulse, Potions, a GRIND until the rival is winnable, then saved below his trigger", + "start": {"map": "CeruleanCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"}, + "events": [ + { + "id": "teach_water_pulse", + "kind": "game_action", + "action": "teach", + "args": { + "item": "tm03", + "move": "water-pulse", + "slot": 1, + "forget": "tail-whip" + }, + "why": "TM03 Water Pulse in place of Tail Whip, unless the lead knows it or there is no TM03" + }, + { + "id": "mart_clerk", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "CeruleanCity_Mart", "tiles": [[4, 3]], "facing": "west"} + }, + "why": "out of the Center to the Mart's clerk" + }, + { + "id": "buy_potions", + "kind": "game_action", + "action": "mart", + "args": { + "map": "CeruleanCity_Mart", + "budget": 1500, + "items": [{"item": "potion", "quantity": 3}, {"item": "awakening", "quantity": 2}], + "floor": 1500 + }, + "why": "3 Potions: the GRIND fights wild battles only with 2 or more; 2 Awakenings for the rival's Sleep Powder" + }, + { + "id": "grind_patch", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "Route4", "tiles": [[86, 16]], "facing": "west"} + }, + "why": "west out of the city along Route 4's lower road onto its grass's east edge" + }, + { + "id": "grind_for_rival", + "kind": "game_action", + "action": "grind", + "args": { + "slot": 1, + "level": 28, + "encounters": 150, + "pace": "west", + "heal_every": 0, + "nurse": {"map": "CeruleanCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"}, + "beat": "TRAINER_RIVAL_CERULEAN_BULBASAUR", + "chance": 50 + }, + "why": "wild battles until the sim beats the rival 50% or more, Lv28 at most; the nurse when hurt or low on PP" + }, + { + "id": "cerulean_nurse", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "CeruleanCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"} + }, + "why": "back to the Center: the rival's battle starts at full HP and PP" + }, + { + "id": "heal_cerulean", + "kind": "heal", + "why": "full HP" + }, + { + "id": "below_rival_trigger", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "CeruleanCity", "tiles": [[23, 7]], "facing": "north"} + }, + "why": "out of the Center, north up to (23, 7), short of the trigger row 6" + } + ] + }, + "execution": { + "menu": "full", + "lead": "after_brock", + "notes": { + "checkpoint": [ + "Before the rival north of Cerulean (00.15b), from the Center: first TM03 Water Pulse over Tail Whip, if the lead doesn't know it yet, so the GRIND's sim plays it (a run without TM03 from Misty skips the step). Then 3 Potions at the Mart (CeruleanCity_Mart_Items: POTION is row 3, 300 each; Mt. Moon's trainers leave well over the floor) and 2 Awakenings (row 6, 250 each; pokefirered items.json) for the rival's Bulbasaur's Sleep Powder (console B, m56: asleep at 34/65 HP, it fainted two turns later with 15 Potions), 1400 of the floor's 1500. Then a GRIND on Route 4's grass east of Mt. Moon (75..86, 11..17; Spearow, Rattata, Ekans and Mankey around Lv10, about 80 EXP each), healing at the Center, until the battle sim beats the rival 00.15b fights 50% or more: the win chance his battle refuses below. Console B's Wartortle (Lv22, 65 HP, Water Pulse) is about 42% there and 62% at Lv23; Lv28 (about 88%, some 120 battles from Lv22) is the cap. Then the nurse, and the save on (23, 7), the tile below his trigger: his battle is its own checkpoint, 00.15b, verified and retried from this save." + ] + } + }, + "metadata": {"phase": "testing"} +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.15b.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.15b.plan.json new file mode 100644 index 0000000000..a2168fb5b3 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.15b.plan.json @@ -0,0 +1,47 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.15b", + "title": "Cerulean: Water Pulse if not known, then the rival north of the city", + "start": {"map": "CeruleanCity", "tiles": [[23, 7]], "facing": "north"}, + "events": [ + { + "id": "teach_water_pulse", + "kind": "game_action", + "action": "teach", + "args": { + "item": "tm03", + "move": "water-pulse", + "slot": 1, + "forget": "tail-whip" + }, + "why": "TM03 Water Pulse in place of Tail Whip, unless the lead knows it" + }, + { + "id": "rival_trigger", + "kind": "step", + "args": { + "direction": "north" + }, + "why": "onto (23, 6), the middle trigger: \"Yo! !\"" + }, + { + "id": "rival_cerulean", + "kind": "battle", + "declared_after": {"map": "CeruleanCity", "tiles": [[23, 6]], "facing": "south"}, + "why": "Pidgeotto, Abra, Rattata and Bulbasaur; then the FAME CHECKER" + } + ] + }, + "execution": { + "menu": "full", + "lead": "after_brock", + "notes": { + "checkpoint": [ + "The rival north of Cerulean (CeruleanCity scripts.inc): the only way north to Nugget Bridge is columns 22..24, and a step onto row 6 there (CeruleanCity_EventScript_RivalTrigger*, VAR_MAP_SCENE_CERULEAN_CITY_RIVAL 0) brings him down to the player. From the middle, (23, 6), he stops at (23, 5); after the battle he walks round the player and off south, and the player, turning to watch him, ends facing south. His FAME CHECKER's text is read to the overworld with the battle's. For a player who took Squirtle he has Pidgeotto Lv17, Abra Lv16, Rattata Lv15 and Bulbasaur Lv18 (sParty_RivalCeruleanBulbasaur), whose Vine Whip and Sleep Powder are the danger. The row starts from 00.15's save below the trigger, and saves after him. First TM03 Water Pulse over Tail Whip (from the bag, where the player stands), if the lead doesn't know it yet: console B's save (2026-11-03) is past Misty's TEACH, which failed there. Where she taught it, the step reads the moves and does nothing." + ] + } + }, + "metadata": {"phase": "testing"} +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.16.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.16.plan.json new file mode 100644 index 0000000000..5143144bd4 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.16.plan.json @@ -0,0 +1,189 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.16", + "title": "Nugget Bridge: the nurse, five trainers and the Rocket", + "start": {"map": "CeruleanCity", "tiles": [[23, 6]], "facing": "south"}, + "events": [ + { + "id": "cerulean_nurse", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "CeruleanCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"} + }, + "why": "back to the Center after the rival, before Nugget Bridge" + }, + { + "id": "heal_cerulean", + "kind": "heal", + "why": "full HP" + }, + { + "id": "below_cale_line", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "Route24", "tiles": [[11, 32]], "facing": "north"} + }, + "why": "out of the Center, north past the rival's row onto the bridge, below Cale's row" + }, + { + "id": "cale_line", + "kind": "step", + "action": "trainer_line", + "args": { + "direction": "north" + }, + "why": "onto (11, 31), beside Cale" + }, + { + "id": "bug_catcher_cale", + "kind": "battle", + "declared_after": {"map": "Route24", "tiles": [[11, 31]], "facing": "north"}, + "why": "his Bug Pokemon" + }, + { + "id": "below_ali_line", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "north", "tiles": 2}] + }, + "why": "up to (11, 29)" + }, + { + "id": "ali_line", + "kind": "step", + "action": "trainer_line", + "args": { + "direction": "north" + }, + "why": "onto (11, 28), beside Ali" + }, + { + "id": "lass_ali", + "kind": "battle", + "declared_after": {"map": "Route24", "tiles": [[11, 28]], "facing": "north"}, + "why": "her Pokemon" + }, + { + "id": "below_timmy_line", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "north", "tiles": 2}] + }, + "why": "up to (11, 26)" + }, + { + "id": "timmy_line", + "kind": "step", + "action": "trainer_line", + "args": { + "direction": "north" + }, + "why": "onto (11, 25), beside Timmy" + }, + { + "id": "youngster_timmy", + "kind": "battle", + "declared_after": {"map": "Route24", "tiles": [[11, 25]], "facing": "north"}, + "why": "his Pokemon" + }, + { + "id": "below_reli_line", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "north", "tiles": 2}] + }, + "why": "up to (11, 23)" + }, + { + "id": "reli_line", + "kind": "step", + "action": "trainer_line", + "args": { + "direction": "north" + }, + "why": "onto (11, 22), beside Reli" + }, + { + "id": "lass_reli", + "kind": "battle", + "declared_after": {"map": "Route24", "tiles": [[11, 22]], "facing": "north"}, + "why": "her Pokemon" + }, + { + "id": "below_ethan_line", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "north", "tiles": 2}] + }, + "why": "up to (11, 20)" + }, + { + "id": "ethan_line", + "kind": "step", + "action": "trainer_line", + "args": { + "direction": "north" + }, + "why": "onto (11, 19), beside Ethan" + }, + { + "id": "camper_ethan", + "kind": "battle", + "declared_after": {"map": "Route24", "tiles": [[11, 19]], "facing": "north"}, + "why": "his Pokemon" + }, + { + "id": "ready_for_rocket", + "kind": "ready", + "args": { + "target": {"map": "CeruleanCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"} + }, + "why": "items for a status or low HP; the nurse only if they can't" + }, + { + "id": "below_rocket_trigger", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "Route24", "tiles": [[11, 16]], "facing": "north"} + }, + "why": "up the bridge to below the Rocket's trigger (11, 15)" + }, + { + "id": "rocket_trigger", + "kind": "step", + "args": { + "direction": "north" + }, + "why": "onto (11, 15), beside the Rocket" + }, + { + "id": "rocket_grunt", + "kind": "battle", + "declared_after": {"map": "Route24", "tiles": [[11, 15]], "facing": "east"}, + "why": "the NUGGET, then Ekans and Zubat, Lv15" + } + ] + }, + "execution": { + "menu": "full", + "lead": "after_brock", + "notes": { + "checkpoint": [ + "Nugget Bridge (Route24 map.json) is x 10..12 from row 32 north to row 16, the city's columns 22..24 (offset 12). Its five trainers stand on it facing across, sight 2, so each line crosses the middle column 11 on the trainer's row: Bug Catcher Cale (12, 31), Lass Ali (10, 28), Youngster Timmy (12, 25), Lass Reli (10, 22) and Camper Ethan (12, 19). Each is fought on the step onto their row, beside them: they don't walk, and the player keeps facing north. Two tiles separate the rows, walked as one short leg; the step onto a row goes on a tile at a time until the trainer sees the player (\"trainer_line\"), as the open leg onto the bridge ended a tile short twice on console B (2026-11-03), on (11, 33), and one step left the player out of Cale's sight. Then the Rocket (12, 15): the step onto (11, 15) (Route24_EventScript_RocketTriggerRight, VAR_MAP_SCENE_ROUTE24 0) gives the NUGGET, \"join Team Rocket\", and his battle; he only turns, and the player turns east to him. Camper Shane (5, 21) looks north from the west bank, off the way." + ], + "ready_for_rocket": [ + "A route, not legs: the nurse may have been needed." + ] + } + }, + "metadata": {"phase": "testing"} +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.17.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.17.plan.json new file mode 100644 index 0000000000..b662ddcfe3 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.17.plan.json @@ -0,0 +1,143 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.17", + "title": "Route 24 and 25 to Bill's Sea Cottage: Franklin, Kelsey, Nob and Haley", + "start": {"map": "Route24", "tiles": [[11, 15]], "facing": "east"}, + "events": [ + { + "id": "below_franklin_line", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "Route25", "tiles": [[15, 5]], "facing": "north"} + }, + "why": "north off Nugget Bridge, east into Route 25, round its ledges to (15, 5), below the end of Franklin's line" + }, + { + "id": "franklin_line", + "kind": "step", + "action": "trainer_line", + "args": { + "direction": "north" + }, + "why": "onto (15, 4), at the end of Franklin's line" + }, + { + "id": "hiker_franklin", + "kind": "battle", + "declared_after": {"map": "Route25", "tiles": [[15, 4]], "facing": "north"}, + "why": "Machop and Geodude, Lv15; Franklin stops at (14, 4)" + }, + { + "id": "west_of_dan", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "east", "tiles": 2}, {"direction": "south", "tiles": 2}, {"direction": "east", "tiles": 2}, {"direction": "north", "tiles": 2}] + }, + "why": "to (17, 4), short of Joey's (18, 4); round Wayne (17, 7) to (19, 6); up to (19, 4)" + }, + { + "id": "round_dan", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "east", "tiles": 1}, {"direction": "north", "tiles": 2}, {"direction": "east", "tiles": 4}, {"direction": "west", "tiles": 1}, {"direction": "south", "tiles": 3}, {"direction": "east", "tiles": 1}, {"direction": "south", "tiles": 2}] + }, + "why": "onto (20, 4); up to (20, 2), east to (24, 2), down column 23 past Dan to (23, 5), to (24, 7) above Kelsey's line" + }, + { + "id": "kelsey_line", + "kind": "step", + "action": "trainer_line", + "args": { + "direction": "south" + }, + "why": "onto (24, 8), at the end of Kelsey's line" + }, + { + "id": "picnicker_kelsey", + "kind": "battle", + "declared_after": {"map": "Route25", "tiles": [[24, 8]], "facing": "south"}, + "why": "Nidoran M and Nidoran F, Lv15; Kelsey stops at (23, 8)" + }, + { + "id": "west_of_nob_line", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "east", "tiles": 2}] + }, + "why": "along row 8 to (26, 8)" + }, + { + "id": "nob_line", + "kind": "step", + "action": "trainer_line", + "args": { + "direction": "east" + }, + "why": "onto (27, 8), above Nob" + }, + { + "id": "hiker_nob", + "kind": "battle", + "declared_after": {"map": "Route25", "tiles": [[27, 8]], "facing": "east"}, + "why": "three Geodude and a Machop, Lv13" + }, + { + "id": "below_haley_line", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "east", "tiles": 1}, {"direction": "south", "tiles": 1}, {"direction": "east", "tiles": 1}, {"direction": "north", "tiles": 3}, {"direction": "east", "tiles": 5}, {"direction": "south", "tiles": 3}, {"direction": "east", "tiles": 8}] + }, + "why": "below Flint's column to (29, 9), up to (29, 6), east to (34, 6), down to (34, 9), east along row 9 past Chad's column to the water, (42, 9)" + }, + { + "id": "haley_line", + "kind": "step", + "action": "trainer_line", + "args": { + "direction": "north" + }, + "why": "onto (42, 8), at the end of Haley's line" + }, + { + "id": "lass_haley", + "kind": "battle", + "declared_after": {"map": "Route25", "tiles": [[42, 8]], "facing": "north"}, + "why": "Oddish, Pidgey and Oddish, Lv13; Haley stops at (42, 7)" + }, + { + "id": "sea_cottage", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "Route25_SeaCottage", "tiles": [[7, 8]], "facing": "north"} + }, + "why": "east along row 8, up column 51 into the Sea Cottage (51, 4), a step in from its mat" + } + ] + }, + "execution": { + "menu": "full", + "lead": "after_brock", + "notes": { + "checkpoint": [ + "Route 24 north of Nugget Bridge (Route24 map.json) joins Route 25 by its rows 7..9; the ledges on Route 25's row 6 (x 0..9) leave the way north at x 12..13. Route 25 (Route25 map.json, scripts.inc) to Bill's Sea Cottage door (51, 4): of its nine trainers, four can't be walked around.", + "Hiker Franklin (11, 4) faces east, sight 4, over (12..15, 4), and Hiker Wayne (17, 7) east over (18..19, 7): the only ways east past x 15. Franklin is fought, from (15, 5) on the step onto (15, 4), the end of his line: he walks up to (14, 4).", + "Youngster Joey (18, 2) faces south over (18, 3..4): the way keeps off column 18, south round Wayne to (19, 6) and up to (19, 4).", + "Youngster Dan (22, 4) looks around, sight 2, over the only way east, (20..21, 4). On (20, 4), a one-tile leg, he may see the player and walk up to (21, 4); so the way goes north from there to row 2, east, and down column 23 past him to (23, 5), off every tile he may walk up to. Where his sight is crossed, the leg ends on a wall or is one tile; if he looks the player's way, story_interrupts() fight him.", + "Picnicker Kelsey (22, 8) faces east over (23..24, 8), across the only way on: fought on the step onto (24, 8); she walks up to (23, 8).", + "Hiker Nob (27, 9) faces north over (27, 6..8), Camper Flint (28, 4) south over (28, 5..7): every way east crosses one. Nob is fought on the step onto (27, 8), beside him; the way on keeps off Flint's column, by one-tile legs and legs to walls.", + "Youngster Chad (36, 4) walks up and down column 36 (rows 2..7), so he may see any tile of it down to row 9. The way crosses his column on row 9, a leg to the water at (42, 9), where he can only walk up beside it.", + "Lass Haley (42, 5) faces south over (42, 6..8), the only way east of x 42: fought on the step onto (42, 8); she walks up to (42, 7).", + "The row saves inside the Sea Cottage, which the save card names ROUTE 25." + ] + } + }, + "metadata": {"phase": "testing"} +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.18.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.18.plan.json new file mode 100644 index 0000000000..ce6a0dcb99 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.18.plan.json @@ -0,0 +1,104 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.18", + "title": "Bill's Sea Cottage: the Cell Separator and the S.S. Ticket", + "start": {"map": "Route25_SeaCottage", "tiles": [[7, 8]], "facing": "north"}, + "events": [ + { + "id": "below_bill_clefairy", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "Route25_SeaCottage", "tiles": [[10, 7]], "facing": "north"} + }, + "why": "below the Clefairy (10, 6), facing it" + }, + { + "id": "bill_clefairy", + "kind": "talk", + "why": "\"Hiya! I'm a POKEMON... ...No I'm not!\" ... \"Help me out!\"" + }, + { + "id": "help_bill", + "kind": "answer", + "why": "YES: \"run the Cell Separation on the PC\"" + }, + { + "id": "bill_into_teleporter", + "kind": "scene", + "declared_after": {"map": "Route25_SeaCottage", "tiles": [[10, 7]], "facing": "north"}, + "why": "the Clefairy walks up into the right teleporter" + }, + { + "id": "pc_front", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "Route25_SeaCottage", "tiles": [[4, 6]], "facing": "north"} + }, + "why": "below the PC (4, 5), facing it" + }, + { + "id": "cell_separator", + "kind": "talk", + "why": "the PC: \" initiated the TELEPORTER's CELL SEPARATOR!\"" + }, + { + "id": "bill_comes_out", + "kind": "scene", + "declared_after": {"map": "Route25_SeaCottage", "tiles": [[4, 6]], "facing": "north"}, + "why": "the teleporters run; Bill comes out of the left one and walks to (7, 6)" + }, + { + "id": "beside_bill", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "east", "tiles": 2}] + }, + "why": "to (6, 6), west of Bill, facing him" + }, + { + "id": "thank_bill", + "kind": "talk", + "why": "\"Thanks, bud! ... take this\"" + }, + { + "id": "ss_ticket", + "kind": "scene", + "declared_after": {"map": "Route25_SeaCottage", "tiles": [[6, 6]], "facing": "east"}, + "why": "the S.S. TICKET; \"... the S.S. ANNE ... go instead\"" + }, + { + "id": "around_bill", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "south", "tiles": 2}, {"direction": "east", "tiles": 1}] + }, + "why": "to (7, 8), above the mat; Bill stands on (7, 6) after his scene" + }, + { + "id": "out_of_cottage", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "Route25", "tiles": [[51, 5]], "facing": "south"} + }, + "why": "down to the mat and out; the door puts the player below it" + } + ] + }, + "execution": { + "menu": "full", + "lead": "after_brock", + "notes": { + "checkpoint": [ + "Bill's Sea Cottage (Route25_SeaCottage scripts.inc). Bill is the Clefairy at (10, 6) (FLAG_HELPED_BILL_IN_SEA_COTTAGE unset): talked to from (10, 7), below him, he asks \"Help me out!\" (YES/NO; NO goes on the same), says to run the Cell Separation on the PC, and walks up into the right teleporter (10, 3); with the player facing north he walks straight up. The PC (4, 5) answers only from the south, (4, 6). Its scene: the teleporters run, Bill comes out of the left one (3, 3) and walks to (7, 6) (BillWalkToMiddleOfRoom); the player isn't moved. Talked to from (6, 6), Bill gives the S.S. TICKET, no YES/NO, and goes on about the S.S. ANNE (FLAG_GOT_SS_TICKET, which also hides Nugget Bridge's Rocket). Out by the mat (7, 9); the door puts the player on (51, 5), facing south. The maps keep Bill at (7, 5), but after his scene he stands on (7, 6), in the way from (6, 6) to the mat (console B, 2026-11-03), so the walk out goes around him to (7, 8) first." + ] + } + }, + "metadata": {"phase": "testing"} +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.19.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.19.plan.json new file mode 100644 index 0000000000..aec59c3685 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.19.plan.json @@ -0,0 +1,53 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.19", + "title": "Route 25's south path back to Cerulean's Pokemon Center", + "start": {"map": "Route25", "tiles": [[51, 5]], "facing": "south"}, + "events": [ + { + "id": "above_cerulean_ledge", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "CeruleanCity", "tiles": [[27, 0]], "facing": "south"} + }, + "why": "Route 25's south path west, Route 24 east of the bridge south, to above Cerulean's ledge (27, 1)" + }, + { + "id": "cerulean_ledge_hop", + "kind": "step", + "args": { + "direction": "south" + }, + "declared_after": {"map": "CeruleanCity", "tiles": [[27, 2]], "facing": "south"}, + "why": "down the ledge (27, 1)" + }, + { + "id": "cerulean_nurse", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "CeruleanCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"} + }, + "why": "into the city to the Pokemon Center" + }, + { + "id": "heal_cerulean", + "kind": "heal", + "why": "full HP" + } + ] + }, + "execution": { + "menu": "full", + "lead": "after_brock", + "notes": { + "checkpoint": [ + "Back to Cerulean by Route 25's south path (Route25 map.json): from below the cottage down column 51 to row 12, west along row 12 and row 11 into Route 24 (x 14..23, row 11), and down its column 14..16 east of Nugget Bridge to Cerulean's north edge (x 26..28, offset 12). No trainer stands on it. Cerulean's row 1 there is a ledge (26..28, 1), hopped south from (27, 0); then on into the city to the Pokemon Center." + ] + } + }, + "metadata": {"phase": "testing"} +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.20.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.20.plan.json new file mode 100644 index 0000000000..6dba500518 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.20.plan.json @@ -0,0 +1,82 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.20", + "title": "Route 24's grass: an Oddish for Cut, then the Center", + "start": {"map": "CeruleanCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"}, + "events": [ + { + "id": "mart_clerk", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "CeruleanCity_Mart", "tiles": [[4, 3]], "facing": "west"} + }, + "why": "out of the Center to the Mart's clerk" + }, + { + "id": "buy_poke_balls", + "kind": "game_action", + "action": "mart", + "args": { + "map": "CeruleanCity_Mart", + "budget": 1400, + "items": [{"item": "poke-ball", "quantity": 7}], + "floor": 1500 + }, + "why": "7 Poke Balls for the Oddish" + }, + { + "id": "oddish_patch", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "Route24", "tiles": [[3, 19]]} + }, + "why": "north over Nugget Bridge, west to the cliff and down column 3 onto the grass's first row, out of Shane's column 5" + }, + { + "id": "catch_oddish", + "kind": "game_action", + "action": "capture", + "args": { + "species": "oddish", + "catches": 1, + "encounters": 30, + "balls": 7, + "pace": "east", + "turns": 2 + }, + "why": "wild battles until an Oddish, then Poke Balls; any other species is run from" + }, + { + "id": "cerulean_nurse", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "CeruleanCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"} + }, + "why": "back over the bridge to the Center" + }, + { + "id": "heal_cerulean", + "kind": "heal", + "why": "full HP" + } + ] + }, + "execution": { + "menu": "full", + "lead": "after_brock", + "notes": { + "checkpoint": [ + "Stopgap for console B's save, which caught nothing on Route 1. A new playthrough should instead catch a Rattata on Route 1 or 22 early, as its Cut user and spare member, and drop this row (and its walk over Nugget Bridge and back).", + "An Oddish for HM01 Cut, and a second member behind the lead (docs/design/AutoStory-FRLG-FutureEvents.md, \"Console B run choices\"). Route 24's grass (Route24 map.json: x 3..5, rows 19..31, west of Nugget Bridge) is the nearest to the Center with Oddish: FireRed's sRoute24_FireRed (pokefirered wild_encounters.json) has it in 25% of battles, Lv12..14, as Route 25's grass; Routes 5 and 6 aren't on the story's maps yet. Up the bridge, whose trainers 00.16 beat, west along rows 10..15 to the cliff (3, 15) and down column 3 to the grass's first row, (3, 19); the step paces east to (4, 19) and back. Camper Shane (5, 21) faces north, sight 5, over (5, 16..20): column 5 is kept off. The leg west ends on the cliff, not open: on console B (m63) an open leg west to (4, 15) ended a tile short, and the walk down column 5 came into Shane's sight.", + "First 7 Poke Balls at the Mart (row 1, 200 each; the bag isn't read, so the step buys them whatever the bag holds). The floor, from 00.15's 1500 less its 1400: the rival's 288 (4 x 18 x 4), the Rocket's 480 (4 x 15 x 8), Franklin's 540 and Nob's 468 (hikers, 9) alone make 1876 (pokefirered gTrainerMoneyTable). An Oddish at full HP (catch rate 255) stays in a Poke Ball about 1 time in 3 (Gen 3: a = 85, four shakes of 0.76), so 7 balls catch it about 94% of the time; the step throws 7 at most, in 30 battles (none an Oddish: 0.02%). Nothing weakens it: the HP bar isn't read on the console yet.", + "The Oddish joins the party second. Battles keep the lead in (PokemonFRLG_AutoStoryBattleDecisions.h): the Oddish is sent only when the lead faints in a trainer's battle, which counts as lost. Back to the nurse, and the save in the Center." + ] + } + }, + "metadata": {"phase": "testing"} +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.21.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.21.plan.json new file mode 100644 index 0000000000..838632aa41 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.21.plan.json @@ -0,0 +1,95 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.21", + "title": "The Cerulean Rocket, Route 5, the Underground Path and Route 6 to Vermilion's Pokemon Center: Jeff", + "start": {"map": "CeruleanCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"}, + "events": [ + { + "id": "west_of_rocket", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "CeruleanCity", "tiles": [[32, 7]], "facing": "east"} + }, + "why": "through the burgled house and out of the hole in its back wall, west of the Rocket (33, 6)" + }, + { + "id": "rocket_trigger", + "kind": "step", + "args": { + "direction": "east" + }, + "why": "onto (33, 7), below the Rocket" + }, + { + "id": "rocket_grunt", + "kind": "battle", + "declared_after": {"map": "CeruleanCity", "tiles": [[33, 7]], "facing": "north"}, + "why": "Machop and Drowzee, Lv17; TM28 Dig" + }, + { + "id": "route6_column15", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "Route6", "tiles": [[15, 14]]} + }, + "why": "round the yard and down Cerulean's east side, Route 5 into the Underground Path, through it onto Route 6, west to column 15" + }, + { + "id": "round_keigo_and_elijah", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "south", "tiles": 19}, {"direction": "north", "tiles": 1}, {"direction": "north", "tiles": 1}, {"direction": "west", "tiles": 8}, {"direction": "south", "tiles": 2}, {"direction": "east", "tiles": 2}] + }, + "why": "down column 15 to the wall (15, 33); up to (15, 31), west to the wall (7, 31), down to the wall (7, 33), east to (9, 33)" + }, + { + "id": "jeff_line", + "kind": "step", + "action": "trainer_line", + "args": { + "direction": "east" + }, + "why": "onto (10, 33), in Jeff's line" + }, + { + "id": "camper_jeff", + "kind": "battle", + "declared_after": {"map": "Route6", "tiles": [[10, 33]], "facing": "east"}, + "why": "Spearow and Raticate, Lv16; Jeff stops at (11, 33)" + }, + { + "id": "vermilion_nurse", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "VermilionCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"} + }, + "why": "down Route 6's south path into Vermilion City, to the Pokemon Center" + }, + { + "id": "heal_vermilion", + "kind": "heal", + "why": "full HP" + } + ] + }, + "execution": { + "menu": "full", + "lead": "after_brock", + "notes": { + "checkpoint": [ + "Cerulean's only way south without Cut (CeruleanCity map.json, scripts.inc) is through the burgled house (30, 11), whose door the policeman leaves once the S.S. TICKET is had, out of the hole in its back wall into the yard (31, 8). The Rocket there (33, 6) stops the player on (33, 5) or (33, 7) (CeruleanCity_EventScript_GruntTrigger*): from (32, 7), the step east onto (33, 7) turns the player to him; Machop and Drowzee, Lv17, then TM28 Dig, and he is gone. Then east round the yard, down to the city's south edge by the path along its east side (39..40, 20..31), down Route 5's east side to the Underground Path's north house (31, 31), through its tunnel and out of the south house onto Route 6, below its door (19, 14).", + "Route 6: Bug Catcher Keigo (3, 16) faces east, sight 5, over the middle path (4..8, 16); Bug Catcher Elijah (20, 25) faces west, sight 3, over the east path (17..19, 25). The way goes down column 15, through the grass to the wall (15, 33), out of both lines; the open leg west to it, a tile short, leaves the player on column 16, out of them too.", + "Camper Ricky and Picnicker Nancy (12..13, 21) battle only when talked to.", + "Picnicker Isabelle (13, 32) and Camper Jeff (13, 33) face west, sight 3, over (10..12, 32) and (10..12, 33); the only way south, (10..12, 34), is from Jeff's row. Up to (15, 31), west to the wall (7, 31), down to the wall (7, 33), east: Jeff is fought on the step onto (10, 33) and walks up to (11, 33). Isabelle's row is kept off.", + "Then down into Vermilion City (offset 12) to its Pokemon Center." + ] + } + }, + "metadata": {"phase": "testing"} +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.22.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.22.plan.json new file mode 100644 index 0000000000..b2506e5c1c --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.22.plan.json @@ -0,0 +1,160 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.22", + "title": "The S.S. Anne: the rival, HM01 Cut from the Captain, back to Vermilion's Pokemon Center", + "start": {"map": "VermilionCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"}, + "events": [ + { + "id": "above_ticket_check", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "VermilionCity", "tiles": [[23, 32]], "facing": "south"} + }, + "why": "out of the Center down to the harbor, above the ticket check (23, 33)" + }, + { + "id": "ticket_check", + "kind": "step", + "args": { + "direction": "south" + }, + "why": "onto (23, 33): \"Do you have a ticket?\"" + }, + { + "id": "show_ss_ticket", + "kind": "scene", + "declared_after": {"map": "VermilionCity", "tiles": [[23, 33]], "facing": "east"}, + "why": "the S.S. TICKET; the player turns to the sailor" + }, + { + "id": "aboard", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "SSAnne_1F_Corridor", "tiles": [[19, 2]], "facing": "south"} + }, + "why": "onto the pier, along the gangway and in by 1F's door, a step below it" + }, + { + "id": "past_the_cabins", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "south", "tiles": 8}, {"direction": "north", "tiles": 1}, {"direction": "west", "tiles": 6}, {"direction": "north", "tiles": 1}] + }, + "why": "to the wall (19, 10), up a step, west to the worker (12, 9), up a step to (13, 8): off the cabins' mats on row 10" + }, + { + "id": "below_rival_trigger", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "SSAnne_2F_Corridor", "tiles": [[30, 7]], "facing": "north"} + }, + "why": "west along 1F, up the stairs (3, 8) and along 2F below the Captain's door" + }, + { + "id": "rival_trigger", + "kind": "step", + "args": { + "direction": "north" + }, + "why": "onto (30, 6): the rival comes out of the Captain's door" + }, + { + "id": "rival_ss_anne", + "kind": "battle", + "declared_after": {"map": "SSAnne_2F_Corridor", "tiles": [[30, 6]], "facing": "north"}, + "why": "Pidgeotto, Raticate, Kadabra and Ivysaur" + }, + { + "id": "behind_captain", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "SSAnne_CaptainsOffice", "tiles": [[5, 5]], "facing": "north"} + }, + "why": "into the Captain's office, behind the Captain (5, 4)" + }, + { + "id": "captain", + "kind": "talk", + "why": "\"Ooargh... I feel hideous... Urrp! Seasick...\"" + }, + { + "id": "hm01_cut", + "kind": "scene", + "declared_after": {"map": "SSAnne_CaptainsOffice", "tiles": [[5, 5]], "facing": "north"}, + "why": "the player rubs his back; HM01, and what Cut does" + }, + { + "id": "off_2f", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "SSAnne_1F_Corridor", "tiles": [[13, 8]]} + }, + "why": "back along 2F, down the stairs and east along 1F's row 8" + }, + { + "id": "round_the_sailor", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "east", "tiles": 4}, {"direction": "south", "tiles": 1}, {"direction": "east", "tiles": 2}] + }, + "why": "to the sailor (18, 8), down a step, east to (19, 9): off the cabins' mats on row 10" + }, + { + "id": "below_ship_door", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "SSAnne_1F_Corridor", "tiles": [[19, 2]], "facing": "north"} + }, + "why": "up below the door to the gangway" + }, + { + "id": "off_the_ship", + "kind": "step", + "args": { + "direction": "north" + }, + "why": "out onto the gangway" + }, + { + "id": "ss_anne_sails", + "kind": "scene", + "declared_after": {"map": "VermilionCity", "tiles": [[23, 32]], "facing": "north"}, + "why": "the ship sails; the player is walked off the pier to (23, 32)" + }, + { + "id": "vermilion_nurse", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "VermilionCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"} + }, + "why": "back to the Pokemon Center" + }, + { + "id": "heal_vermilion", + "kind": "heal", + "why": "full HP" + } + ] + }, + "execution": { + "menu": "full", + "lead": "after_brock", + "notes": { + "checkpoint": [ + "The S.S. Anne (VermilionCity, SSAnne_* scripts.inc). The step onto (23, 33) (VermilionCity_EventScript_CheckTicket) has the sailor (24, 33) ask for a ticket; the S.S. TICKET (00.18) is shown and the player turns east to him. Then onto the pier (23, 34), along the gangway, through 1F, by legs off its cabins' doormats on row 10, which planned routes cross, and up its stairs (3, 8) to 2F. The step onto (30, 6), below the Captain's door (30, 2) (SSAnne_2F_Corridor_EventScript_RivalTriggerLeft), brings the rival out and down to (30, 5); the player keeps facing north, and after the battle he walks round the player and off. For a player who took Squirtle: Pidgeotto Lv19, Raticate Lv16, Kadabra Lv18, Ivysaur Lv20. The ship's trainers are in its cabins and on its deck, off the way. The Captain (5, 4) faces up; talked to from (5, 5) he is rubbed on the back and gives HM01 (VAR_MAP_SCENE_VERMILION_CITY 1). Back out through 1F's door (19, 1): on the gangway the ship sails (SSAnne_Exterior_ExitSSAnne), the player is put on (23, 34) and walked up to (23, 32) (VermilionCity_EventScript_ExitSSAnne). Cut is taught later, to the Oddish." + ] + } + }, + "metadata": {"phase": "testing"} +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.23.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.23.plan.json new file mode 100644 index 0000000000..bdb361e0b0 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.23.plan.json @@ -0,0 +1,187 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.23", + "title": "Vermilion Gym: Cut and Dig, the tree, Dwayne, Baily and Tucker, the trash cans", + "start": {"map": "VermilionCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"}, + "events": [ + { + "id": "teach_cut", + "kind": "game_action", + "action": "teach", + "args": { + "item": "hm01", + "move": "cut", + "slot": 2 + }, + "why": "HM01 Cut to the Oddish, second in the party, unless it knows it" + }, + { + "id": "teach_dig", + "kind": "game_action", + "action": "teach", + "args": { + "item": "tm28", + "move": "dig", + "slot": 1, + "forget": "withdraw" + }, + "why": "TM28 Dig in place of Withdraw, for Lt. Surge, unless the lead knows it or there is no TM28" + }, + { + "id": "above_gym_tree", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "VermilionCity", "tiles": [[19, 23]], "facing": "south"} + }, + "why": "out of the Center, south through the city to above the tree (19, 24)" + }, + { + "id": "cut_gym_tree", + "kind": "game_action", + "action": "cut_tree", + "args": { + "direction": "south" + }, + "declared_after": {"map": "VermilionCity", "tiles": [[19, 24]], "facing": "south"}, + "why": "the Oddish cuts the tree; a step onto its tile" + }, + { + "id": "gym_door", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "VermilionCity_Gym", "tiles": [[5, 19]], "facing": "north"} + }, + "why": "down into the yard and in by the gym's door (14, 25)" + }, + { + "id": "west_of_dwayne_line", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "north", "tiles": 4}, {"direction": "east", "tiles": 2}] + }, + "why": "up column 5 to the can (5, 14), east to (7, 15): out of Dwayne's and Baily's sight" + }, + { + "id": "dwayne_sight", + "kind": "step", + "action": "trainer_wait", + "args": { + "direction": "east" + }, + "why": "onto (8, 15), two below Dwayne (8, 13): he turns to the player and walks up to (8, 14)" + }, + { + "id": "sailor_dwayne", + "kind": "battle", + "declared_after": {"map": "VermilionCity_Gym", "tiles": [[8, 15]], "facing": "north"}, + "why": "two Pikachu, Lv21" + }, + { + "id": "east_of_baily_line", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "west", "tiles": 4}, {"direction": "north", "tiles": 2}, {"direction": "west", "tiles": 1}] + }, + "why": "west along row 15 to (4, 15), up to (4, 13), west to (3, 13): out of Baily's sight" + }, + { + "id": "baily_sight", + "kind": "step", + "action": "trainer_wait", + "args": { + "direction": "west" + }, + "why": "onto (2, 13), two below Baily (2, 11): he turns to the player and walks up to (2, 12)" + }, + { + "id": "engineer_baily", + "kind": "battle", + "declared_after": {"map": "VermilionCity_Gym", "tiles": [[2, 13]], "facing": "north"}, + "why": "Voltorb and Magnemite, Lv21" + }, + { + "id": "below_tucker_line", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "east", "tiles": 2}, {"direction": "north", "tiles": 4}, {"direction": "east", "tiles": 1}] + }, + "why": "east to (4, 13), up column 4 past Baily's row to (4, 9), east to (5, 9): below Tucker's line, not on it" + }, + { + "id": "tucker_line", + "kind": "step", + "action": "trainer_line", + "args": { + "direction": "north" + }, + "why": "onto (5, 8), in Tucker's line: he walks up to (6, 8)" + }, + { + "id": "gentleman_tucker", + "kind": "battle", + "declared_after": {"map": "VermilionCity_Gym", "tiles": [[5, 8]], "facing": "east"}, + "why": "Pikachu, Lv23" + }, + { + "id": "trash_cans", + "kind": "game_action", + "action": "trash_cans", + "why": "the cans until both locks open; a wrong second can resets them" + }, + { + "id": "below_gym_tree", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "VermilionCity", "tiles": [[19, 25]], "facing": "north"} + }, + "why": "out of the gym, east to below the tree, grown back" + }, + { + "id": "cut_tree_out", + "kind": "game_action", + "action": "cut_tree", + "args": { + "direction": "north" + }, + "declared_after": {"map": "VermilionCity", "tiles": [[19, 24]], "facing": "north"}, + "why": "the tree again; a step onto its tile" + }, + { + "id": "vermilion_nurse", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "VermilionCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"} + }, + "why": "north through the city to the Pokemon Center" + }, + { + "id": "heal_vermilion", + "kind": "heal", + "why": "full HP" + } + ] + }, + "execution": { + "menu": "full", + "lead": "after_brock", + "notes": { + "checkpoint": [ + "HM01 Cut, from the S.S. Anne (00.22), to the Oddish (00.20), second in the party: a wild Oddish of Lv12 to 14 knows 2 or 3 moves (Absorb, Sweet Scent, Poison Powder at 14), so it has room. TM28 Dig, from the Cerulean Rocket (00.21), to the lead in place of Withdraw: Ground, twice as strong on Lt. Surge's three, it takes the sim's chance against him for a Lv28 Wartortle with 14 Potions from 6% to 47%. Vermilion's tree (19, 24) (EventScript_CutTree) is the only way into the gym's yard, row 24 being walls but for it; the gym's door is (14, 25). In the gym, the trainers as below, then the trash cans until the door opens; out, the tree cut again from below, and back to the nurse.", + "The gym (VermilionCity_Gym map.json, scripts.inc), 11 x 20, entered on (5, 19): the cans on rows 10, 12 and 14 at x 1, 3, 5, 7, 9 (PokemonFRLG_AutoStoryTrashCans.h), the beams across rows 6 and 7 that the two switches turn off, Lt. Surge (5, 2) facing down above them. Its trainers, sight 3:", + "Sailor Dwayne (8, 13) and Engineer Baily (2, 11) look around (MOVEMENT_TYPE_LOOK_AROUND): between them they see across rows 11 and 13 and down columns 2 and 8, so no way from the door to the cans keeps out of their sight. Each is fought from the second tile of his line, stepped onto from beside it, out of sight, and waited on there until he turns to the player (\"trainer_wait\"): Dwayne from (8, 15), stepped onto from (7, 15), Baily from (2, 13), from (3, 13). Each walks up a tile, Dwayne to (8, 14), Baily to (2, 12), and stays there while the player is in the gym.", + "Gentleman Tucker (7, 8) faces west over (4..6, 8): fought on the step up from (5, 9) onto (5, 8); he walks up to (6, 8).", + "The cans' stands, on rows 9, 11 and 13 above each, are clear of where the three stand after their battles. Leaving the gym puts them back where the map has them, beaten, and grows the tree back." + ] + } + }, + "metadata": {"phase": "testing"} +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.24.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.24.plan.json new file mode 100644 index 0000000000..a689c39816 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.24.plan.json @@ -0,0 +1,137 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.24", + "title": "Route 6's grass until Lt. Surge is winnable, then through the open beams to him", + "start": {"map": "VermilionCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"}, + "events": [ + { + "id": "surge_winnable", + "kind": "game_action", + "action": "grind_check", + "args": { + "slot": 1, + "level": 32, + "encounters": 150, + "pace": "east", + "heal_every": 0, + "beat": "TRAINER_LEADER_LT_SURGE", + "chance": 50 + }, + "why": "the lead as it is: if the sim beats Lt. Surge 50% or more already, no trip to Route 6" + }, + { + "id": "route6_south_path", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "Route6", "tiles": [[11, 34]], "facing": "north"} + }, + "skip_if": ["surge_winnable"], + "why": "out of the Center, north out of the city onto Route 6's path, below Jeff's row" + }, + { + "id": "round_isabelle_line", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "north", "tiles": 1}, {"direction": "west", "tiles": 4}, {"direction": "north", "tiles": 2}, {"direction": "east", "tiles": 5}, {"direction": "east", "tiles": 1}] + }, + "skip_if": ["surge_winnable"], + "why": "onto Jeff's row (11, 33), west to the wall (7, 33), up to (7, 31), east along row 31 to (12, 31) and a step onto the grass, (13, 31): out of Isabelle's line" + }, + { + "id": "grind_for_surge", + "kind": "game_action", + "action": "grind", + "args": { + "slot": 1, + "level": 32, + "encounters": 150, + "pace": "east", + "heal_every": 0, + "nurse": {"map": "VermilionCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"}, + "beat": "TRAINER_LEADER_LT_SURGE", + "chance": 50 + }, + "skip_if": ["surge_winnable"], + "why": "wild battles until the sim beats Lt. Surge 50% or more, Lv32 at most; the nurse when hurt or low on PP" + }, + { + "id": "west_on_row_31", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "Route6", "tiles": [[7, 31]]} + }, + "skip_if": ["surge_winnable"], + "why": "west along row 31, out of the grass, to the wall (7, 31)" + }, + { + "id": "down_to_jeff_row", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "south", "tiles": 2}, {"direction": "east", "tiles": 4}] + }, + "skip_if": ["surge_winnable"], + "why": "down to the wall (7, 33), east along Jeff's row to (11, 33): out of Isabelle's line" + }, + { + "id": "vermilion_nurse", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "VermilionCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"} + }, + "skip_if": ["surge_winnable"], + "why": "south into the city to the Pokemon Center" + }, + { + "id": "heal_vermilion", + "kind": "heal", + "skip_if": ["surge_winnable"], + "why": "full HP" + }, + { + "id": "above_gym_tree", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "VermilionCity", "tiles": [[19, 23]], "facing": "south"} + }, + "why": "out of the Center, south through the city to above the tree (19, 24)" + }, + { + "id": "cut_gym_tree", + "kind": "game_action", + "action": "cut_tree", + "args": { + "direction": "south" + }, + "declared_after": {"map": "VermilionCity", "tiles": [[19, 24]], "facing": "south"}, + "why": "the tree; a step onto its tile" + }, + { + "id": "below_lt_surge", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "VermilionCity_Gym", "tiles": [[5, 3]], "facing": "north"} + }, + "why": "into the gym, up round the cans and through the beams, off, to below Surge (5, 2)" + } + ] + }, + "execution": { + "menu": "full", + "lead": "after_brock", + "notes": { + "checkpoint": [ + "Wild battles on Route 6 until the sim beats Lt. Surge half the time: with Dig, 47% at Lv28 and 51% at Lv29, so a lead the gym's trainers have brought to Lv29 passes at once, and a Lv28 one after a level. The grass nearest the city is Route 6's south patch (13..16, 30..33); Picnicker Isabelle (13, 32) faces west over (10..12, 32), on the way north from the city, so the walk goes along Jeff's row 33 (he is beaten) to the wall (7, 33), up to row 31 and east along it onto the patch's west edge, (13, 31), above Isabelle, out of her line. Back to the nurse the same way. All that is skipped when the lead, read in the Center, passes already. Then the tree, the gym, whose trainers stand where the map has them, beaten, and whose beams stay off (FLAG_FOUND_BOTH_VERMILION_GYM_SWITCHES): up column 5 to below Lt. Surge, and saved there." + ] + } + }, + "metadata": {"phase": "testing"} +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.25.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.25.plan.json new file mode 100644 index 0000000000..b9da1007b8 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.25.plan.json @@ -0,0 +1,74 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.25", + "title": "Vermilion Gym: Lt. Surge, the THUNDERBADGE, then the Center", + "start": {"map": "VermilionCity_Gym", "tiles": [[5, 3]], "facing": "north"}, + "events": [ + { + "id": "challenge_lt_surge", + "kind": "talk", + "why": "\"Hey, kid! What do you think you're doing here?\"" + }, + { + "id": "lt_surge", + "kind": "battle", + "declared_after": {"map": "VermilionCity_Gym", "tiles": [[5, 3]], "facing": "north"}, + "why": "Voltorb, Pikachu and Raichu; THUNDERBADGE and TM34" + }, + { + "id": "below_gym_tree", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "VermilionCity", "tiles": [[19, 25]], "facing": "north"} + }, + "why": "down through the beams, out of the gym, east to below the tree, grown back" + }, + { + "id": "cut_tree_out", + "kind": "game_action", + "action": "cut_tree", + "args": { + "direction": "north" + }, + "declared_after": {"map": "VermilionCity", "tiles": [[19, 24]], "facing": "north"}, + "why": "the tree; a step onto its tile" + }, + { + "id": "below_oaks_aide", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "VermilionCity", "tiles": [[14, 10]]} + }, + "why": "north through the city and west along row 10 to the water, (14, 10): off Oak's aide's row 7" + }, + { + "id": "vermilion_nurse", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "VermilionCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"} + }, + "why": "up to the Pokemon Center" + }, + { + "id": "heal_vermilion", + "kind": "heal", + "why": "full HP" + } + ] + }, + "execution": { + "menu": "full", + "lead": "after_brock", + "notes": { + "checkpoint": [ + "Lt. Surge (5, 2), talked to from below, from the save in front of him: Voltorb Lv21, Pikachu Lv18 and Raichu Lv24, Shock Wave and Thunder Wave, a Super Potion and a Full Heal (sParty_LeaderLtSurge); then the THUNDERBADGE and TM34, read to the overworld with the battle's text. Out, the tree, and the nurse. Surge's win also puts Oak's aide on Vermilion City's (25, 7) (VermilionCity_Gym_EventScript_ShowOaksAide), where he stays until talked to; the story's maps don't have him. The way to the nurse along row 7 runs into him (console B, 2026-11-03: the leg west stopped beside him and the step into the Center's door went into a house), so it goes along row 10 to the water instead, clear of him, and up column 14 from there." + ] + } + }, + "metadata": {"phase": "testing"} +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.26.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.26.plan.json new file mode 100644 index 0000000000..1ee5abc86d --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.26.plan.json @@ -0,0 +1,162 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.26", + "title": "The BIKE VOUCHER from the Fan Club, back north to Cerulean, the BICYCLE, Repels and Escape Ropes", + "start": {"map": "VermilionCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"}, + "events": [ + { + "id": "below_center", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "VermilionCity", "tiles": [[14, 10]]} + }, + "why": "out of the Center, down to the water (14, 10): off Oak's aide's row 7" + }, + { + "id": "beside_chairman", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "VermilionCity_PokemonFanClub", "tiles": [[4, 4]], "facing": "east"} + }, + "why": "east along row 10, down to the Fan Club's door (12, 17), in, and up its west side beside the chairman (5, 4)" + }, + { + "id": "chairman", + "kind": "talk", + "why": "\"I chair the POKEMON Fan Club!\" ... \"Did you come to hear about my POKEMON?\"" + }, + { + "id": "hear_story", + "kind": "answer", + "why": "YES: his story" + }, + { + "id": "bike_voucher", + "kind": "scene", + "declared_after": {"map": "VermilionCity_PokemonFanClub", "tiles": [[4, 4]], "facing": "east"}, + "why": "the story of his Rapidash; the BIKE VOUCHER" + }, + { + "id": "west_of_oaks_aide", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "VermilionCity", "tiles": [[22, 10]]} + }, + "why": "out of the Fan Club, east along row 18 and up column 22 to (22, 10)" + }, + { + "id": "route6_south_path", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "Route6", "tiles": [[11, 34]], "facing": "north"} + }, + "why": "up column 22 west of Oak's aide (25, 7), out of the city onto Route 6's path, below Jeff's row" + }, + { + "id": "round_isabelle_and_elijah", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "north", "tiles": 1}, {"direction": "west", "tiles": 4}, {"direction": "north", "tiles": 2}, {"direction": "east", "tiles": 9}, {"direction": "north", "tiles": 19}] + }, + "why": "onto Jeff's row (11, 33), west to the wall (7, 33), up to (7, 31), east along row 31 to the wall (16, 31), up column 16 to the ledge (16, 12): out of Isabelle's and Elijah's lines" + }, + { + "id": "below_cerulean_tree", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "CeruleanCity", "tiles": [[26, 33]], "facing": "north"} + }, + "why": "the Underground Path north, up Route 5's side into Cerulean, below the tree (26, 32)" + }, + { + "id": "cut_cerulean_tree", + "kind": "game_action", + "action": "cut_tree", + "args": { + "direction": "north" + }, + "declared_after": {"map": "CeruleanCity", "tiles": [[26, 32]], "facing": "north"}, + "why": "the tree; a step onto its tile" + }, + { + "id": "bike_clerk", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "CeruleanCity_BikeShop", "tiles": [[7, 3]], "facing": "east"} + }, + "why": "west into the Bike Shop (13, 28), across the counter from the clerk (9, 3)" + }, + { + "id": "talk_bike_clerk", + "kind": "talk", + "why": "\"Oh, that's... A BIKE VOUCHER!\"" + }, + { + "id": "bicycle", + "kind": "scene", + "declared_after": {"map": "CeruleanCity_BikeShop", "tiles": [[7, 3]], "facing": "east"}, + "why": "the voucher exchanged for a BICYCLE" + }, + { + "id": "mart_clerk", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "CeruleanCity_Mart", "tiles": [[4, 3]], "facing": "west"} + }, + "why": "out of the Bike Shop to the Mart's clerk" + }, + { + "id": "buy_repels", + "kind": "game_action", + "action": "mart", + "args": { + "map": "CeruleanCity_Mart", + "budget": 2850, + "items": [{"item": "repel", "quantity": 5}, {"item": "escape-rope", "quantity": 2}], + "floor": 6000 + }, + "why": "5 Repels and 2 Escape Ropes, 2850 at most" + }, + { + "id": "cerulean_nurse", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "CeruleanCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"} + }, + "why": "out of the Mart to the Center" + }, + { + "id": "heal_cerulean", + "kind": "heal", + "why": "full HP" + } + ] + }, + "execution": { + "menu": "full", + "lead": "after_brock", + "notes": { + "checkpoint": [ + "The BIKE VOUCHER and the BICYCLE, from Vermilion's Center to Cerulean's (pokeguy 43:50 to 45:00).", + "The Pokemon Fan Club (VermilionCity_PokemonFanClub map.json, scripts.inc), in by Vermilion's (12, 17): the chairman (5, 4) sits above a table (5..6, 5..6) with the worker (6, 4) east of him, so he is talked to from (4, 4), west of him. \"Did you come to hear about my POKEMON?\" YES: his story, then the BIKE VOUCHER (FLAG_GOT_BIKE_VOUCHER). Oak's aide stands on Vermilion's (25, 7) since Lt. Surge, where the story's maps don't have him: the way planned from the Center's door goes east along his row 7, so the walk goes down to the water (14, 10) first, as 00.25 came up from it. From the Fan Club, up to (22, 10) first, so that the way on to Route 6 goes up column 22, west of him, not round by column 27.", + "Route 6 north, the trainers as 00.21 left them: Jeff (13, 33) beaten, Isabelle (13, 32) and Elijah (20, 25) not. As in 00.24, onto Jeff's row, west to the wall (7, 33) and up to row 31, above Isabelle's line; then east along row 31 to the wall (17, 31) and up column 16, west of Elijah's line (17..19, 25) and east of Keigo's (4..8, 16), to the ledge (16, 11). The first three legs are 00.24's, walked on console B; the two after end on walls, which the walker holds again after a wild battle in the grass.", + "The Underground Path north, Route 5's sides, which have no trainer, and Cerulean's south edge, whose way into the city without the burgled house is the tree (26, 32) (pokeguy 44:42).", + "The Bike Shop (CeruleanCity_BikeShop), in by (13, 28): the clerk (9, 3) is across the counter (8, 3), talked to from (7, 3). With the voucher he gives the BICYCLE (FLAG_GOT_BICYCLE) with no YES/NO; it isn't registered or ridden yet.", + "The Mart: 5 Repels (row 9, 350 each) and 2 Escape Ropes (row 8, 550 each; pokefirered items.json), 2850 in all. Console B had about 9000 after Lt. Surge (2026-11-03); the floor of 6000 leaves 3000 or more after them.", + "The nurse, and the save in Cerulean's Center." + ] + } + }, + "metadata": {"phase": "testing"} +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.27.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.27.plan.json new file mode 100644 index 0000000000..b5d00cf933 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.27.plan.json @@ -0,0 +1,217 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.27", + "title": "East over Route 9 to Route 10's Pokemon Center: the two trees, Alicia, Jeremy and Conner", + "start": {"map": "CeruleanCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"}, + "events": [ + { + "id": "above_cerulean_tree", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "CeruleanCity", "tiles": [[26, 31]], "facing": "south"} + }, + "why": "out of the Center, south through the city to above the tree (26, 32), grown back" + }, + { + "id": "cut_cerulean_tree", + "kind": "game_action", + "action": "cut_tree", + "args": { + "direction": "south" + }, + "declared_after": {"map": "CeruleanCity", "tiles": [[26, 32]], "facing": "south"}, + "why": "the tree; a step onto its tile" + }, + { + "id": "west_of_route9_tree", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "Route9", "tiles": [[1, 8]], "facing": "east"} + }, + "why": "down to row 33, east and up column 39 or 40 to row 18, east out of the city onto Route 9, west of its tree (2, 8)" + }, + { + "id": "cut_route9_tree", + "kind": "game_action", + "action": "cut_tree", + "args": { + "direction": "east" + }, + "declared_after": {"map": "Route9", "tiles": [[2, 8]], "facing": "east"}, + "why": "Route 9's tree; a step onto its tile" + }, + { + "id": "above_alicia_line", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "Route9", "tiles": [[11, 9]], "facing": "south"} + }, + "why": "east to (11, 9), above the west end of Alicia's line" + }, + { + "id": "alicia_line", + "kind": "step", + "action": "trainer_line", + "args": { + "direction": "south" + }, + "why": "onto (11, 10), in Alicia's line: she walks up to (12, 10)" + }, + { + "id": "picnicker_alicia", + "kind": "battle", + "declared_after": {"map": "Route9", "tiles": [[11, 10]], "facing": "east"}, + "why": "Oddish, Bellsprout, Oddish and Bellsprout, Lv18" + }, + { + "id": "alicia_ledge_hop", + "kind": "step", + "args": { + "direction": "south" + }, + "declared_after": {"map": "Route9", "tiles": [[11, 12]], "facing": "south"}, + "why": "down the ledge (11, 11)" + }, + { + "id": "west_of_jeremy_sight", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "Route9", "tiles": [[19, 13]], "facing": "east"} + }, + "why": "down to row 13 and east along it to (19, 13), west of Jeremy's north line" + }, + { + "id": "jeremy_sight", + "kind": "step", + "action": "trainer_wait", + "args": { + "direction": "east" + }, + "why": "onto (20, 13), four above Jeremy (20, 17): when he looks north he walks up to (20, 14)" + }, + { + "id": "hiker_jeremy", + "kind": "battle", + "declared_after": {"map": "Route9", "tiles": [[20, 13]], "facing": "south"}, + "why": "Machop and Onix, Lv20" + }, + { + "id": "below_conner_line", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "Route9", "tiles": [[52, 8]], "facing": "north"} + }, + "why": "east along row 13 and up column 52 to (52, 8), below the east end of Conner's line" + }, + { + "id": "conner_line", + "kind": "step", + "action": "trainer_line", + "args": { + "direction": "north" + }, + "why": "onto (52, 7), the end of Conner's line: he walks up to (51, 7)" + }, + { + "id": "bug_catcher_conner", + "kind": "battle", + "declared_after": {"map": "Route9", "tiles": [[52, 7]], "facing": "west"}, + "why": "Caterpie, Weedle and Venonat, Lv20" + }, + { + "id": "round_brice", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "north", "tiles": 2}, {"direction": "west", "tiles": 1}, {"direction": "north", "tiles": 2}, {"direction": "west", "tiles": 3}, {"direction": "north", "tiles": 2}, {"direction": "east", "tiles": 16}, {"direction": "south", "tiles": 1}] + }, + "why": "up to the ledge (52, 4), up column 51 to Brice's row, west to the rock (48, 3) (or (48, 1)), up to (48, 1), east along row 1 to the rock (64, 1), down to (64, 2)" + }, + { + "id": "above_east_ledge", + "kind": "step", + "args": { + "direction": "south" + }, + "declared_after": {"map": "Route9", "tiles": [[64, 3]], "facing": "south"}, + "why": "onto (64, 3), above the ledge (64, 4)" + }, + { + "id": "east_ledge_hop", + "kind": "step", + "args": { + "direction": "south" + }, + "declared_after": {"map": "Route9", "tiles": [[64, 5]], "facing": "south"}, + "why": "down the ledge (64, 4)" + }, + { + "id": "above_caitlin_line", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "south", "tiles": 3}, {"direction": "east", "tiles": 6}] + }, + "why": "down column 64 to row 8, east along it to (70, 8): above Caitlin's line (61..64, 9)" + }, + { + "id": "route10_ledge_end", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "Route10", "tiles": [[17, 11]], "facing": "east"} + }, + "why": "east onto Route 10, down to row 11 west of the grass and east along it to the wall (17, 11), above the fence post (17, 12)" + }, + { + "id": "below_center_door", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "west", "tiles": 1}, {"direction": "south", "tiles": 12}, {"direction": "west", "tiles": 1}, {"direction": "north", "tiles": 2}, {"direction": "west", "tiles": 5}, {"direction": "east", "tiles": 3}] + }, + "why": "into the ledge's gap (16, 11), down column 16 to row 23, a tile west, up to the Center's wall (15, 21), west along row 21 to the wall (10, 21), east to (13, 21), below the door" + }, + { + "id": "route10_nurse", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "Route10_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"} + }, + "why": "up onto the Center's door (13, 20), to the nurse" + }, + { + "id": "heal_route10", + "kind": "heal", + "why": "full HP" + } + ] + }, + "execution": { + "menu": "full", + "lead": "after_brock", + "notes": { + "checkpoint": [ + "East out of Cerulean over Route 9 to Route 10's Pokemon Center (pokeguy 45:12 to 47:27), on foot: the Bicycle isn't registered yet.", + "Cerulean (CeruleanCity map.json): the way east, column 39..40 up from row 33 to rows 18..19 and out of the city's east edge, is reached from the city only through the tree (26, 32), grown back since 00.26 (its flag is a FLAG_TEMP), or the burgled house. Cut from above. Route 9 joins the city's rows 18..19 by its rows 8..9 (offset -10); its tree (2, 8) (FLAG_TEMP_12) closes them, (2, 9) being rock: cut from (1, 8), west of it.", + "Route 9 (Route9 map.json, scripts.inc), its ledges all facing south. Of its nine trainers, three can't be walked around, as in pokeguy's run, where Jeremy happened to look away:", + "Picnicker Alicia (14, 10) faces west, sight 3, over (11..13, 10), the only tiles above the ledge row 11 the way west goes down by: fought on the step onto (11, 10); she walks up to (12, 10). Then down the ledge (11, 11).", + "Hiker Jeremy (20, 17) looks north and west (FACE_UP_AND_LEFT), sight 4: north over (20, 13..16), every way east of column 19 below the rocks of row 12. Fought on (20, 13), waiting for him to look north (trainer_wait); he walks up to (20, 14).", + "Bug Catcher Conner (49, 7) faces east, sight 3, over (50..52, 7): the way north from row 13 is column 52 alone (the ledges of row 11 face south), and row 7 is the way onto the ridge. Fought on the step onto (52, 7); he walks up to (51, 7).", + "Hiker Brice wanders row 2 (50..56), looking west and east, sight 1, over (49..57, 2), and the way up from the ledges of row 4 is (50..51, 4) below him. The leg up column 51 ends on row 3 if he stands at (51, 2), else it goes on to (51, 1) past him, and he may see the player there; either way the legs to walls after it meet on (48, 1): west to the rock (48, 3) or (48, 1), up to (48, 1). Row 1 is clear of his sight; east along it to the rock (64, 1) and down column 64 past the hidden Rare Candy (63, 2), not picked up. A held leg down to (64, 3) would hop the ledge (64, 4) and go on, so the last tile is one step, then the hop.", + "Picnicker Caitlin (60, 9) faces east over (61..64, 9): the way to Route 10 goes along row 8, above her line, by legs to (70, 8), a tile short of the edge. Camper Chris (26, 7), Bug Catcher Brent (26, 1), Camper Drew (36, 6) and Hiker Alan (61, 16) are off the way; TM40 (12, 17) is left.", + "Route 10 (Route10 map.json) joins Route 9's rows 8..10 by its own; its north part, down to the Center's door (13, 20), has no trainer on the way and its grass is walked round. The trees west of the door (10, 20..26) stay. The walk there ends its open legs where a tile of error can't reach a blocker, and finds its place again on walls (console B, 2026-11-09, two runs \"no fade\" at the door): the step onto Route 10 is not always held up, so the player may stand a tile further east, and the leg along row 11 holds to the wall (17, 11) instead of ending on (16, 11) by count. The 12 tiles down column 16 may end a tile short or long: from rows 22..29 a tile west and up to the Center's wall (15, 20) all end on (15, 21). West along row 21 to the wall (9, 21) ends on (10, 21), three west of the door's column: the only count no wall after it checks.", + "The nurse, and the save in Route 10's Center: the save card names ROUTE 10." + ] + } + }, + "metadata": {"phase": "testing"} +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-parcel-00.05.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-parcel-00.05.json deleted file mode 100644 index 2090ba206e..0000000000 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-parcel-00.05.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "format": "pokesim-native-checkpoint-export/1", - "game": "frlg", - "checkpoint": { - "id": "00.05", - "title": "Route 1 to Viridian Mart: Oak's Parcel", - "start": { - "certainty": "tile", - "map": "PalletTown_ProfessorOaksLab", - "where": {"facing": "south", "kind": "tiles", "tiles": [[7, 8]]} - }, - "events": [ - { - "id": "below_mart_door", - "kind": "route", - "target": { - "certainty": "tile", - "map": "ViridianCity", - "where": {"facing": "north", "kind": "tiles", "tiles": [[36, 20]]} - }, - "why": "Route 1, running from wild battles" - }, - { - "id": "mart_door", - "kind": "step", - "why": "the clerk's scene starts on entering" - }, - { - "id": "parcel_from_clerk", - "kind": "scene", - "declared_after": { - "certainty": "tile", - "map": "ViridianCity_Mart", - "where": {"facing": "west", "kind": "tiles", "tiles": [[4, 3]]} - }, - "why": "the clerk gives OAK'S PARCEL" - } - ] - }, - "native_fields": { - "menu": "before_pokedex", - "supplies": { - "antidotes": 0, - "foe_out": null, - "foes": [], - "hp_fill": 1.0, - "hp_red": false, - "hurt": false, - "lead": { - "level": 0, - "moves": [{"move": "tackle", "pp": 35}, {"move": "tail-whip", "pp": 30}], - "moves_read": false, - "moves_through_level": 5, - "species": "squirtle", - "stats": null - }, - "parlyz_heals": 0, - "pocket": ["potion", "antidote", "parlyz-heal"], - "potions": 0, - "protected_slots": [], - "risk": "low", - "status": "no status", - "trainer": "", - "wild_foes": [] - } - }, - "source_revision": "b170b7d2103e887ded825c37fdbdc19fd654fca8", - "status": "native-table-export", - "state_basis": "native-table-bookkeeping", - "unbound": ["runtime_configuration", "map_pins", "executor_bindings", "entry_evidence", "effective_save_retry_policy"] -} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-parcel-00.05.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-parcel-00.05.plan.json deleted file mode 100644 index 6df2d7a0d2..0000000000 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-parcel-00.05.plan.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "format": "pokesim-authored-checkpoint/1", - "game": "frlg", - "checkpoint": { - "id": "00.05", - "title": "Route 1 to Viridian Mart: Oak's Parcel", - "start": { - "certainty": "tile", - "map": "PalletTown_ProfessorOaksLab", - "where": {"facing": "south", "kind": "tiles", "tiles": [[7, 8]]} - }, - "events": [ - { - "id": "below_mart_door", - "kind": "route", - "target": { - "certainty": "tile", - "map": "ViridianCity", - "where": {"facing": "north", "kind": "tiles", "tiles": [[36, 20]]} - }, - "why": "Route 1, running from wild battles" - }, - { - "id": "mart_door", - "kind": "step", - "why": "the clerk's scene starts on entering", - "direction": "north" - }, - { - "id": "parcel_from_clerk", - "kind": "scene", - "declared_after": { - "certainty": "tile", - "map": "ViridianCity_Mart", - "where": {"facing": "west", "kind": "tiles", "tiles": [[4, 3]]} - }, - "why": "the clerk gives OAK'S PARCEL" - } - ] - }, - "execution": {"menu": "before_pokedex"} -} diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index f8b3449b48..6bffa66c1c 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1948,6 +1948,8 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFoeTracker.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFoeTracker.h + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGameArgs.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGameArgs.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGrind.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGrind.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGrind_Tests.cpp @@ -1973,6 +1975,7 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRngOptions.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRowSim.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRowSim.h + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows_Tests.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRunPlan_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySimulation_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySummary.cpp @@ -1986,8 +1989,6 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepTable.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepTable.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepTable_Tests.cpp - Source/VideoGames/PokemonFRLG/Programs/AutoStory/Data/JsonParser.cpp - Source/VideoGames/PokemonFRLG/Programs/AutoStory/Data/JsonParser.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/Data/JsonWriter.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/Data/JsonWriter.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/Data/LegacyJsonFormat.h @@ -1995,10 +1996,6 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/AutoStory/Data/Json_Tests.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h - Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableCeladon.cpp - Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableSteps.cpp - Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableSteps.h - Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableVermilionGym.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTeach.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTeach.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTeach_Tests.cpp @@ -2008,10 +2005,10 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTrashCans.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTrashCans.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTrashCans_Tests.cpp - Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVariantWords.cpp - Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVariantWords.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVermilion_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVermilionGym_Tests.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryViridianMart.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryViridianMart.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryWinChance.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryWinChance.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp