Skip to content

fix(parser): "for each <TYPE> card <verb> this way" counts only that card type#4703

Merged
matthewevans merged 1 commit into
phase-rs:mainfrom
minion1227:minion_4697
Jul 1, 2026
Merged

fix(parser): "for each <TYPE> card <verb> this way" counts only that card type#4703
matthewevans merged 1 commit into
phase-rs:mainfrom
minion1227:minion_4697

Conversation

@minion1227

Copy link
Copy Markdown
Contributor

Closes #4697.

Bug: Dread Summons — "Each player mills X cards. For each creature card put into a graveyard this way, you create a … Zombie" — created a Zombie for every milled card, not just creature cards. parse_for_each_clause recognized the tracked-set "this way" count but dropped the "creature" card-type filter, yielding the unfiltered QuantityRef::TrackedSetSize.

Fix: add parse_filtered_tracked_set_this_way, tried right before the bare TrackedSetSize fallback (mirroring the existing parse_filtered_revealed_this_way / parse_filtered_destroyed_this_way helpers): a "<TYPE> card <verb> this way" clause with a specific card type routes to the already-runtime-supported QuantityRef::FilteredTrackedSetSize { filter, caused_by: None }, which counts only the matching members of the most recent tracked set. A bare "card" (or typeless clause) returns None and keeps TrackedSetSize. Covers the whole "for each ⟨filter⟩ card ⟨verb⟩ this way" class (creature / land / artifact / … put into a graveyard / milled / exiled). No new engine variant.

CR 608.2c + CR 400.7.

Tests: "creature card put into a graveyard this way" → FilteredTrackedSetSize(Creature); bare "card …" → TrackedSetSize (regression). cargo fmt + clippy + parser combinator gate clean; 204 oracle_quantity + 2308 oracle_effect + 116 token-effect tests green (nonland-discarded / milled / destroyed cause-filtered paths intact).

🤖 Generated with Claude Code

@minion1227 minion1227 requested a review from matthewevans as a code owner July 1, 2026 12:49

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request implements parsing for the ' card this way' clause (e.g., 'creature card put into a graveyard this way') to support CR 608.2c and CR 400.7. It introduces the parse_filtered_tracked_set_this_way helper function using nom combinators, integrates it into the 'for each' clause parser, and adds corresponding unit tests. No review comments were provided, and the implementation adheres to the repository's architectural guidelines, so there is no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

…card type

Dread Summons (phase-rs#4697) — "Each player mills X cards. For each creature card put
into a graveyard this way, you create a … Zombie" — created a Zombie for EVERY
milled card, not just creature cards. `parse_for_each_clause` recognized the
tracked-set "this way" count but dropped the "creature" card-type filter,
yielding the unfiltered `QuantityRef::TrackedSetSize`.

Add `parse_filtered_tracked_set_this_way`, tried right before the bare
`TrackedSetSize` fallback (mirroring the existing `parse_filtered_revealed_this_
way` / `parse_filtered_destroyed_this_way` helpers): a "<TYPE> card <verb> this
way" clause with a SPECIFIC card type routes to the already-runtime-supported
`QuantityRef::FilteredTrackedSetSize { filter, caused_by: None }`, which counts
only the matching members of the most recent tracked set. A bare "card" (or a
typeless clause) returns `None` and keeps `TrackedSetSize`. Covers the whole
"for each <filter> card <verb> this way" class (creature / land / artifact / …
put into a graveyard / milled / exiled). No new engine variant.

CR 608.2c (anaphoric tracked set) + CR 400.7 (filtered subset).

Tests: "creature card put into a graveyard this way" → FilteredTrackedSetSize
(Creature); bare "card put into a graveyard this way" → TrackedSetSize
(regression). fmt + clippy + parser combinator gate clean; 204 oracle_quantity +
2308 oracle_effect + 116 token-effect tests green (nonland-discarded / milled /
destroyed cause-filtered paths intact).

Closes phase-rs#4697

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

Parse changes introduced by this PR · 22 card(s), 17 signature(s) (baseline: main e0eff39264c8)

3 card(s) · ability/Pump · field p/t: +cards moved/+cards moved+filtered tracked set (creature)/+filtered tracked set (creature)

Examples: Ledev Champion, Orphans of the Wheat, Siege Striker

2 card(s) · ability/Draw · field count: cards movedfiltered tracked set (land)

Examples: Eumidian Wastewaker, Patient Rebuilding

2 card(s) · ability/GainLife · field amount: 4*cards moved4*filtered tracked set (creature)

Examples: Harmony of Nature, Marshaling the Troops

2 card(s) · ability/LoseLife · field amount: 2*cards moved2*filtered tracked set (creature)

Examples: Liliana's Indignation, Reign of Terror

1 card(s) · ability/ChangeZone · field target: mv cards moved- opponent controls permanent non-landmv filtered tracked set (creature)- opponent controls permanent non-land

Examples: Teferi Akosa of Zhalfir

1 card(s) · ability/DealDamage · field amount: cards movedfiltered tracked set (Island)

Examples: Monsoon

1 card(s) · ability/Discard · field count: cards movedfiltered tracked set (Swamp)

Examples: Sink into Takenuma

1 card(s) · ability/Draw · field count: cards movedfiltered tracked set (Gate)

Examples: Guild Summit

1 card(s) · ability/Draw · field count: cards movedfiltered tracked set (Human)

Examples: Minas Tirith Garrison

1 card(s) · ability/Draw · field count: cards movedfiltered tracked set (creature)

Examples: Coerced Confession

1 card(s) · ability/GainLife · field amount: 2*cards moved2*filtered tracked set (creature)

Examples: Jaddi Lifestrider

1 card(s) · ability/Pump · field p/t: +cards moved/+cards moved+filtered tracked set (Plains)/+filtered tracked set (Plains)

Examples: Plow Through Reito

1 card(s) · ability/PumpAll · field p/t: +cards moved/+cards moved+filtered tracked set (Plains)/+filtered tracked set (Plains)

Examples: Charge Across the Araba

1 card(s) · ability/PutCounter · field counter: TrackedSetSize P1P1FilteredTrackedSetSize { filter: Typed(TypedFilter { type_filters: [Creature], controller: None, properties: [] }), cau…

Examples: Kaima, the Fractured Calm

1 card(s) · ability/PutCounter · field counter: TrackedSetSize timeFilteredTrackedSetSize { filter: Typed(TypedFilter { type_filters: [Creature], controller: None, properties: [] }), cau…

Examples: Out of Time

1 card(s) · ability/Token · field token: cards moved× +1/+1 White/Blue Merfolk (Creature Merfolk)filtered tracked set (permanent)× +1/+1 White/Blue Merfolk (Creature Merfolk)

Examples: Wanderwine Farewell

1 card(s) · ability/Token · field token: cards moved× +4/+4 White Angel (Creature Angel) with Flyingfiltered tracked set (creature)× +4/+4 White Angel (Creature Angel) with Flying

Examples: Devout Invocation

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

Maintainer review: passes the authorized review bar at head 383d737892e51265794e444156dfb2a1a2ddda88.

@matthewevans matthewevans added the bug Bug fix label Jul 1, 2026
@matthewevans matthewevans added this pull request to the merge queue Jul 1, 2026
Merged via the queue into phase-rs:main with commit 10724a7 Jul 1, 2026
11 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.

[Card Bug] Mill X cards, for each creature milled...

2 participants