Skip to content

Drive every optional resolution choice from one table - #469

Merged
valzargaming merged 1 commit into
mainfrom
claude/project-thread-unhs00
Nov 12, 2026
Merged

valzargaming merged 1 commit into
mainfrom
claude/project-thread-unhs00

Conversation

@valzargaming

Copy link
Copy Markdown
Member

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 own applyEffect() case, chooseOptional…() method, saved-state validation branch, panel action, three MatchMessageBuilder entries and PracticeBot case.

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) and Game::canPayOptional($seat, $kind) replace seven choose methods and canPayOptionalRedGoblin().
  • One validator block in Game::fromArray() replaces the nested-ternary version.
  • One panel route, one pair of buttons, one prompt lookup and one bot policy.

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

  • Saved-game format and STATE_VERSION (still 16). No migration is needed.
  • Effect and choice type names, prompts, button labels and error messages.
  • Discord custom ids (maygoblin, mayuntap, …), so buttons on already-sent messages keep working.
  • An answer still names the kind it was meant for, so a control for one kind cannot answer another. The existing cross-effect tests cover this.
  • Practice-bot behavior: accept when payable, never draw from an empty library.

Tests

  • Engine tests call the new method names; assertions are otherwise untouched. MatchesTest panel tests are unchanged.
  • New OptionalChoicesTest checks every entry is complete and its panel action unique.
  • Full suite locally: 2591 tests, 2 skipped (the existing missing-import skips). Pint clean. Source pins refreshed with composer pins; OptionalChoices.php is 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

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
Copilot AI balanced review requested due to automatic review settings November 12, 2026 23:08
@valzargaming valzargaming self-assigned this Nov 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@valzargaming
valzargaming merged commit 63a4855 into main Nov 12, 2026
4 checks passed
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.

3 participants