diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryActions.cpp b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryActions.cpp
index 9590d82a58..65b02c2225 100644
--- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryActions.cpp
+++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryActions.cpp
@@ -86,10 +86,12 @@ void fight_battle_in_progress(
BlueDialogDetector blue_dialog;
TealDialogDetector teal_dialog;
const WallClock deadline = current_time() + timeout;
+ bool attacked = false;
while (true){
context.wait_for_all_requests();
const VideoSnapshot screen = console.video().snapshot();
- if (white_dialog.detect(screen) || blue_dialog.detect(screen) || teal_dialog.detect(screen)){
+ const bool dialog = white_dialog.detect(screen) || blue_dialog.detect(screen) || teal_dialog.detect(screen);
+ if (dialog && attacked){
return;
}
if (current_time() > deadline){
@@ -99,7 +101,13 @@ void fight_battle_in_progress(
console
);
}
- battle_state.attempt_one_attack(env, console, context);
+ if (dialog || !battle_state.attempt_one_attack(env, console, context)){
+ if (!attacked){
+ pbf_press_button(context, BUTTON_A, 160ms, 400ms);
+ }
+ continue;
+ }
+ attacked = true;
}
}
diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryActions.h b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryActions.h
index 19de9d6798..9e1272accf 100644
--- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryActions.h
+++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryActions.h
@@ -36,7 +36,6 @@ class StoryActionNotImplemented : public OperationFailedException{
public:
explicit StoryActionNotImplemented(std::string message);
- // code-health: allow char_pointer -- the exception base class's name() returns const char*
virtual const char* name() const override{
return "StoryActionNotImplemented";
}
@@ -52,9 +51,12 @@ void fight_battle(
BattleAIOption& battle_ai
);
-// In a battle that is already on screen: attacks with TrainerBattleState
-// until a dialog box shows (the speech after a win or a loss). For story
-// battles, which show no Run prompt for fight_battle() to start on.
+// A story battle, from the talk before it: attacks with TrainerBattleState
+// until a dialog box shows (the speech after a win or a loss). Until the
+// first attack lands, a dialog box or a failed lock-on gets A instead: the
+// trainer's lines, the challenge cutscene's subtitle (no text box) and
+// tutorial cards (Taunie's battle in 03.02, console B 2026-11-10). For
+// story battles, which show no Run prompt for fight_battle() to start on.
// Throws OperationFailedException after `timeout`.
void fight_battle_in_progress(
ProgramEnvironment& env, ConsoleHandle& console, ProControllerContext& context,
diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStory.cpp b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStory.cpp
index 4d51218b0e..1e3d823549 100644
--- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStory.cpp
+++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStory.cpp
@@ -40,7 +40,7 @@ AutoStory_Descriptor::AutoStory_Descriptor()
"PokemonLZA:AutoStory",
std::format("{} LZA", STRING_POKEMON), "Auto Story",
"Programs/PokemonLZA/AutoStory.html",
- "Play the main story of Pokemon Legends: Z-A. Prototype: plays a new game to the station platform, as recorded on a console. "
+ "Play the main story of Pokemon Legends: Z-A. Prototype: Main Mission 01 as recorded on a console; plays from a new game to the starter and Andi. "
"Start a new game and pick its language, look and name by hand: checkpoint 01.00 starts on the Confirm Choices screen that follows. "
"It checks that screen, presses nothing anywhere else, and picks Ready!. Later checkpoints load their save first. "
"Set Game Language to the language the game is set to: the program reads place names in it.",
@@ -82,6 +82,16 @@ AutoStory::AutoStory()
true
)
, RUN(checkpoint_database(), Gen8ToGen9Languages_Database())
+ , STARTER(
+ "Starter Pokemon:",
+ {
+ {StarterChoice::CHIKORITA, "chikorita", "Chikorita"},
+ {StarterChoice::TEPIG, "tepig", "Tepig"},
+ {StarterChoice::TOTODILE, "totodile", "Totodile"},
+ },
+ LockMode::LOCK_WHILE_RUNNING,
+ StarterChoice::CHIKORITA
+ )
, RELOAD_AT_BOUNDARIES(
"Reload at Checkpoint Boundaries:
Reload the save before a checkpoint whose plan asks for it "
"when the run comes from the checkpoint before. Off: run straight on. A failed checkpoint's retry reloads either way.",
@@ -98,6 +108,7 @@ AutoStory::AutoStory()
PA_ADD_OPTION(LANGUAGE);
RUN.LANGUAGE.set_visibility(ConfigOptionState::HIDDEN);
PA_ADD_OPTION(RUN);
+ PA_ADD_OPTION(STARTER);
PA_ADD_OPTION(BATTLE_AI);
PA_ADD_OPTION(RELOAD_AT_BOUNDARIES);
PA_ADD_OPTION(GO_HOME_WHEN_DONE);
@@ -153,11 +164,13 @@ void connect_controller(ConsoleHandle& console, ProControllerContext& context, c
require_player(console, context, BUTTON_L);
}
-// PLZA's game for a run on `story`, pausing at `breakpoints` (the
+// PLZA's game for a run on `story` with `starter`, pausing at `breakpoints` (the
// BREAKPOINTS option): before each step, or each leg too, where a lab build
// waits for the user (Pokemon_StoryBreakpoints.h).
-StoryGame run_game(StoryEnv& story, const StoryData& data, StoryBreakpoints breakpoints, CancellableScope& scope){
- StoryGame game = make_plza_story_game(story, data.autosaves);
+StoryGame run_game(
+ StoryEnv& story, StarterChoice starter, const StoryData& data, StoryBreakpoints breakpoints, CancellableScope& scope
+){
+ StoryGame game = make_plza_story_game(story, starter, data.autosaves);
game.breakpoints = breakpoints;
game.pause_point = make_story_pause_hook(scope);
return game;
@@ -190,7 +203,7 @@ void AutoStory::program(SingleSwitchProgramEnvironment& env, ProControllerContex
.env = env, .context = context, .language = LANGUAGE, .battle_ai = BATTLE_AI
};
PlzaConsoleBackend backend(story);
- const StoryGame game = run_game(story, story_data, RUN.breakpoints(), context);
+ const StoryGame game = run_game(story, STARTER, story_data, RUN.breakpoints(), context);
StoryEngine engine(game, backend);
RunState state;
load_start_save(env.console, game, backend, rows, first);
diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStory.h b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStory.h
index 5d1c144629..154fb7b404 100644
--- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStory.h
+++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStory.h
@@ -57,6 +57,7 @@ class AutoStory : public SingleSwitchProgramInstance{
// The start and end checkpoints, attempts and checks. Its own language
// dropdown is hidden: LANGUAGE above is PLZA's.
Pokemon::StoryRunOptions RUN;
+ EnumDropdownOption STARTER;
BattleAIOption BATTLE_AI;
// Off: a run of several checkpoints runs straight on at the rows whose
// plans say "reload_when_chained"; on: it reloads the save there.
diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryBackend.h b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryBackend.h
index 9989979198..6b04cca52e 100644
--- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryBackend.h
+++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryBackend.h
@@ -41,6 +41,14 @@ namespace NintendoSwitch{
namespace PokemonLZA{
+// The starters Mission 1 offers. The player picks one by walking up to it
+// and talking to it.
+enum class StarterChoice{
+ CHIKORITA,
+ TEPIG,
+ TOTODILE,
+};
+
// The console a run plays on, for the actions only a console can do
// (menus, OCR, the battle AI).
struct StoryEnv{
diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryEngine_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryEngine_Tests.cpp
index b4af8fe9b1..2485e6034c 100644
--- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryEngine_Tests.cpp
+++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryEngine_Tests.cpp
@@ -2,13 +2,12 @@
*
* From: https://github.com/PokemonAutomation/
*
- * The new game's scene steps, the walks' compass turns, and every checkpoint, through the shared
+ * The new game's and 01.01's scene steps and walks, and every checkpoint, through the shared
* story engine on its scripted backend (FakeStoryBackend).
*
*/
#include
-#include
#include
#include
#include
@@ -83,7 +82,7 @@ StoryCheckpoint step_of(std::string_view id, std::string_view name){
// `checkpoint` on PLZA's engine over `backend`.
Pokemon::StoryEngineReport run_plza(FakeBackend& backend, const StoryCheckpoint& checkpoint){
- const Pokemon::StoryGame game = make_offline_plza_story_game();
+ const Pokemon::StoryGame game = make_plza_story_game(StarterChoice::CHIKORITA);
Pokemon::StoryEngine engine(game, backend);
Pokemon::RunState state;
return engine.run_checkpoint(checkpoint, Pokemon::SavePoint::RUN_END, state);
@@ -139,6 +138,74 @@ UnitTestResult test_opening_waits_for_platform(CancellableScope& scope){
return expect_inputs(backend, std::vector(6, "wait 300ms"));
}
+// 01.01's start check: one look at the platform is not enough, and with
+// no platform it fails within its 10 s, pressing nothing.
+UnitTestResult test_start_check_needs_platform(CancellableScope& scope){
+ FakeBackend backend = fake_plza({
+ with_reading(look_at(0ms), PLATFORM_READING),
+ look_at(500ms),
+ }, scope);
+ const Pokemon::StoryEngineReport report = run_plza(backend, step_of("01.01", "on_platform"));
+ if (report.run.completed || report.run.failure.failure != "platform_not_seen"){
+ return std::format("Expected platform_not_seen, got {}", to_string(report.run.failure));
+ }
+ for (const std::string& input : backend.inputs()){
+ if (input != "wait 300ms"){
+ return std::format("Expected only waits, got {}", input);
+ }
+ }
+ return true;
+}
+
+// A walk starts only on free control: platform_to_plaza on a text box
+// waits for it, then fails with no input but its waits.
+UnitTestResult test_walk_needs_free_control(CancellableScope& scope){
+ FakeBackend backend = fake_plza({look_at(0ms, {EngineEvent::DIALOG_BOX})}, scope);
+ const Pokemon::StoryEngineReport report = run_plza(backend, step_of("01.01", "platform_to_plaza"));
+ if (report.run.completed || report.run.failure.failure != "walk_not_free"){
+ return std::format("Expected walk_not_free, got {}", to_string(report.run.failure));
+ }
+ for (const std::string& input : backend.inputs()){
+ if (input != "wait 250ms"){
+ return std::format("Expected only waits, got {}", input);
+ }
+ }
+ return true;
+}
+
+// platform_to_plaza: the first leg, the turn (L, the stick tapped at 90
+// degrees) and L again, then the last leg held in slices until the white
+// fade.
+UnitTestResult test_walk_ends_on_white_fade(CancellableScope& scope){
+ FakeBackend backend = fake_plza({
+ look_at(0ms), look_at(150ms),
+ look_at(12000ms), look_at(12250ms), look_at(12500ms, {EngineEvent::FADE_WHITE}),
+ }, scope);
+ const Pokemon::StoryEngineReport report = run_plza(backend, step_of("01.01", "platform_to_plaza"));
+ if (report.verdict != Pokemon::CheckpointVerdict::PASSED){
+ return std::format("Expected the walk to end on the white fade: {}", to_string(report.run.failure));
+ }
+ return expect_inputs(backend, {
+ "wait 250ms", "hold north 4500ms walk", "press L", "stick 90deg 150ms walk, release 100ms", "press L",
+ "hold north 250ms walk", "hold north 250ms walk", "hold north 250ms walk",
+ });
+}
+
+// platform_to_plaza with no white fade fails once the last leg's 10 s are
+// held: 40 slices.
+UnitTestResult test_walk_fails_at_bound(CancellableScope& scope){
+ FakeBackend backend = fake_plza({look_at(0ms)}, scope);
+ const Pokemon::StoryEngineReport report = run_plza(backend, step_of("01.01", "platform_to_plaza"));
+ if (report.run.completed || report.run.failure.failure != "walk_no_end"){
+ return std::format("Expected walk_no_end, got {}", to_string(report.run.failure));
+ }
+ const size_t slices = (size_t)std::count(backend.inputs().begin(), backend.inputs().end(), "hold north 250ms walk");
+ if (slices != 40){
+ return std::format("Expected 40 slices of 250 ms, held {}.", slices);
+ }
+ return true;
+}
+
// The opening ends on "Your train has arrived in Lumiose City!", a text box
// with the advance arrow that waits for A (console B, 2026-11-13: the run
// waited 100 s on it and failed platform_not_seen; one A by hand went on to
@@ -197,6 +264,180 @@ UnitTestResult test_face_heading(CancellableScope& scope){
return expect_inputs(blind, {});
}
+// Pancham cornered (text_to_choice): B through the text, done at the
+// choice without pressing it.
+UnitTestResult test_text_to_choice(CancellableScope& scope){
+ const Observation choice = look_at(2000ms, {EngineEvent::DIALOG_BOX, EngineEvent::CHOICE_BOX});
+ FakeBackend backend = fake_plza({look_at(0ms, {EngineEvent::DIALOG_BOX}), choice}, scope);
+ const Pokemon::StoryEngineReport report = run_plza(backend, step_of("01.02", "pancham_cornered"));
+ if (report.verdict != Pokemon::CheckpointVerdict::PASSED){
+ return std::format("Expected the scene to end at the choice: {}", to_string(report.run.failure));
+ }
+ return expect_inputs(backend, {"press B"});
+}
+
+// 01.01's arrival scenes (mash_to_move_hints): A at the text and at the
+// choice (its top row), one blind A in a 20 s text-free flyover, done
+// once the controls hint has shown a second.
+UnitTestResult test_arrival_ends_on_controls_hint(CancellableScope& scope){
+ FakeBackend backend = fake_plza({
+ look_at(0ms, {EngineEvent::DIALOG_BOX}),
+ look_at(1000ms),
+ look_at(21000ms),
+ look_at(22000ms, {EngineEvent::DIALOG_BOX, EngineEvent::CHOICE_BOX}),
+ look_at(23000ms),
+ with_reading(look_at(24000ms), CONTROLS_HINT_READING),
+ with_reading(look_at(24500ms), CONTROLS_HINT_READING),
+ with_reading(look_at(25100ms), CONTROLS_HINT_READING),
+ }, scope);
+ const Pokemon::StoryEngineReport report = run_plza(backend, step_of("01.01", "arrival_scenes"));
+ if (report.verdict != Pokemon::CheckpointVerdict::PASSED){
+ return std::format("Expected the scenes to end on the controls hint: {}", to_string(report.run.failure));
+ }
+ const auto presses = std::count_if(backend.inputs().begin(), backend.inputs().end(), [](const std::string& input){
+ return input.starts_with("press");
+ });
+ const auto a_presses = std::count(backend.inputs().begin(), backend.inputs().end(), "press A");
+ if (presses != 3 || a_presses != 3){
+ return std::format("Expected A at the text, once in the flyover and at the choice, got [{}].", joined(backend.inputs()));
+ }
+ return true;
+}
+
+// 01.01's ad (run 2, 2026-11-10 13:28): subtitles with no box. A at each
+// advance chevron, a blind A once nothing has shown for 5 s, none once
+// the controls hint shows; done when it has shown a second.
+// 01.02's battle area (console B, 2026-11-10 14:53): A at the text, a
+// fade, then free control with only the "A: Talk" prompt, no controls
+// hint. The prompt held a second ends the step; no press at it.
+UnitTestResult test_battle_area_ends_on_interact_prompt(CancellableScope& scope){
+ FakeBackend backend = fake_plza({
+ look_at(0ms, {EngineEvent::DIALOG_BOX}),
+ look_at(1000ms, {EngineEvent::FADE_BLACK}),
+ look_at(3000ms),
+ look_at(3250ms, {EngineEvent::INTERACT_PROMPT}),
+ look_at(3750ms, {EngineEvent::INTERACT_PROMPT}),
+ look_at(4300ms, {EngineEvent::INTERACT_PROMPT}),
+ }, scope);
+ const Pokemon::StoryEngineReport report = run_plza(backend, step_of("01.02", "battle_area"));
+ if (report.verdict != Pokemon::CheckpointVerdict::PASSED){
+ return std::format("Expected the battle area to end on the interact prompt: {}", to_string(report.run.failure));
+ }
+ std::vector presses;
+ std::copy_if(backend.inputs().begin(), backend.inputs().end(), std::back_inserter(presses), [](const std::string& input){
+ return input.starts_with("press");
+ });
+ if (presses != std::vector{"press A"}){
+ return std::format("Expected one A at the text, got [{}].", joined(backend.inputs()));
+ }
+ return true;
+}
+
+UnitTestResult test_arrival_presses_through_the_ad(CancellableScope& scope){
+ FakeBackend backend = fake_plza({
+ look_at(0ms),
+ with_reading(look_at(1000ms), ADVANCE_ARROW_READING),
+ with_reading(look_at(2000ms), ADVANCE_ARROW_READING),
+ look_at(2500ms),
+ look_at(6000ms),
+ look_at(7100ms),
+ with_reading(look_at(8000ms), CONTROLS_HINT_READING),
+ with_reading(look_at(8500ms), CONTROLS_HINT_READING),
+ with_reading(look_at(9100ms), CONTROLS_HINT_READING),
+ }, scope);
+ const Pokemon::StoryEngineReport report = run_plza(backend, step_of("01.01", "arrival_scenes"));
+ if (report.verdict != Pokemon::CheckpointVerdict::PASSED){
+ return std::format("Expected the ad to end on the controls hint: {}", to_string(report.run.failure));
+ }
+ std::vector presses;
+ std::copy_if(backend.inputs().begin(), backend.inputs().end(), std::back_inserter(presses), [](const std::string& input){
+ return input.starts_with("press");
+ });
+ if (presses != std::vector{"press A", "press A", "press A"}){
+ return std::format("Expected A at the two chevrons and one blind A, got [{}].", joined(backend.inputs()));
+ }
+ return true;
+}
+
+// 01.01's arrival (run 3, 2026-11-10 13:49): A at the last box, then the
+// "MAIN MISSION 01" banner on two looks ends the step, which returns
+// once the banner has gone, with no press at it. A banner still up after
+// 10 s (01.03's "MAIN MISSION 02", console B 2026-11-10) gets A 3 times,
+// then the step returns all the same.
+UnitTestResult test_arrival_ends_on_mission_banner(CancellableScope& scope){
+ for (const bool goes : {true, false}){
+ std::vector> looks{
+ look_at(0ms, {EngineEvent::DIALOG_BOX}),
+ look_at(500ms),
+ with_reading(look_at(1000ms), MISSION_BANNER_READING),
+ with_reading(look_at(1250ms), MISSION_BANNER_READING),
+ with_reading(look_at(1500ms), MISSION_BANNER_READING),
+ };
+ if (goes){
+ looks.push_back(look_at(4000ms));
+ }
+ FakeBackend backend = fake_plza(std::move(looks), scope);
+ const Pokemon::StoryEngineReport report = run_plza(backend, step_of("01.01", "arrival_scenes"));
+ if (report.verdict != Pokemon::CheckpointVerdict::PASSED){
+ return std::format("Expected the scenes to end on the mission banner: {}", to_string(report.run.failure));
+ }
+ const auto presses = std::count_if(backend.inputs().begin(), backend.inputs().end(), [](const std::string& input){
+ return input.starts_with("press");
+ });
+ const auto expected = goes ? 1 : 4;
+ if (presses != expected){
+ return std::format("Expected {} A presses, got [{}].", expected, joined(backend.inputs()));
+ }
+ }
+ return true;
+}
+
+// 01.03's after_andi (console B, 2026-11-10): A at the box, A at each
+// look at the "MAIN MISSION 01 COMPLETE" card, then "MAIN MISSION 02" on
+// two looks ends the step. A banner that goes by itself gets no press; one
+// that stays past 10 s gets A 3 times.
+UnitTestResult test_after_andi_presses_complete_card(CancellableScope& scope){
+ for (const bool goes : {true, false}){
+ std::vector> looks{
+ look_at(0ms, {EngineEvent::DIALOG_BOX}),
+ with_reading(look_at(500ms), MISSION_COMPLETE_READING),
+ with_reading(look_at(1000ms), MISSION_COMPLETE_READING),
+ look_at(1500ms),
+ with_reading(look_at(2000ms), MISSION_BANNER_READING),
+ with_reading(look_at(2250ms), MISSION_BANNER_READING),
+ };
+ if (goes){
+ looks.push_back(look_at(2500ms));
+ }
+ FakeBackend backend = fake_plza(std::move(looks), scope);
+ const Pokemon::StoryEngineReport report = run_plza(backend, step_of("01.03", "after_andi"));
+ if (report.verdict != Pokemon::CheckpointVerdict::PASSED){
+ return std::format("Expected after_andi to end on the mission banner: {}", to_string(report.run.failure));
+ }
+ const auto presses = std::count_if(backend.inputs().begin(), backend.inputs().end(), [](const std::string& input){
+ return input.starts_with("press");
+ });
+ const auto expected = goes ? 3 : 6;
+ if (presses != expected){
+ return std::format("Expected {} A presses (the box, the card twice, the banner if it stays), got [{}].",
+ expected, joined(backend.inputs()));
+ }
+ }
+ return true;
+}
+
+// 01.01's arrival scenes: a minute with nothing busy and no controls hint
+// (a text-free cutscene, or control the detectors miss) fails the step
+// instead of taking it for control.
+UnitTestResult test_arrival_quiet_fails(CancellableScope& scope){
+ FakeBackend backend = fake_plza({look_at(0ms), look_at(30000ms), look_at(61000ms)}, scope);
+ const Pokemon::StoryEngineReport report = run_plza(backend, step_of("01.01", "arrival_scenes"));
+ if (report.verdict == Pokemon::CheckpointVerdict::PASSED || report.run.failure.failure != "scene_quiet"){
+ return std::format("Expected a quiet minute to fail as scene_quiet, got {}", to_string(report.run.failure));
+ }
+ return true;
+}
+
// What PLZA refuses: console actions fail as console_only off a console,
// and tile walks and unknown actions fail the lint.
UnitTestResult test_refused_steps(CancellableScope& scope){
@@ -311,7 +552,7 @@ BoundaryRun run_boundary(
looks.push_back(platform[i] ? with_reading(look, PLATFORM_READING) : look);
}
FakeBackend backend = fake_plza(std::move(looks), scope);
- Pokemon::StoryGame game = make_offline_plza_story_game();
+ Pokemon::StoryGame game = make_plza_story_game(StarterChoice::CHIKORITA);
BoundaryRun run;
game.reload = [&run](Pokemon::StoryBackend& backend){
run.reloads++;
@@ -449,7 +690,7 @@ UnitTestResult test_walk_to_prompt(CancellableScope& scope){
// step's own pause, each labelled with the leg's turn and walk.
UnitTestResult test_walk_pauses_before_each_leg(CancellableScope& scope){
std::vector pauses;
- Pokemon::StoryGame game = make_offline_plza_story_game();
+ Pokemon::StoryGame game = make_plza_story_game(StarterChoice::CHIKORITA);
game.breakpoints = Pokemon::StoryBreakpoints::LEGS;
game.pause_point = [&pauses](std::string_view label){
pauses.emplace_back(label);
@@ -510,7 +751,18 @@ class Test_AutoStoryEngine : public UnitTest{
const EngineTestCase ENGINE_TEST_CASES[] = {
{.name = "01.00 opening: no presses, done on two looks at the platform after the autosave", .input = {.body = test_opening_waits_for_platform}, .expectation = {}},
{.name = "01.00 opening: one A at the arrival text with the advance arrow", .input = {.body = test_opening_presses_through_arrival_text}, .expectation = {}},
+ {.name = "01.01 start check: fails without the platform", .input = {.body = test_start_check_needs_platform}, .expectation = {}},
+ {.name = "01.01 text_to_choice: B through the text, done at the choice", .input = {.body = test_text_to_choice}, .expectation = {}},
+ {.name = "01.01 arrival_scenes: A through text and choice, done on the controls hint", .input = {.body = test_arrival_ends_on_controls_hint}, .expectation = {}},
+ {.name = "01.01 arrival_scenes: A through the ad's boxless subtitles", .input = {.body = test_arrival_presses_through_the_ad}, .expectation = {}},
+ {.name = "01.01 arrival_scenes: done on the mission banner once it has gone, A if it stays", .input = {.body = test_arrival_ends_on_mission_banner}, .expectation = {}},
+ {.name = "01.03 after_andi: A at the mission complete card, then the banner, A if it stays", .input = {.body = test_after_andi_presses_complete_card}, .expectation = {}},
+ {.name = "01.01 arrival_scenes: a quiet minute without the hint fails", .input = {.body = test_arrival_quiet_fails}, .expectation = {}},
+ {.name = "01.02 battle_area: done on the \"A: Talk\" prompt", .input = {.body = test_battle_area_ends_on_interact_prompt}, .expectation = {}},
{.name = "face_heading: turns by the minimap's heading", .input = {.body = test_face_heading}, .expectation = {}},
+ {.name = "01.01 platform_to_plaza: no walk without free control", .input = {.body = test_walk_needs_free_control}, .expectation = {}},
+ {.name = "01.01 platform_to_plaza: ends on the white fade", .input = {.body = test_walk_ends_on_white_fade}, .expectation = {}},
+ {.name = "01.01 platform_to_plaza: fails at its bound", .input = {.body = test_walk_fails_at_bound}, .expectation = {}},
{.name = "refused: console actions off a console, tile walks, unknown actions", .input = {.body = test_refused_steps}, .expectation = {}},
{.name = "every checkpoint runs in step order, testing never saves", .input = {.body = test_every_checkpoint_runs}, .expectation = {}},
{.name = "reload_when_chained: reload between the rows, as its own event", .input = {.body = test_reload_when_chained}, .expectation = {}},
diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.cpp b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.cpp
index 3eb56af153..95efb41a6f 100644
--- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.cpp
+++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.cpp
@@ -73,6 +73,12 @@ const std::map>& console_game_actions(){
{"confirm_new_game", [](StoryEnv& env){ confirm_new_game_choices(env.env.console, env.context); }},
{"choose_0", [](StoryEnv& env){ choose_dialog_option(env.env.console, env.context, 0); }},
{"choose_1", [](StoryEnv& env){ choose_dialog_option(env.env.console, env.context, 1); }},
+ {"story_battle_start", [](StoryEnv& env){
+ mash_scene(env.env.console, env.context, SceneMashGoal::BATTLE, BUTTON_A, 90s);
+ }},
+ {"story_battle", [](StoryEnv& env){
+ fight_battle_in_progress(env.env, env.env.console, env.context, env.battle_ai, 120s);
+ }},
};
return actions;
}
@@ -119,6 +125,15 @@ StoryActionSpec walk_spec(){
});
}
+// "approach_starter": the walk to each starter, by the starter's key.
+StoryActionSpec approach_starter_spec(){
+ std::vector args;
+ for (StarterChoice starter : STARTER_CHOICES){
+ args.push_back(legs_arg(std::string(starter_key(starter)), false, "the walk to this starter, as a walk's legs"));
+ }
+ return game_spec("approach_starter", std::move(args));
+}
+
// Builds the handlers. The console actions hold the console; without one
@@ -126,8 +141,9 @@ StoryActionSpec walk_spec(){
// refuses them before their handler.
class PlzaHandlers{
public:
- explicit PlzaHandlers(StoryEnv* env)
+ PlzaHandlers(StoryEnv* env, StarterChoice starter)
: m_env(env)
+ , m_starter(starter)
{
if (m_env != nullptr){
m_heading = heading_reader(*m_env);
@@ -167,6 +183,22 @@ class PlzaHandlers{
};
}
+ // "approach_starter": the walk to the run's starter, from the arg of
+ // its name. A starter with no walk is not implemented.
+ Handler approach_starter() const{
+ return [heading = m_heading, starter = m_starter](
+ Pokemon::StoryBackend& backend, const StoryActionCall& call, Pokemon::RunState& state
+ ){
+ const std::string_view key = starter_key(starter);
+ if (!call.args.contains(key)){
+ return not_implemented("approach_starter", std::format(
+ "the walk to {}: only Chikorita's was recorded (console B, 2026-11-08).", key
+ ))(backend, call, state);
+ }
+ return walk_legs(backend, call, story_walk_move(call.args, key), heading);
+ };
+ }
+
static Handler not_implemented(std::string name, std::string todo){
return [name = std::move(name), todo = std::move(todo)](
Pokemon::StoryBackend& backend, const StoryActionCall&, Pokemon::RunState&
@@ -230,6 +262,7 @@ class PlzaHandlers{
}
StoryEnv* m_env;
+ StarterChoice m_starter;
// The compass for the walks; none without a console, where a look
// carries its own heading.
PlzaReader m_heading;
@@ -352,6 +385,7 @@ using HandlerOf = Handler (*)(const PlzaHandlers& handlers);
const std::map>& story_game_actions(){
static const std::map> actions{
{"walk", [](const PlzaHandlers& handlers){ return handlers.walk(); }},
+ {"approach_starter", [](const PlzaHandlers& handlers){ return handlers.approach_starter(); }},
{"mash_to_move_hints", [](const PlzaHandlers&){ return PlzaHandlers::move_hints(); }},
{"text_to_choice", [](const PlzaHandlers&){ return PlzaHandlers::text_to_choice(); }},
{"wait_for_platform", [](const PlzaHandlers&){ return platform_handler(PlatformWait::PLATFORM_ONLY); }},
@@ -439,8 +473,8 @@ const Pokemon::StoryActionRegistry& spec_registry(){
}
// PLZA's actions over `env` (none: no console), with no save or reload.
-Pokemon::StoryGame plza_game_actions(StoryEnv* env){
- const PlzaHandlers handlers(env);
+Pokemon::StoryGame plza_game_actions(StoryEnv* env, StarterChoice starter){
+ const PlzaHandlers handlers(env, starter);
Pokemon::StoryGame game;
game.id = "plza";
for (StoryActionSpec& spec : plza_story_action_specs()){
@@ -484,6 +518,7 @@ std::vector plza_story_action_specs(){
specs.push_back(console_only(game_spec(name)));
}
specs.push_back(walk_spec());
+ specs.push_back(approach_starter_spec());
for (const auto& [name, todo] : story_actions_not_implemented()){
specs.push_back(game_spec(name));
}
@@ -520,9 +555,9 @@ StoryMove story_walk_move(const StoryActionArgs& args, std::string_view legs){
}
Pokemon::StoryGame make_plza_story_game(
- StoryEnv& env, std::set> autosave_rows
+ StoryEnv& env, StarterChoice starter, std::set> autosave_rows
){
- Pokemon::StoryGame game = plza_game_actions(&env);
+ Pokemon::StoryGame game = plza_game_actions(&env, starter);
// Slow, and it throws without the minimap: never after a checkpoint.
game.readers.push_back({
.name = std::string(Pokemon::STORY_HEADING), .supplies = {std::string(Pokemon::STORY_HEADING)},
@@ -550,8 +585,8 @@ Pokemon::StoryGame make_plza_story_game(
return game;
}
-Pokemon::StoryGame make_offline_plza_story_game(){
- return plza_game_actions(nullptr);
+Pokemon::StoryGame make_plza_story_game(StarterChoice starter){
+ return plza_game_actions(nullptr, starter);
}
diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.h b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.h
index 94216e4eee..d756c82469 100644
--- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.h
+++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.h
@@ -54,14 +54,19 @@ const std::map>& story_actions_not_impleme
// reads them; "end", "fade_white" or "fade_black"; "heading"),
// walked once the screen shows free control
// (check_can_walk()), until its end fade if it has one
-// (walk_until()); the platform waits "wait_for_platform" and
+// (walk_until()); "approach_starter" (args "chikorita",
+// "tepig", "totodile", each a walk's legs: the run's starter's
+// is walked as "walk" would, a starter with none is not
+// implemented); the platform waits "wait_for_platform" and
// "opening_to_platform"; the scene machines
// "mash_to_move_hints" (args min_length_ms, quiet_ms) and
// "text_to_choice" (run_scene_machine()); a console step, one
// call through the game's own screens with no args:
// "confirm_new_game" (01.00, on "Confirm Choices");
// "choose_0" / "choose_1" (that row of the choices on screen);
-// or an action of story_actions_not_implemented()
+// "story_battle_start" (A to the battle), "story_battle"
+// (attack until a dialog shows); or an action of
+// story_actions_not_implemented()
//
// Every action that works through the game's own screens is console_only.
// BATTLE is the built-in "fight" (the backend's battle), SAVE the
@@ -79,25 +84,26 @@ const std::vector& plza_story_specs();
// (plza_step_arg_errors(), PokemonLZA_AutoStoryStepValidator.h).
std::vector plza_story_lint(const Pokemon::StoryCheckpoint& checkpoint);
-// The walk of `args`: the legs of its arg `legs` ("legs" for a walk), each [turn in degrees clockwise
+// The walk of `args`: the legs of its arg `legs` ("legs" for a walk, the
+// starter's key for approach_starter), each [turn in degrees clockwise
// (negative: left), walk ms], and its "heading", if any. The args must
// have passed plza_story_lint().
StoryMove story_walk_move(const Pokemon::StoryActionArgs& args, std::string_view legs);
// PLZA as a StoryGame on the console `env`, which must outlive it.
-// The walks read the
+// `starter` is the one approach_starter walks to; the walks read the
// compass with heading_reader(). The save waits out the game's autosave at
// the end of the checkpoints of `autosave_rows` (the run's
// StoryData::autosaves) and saves through the menu after the others; the
// reload resets the game from HOME.
Pokemon::StoryGame make_plza_story_game(
- StoryEnv& env, std::set> autosave_rows
+ StoryEnv& env, StarterChoice starter, std::set> autosave_rows
);
// The same with no console, for tests and simulations: the console_only
// actions fail as "console_only", the walks read the heading the looks
// carry, and there is no save or reload.
-Pokemon::StoryGame make_offline_plza_story_game();
+Pokemon::StoryGame make_plza_story_game(StarterChoice starter);
// `rows` in order from the save the game is on, as
// StoryEngine::run_segment() runs them, `policy`'s attempts per checkpoint.
diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStorySceneMachine_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStorySceneMachine_Tests.cpp
index 524be158e1..0162797a2c 100644
--- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStorySceneMachine_Tests.cpp
+++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStorySceneMachine_Tests.cpp
@@ -320,6 +320,33 @@ UnitTestResult test_to_battle(Logger&){
});
}
+// platform_to_plaza is the walk that ends on an event (the white fade),
+// and every walk that ends on one holds a last leg that walks.
+UnitTestResult test_move_ends(Logger&){
+ std::vector ending;
+ for (const Pokemon::StoryCheckpoint& row : story_checkpoints()){
+ for (const Pokemon::StoryStep& step : row.steps){
+ const auto end = step.args.find("end");
+ if (step.action != "walk" || end == step.args.end()){
+ continue;
+ }
+ ending.push_back(step.name);
+ const StoryMove move = story_walk_move(step.args, "legs");
+ if (move.legs.empty() || move.legs.back().walk <= 0ms){
+ return std::format("{}: its last leg has no walk to hold until the event.", step.name);
+ }
+ const std::string& fade = std::get(end->second);
+ if (fade != "fade_white" && fade != "fade_black"){
+ return std::format("{}: ends on {}, not a fade.", step.name, fade);
+ }
+ }
+ }
+ if (ending != std::vector{"platform_to_plaza"}){
+ return std::format("Expected only platform_to_plaza to end on an event, {} do.", ending.size());
+ }
+ return true;
+}
+
struct SceneMachineCase{
std::string name;
@@ -415,6 +442,11 @@ const SceneMachineCase SCENE_MACHINE_CASES[] = {
.input = {.body = test_state_actions},
.expectation = {},
},
+ {
+ .name = "walks that end on a fade",
+ .input = {.body = test_move_ends},
+ .expectation = {},
+ },
};
void add_tests_AutoStorySceneMachine(UnitTestDatabase& database){
diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.cpp b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.cpp
index af63154803..d4293f605c 100644
--- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.cpp
+++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.cpp
@@ -45,9 +45,39 @@ void add_legs_errors(std::string_view step, std::string_view key, const TimedLeg
}
}
+// What is wrong with an "approach_starter" step's walks: it needs one.
+std::vector starter_walk_errors(const Pokemon::StoryStep& step){
+ std::vector errors;
+ bool any = false;
+ for (StarterChoice starter : STARTER_CHOICES){
+ const auto legs = step.args.find(starter_key(starter));
+ if (legs != step.args.end()){
+ any = true;
+ add_legs_errors(step.name, legs->first, std::get(legs->second), errors);
+ }
+ }
+ if (!any){
+ errors.push_back(std::format("{}: no walk to any starter", step.name));
+ }
+ return errors;
+}
+
} // namespace
+// approach_starter's arg for each starter: the walk to it.
+std::string_view starter_key(StarterChoice starter){
+ switch (starter){
+ case StarterChoice::CHIKORITA:
+ return "chikorita";
+ case StarterChoice::TEPIG:
+ return "tepig";
+ case StarterChoice::TOTODILE:
+ return "totodile";
+ }
+ return "";
+}
+
// A walk's "end" arg as the event it ends on: a fade.
std::optional walk_end_event(std::string_view end){
if (end == "fade_white"){
@@ -59,13 +89,16 @@ std::optional walk_end_event(std::string_view en
return std::nullopt;
}
-// What is wrong with the args of a "walk" step;
+// What is wrong with the args of a "walk" or "approach_starter" step;
// nothing for any other step.
std::vector plza_step_arg_errors(const Pokemon::StoryStep& step){
std::vector errors;
if (step.kind != StoryStepKind::GAME){
return errors;
}
+ if (step.action == "approach_starter"){
+ return starter_walk_errors(step);
+ }
if (step.action != "walk"){
return errors;
}
diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.h b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.h
index fb87f619c5..2206d77d8c 100644
--- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.h
+++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.h
@@ -4,7 +4,7 @@
*
* PLZA's checks of a story step's args beyond their types, which the
* engine's lint (StoryActionRegistry::lint) checks: a walk's legs, its end
- * fade and heading.
+ * fade, wait and heading, and approach_starter's walks.
*
*/
@@ -24,11 +24,17 @@ namespace NintendoSwitch{
namespace PokemonLZA{
+// The starters, in the order approach_starter's args list them.
+inline constexpr StarterChoice STARTER_CHOICES[] = {StarterChoice::CHIKORITA, StarterChoice::TEPIG, StarterChoice::TOTODILE};
+
+// approach_starter's arg for `starter`: the walk to it ("chikorita").
+std::string_view starter_key(StarterChoice starter);
+
// A walk's "end" arg as the event it ends on: "fade_white" or
// "fade_black"; nothing for any other name.
std::optional walk_end_event(std::string_view end);
-// What is wrong with the args of a "walk" step:
+// What is wrong with the args of a "walk" or "approach_starter" step:
// each leg a [turn, ms] pair, turning -180 to 180 degrees and walking 0 ms
// or more, some leg walking; an end a fade, after a leg that walks; a
// heading 0 to 359. Nothing for any other step.
diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStoryFiles.h b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStoryFiles.h
index c4f7d917df..ec725f3860 100644
--- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStoryFiles.h
+++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStoryFiles.h
@@ -42,8 +42,9 @@ StoryData load_story_data(std::span dev_files);
const StoryData& builtin_story_data();
// The built-in story (load_story_data() with no dev files), read once:
-// what the tests, the lint and the program's dropdowns use. The first,
-// 01.00, plays a new game to the station platform without a save, from
+// what the tests, the lint and the program's dropdowns use: 01.xx Main
+// Mission 01 (new game, Pancham, the starter). Only the first, 01.00,
+// starts without a save: it plays a new game to the station platform from
// the new game's "Confirm Choices", its choices made by hand.
const std::vector& story_checkpoints();
diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryTable.h b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryTable.h
index 5037fb1188..43e3b8a5bd 100644
--- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryTable.h
+++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryTable.h
@@ -11,7 +11,8 @@
* legs: a relative turn and a walk time each (PokemonLZA_AutoStoryGame.h).
*
* Recorded 2026-11-08/09 on console B, played step by step from a new
- * game. Every walk was measured walking, not dashing. Steps the game
+ * game through Main Mission 01. Every walk was measured walking, not
+ * dashing. Steps the game
* has no code for yet are GAME steps of story_actions_not_implemented().
*
* This is the story as data, with no IO: the checkpoint files it is read
diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryTable_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryTable_Tests.cpp
index 7584f5fdbd..6eb2cdb24c 100644
--- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryTable_Tests.cpp
+++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryTable_Tests.cpp
@@ -54,6 +54,60 @@ UnitTestResult test_story_table_lints(Logger&){
return true;
}
+// The step `name` of checkpoint `id` in `checkpoints`; null if none.
+const StoryStep* find_step(const std::vector& checkpoints, std::string_view id, std::string_view name){
+ for (const StoryCheckpoint& row : checkpoints){
+ for (const StoryStep& step : row.steps){
+ if (row.id == id && step.name == name){
+ return &step;
+ }
+ }
+ }
+ return nullptr;
+}
+
+// `move`'s legs as [turn, ms] pairs, for messages and comparisons.
+std::vector> leg_pairs(const StoryMove& move){
+ std::vector> pairs;
+ for (const StoryWalkLeg& leg : move.legs){
+ pairs.emplace_back((int)leg.turn, leg.walk.count());
+ }
+ return pairs;
+}
+
+// Every walk reads as a move with legs (its args passed the lint), and
+// platform_to_plaza reads as recorded, ending on the white fade.
+UnitTestResult test_story_walks_read(Logger&){
+ size_t walks = 0;
+ for (const StoryCheckpoint& row : story_checkpoints()){
+ for (const StoryStep& step : row.steps){
+ if (step.kind != StoryStepKind::GAME || step.action != "walk"){
+ continue;
+ }
+ walks++;
+ if (story_walk_move(step.args, "legs").legs.empty()){
+ return std::format("{} {}: no legs.", row.id, step.name);
+ }
+ }
+ }
+ if (walks != 2){
+ return std::format("Expected the 2 recorded walks, found {}.", walks);
+ }
+ const StoryStep* plaza = find_step(story_checkpoints(), "01.01", "platform_to_plaza");
+ if (plaza == nullptr){
+ return "Expected 01.01 platform_to_plaza.";
+ }
+ const std::vector> expected{{0, 4500}, {90, 10000}};
+ if (leg_pairs(story_walk_move(plaza->args, "legs")) != expected){
+ return "Expected platform_to_plaza's legs [[0, 4500], [90, 10000]].";
+ }
+ const auto end = plaza->args.find("end");
+ if (end == plaza->args.end() || std::get(end->second) != "fade_white"){
+ return "Expected platform_to_plaza to end on the white fade.";
+ }
+ return true;
+}
+
// Each action that is not implemented says what it waits for, is no move's
// name, and is in a step.
UnitTestResult test_not_implemented_actions(Logger&){
@@ -151,6 +205,19 @@ UnitTestResult test_reload_when_chained_field(Logger&){
return true;
}
+// 01.02 reloads when run after 01.01, whose autosave is 01.02's start;
+// with 01.01 saving through the menu instead, 01.02's reload is refused.
+UnitTestResult test_mm1_reload_when_chained(Logger&){
+ if (!builtin_story_data().reload_when_chained.contains("01.02")){
+ return "Expected 01.02 to reload when chained.";
+ }
+ const std::string problem = load_problem(dev_with_execution("01.01", R"("save": "menu")"));
+ if (problem.find("does not end on the game's autosave") == std::string::npos){
+ return std::format("01.01 saving through the menu: expected 01.02's reload refused, got \"{}\".", problem);
+ }
+ return true;
+}
+
// A run can play every row: none names an action that is not implemented.
UnitTestResult test_every_row_ready(Logger&){
const size_t ready = story_rows_ready(story_checkpoints());
@@ -218,6 +285,100 @@ UnitTestResult test_scene_mash_rule(Logger&){
return true;
}
+// Chikorita's walk is recorded in 01.03's approach_starter, and only hers.
+UnitTestResult test_starter_moves(Logger&){
+ const StoryStep* approach = find_step(story_checkpoints(), "01.03", "approach_starter");
+ if (approach == nullptr || approach->action != "approach_starter"){
+ return "Expected 01.03 approach_starter.";
+ }
+ if (approach->args.contains("tepig") || approach->args.contains("totodile")){
+ return "Expected only Chikorita's walk.";
+ }
+ if (!approach->args.contains("chikorita")){
+ return "Expected the walk to Chikorita.";
+ }
+ const std::vector> expected{{-70, 750}};
+ if (leg_pairs(story_walk_move(approach->args, "chikorita")) != expected){
+ return "Expected Chikorita's walk [[-70, 750]].";
+ }
+ return true;
+}
+
+// The built-in text of checkpoint file `name` ("plza-01.02.plan").
+std::string builtin_text(std::string_view name){
+ for (const auto& [file, text] : autostory_checkpoint_json()){
+ if (file == name){
+ return text;
+ }
+ }
+ return "";
+}
+
+// `text` with its first `from` replaced by `to`.
+std::string replaced(std::string text, std::string_view from, std::string_view to){
+ const size_t at = text.find(from);
+ if (at != std::string::npos){
+ text.replace(at, from.size(), to);
+ }
+ return text;
+}
+
+// The ParseException message of load_story_data() on the one dev file
+// `text`; empty if it loads.
+std::string dev_load_error(std::string_view name, std::string text){
+ const StoryDevFile dev{.name = std::string(name), .path = std::format("/dev/{}", name), .text = std::move(text)};
+ try{
+ load_story_data(std::span(&dev, 1));
+ }catch (ParseException& e){
+ return e.message();
+ }
+ return "";
+}
+
+// A dev file replaces the built-in checkpoint of its name and no other,
+// and is named; a bad one (not JSON, a leg of 3 numbers, a negative walk,
+// an unknown file, another id) fails naming its path.
+UnitTestResult test_dev_override(Logger&){
+ const std::string chase = builtin_text("plza-01.02.plan");
+ const std::string_view legs = "[[-15, 4000], [-75, 3500]";
+ if (chase.find(legs) == std::string::npos){
+ return "Expected chase_pancham's legs in plza-01.02.plan.json.";
+ }
+ const StoryDevFile dev{
+ .name = "plza-01.02.plan.json", .path = "/dev/plza-01.02.plan.json",
+ .text = replaced(chase, legs, "[[-15, 4200], [-75, 3500]"),
+ };
+ const StoryData data = load_story_data(std::span(&dev, 1));
+ if (data.dev_files.size() != 1 || data.dev_files[0].first != dev.name || data.dev_files[0].second != dev.path){
+ return "Expected the dev file to be named with its path.";
+ }
+ if (data.checkpoints.size() != story_checkpoints().size() || data.autosaves != story_autosave_rows()){
+ return "Expected the same rows and autosaves as the built-in story.";
+ }
+ const StoryStep* tuned = find_step(data.checkpoints, "01.02", "chase_pancham");
+ if (tuned == nullptr || leg_pairs(story_walk_move(tuned->args, "legs")).front() != std::pair(-15, 4200)){
+ return "Expected the dev file's first leg, [-15, 4200].";
+ }
+ const StoryStep* plaza = find_step(data.checkpoints, "01.01", "platform_to_plaza");
+ if (plaza == nullptr || leg_pairs(story_walk_move(plaza->args, "legs")).front() != std::pair(0, 4500)){
+ return "Expected 01.01 to stay built-in.";
+ }
+ const std::pair bad[] = {
+ {"plza-01.02.plan.json", "{ not json"},
+ {"plza-01.02.plan.json", replaced(chase, legs, "[[-15, 4000, 1], [-75, 3500]")},
+ {"plza-01.02.plan.json", replaced(chase, legs, "[[-15, -4000], [-75, 3500]")},
+ {"plza-09.99.plan.json", chase},
+ {"plza-01.02.plan.json", replaced(chase, "\"01.02\"", "\"01.09\"")},
+ };
+ for (const auto& [name, text] : bad){
+ const std::string error = dev_load_error(name, text);
+ if (error.find(std::format("/dev/{}", name)) == std::string::npos){
+ return std::format("Expected {} to fail naming its path, got \"{}\".", name, error);
+ }
+ }
+ return true;
+}
+
// The new game's start: 01.00 starts on "Confirm Choices" after the
// choices made by hand, without a save; every later row loads one. A run
@@ -286,11 +447,26 @@ const AutoStoryTableCase AUTO_STORY_TABLE_CASES[] = {
.input = {.body = test_story_table_lints},
.expectation = {},
},
+ {
+ .name = "Story table: every walk reads its legs",
+ .input = {.body = test_story_walks_read},
+ .expectation = {},
+ },
{
.name = "Story table: actions not implemented say what they wait for",
.input = {.body = test_not_implemented_actions},
.expectation = {},
},
+ {
+ .name = "Starters: the walk to Chikorita is recorded",
+ .input = {.body = test_starter_moves},
+ .expectation = {},
+ },
+ {
+ .name = "Dev checkpoints: replace the built-in file of their name, fail naming the file",
+ .input = {.body = test_dev_override},
+ .expectation = {},
+ },
{
.name = "Story table: the autosave rows, and 01.03 saves through the menu",
.input = {.body = test_autosave_rows},
@@ -306,6 +482,11 @@ const AutoStoryTableCase AUTO_STORY_TABLE_CASES[] = {
.input = {.body = test_reload_when_chained_field},
.expectation = {},
},
+ {
+ .name = "reload_when_chained: 01.02 after 01.01's autosave",
+ .input = {.body = test_mm1_reload_when_chained},
+ .expectation = {},
+ },
{
.name = "Scene mash: a scene that never starts fails at its start window",
.input = {.body = test_scene_start_window},
diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.01.plan.json b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.01.plan.json
new file mode 100644
index 0000000000..92358ddafb
--- /dev/null
+++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.01.plan.json
@@ -0,0 +1,45 @@
+{
+ "format": "pokesim-authored-checkpoint/1",
+ "game": "plza",
+ "checkpoint": {
+ "id": "01.01",
+ "title": "The platform to Main Mission 01",
+ "start": {
+ "place": "LumioseCity"
+ },
+ "events": [
+ {
+ "id": "on_platform",
+ "kind": "game_action",
+ "why": "start check: on the station platform with free control, as 01.00 ends",
+ "action": "wait_for_platform",
+ "args": {
+ "timeout_ms": 10000
+ }
+ },
+ {
+ "id": "platform_to_plaza",
+ "kind": "game_action",
+ "why": "steps 6-7: down the platform, then right until the white fade. Measured 2026-11-08 on console B, walk not run. Holds the last leg until the white fade into the arrival scenes; 6000 ms was the recorded walk, which overshot into it.",
+ "action": "walk",
+ "args": {
+ "legs": [[0, 4500], [90, 10000]],
+ "end": "fade_white"
+ }
+ },
+ {
+ "id": "arrival_scenes",
+ "kind": "game_action",
+ "why": "steps 8-10: the white title card (~15 s), the text-free city flyover (~20 s), the starters and the girl, \"You're a tourist?\" (top choice), the ad, Pancham steals the bag; ends on the \"MAIN MISSION 01: get the bag back\" banner (once it has gone), or on the controls hint (free control)",
+ "action": "mash_to_move_hints"
+ }
+ ],
+ "metadata": {
+ "phase": "testing",
+ "source": "console B recording, 2026-11-08/09: played step by step from a new game"
+ }
+ },
+ "execution": {
+ "save": "autosave"
+ }
+}
diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.02.plan.json b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.02.plan.json
new file mode 100644
index 0000000000..6643298e9b
--- /dev/null
+++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.02.plan.json
@@ -0,0 +1,51 @@
+{
+ "format": "pokesim-authored-checkpoint/1",
+ "game": "plza",
+ "checkpoint": {
+ "id": "01.02",
+ "title": "Main Mission 01: chase Pancham to the battle area",
+ "start": {
+ "place": "LumioseCity"
+ },
+ "events": [
+ {
+ "id": "chase_pancham",
+ "kind": "game_action",
+ "why": "step 11: after Pancham, through the archway, around the starters into the scene. NEEDS TUNING. Measured 2026-11-08 on console B, walk not run. The sidestep around the starters had no time recorded: 1000 ms is a placeholder. The first turn is from where the player faces (L first), as from the save; a run from 01.01 reloads the save first (reload_when_chained), since 01.01's scenes leave the player turned to the boy and the chase went the wrong way from there (console B, 2026-11-13).",
+ "action": "walk",
+ "args": {
+ "legs": [[-15, 4000], [-75, 3500], [90, 9000], [-90, 0], [90, 1000], [-90, 4000]]
+ }
+ },
+ {
+ "id": "pancham_cornered",
+ "kind": "game_action",
+ "why": "step 12: the scene up to its choice",
+ "action": "text_to_choice"
+ },
+ {
+ "id": "battle_with_pokemon",
+ "kind": "game_action",
+ "why": "step 12: choose \"Battle with Pokemon!\" (second choice)",
+ "action": "choose_1"
+ },
+ {
+ "id": "battle_area",
+ "kind": "game_action",
+ "why": "step 12: the scene until free control in the battle area; autosave",
+ "action": "mash_to_move_hints",
+ "args": {
+ "min_length_ms": 20000
+ }
+ }
+ ],
+ "metadata": {
+ "phase": "testing",
+ "source": "console B recording, 2026-11-08/09: played step by step from a new game; split from 01.01 at the MAIN MISSION 01 autosave (2026-11-10)"
+ }
+ },
+ "execution": {
+ "save": "autosave",
+ "reload_when_chained": true
+ }
+}
diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.03.plan.json b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.03.plan.json
new file mode 100644
index 0000000000..36bd3ff2ab
--- /dev/null
+++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.03.plan.json
@@ -0,0 +1,52 @@
+{
+ "format": "pokesim-authored-checkpoint/1",
+ "game": "plza",
+ "checkpoint": {
+ "id": "01.03",
+ "title": "Main Mission 01: the starter and Andi",
+ "start": {
+ "place": "LumioseCity"
+ },
+ "events": [
+ {
+ "id": "approach_starter",
+ "kind": "game_action",
+ "why": "step 13: walk up to the starter (only Chikorita's walk was recorded). Ends at the \"A Talk Chikorita\" prompt. Measured 2026-11-08 on console B and checked by hand from the autosave, walk not run as a story step. Only Chikorita's walk is recorded.",
+ "action": "approach_starter",
+ "args": {
+ "chikorita": [[-70, 750]]
+ }
+ },
+ {
+ "id": "talk_to_starter",
+ "kind": "talk",
+ "why": "step 13: A at \"A Talk Chikorita\""
+ },
+ {
+ "id": "andi_battle_start",
+ "kind": "game_action",
+ "why": "steps 14-15: choose it, the pre-battle talk, \"Go! Chikorita!\", the battling tutorial",
+ "action": "story_battle_start"
+ },
+ {
+ "id": "andi_battle",
+ "kind": "game_action",
+ "why": "step 16: beat Andi's Pancham (Lv 6), until Andi's speech",
+ "action": "story_battle"
+ },
+ {
+ "id": "after_andi",
+ "kind": "game_action",
+ "why": "step 17: fist bump, night in the Battle Zone, the Main Mission 02 banner and its autosave; the MAIN MISSION 01 COMPLETE card waits for A (console B, 2026-11-10)",
+ "action": "mash_to_move_hints"
+ }
+ ],
+ "metadata": {
+ "phase": "verification",
+ "source": "console B recording, 2026-11-08/09: played step by step from a new game; split from 01.01 at the MAIN MISSION 01 autosave (2026-11-10); split from 01.02 at the battle area autosave (2026-11-10)"
+ }
+ },
+ "execution": {
+ "save": "menu"
+ }
+}