From d0b6ad0bcc2283c7f0673cf79f5d0313c71b31f2 Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 10 Nov 2026 11:38:18 -0800 Subject: [PATCH] FRLG AutoStory: mark stage 1's checkpoints "phase": "testing" Each StoryData file of 00.01 to 00.10 gets "metadata": {"phase": "testing"}, as the later stages' files have. The table reader takes the metadata off before the shared reader (which doesn't take it yet), checking it holds only a known phase, as stage 3's reader does. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../AutoStory/PokemonFRLG_AutoStoryTable.cpp | 26 ++++++++++++++++++- .../AutoStory/PokemonFRLG_AutoStoryTable.h | 3 +++ .../AutoStory/StoryData/frlg-00.01.plan.json | 3 ++- .../AutoStory/StoryData/frlg-00.02.plan.json | 3 ++- .../AutoStory/StoryData/frlg-00.03.plan.json | 3 ++- .../AutoStory/StoryData/frlg-00.04.plan.json | 3 ++- .../AutoStory/StoryData/frlg-00.05.plan.json | 3 ++- .../AutoStory/StoryData/frlg-00.06.plan.json | 3 ++- .../AutoStory/StoryData/frlg-00.07.plan.json | 3 ++- .../AutoStory/StoryData/frlg-00.08.plan.json | 3 ++- .../AutoStory/StoryData/frlg-00.09.plan.json | 3 ++- .../AutoStory/StoryData/frlg-00.10.plan.json | 3 ++- 12 files changed, 48 insertions(+), 11 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp index 88573b08af..8c9b714717 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp @@ -95,6 +95,30 @@ std::set read_note_keys(const JsonObject& execution, std::string_vi 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)); +} + } // namespace @@ -108,7 +132,7 @@ StoryCheckpoint read_story_checkpoint_file(const JsonValue& value, std::string_v note_keys = read_note_keys(execution, where); }; static_cast(checkpoint) = Pokemon::read_authored_checkpoint( - value, "frlg", source, read_execution, story_action_specs() + without_metadata(value, source), "frlg", source, read_execution, story_action_specs() ); for (const std::string& key : note_keys){ bool found = key == "checkpoint"; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h index 99d5ed45d4..62cbb37513 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h @@ -22,6 +22,9 @@ * 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 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 index 31eea5b1d0..3e47c1be6b 100644 --- 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 @@ -25,5 +25,6 @@ "new_game.c: the bedroom at (6, 6), facing the TV." ] } - } + }, + "metadata": {"phase": "testing"} } 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 index 2f09e7db16..06d522c23d 100644 --- 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 @@ -18,5 +18,6 @@ }, "execution": { "menu": "before_pokemon" - } + }, + "metadata": {"phase": "testing"} } 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 index b44478b878..0a86b054dc 100644 --- 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 @@ -37,5 +37,6 @@ "PlayerEnter walks the player up 8 tiles from the lab's door." ] } - } + }, + "metadata": {"phase": "testing"} } 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 index af5c28173a..54ca333a84 100644 --- 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 @@ -72,5 +72,6 @@ "The rival leaves; PlayerWatchRivalExitAfterBattleRight ends facing down." ] } - } + }, + "metadata": {"phase": "testing"} } 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 index d3923d0565..19e8a2e15e 100644 --- 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 @@ -37,5 +37,6 @@ "ApproachCounter: up 4 from the mat, then faces the clerk." ] } - } + }, + "metadata": {"phase": "testing"} } 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 index 431917879d..f58aba06bb 100644 --- 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 @@ -29,5 +29,6 @@ }, "execution": { "menu": "full" - } + }, + "metadata": {"phase": "testing"} } 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 index 4abe1885aa..75e4db6a09 100644 --- 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 @@ -91,5 +91,6 @@ "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." ] } - } + }, + "metadata": {"phase": "testing"} } 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 index c02e6e877f..ddb92f9f99 100644 --- 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 @@ -78,5 +78,6 @@ "Out of the forest, wild battles are run from; trainers are still fought." ] } - } + }, + "metadata": {"phase": "testing"} } 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 index 28b36cc3e4..c756fe3bec 100644 --- 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 @@ -75,5 +75,6 @@ "On to Brock unless red HP or a status is left that no item cures." ] } - } + }, + "metadata": {"phase": "testing"} } 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 index b8cf6a8ccd..6c4b5e9883 100644 --- 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 @@ -44,5 +44,6 @@ "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)." ] } - } + }, + "metadata": {"phase": "testing"} }