Repository navigation
Validate saved pending choices in one place - #471
Merged
Merged
Conversation
Game::fromArray() was 306 lines, half of it validation of the saved pending choice with the same continuation checks written out four times. The validation moves unchanged into validateSavedChoice(), and the repeated step and followed-target loops become assertSavedSteps() and assertSavedFollowed(). Error messages and accepted saves are unchanged. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WTP2SqPTWy8sMSFHkDL2C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Val · project thread
Item 4 of the structural review: the saved-continuation validator.
What changed
Game::fromArray()was 306 lines, about half of it validation of the saved pending choice. That validation moves unchanged intoGame::validateSavedChoice();fromArray()is now 155 lines and reads as plain loading.[effect, target]steps" loop was written out four times and the followed-target loop twice. They are nowassertSavedSteps()andassertSavedFollowed(), each taking the caller's error message.What this does not do
The review also suggested one small class per choice kind (validate, options, apply, describe).
OptionalChoices(#469) already covers the seven "you may" kinds that way. The other kinds (look,sacrifice,fabricate,entry_life,scry,discard,mode, …) differ enough that classes for them would be a larger change, and several open PRs add or alter choice kinds, so that part is left for after those land.Verification
Full suite locally: 2591 tests, 2 skipped (the existing missing-import skips). Pint clean.
Game.phppin refreshed withcomposer pins.Generated by Claude Code