Skip to content

fix(engine): wire "as ~ becomes attached, choose" replacement for Psychic Paper#5854

Merged
matthewevans merged 3 commits into
phase-rs:mainfrom
nghetienhiep:fix/issue-5821
Jul 16, 2026
Merged

fix(engine): wire "as ~ becomes attached, choose" replacement for Psychic Paper#5854
matthewevans merged 3 commits into
phase-rs:mainfrom
nghetienhiep:fix/issue-5821

Conversation

@nghetienhiep

Copy link
Copy Markdown
Contributor

Psychic Paper's continuous grant (ward, can't-be-blocked, name/type set
from the last chosen name/type) was already implemented and tested, but
the leading "As this Equipment becomes attached to a creature, choose a
creature card name and a creature type" clause parsed to Unimplemented —
nothing ever actually prompted the choice, so the grant read empty.

Reuses the existing ReplacementEvent::Attached matcher/applier (declared
but never produced by any parser) and routes Effect::Attach's single
resolver through the replacement pipeline, so any "as it becomes
attached, choose ..." definition fires regardless of which ability moves
the attachment. The two-part choice ("a creature card name and a
creature type") is parsed via a small conjunction combinator that
re-dispatches each conjunct through the existing named-choice phrase
table, extended generically rather than special-cased to this card.

Closes #5821

…chic Paper

Psychic Paper's continuous grant (ward, can't-be-blocked, name/type set
from the last chosen name/type) was already implemented and tested, but
the leading "As this Equipment becomes attached to a creature, choose a
creature card name and a creature type" clause parsed to Unimplemented —
nothing ever actually prompted the choice, so the grant read empty.

Reuses the existing ReplacementEvent::Attached matcher/applier (declared
but never produced by any parser) and routes Effect::Attach's single
resolver through the replacement pipeline, so any "as it becomes
attached, choose ..." definition fires regardless of which ability moves
the attachment. The two-part choice ("a creature card name and a
creature type") is parsed via a small conjunction combinator that
re-dispatches each conjunct through the existing named-choice phrase
table, extended generically rather than special-cased to this card.

Closes phase-rs#5821
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown

Parse changes introduced by this PR

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

deliver_attach's apply_pending_post_replacement_effect call (Psychic
Paper's attach-time choice) is a reviewed new consumer site; freeze
the ratchet baseline to match.
@matthewevans matthewevans self-assigned this Jul 16, 2026
@matthewevans matthewevans added the bug Bug fix label Jul 16, 2026

@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.

Request changes — only actual attachment events may trigger Attached.

🔴 Blocker

[HIGH] The replacement matches every attachment ZoneChange to battlefield, including an unattached Psychic Paper ETB. Evidence: crates/engine/src/game/replacement.rs:3409-3435. Why it matters: Attached triggers when no attachment occurred. Suggested fix: require an actual attach operation/event and add the unattached-ETB regression.

Recommendation: request-changes.

@matthewevans matthewevans removed their assignment Jul 16, 2026
…vents

attached_matcher's ZoneChange branch matched any Aura/Equipment entering
the battlefield, including a plain unattached Equipment ETB (CR 301.5b:
Equipment enters like other artifacts, not attached). That false match
let Psychic Paper's "as it becomes attached, choose ..." replacement fire
on cast, before it was ever equipped. Gate the branch on the zone change's
attach_to slot actually being populated, and add a regression test that
casting bare Psychic Paper settles at Priority instead of stalling on the
name/type prompt.

Addresses review feedback on phase-rs#5854.
@matthewevans matthewevans self-assigned this Jul 16, 2026

@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 — the attach-time matcher now requires an actual attachment target, and the current runtime regression proves a bare Equipment ETB does not prompt.

@matthewevans
matthewevans enabled auto-merge July 16, 2026 00:58
@matthewevans matthewevans removed their assignment Jul 16, 2026
@matthewevans
matthewevans added this pull request to the merge queue Jul 16, 2026
Merged via the queue into phase-rs:main with commit 746299a Jul 16, 2026
13 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.

Seam: as-becomes-attached choice + name/type override (Psychic Paper) — requesting accepted

2 participants