magefree / mage

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

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

Open xenohedron opened 11 months ago

xenohedron commented 11 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 11 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 11 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 11 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.

JayDi85 commented 3 weeks ago

I don’t understand the problem — mtg rules uses Damage Assignment Order. It’s defined by players on declare blockers step. All other calculations use that order. Players can change excess damage distribution only (trample), but not the order (it’s defined at the start).

Can you explain:

  1. Current xmage behaviour;
  2. What’s wrong;
  3. Correct xmage behaviour.
ssk97 commented 3 weeks ago
  1. When a defending creature can block multiple attacking creatues, the order that the attacking creatures assign their damage in seems arbitrary (In contrast to the order that the blockers take that damage, which is correctly using the Damage Asssignment Order)
  2. If a creature with trample isn't late enough in the attacking order, it can't assign trample damage to the player since the multi-blocking creature doesn't yet have lethal damage assigned to it.
  3. Technically the correct behaviour is to allow any damage assignment and only check for legality once at the very end, but that seems like really bad UI. The automatic ordering of attackers with trample last would cover most cases, though I think it wouldn't solve the same issue when combined with replacement effects that modify how much damage is dealt.
Grath commented 3 weeks ago

https://magic.wizards.com/en/news/feature/foundations-mechanics This discussion is eerily well timed: damage assignment order is ceasing to exist as of Magic Foundations, so damage assignment in combat will need to be entirely overhauled anyways; I'm not sure how things like assigning damage when multiple attackers are being blocked by multiple defenders (one or more of whom can block multiple attackers at once) would work best; perhaps 'click on an attacking creature that was blocked, assign its damage however you want to each creature blocking it, move on to other creatures until all damage has been assigned'? Would be nice to have some shortcuts like, if you have enough damage to kill all blocking creatures it offers (but does not force - see [[Maarika, Brutal Gladiator]] or any other creature which interacts with excess damage) the option to assign lethal damage to each blocking creature, similar to things like when Palinchron offers to untap all your lands because you can untap more lands than you have tapped lands.

github-actions[bot] commented 3 weeks ago

Maarika, Brutal Gladiator - (Gatherer) (Scryfall) (EDHREC)

{2}{B}{R}{G} Legendary Creature — Human Warrior 7/4 Maarika, Brutal Gladiator must be blocked if able. As long as it's your turn, Maarika has indestructible. Whenever Maarika deals damage to a creature, if that creature was dealt excess damage this turn, that creature's controller sacrifices a noncreature, nonland permanent.

JayDi85 commented 3 weeks ago

Well, new rules must simplify UX. No needs in blockers order dialogs. No needs in multiple assign damage dialogs. Now users can use single assignment damage dialog with damage distribution logic between blocking creatures. I was planning to use it in combat after implemented for Master of the Wild Hunt in 0fbd9bb60f81f1d0ad7e915d840259e15dbd6795. Now such dialog required by new rules.

JayDi85 commented 3 weeks ago

Dialog example from Master of the Wild Hunt:

shot_241026_090402

Grath commented 2 weeks ago

I agree with that UI being a good idea for assigning damage from one creature, but that doesn't solve the problem that this issue has - where you need to be able to choose the order in which attackers deal damage, so that you can maximize the value of trample.

I would suggest this solution, potentially to be used when there's one blocker that's blocking multiple attackers, either "only for the attackers that were blocked by one creature" or "whenever there's one blocker blocking multiple attackers", or used all the time to simplify the flow: