magefree / mage

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

Combat damage assignment for attackers with trample and blockers blocking multiple creatures #11567

Open xenohedron opened 8 months ago

xenohedron commented 8 months ago

Noticed today in the XDHS with [[Guardian of the Gateless]] but is presumably a general issue with how combat is implemented. It was blocking a 3/5, 4/4 trample, and 4/4 not trample (so becoming a 6/6). The correct functionality would be to assign 0-4 trample damage. However, the way it seems to work was assigning 3 from the 3/5, then prompting to assign 3 or 4 from the trampler (so 0 or 1 to face), then 4 from the non trampler all to the blocker.

702.19b The controller of an attacking creature with trample first assigns damage to the creature(s) blocking it. Once all those blocking creatures are assigned lethal damage, any excess damage is assigned as its controller chooses among those blocking creatures and the player, planeswalker, or battle the creature is attacking. When checking for assigned lethal damage, take into account damage already marked on the creature and damage from other creatures that’s being assigned during the same combat damage step, but not any abilities or effects that might change the amount of damage that’s actually dealt. The attacking creature’s controller need not assign lethal damage to all those blocking creatures but in that case can’t assign any damage to the player or planeswalker it’s attacking.

One potential kludge to fix this in most scenarios would be to order attackers (i.e. combat groups) as follows when assigning damage:

  1. Attackers without trample
  2. Attackers with trample and deathtouch
  3. Attackers with trample but not deathtouch

More formally true to rules would be like, have the attackers assign in any order, tramplers can assign 0-N, at the end check that the blocker is receiving lethal and if not reject all assignments and make them try again, but that seems a bit trickier! Ideally it would be possible to assign damage from three 2/4 tramplers to one 3/3 blocker as 1+1 1+1 1+1 (if you wanted each creature to trigger damage to player for example).

github-actions[bot] commented 8 months ago

Guardian of the Gateless - (Gatherer) (Scryfall) (EDHREC)

{4}{W} Creature — Angel 3/3 Flying Guardian of the Gateless can block any number of creatures. Whenever Guardian of the Gateless blocks, it gets +1/+1 until end of turn for each creature it's blocking.

ssk97 commented 8 months ago

Key rule for proper handling:

510.1e Once a player has assigned combat damage from each attacking or blocking creature they control, the total damage assignment (not solely the damage assignment of any individual attacking or blocking creature) is checked to see if it complies with the above rules. If it doesn’t, the combat damage assignment is illegal; the game returns to the moment before that player began to assign combat damage. (See rule 728, “Handling Illegal Actions.”)

An assigned order would likely be much simpler to implement though.

tiera3 commented 8 months ago

The other thing to take into account with this fix is cards like Pride of Lions that have oracle text of "You may have ~ assign its combat damage as though it weren’t blocked". Is this choice made at the start of the damage assignment step? If so, it shouldn't be a problem.

https://scryfall.com/search?q=o%3A%22weren%27t+blocked%22 currently returns 19 relevant cards.

Simply putting them first in the evaluation order will work most of the time - unless that creature itself has trample making things more complicated.