Skip to content

AutoStory: share AutoStoryStats, add Runs, clearer labels - #519

Merged
dayfine merged 2 commits into
mainfrom
autostory/shared-stats
Nov 15, 2026
Merged

dayfine merged 2 commits into
mainfrom
autostory/shared-stats

Conversation

@dayfine

@dayfine dayfine commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

SV's AutoStoryStats lived in the SV AutoStory tools header, so the other games' AutoStory programs couldn't reuse it, and its labels (Segment, Checkpoint, Reset) didn't say what was counted. This moves it to Pokemon/AutoStory/Pokemon_AutoStoryStats.h, adds a Runs counter that SV's AutoStory bumps at program start, and renames the labels to Segments Started, Checkpoints Started (SV counts a checkpoint when it saves at its start) and Resets. StatsTracker aliases map the old labels to the new ones, so saved totals carry over. A new Pokemon::AutoStoryStats unit test loads old, new and mixed stats lines; Fork Draft CI builds and runs it.

Move SV's AutoStoryStats to Pokemon/AutoStory/Pokemon_AutoStoryStats.h so
other games' AutoStory programs can use it. Add a Runs counter, counted at
program start. Rename Segment, Checkpoint and Reset to Segments Started,
Checkpoints Passed and Resets, with aliases so saved totals carry over.

@dayfine dayfine left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed SHA: 14c9bff

Verdict

NEEDS_REWORK

One label is wrong. The aliases, the Runs placement and the mechanical renames are fine.

Medium: "Checkpoints Passed" counts checkpoint starts, not checkpoints passed. m_checkpoints_passed++ runs in checkpoint_save() (PokemonSV_AutoStoryTools.cpp:1182) and in the i==0 branch of checkpoint_reattempt_loop_tutorial() (:1505). Both run the save before action(i), so the counter goes up when a checkpoint begins. A run from 03.08 that fails on its first attempt still shows "Checkpoints Passed: 1", and the last checkpoint a run completes is never counted. The old label "Checkpoint" was vague enough to cover this; the new one isn't. The cheap fix is to name it "Checkpoints Started", which also matches "Segments Started" (update the alias target and the test expectations). Moving the increment after action() would change SV's behaviour, so leave that to its own PR if anyone wants it.

Checked, OK:

  • Aliases: parse_and_append_line() stores old labels under their own keys (m_stats["Segment"], ...), and StatsTracker::to_str() folds every aliased key into its target before printing. StatList::aggregate() parses all saved lines into one tracker and prints through to_str(), so old "Segment"/"Checkpoint"/"Reset" totals do show up under the new labels, and saved files are never rewritten. The three test cases cover old, new and mixed lines. The mixed case also covers the comma in 1,234.
  • Runs is counted after the 16:9 / performance-class checks, the test-code early return and the start/end order checks (each of which throws or returns), and before require_player and the settings changes. That's a sensible point: a setup error doesn't count as a run, and anything that touches the game does.
  • All 40 m_segment++ sites were renamed (40 -/40 + lines); no other m_segment/m_checkpoint/m_reset users are left in the tree. ClaimMysteryGift.cpp's unused AutoStoryStats still resolves through the using.
  • Test shape (name / input / expectation, nested) matches the house style. The SourceFiles.cmake entries are present.

Nit: the three blank lines removed in AutoStory::program(). Removing them to stay under code health's function-length limit is metric-gaming, but small: the three lines were a double blank line, a blank line before a closing brace and a whitespace-only line, so the diff is a cleanup anyway. Acceptable. If the function grows again, move the setup checks (or the Runs bump plus update_stats) into a helper rather than deleting more blank lines. The PR description could say why those lines changed.

Counts: 1 medium, 1 nit.

SV bumps the counter in checkpoint_save(), before the checkpoint runs, so it counts checkpoints started.
@dayfine

dayfine commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

Review 5909634093: renamed the label to "Checkpoints Started" (old "Checkpoint" now aliases to it) and the member to m_checkpoints_started, in d93032c. The increment stays where it is, so SV behaviour is unchanged; the stats tests expect the new label. Description updated. The blank-line cleanup is left as is.

@dayfine dayfine left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed SHA: d93032c

Verdict

APPROVED

LGTM. This re-review covers d93032c, the only commit since 14c9bff.

Previous medium (wrong label): fixed. The label is now "Checkpoints Started" and the member is m_checkpoints_started. The change covers the constructor binding, the display order, the Checkpoint alias target and both increment sites in PokemonSV_AutoStoryTools.cpp (checkpoint_save() and the tutorial i==0 branch). The increments stay where they were, so SV's behaviour is unchanged. All three test expectations use the new label. The mixed test case still checks that old Checkpoint: 10 folds into new Checkpoints Started: 5 to give 15. No m_checkpoints_passed or "Checkpoints Passed" is left in the tree. "Checkpoints Passed" never reached main, so it needs no alias. CRLF line endings are kept. The PR description now says why the label reads "Started".

Previous nit (blank lines in AutoStory::program()): left as is, which is fine. Nothing new.

Fork Draft CI (ubuntu build + tests, code-health, no-tabs) is green at this SHA.

Counts: 0 findings.

@dayfine
dayfine marked this pull request as ready for review November 15, 2026 19:15
@dayfine
dayfine merged commit 5cddaa7 into main Nov 15, 2026
10 checks passed
dayfine added a commit that referenced this pull request Nov 15, 2026
dayfine added a commit that referenced this pull request Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant