magefree / mage

Magic Another Game Engine
http://xmage.today
MIT License
1.89k stars 773 forks source link

Protection's prevention effect should be handled at the same time as other prevention/redirect #10680

Open Susucre opened 1 year ago

Susucre commented 1 year ago

From a discussion in https://github.com/magefree/mage/pull/10652#discussion_r1276595896 I went digging in the ruling, and I think our way to handle the prevention part of protection is not exactly right.

Protection is in part a prevention effect:

702.16e Any damage that would be dealt by sources that have the stated quality to a permanent or player with protection is prevented.

When there are muliple prevention/protection applying at the same time, the player controlling the affected object's controller choose one, apply it, then repeat until there is no effect left to apply.

616.1. If two or more replacement and/or prevention effects are attempting to modify the way an event affects an object or player, the affected object’s controller (or its owner if it has no controller) or the affected player chooses one to apply, following the steps listed below. If two or more players have to make these choices at the same time, choices are made in APNAP order (see rule 101.4). 616.1a-d: [Do not matter for damage effects] 616.1e Any of the applicable replacement and/or prevention effects may be chosen. 616.1f Once the chosen effect has been applied, this process is repeated (taking into account only replacement or prevention effects that would now be applicable) until there are no more left to apply.

Both in PermanentImpl and PlayerImpl, the protection effect is currently applied after prevention/replacement. And from what I understand from the rules, they should be handled together.

xenohedron commented 8 months ago

Example of bug: [[Phantom Centaur]] being damaged by a black source has counters removed, but should ask which replacement effect to use (typically player will want to prevent the damage and not remove counters).

github-actions[bot] commented 8 months ago

Phantom Centaur - (Gatherer) (Scryfall) (EDHREC)

{2}{G}{G} Creature — Centaur Spirit 2/0 Protection from black Phantom Centaur enters the battlefield with three +1/+1 counters on it. If damage would be dealt to Phantom Centaur, prevent that damage. Remove a +1/+1 counter from Phantom Centaur.