Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[refactor/bugfix] use rule 802.2a where appropriate. #13179

Merged
merged 2 commits into from
Dec 25, 2024

Conversation

Grath
Copy link
Contributor

@Grath Grath commented Dec 22, 2024

Many effects which relied on getDefendingPlayerId would fail if the attacking creature had been removed from combat before they resolved, in which case the defending player ID would be null. This fixes these issues.

Many effects which relied on getDefendingPlayerId would fail if the attacking creature had been removed from combat before they resolved, in which case the defending player ID would be null. This fixes these issues.
@xenohedron
Copy link
Contributor

802.2a.
Any rule, object, or effect that refers to a "defending player" refers to one specific defending player, not to all of the defending players.
If an ability of an attacking creature refers to a defending player, or a spell or ability refers to both an attacking creature and a defending player, then unless otherwise specified, the defending player it's referring to is the player that creature is attacking, the controller of the planeswalker that creature is attacking, or the protector of the battle that player is attacking.
If that creature is no longer attacking, the defending player it's referring to is the player that creature was attacking before it was removed from combat, the controller of the planeswalker that creature was attacking before it was removed from combat, or the protector of the battle that player was attacking before it was removed from combat.
If a spell or ability could apply to multiple attacking creatures, the appropriate defending player is individually determined for each of those attacking creatures.
If there are multiple defending players that could be chosen, the controller of the spell or ability chooses one.

Copy link
Member

@JayDi85 JayDi85 left a comment

Choose a reason for hiding this comment

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

Can you provide some buggy use cases or tests?

@Grath
Copy link
Contributor Author

Grath commented Dec 22, 2024

Can you provide some buggy use cases or tests?

I'll confirm my suspicions in a sec to write a test for a simpler buggy use case, but I encountered it trying to do [[Norin the Wary]] + [[Blade of Selves]] - Myriad would fail due to null defending player when Norin had already exiled himself before Myriad resolved.

Must have 802.2a rules text here or it's part (about founding of defending player). Can it be a default logic (allowFormer = true)? Looks like rules used it for anything.

Yeah, it's probably possible to default it to true. There's a couple use cases where it's important to be false I think, but most cases it can be true. Lemme look over it a bit further.

Copy link

Norin the Wary - (Gatherer) (Scryfall) (EDHREC)

{R}
Legendary Creature — Human Warrior
2/1
When a player casts a spell or a creature attacks, exile Norin the Wary. Return it to the battlefield under its owner's control at the beginning of the next end step.

Blade of Selves - (Gatherer) (Scryfall) (EDHREC)

{2}
Artifact — Equipment
Equipped creature has myriad. (Whenever it attacks, for each opponent other than defending player, you may create a token copy that's tapped and attacking that player or a planeswalker they control. Exile the tokens at end of combat.)
Equip {4}

…red ability.

Change allowFormer to be true by default, reduce falses to only necessary cases.
@github-actions github-actions bot added the tests label Dec 22, 2024
@Grath Grath merged commit 6b9532f into magefree:master Dec 25, 2024
8 checks passed
4825764518 pushed a commit to 4825764518/mage that referenced this pull request Feb 17, 2025
* [refactor/bugfix] use rule 802.2a where appropriate.

Many effects which relied on getDefendingPlayerId would fail if the attacking creature had been removed from combat before they resolved, in which case the defending player ID would be null. This fixes these issues.

* Add test for removing attacking creature with Defending Player triggered ability.

Change allowFormer to be true by default, reduce falses to only necessary cases.
4825764518 pushed a commit to 4825764518/mage that referenced this pull request Mar 7, 2025
* [refactor/bugfix] use rule 802.2a where appropriate.

Many effects which relied on getDefendingPlayerId would fail if the attacking creature had been removed from combat before they resolved, in which case the defending player ID would be null. This fixes these issues.

* Add test for removing attacking creature with Defending Player triggered ability.

Change allowFormer to be true by default, reduce falses to only necessary cases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants