Skip to content

fix/6435 mosswort bridge hideaway playfromexile - #6784

Merged
matthewevans merged 3 commits into
phase-rs:mainfrom
claytonlin1110:fix/6435-mosswort-bridge-hideaway-playfromexile
Jul 29, 2026
Merged

fix/6435 mosswort bridge hideaway playfromexile#6784
matthewevans merged 3 commits into
phase-rs:mainfrom
claytonlin1110:fix/6435-mosswort-bridge-hideaway-playfromexile

Conversation

@claytonlin1110

@claytonlin1110 claytonlin1110 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Bug Fixes

    • Improved “look then cast” selection for hidden/private-library and exile-based prompts, with correct controller scoping and casting eligibility.
    • Fixed handling when linked exile filters reference exiled-by-source, ensuring the right cast targets are offered.
    • Preserved the proper decline fallback for optional selections.
    • Ensured face-down exile plays receive correct authority (including Play From Exile) in Play-mode cases.
  • Tests

    • Added/updated integration coverage for Windbrisk Heights and Mosswort Bridge hideaway behavior, including permission correctness and power-threshold outcomes.

@coderabbitai

coderabbitai Bot commented Jul 29, 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: 12 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

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: 1d61f2ae-8c50-4140-815f-d03e11053199

📥 Commits

Reviewing files that changed from the base of the PR and between 53d4dcb and 2855501.

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

Walkthrough

CastFromZone resolution now supports controller-scoped private look-then-cast selections, frozen cast constraints, corrected fallback handling, and linked-exile target materialization. Play-mode casts without alternative costs grant PlayFromExile permissions. Hideaway integration tests cover casting, land play, and power gating.

Changes

CastFromZone look and play permissions

Layer / File(s) Summary
Private cast selection and resolution
crates/engine/src/game/effects/cast_from_zone.rs
Adds controller-scoped private hand/library eligibility, freezes cast constraints when prompts open, corrects optional decline continuations, materializes LastRevealed and linked-exile targets, and updates during-resolution cleanup.
Play-from-exile permission stamping
crates/engine/src/game/effects/cast_from_zone.rs
record_lingering_permissions grants PlayFromExile for play-mode effects without alternative ability costs, with unit tests covering permitted and excluded cases.
Hideaway permission integration tests
crates/engine/tests/integration/issue_3246_windbrisk_heights_hideaway_exiled_by_source.rs, crates/engine/tests/integration/issue_6435_mosswort_bridge_hideaway_play.rs, crates/engine/tests/integration/main.rs
Extends Windbrisk Heights assertions and adds Mosswort Bridge tests for free casting, land play, face-up transitions, and power-gated offers; registers the new test module.

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

Sequence Diagram(s)

sequenceDiagram
  participant Player
  participant CastFromZone
  participant GameState
  participant HiddenCard
  Player->>CastFromZone: Activate Hideaway ability
  CastFromZone->>GameState: Resolve private look window
  GameState-->>CastFromZone: Return eligible linked exile card
  CastFromZone->>HiddenCard: Grant ExileWithAltCost and PlayFromExile
  Player->>HiddenCard: Cast spell or play land from exile
Loading

Possibly related PRs

  • phase-rs/phase#6302: Both PRs update private library look-then-cast eligibility and CastFromZone resolution.
  • phase-rs/phase#6782: Both PRs address ExiledBySource linked-exile target resolution.

Suggested reviewers: matthewevans

🚥 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 is concise and accurately summarizes the main change: fixing Mosswort Bridge hideaway play-from-exile behavior.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

A play-mode CastFromZone (e.g. hideaway) must grant face-down exile look/play authority via CastingPermission::PlayFromExile. This fixes Mosswort Bridge and adds integration coverage.

Co-authored-by: Cursor <cursoragent@cursor.com>
@matthewevans
matthewevans force-pushed the fix/6435-mosswort-bridge-hideaway-playfromexile branch from 8a44f59 to 1e57da1 Compare July 29, 2026 10:05
@matthewevans

matthewevans commented Jul 29, 2026

Copy link
Copy Markdown
Member

Parse changes introduced by this PR

✓ No card-parse changes detected.

@matthewevans matthewevans added the bug Bug fix label Jul 29, 2026

@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

🧹 Nitpick comments (1)
crates/engine/tests/integration/issue_6435_mosswort_bridge_hideaway_play.rs (1)

162-196: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the "advance to P0's next main phase" boilerplate into one helper.

