Repository navigation
Drive every optional resolution choice from one table - #469
Merged
Merged
Conversation
Seven "you may" effect kinds each had their own applyEffect case, choose method, saved-state validation branch, panel action, three message-builder entries and practice-bot case. They are now entries in OptionalChoices, read by one Game::chooseOptional(), one validator, one panel route, one pair of buttons and one bot policy. Saved games, effect and choice type names, Discord custom ids, prompts, error messages and the schema version are unchanged. An answer still names the kind it was meant for, so a control for one kind cannot answer another. 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 2 of the structural review: one generic "you may" effect.
What changed
Seven optional effect kinds (
optional_red_goblin,optional_source_untap,optional_source_counter,optional_death_draw,optional_basic_land_search,optional_life_gain,optional_life_loss) each had their ownapplyEffect()case,chooseOptional…()method, saved-state validation branch, panel action, threeMatchMessageBuilderentries andPracticeBotcase.They are now entries in
MTGPocket\Game\OptionalChoices::KINDS. Each entry holds the kind's cost, effects, source binding, first schema version, error messages, panel action and player-facing text. Everything else reads that table:Game::chooseOptional($seat, $kind, $choiceId, $option)andGame::canPayOptional($seat, $kind)replace seven choose methods andcanPayOptionalRedGoblin().Game::fromArray()replaces the nested-ternary version.src/is 109 lines smaller. A new "you may" kind is now one table entry plus the parser wording that emits it.What did not change
STATE_VERSION(still 16). No migration is needed.maygoblin,mayuntap, …), so buttons on already-sent messages keep working.Tests
MatchesTestpanel tests are unchanged.OptionalChoicesTestchecks every entry is complete and its panel action unique.composer pins;OptionalChoices.phpis added as a pin.Note for open engine PRs: any that add another
optional_*kind should add a table entry instead of a new method.Generated by Claude Code