diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp index 2c94231688..fd11956d35 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp @@ -106,6 +106,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 @@ -125,7 +149,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 0201a8e65f..c96fab5a14 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h @@ -26,6 +26,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 638b71fa29..4a051b5b16 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 @@ -26,5 +26,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.01b.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.01b.plan.json index fba9b09f08..e64cad0a98 100644 --- 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 @@ -28,5 +28,6 @@ "SID Helper confirms the name, finishes the intro and reads the Trainer Card from the START menu, without moving the player or saving." ] } - } + }, + "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 e56a583371..a49a93050b 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 @@ -24,5 +24,6 @@ "Starter RNG starts from a save south of the table, facing the ball." ] } - } + }, + "metadata": {"phase": "testing"} } 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 index 08af2bfd81..9b542ed4c9 100644 --- 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 @@ -64,5 +64,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"} }