The same ~35-line block (end step → upkeep → main, optional DeclareAttackers escape, repeat if priority isn't P0) is copy-pasted in all three tests. A single advance_to_next_p0_main(&mut runner) helper next to fund_green keeps the tests readable and keeps the turn-advance semantics in one place.

As per coding guidelines, "Build reusable building blocks and test the building block across its parameter range rather than implementing or testing one-card special cases."

Also applies to: 303-334, 395-426

🤖 Prompt for 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.

In `@crates/engine/tests/integration/issue_6435_mosswort_bridge_hideaway_play.rs`
around lines 162 - 196, The repeated end-step-to-P0-main progression should be
centralized. Add an advance_to_next_p0_main helper near fund_green that performs
the phase advances, handles an optional DeclareAttackers action, and repeats the
sequence when priority_player is not P0; replace the duplicated blocks in all
three affected tests with calls to this helper.

Source: Coding guidelines

🤖 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_6435_mosswort_bridge_hideaway_play.rs`:
- Line 230: Update the matches! expression in the test to bind and match the
card_filter’s None shape directly in its pattern, removing the *card_filter ==
None guard. Preserve the existing matching behavior while satisfying clippy’s -D
warnings gate.

---

Nitpick comments:
In `@crates/engine/tests/integration/issue_6435_mosswort_bridge_hideaway_play.rs`:
- Around line 162-196: The repeated end-step-to-P0-main progression should be
centralized. Add an advance_to_next_p0_main helper near fund_green that performs
the phase advances, handles an optional DeclareAttackers action, and repeats the
sequence when priority_player is not P0; replace the duplicated blocks in all
three affected tests with calls to this helper.
🪄 Autofix (Beta)

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: 01c25a3d-50d6-4218-bf49-7088a69c9729

📥 Commits

Reviewing files that changed from the base of the PR and between 8a44f59 and 1e57da1.

📒 Files selected for processing (4)
  • crates/engine/src/game/effects/cast_from_zone.rs
  • crates/engine/tests/integration/issue_3246_windbrisk_heights_hideaway_exiled_by_source.rs
  • crates/engine/tests/integration/issue_6435_mosswort_bridge_hideaway_play.rs
  • crates/engine/tests/integration/main.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • crates/engine/tests/integration/main.rs
  • crates/engine/src/game/effects/cast_from_zone.rs

..
} if *granted_to == P0
&& *exiled_by_ability_controller == Some(P0)
&& *card_filter == None

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.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

CI blocker: *card_filter == None fails the clippy -D warnings gate.

Inside a matches! pattern you can bind the shape directly instead of comparing to None in the guard.

🔧 Proposed fix
             CastingPermission::PlayFromExile {
                 granted_to,
                 exiled_by_ability_controller,
-                card_filter,
+                card_filter: None,
                 source_id: Some(src),
                 ..
             } if *granted_to == P0
                 && *exiled_by_ability_controller == Some(P0)
-                && *card_filter == None
                 && *src == mosswort
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
&& *card_filter == None
CastingPermission::PlayFromExile {
granted_to,
exiled_by_ability_controller,
card_filter: None,
source_id: Some(src),
..
} if *granted_to == P0
&& *exiled_by_ability_controller == Some(P0)
&& *src == mosswort
🧰 Tools
🪛 GitHub Check: Rust lint (fmt, clippy, parser gate)

[failure] 230-230:
binary comparison to literal Option::None

🤖 Prompt for 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.

In `@crates/engine/tests/integration/issue_6435_mosswort_bridge_hideaway_play.rs`
at line 230, Update the matches! expression in the test to bind and match the
card_filter’s None shape directly in its pattern, removing the *card_filter ==
None guard. Preserve the existing matching behavior while satisfying clippy’s -D
warnings gate.

Source: Linters/SAST tools

@matthewevans matthewevans self-assigned this Jul 29, 2026
@matthewevans

Copy link
Copy Markdown
Member

Maintainer update — current head 53d4dcbe.

The terminal Rust-lint failure was limited to two Option == None test assertions. I replaced both with is_none() and pushed the minimal fix; GitHub CI is now re-running. The CodeRabbit helper-extraction suggestion is a non-blocking test-only nit.

Co-authored-by: Clayton <claytonlin1110@users.noreply.github.com>
@matthewevans

Copy link
Copy Markdown
Member

Maintainer update — current head 2855501e.

main merged #6782 while this PR was under review, creating a one-file module-registration conflict. I ported the branch by retaining both #6435 and #6437 registrations; the functional #6435 diff is unchanged. Required GitHub checks are re-running on this merged head, after which approval/enqueue can resume.

@matthewevans matthewevans left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approved — current head verified.

The CastFromZone authority now supplies the required play-from-exile permission for play-mode grants, with production-pipeline spell, land, and threshold tests. The maintainer port retained both integration registrations; parse diff is unchanged and required checks are green.

@matthewevans
matthewevans added this pull request to the merge queue Jul 29, 2026
@matthewevans matthewevans removed their assignment Jul 29, 2026
Merged via the queue into phase-rs:main with commit 309d7c4 Jul 29, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants