Skip to content

fix(engine): trigger land mana amplification once - #7288

Merged
matthewevans merged 12 commits into
mainfrom
ship/fix-engine-land-mana-amplification
Aug 12, 2026
Merged

fix(engine): trigger land mana amplification once#7288
matthewevans merged 12 commits into
mainfrom
ship/fix-engine-land-mana-amplification

Conversation

@matthewevans

@matthewevans matthewevans commented Aug 12, 2026

Copy link
Copy Markdown
Member

Closes #6979\n\nPreserves the produced-mana event as a single trigger source and matches source-linked land names for Caged Sun and Extraplanar Lens.

Summary by CodeRabbit

  • Bug Fixes
    • Improved mana-production trigger handling for activated abilities, including abilities that produce multiple mana at once.
    • Fixed effects such as Caged Sun and Extraplanar Lens so they trigger correctly based on the producing land and mana color.
    • Added support for matching cards by the name of a card exiled by the effect’s source.
  • Tests
    • Added coverage for land-mana amplification and exiled-card name matching.

@matthewevans
matthewevans enabled auto-merge August 12, 2026 07:06
@coderabbitai

coderabbitai Bot commented Aug 12, 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: 41 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: aa33c5d0-b7aa-40e9-aab2-3ed702ffbd0f

📥 Commits

Reviewing files that changed from the base of the PR and between c22b746 and 4e7a34f.

📒 Files selected for processing (11)
  • crates/engine/src/game/ability_rw.rs
  • crates/engine/src/game/ability_scan.rs
  • crates/engine/src/game/coverage.rs
  • crates/engine/src/game/layers.rs
  • crates/engine/src/game/mana_abilities.rs
  • crates/engine/src/game/triggers.rs
  • crates/engine/src/parser/oracle_trigger.rs
  • crates/engine/src/parser/oracle_trigger_tests.rs
  • crates/engine/src/types/ability.rs
  • crates/engine/tests/integration/issue_6979_land_mana_amplification.rs
  • crates/engine/tests/integration/main.rs
📝 Walkthrough

Walkthrough

The engine now parses and resolves land mana amplification triggers. It adds aggregate ManaAbilityProduced events, supports source-linked exiled-card name filters, and adds regression coverage for Caged Sun and Extraplanar Lens.

Changes

Land mana amplification

Layer / File(s) Summary
Trigger contracts and parser support
crates/engine/src/types/..., crates/engine/src/parser/..., crates/engine/src/game/ability_graph.rs
Adds ManaAbilityProduced, its filters and trigger state, plus Oracle parsing and parser tests for chosen-color and linked-exile land triggers.
Mana event emission and trigger resolution
crates/engine/src/game/mana_abilities.rs, crates/engine/src/game/mana_sources.rs, crates/engine/src/game/trigger_matchers.rs, crates/engine/src/game/triggers.rs, crates/engine/src/game/effects/mana.rs, crates/engine/src/ai_support/..., crates/engine/tests/integration/*
Emits aggregate mana-production events, matches source/player/color constraints, resolves pending events, routes produced mana, and tests Caged Sun and Extraplanar Lens.
Source-linked exiled-card filtering
crates/engine/src/types/ability.rs, crates/engine/src/game/filter.rs, crates/engine/src/game/exile_links.rs, crates/engine/src/game/ability_rw.rs, crates/engine/src/game/ability_scan.rs, crates/engine/src/game/layers.rs, crates/engine/src/game/coverage.rs
Adds SameNameAsExiledBySource matching for live objects and zone-change records, with supporting classification, serialization, coverage, and memoization handling.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Suggested labels: bug, area:engine

Suggested reviewers: lgray, kiannidev, ntindle

🚥 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 summarizes the main fix: land-mana amplification triggers once per produced-mana event.
Linked Issues check ✅ Passed The changes implement land mana-production triggers for Caged Sun and Extraplanar Lens, including required restrictions and regression tests [#6979].
Out of Scope Changes check ✅ Passed The changes are focused on mana-trigger modeling, source-linked land-name filtering, parser support, and issue-specific regression coverage [#6979].
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ 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/fix-engine-land-mana-amplification

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.

@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown

Parse changes introduced by this PR

Baseline pending for 50f08736633050c0fa577ada951fad0026c358fb — this populates once main publishes its coverage snapshot (a few minutes after that commit landed).

@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: 4

🤖 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/src/game/ability_rw.rs`:
- Line 2684: Classify FilterProp::SameNameAsExiledBySource as member-bound by
moving it into the => true arm alongside TargetFilter::ExiledBySource and
FilterProp::InTrackedSet. Add a regression test covering two sources linked to
different exiled names, verifying sibling-order analysis does not treat their
source-bound results as uniform.

In `@crates/engine/src/game/filter.rs`:
- Around line 5183-5189: Update both matcher arms for
FilterProp::SameNameAsExiledBySource so each checks only the exile linked to its
paired exile ability, rather than every ExileLink for source.id. Preserve the
existing name comparison while adding ability or pile identity to the link
context, or limit the property to the supported one-pile class. Add a two-pile
regression test and verified CR 607.2a annotations to both arms.

In `@crates/engine/src/game/mana_abilities.rs`:
- Around line 735-744: Update the aggregate ManaAbilityProduced emission around
produced_for_tap_event to preserve each mana recipient’s identity instead of
assigning the activating player to all produced mana. Emit recipient-scoped
aggregate events or equivalent recipient-scoped entries, and ensure
match_mana_ability_produced validates triggers against the receiving player
while retaining one aggregate resolution per recipient.

In `@crates/engine/tests/integration/issue_6979_land_mana_amplification.rs`:
- Around line 19-68: Rewrite the regression tests around
caged_sun_triggers_once_from_a_non_tap_land_mana_ability and the corresponding
Lens test to activate real mana abilities through the scenario pipeline instead
of injecting GameEvent::ManaAbilityProduced directly. Give the tested land an
actual non-tap mana ability, use distinct controllers for Lens and land, and add
controls for a nonchosen color, nonmatching land name, and opponent-controlled
matching land. Assert that only the matching land controller receives exactly
one additional mana, covering both aggregate production and
one-event-per-mana-unit behavior.
🪄 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: 6f4622fb-f9e1-4047-9241-f230973d4247

📥 Commits

Reviewing files that changed from the base of the PR and between 69ce21a and c22b746.

📒 Files selected for processing (26)
  • crates/engine/src/ai_support/filter.rs
  • crates/engine/src/ai_support/mod.rs
  • crates/engine/src/ai_support/shortcut_efficacy.rs
  • crates/engine/src/analysis/ability_graph.rs
  • crates/engine/src/game/ability_rw.rs
  • crates/engine/src/game/ability_scan.rs
  • crates/engine/src/game/casting_costs.rs
  • crates/engine/src/game/coverage.rs
  • crates/engine/src/game/effects/mana.rs
  • crates/engine/src/game/exile_links.rs
  • crates/engine/src/game/filter.rs
  • crates/engine/src/game/layers.rs
  • crates/engine/src/game/log.rs
  • crates/engine/src/game/mana_abilities.rs
  • crates/engine/src/game/mana_sources.rs
  • crates/engine/src/game/public_state.rs
  • crates/engine/src/game/trigger_index.rs
  • crates/engine/src/game/trigger_matchers.rs
  • crates/engine/src/game/triggers.rs
  • crates/engine/src/parser/oracle_trigger.rs
  • crates/engine/src/parser/oracle_trigger_tests.rs
  • crates/engine/src/types/ability.rs
  • crates/engine/src/types/events.rs
  • crates/engine/src/types/triggers.rs
  • crates/engine/tests/integration/issue_6979_land_mana_amplification.rs
  • crates/engine/tests/integration/main.rs

Comment thread crates/engine/src/game/ability_rw.rs Outdated
Comment thread crates/engine/src/game/filter.rs
Comment thread crates/engine/src/game/mana_abilities.rs Outdated
@matthewevans
matthewevans added this pull request to the merge queue Aug 12, 2026
@matthewevans
matthewevans removed this pull request from the merge queue due to a manual request Aug 12, 2026
@matthewevans
matthewevans added this pull request to the merge queue Aug 12, 2026
@matthewevans
matthewevans removed this pull request from the merge queue due to a manual request Aug 12, 2026
@matthewevans
matthewevans enabled auto-merge August 12, 2026 08:43
@matthewevans

Copy link
Copy Markdown
Member Author

Pushed the test repair rebased on the branch update as 47f66b8c4d.

@matthewevans

Copy link
Copy Markdown
Member Author

Correction: the pushed rebased head is 3c14661bdf (the earlier short hash in my note was incorrect).

@matthewevans
matthewevans added this pull request to the merge queue Aug 12, 2026
Merged via the queue into main with commit ad7ba57 Aug 12, 2026
15 checks passed
@matthewevans
matthewevans deleted the ship/fix-engine-land-mana-amplification branch August 12, 2026 10:58
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.

[Card Bug] Land-mana amplification triggers are unsupported

1 participant