Skip to content

fix(parser): bind Kentaro alternative cost to mana value - #7325

Merged
matthewevans merged 3 commits into
mainfrom
ship/5899-kentaro-alt-cost
Aug 13, 2026
Merged

fix(parser): bind Kentaro alternative cost to mana value#7325
matthewevans merged 3 commits into
mainfrom
ship/5899-kentaro-alt-cost

Conversation

@matthewevans

@matthewevans matthewevans commented Aug 13, 2026

Copy link
Copy Markdown
Member

Fixes #5899.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed alternative spell costs that use {X} to correctly match the affected spell’s mana value.
    • Casting affected spells now presents the correct alternative cost, avoids duplicate X prompts, and deducts the proper amount of mana.
  • Tests

    • Added parser and integration coverage for Kentaro’s alternative cost behavior.

@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@matthewevans, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 13 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b53d787c-4751-4786-af98-35fc105c9f88

📥 Commits

Reviewing files that changed from the base of the PR and between ad753b7 and f5815dd.

📒 Files selected for processing (1)
  • crates/engine/tests/integration/issue_5899_kentaro_alternative_cost.rs
📝 Walkthrough

Walkthrough

Kentaro’s {X} alternative cost now binds to the affected spell’s mana value. The parser converts this form to SelfManaValue, and casting resolves it before payment. Parser and integration tests cover the corrected flow.

Changes

Kentaro alternative cost

Layer / File(s) Summary
Parse spell-mana-value alternative costs
crates/engine/src/parser/oracle_static/cost_mod.rs, crates/engine/src/parser/oracle_static/tests.rs
The parser recognizes a standalone {X} clause bound to a spell’s mana value and converts it to SelfManaValue. Parser tests cover Kentaro’s Samurai filter and dynamic cost.
Resolve self-referential costs during casting
crates/engine/src/game/casting.rs, crates/engine/src/game/keywords.rs
Granted alternative costs resolve self-referential mana placeholders against the affected spell before affordability and payment. Documentation describes nested AbilityCost resolution.
Validate Kentaro casting behavior
crates/engine/tests/integration/issue_5899_kentaro_alternative_cost.rs, crates/engine/tests/integration/main.rs
The integration test verifies the optional alternative cost, casting completion without a second X prompt, and mana consumption. The test module is registered in the engine suite.

Estimated code review effort: 2 (Simple) | ~15 minutes

Mergeability Score: 🟡 Moderate · up to ad753

The regression test does not distinguish Kentaro’s alternative cost from the spell’s normal cost, so an incorrect cast path could still pass. Merge readiness therefore depends on updating the test to require the colored normal cost to fail while the generic alternative cost succeeds.

Possibly related PRs

Suggested labels: bug

Suggested reviewers: lgray, ntindle, dripsmvcp

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the parser fix that binds Kentaro’s alternative cost to the spell’s mana value.
Linked Issues check ✅ Passed The parser, engine changes, and regression tests address issue #5899 by creating a mana-value-based alternative cost without an extra X prompt.
Out of Scope Changes check ✅ Passed All changes support issue #5899 through parser logic, cost resolution, documentation, and targeted regression tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ship/5899-kentaro-alt-cost

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/engine/tests/integration/issue_5899_kentaro_alternative_cost.rs`:
- Around line 20-29: Update the test setup around the Test Samurai created by
add_creature_to_hand so its normal mana cost has mana value 3 but requires
colored mana, while preserving the pool of only three colorless mana; ensure the
cast therefore succeeds only through Kentaro’s resolved generic alternative
cost.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 8f628df9-0cf5-4688-8ad6-c495363ccbd8

📥 Commits

Reviewing files that changed from the base of the PR and between 1e7a9a6 and ad753b7.

📒 Files selected for processing (6)
  • crates/engine/src/game/casting.rs
  • crates/engine/src/game/keywords.rs
  • crates/engine/src/parser/oracle_static/cost_mod.rs
  • crates/engine/src/parser/oracle_static/tests.rs
  • crates/engine/tests/integration/issue_5899_kentaro_alternative_cost.rs
  • crates/engine/tests/integration/main.rs

@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown

Generated for head f5815ddfc40db128f2ceec94e487c9a4dfbf5d49.

Parse changes introduced by this PR · 1 card(s), 2 signature(s) (baseline: main 1e7a9a648cd1)

🟢 Added (1 signature)

  • 1 card · ➕ static/CastWithAlternativeCost(Mana { cost: SelfManaValue }) · added: CastWithAlternativeCost(Mana { cost: SelfManaValue }) (affects=you control Samurai)
    • Affected (first 3): Kentaro, the Smiling Cat

🔴 Removed (1 signature)

  • 1 card · ➖ ability/PayCost · removed: PayCost
    • Affected (first 3): Kentaro, the Smiling Cat

@matthewevans
matthewevans added this pull request to the merge queue Aug 13, 2026
@matthewevans
matthewevans removed this pull request from the merge queue due to a manual request Aug 13, 2026
@matthewevans
matthewevans enabled auto-merge August 13, 2026 03:54
@matthewevans
matthewevans added this pull request to the merge queue Aug 13, 2026
Merged via the queue into main with commit 9a91c93 Aug 13, 2026
15 checks passed
@matthewevans
matthewevans deleted the ship/5899-kentaro-alt-cost branch August 13, 2026 04:18
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.

Kentaro, the Smiling Cat prompts to pay for his casting twice — Instead of creating an alternate pay cost for other Sam…

1 participant