I had an idea about such system, but even in BotArena, it might be beyond my capabilities.
Basically, it would need an interface similar to assigning combat damage. Damage would be created in "packets", with each packet having following characteristics:
1. Source of damage
2. Recipient of damage
3. Combat/noncombat; this could actually be a characteristic of the whole damage-dealing process since I don't think there's a way to deal both combat and noncombat damage at once.
4. Other special characteristics (unpreventable, limited redirection [this sounds better than "unredirectable" since some forms of redirection are still acceptable], deathtouch, lifelink, wither, infect)
5. Various extra effects of damage. Currently, these are:
5a: Damage forces a creature to attack this turn (
Aggravate)
5b: Damage replaces creature's death this turn with exile (
Anger of the Gods,
Annihilating Fire,
Demonfire,
Pillar of Flame,
Red Sun's Zenith,
Yamabushi's Flame,
Yamabushi's Storm)
5c: Damage taps creatures (
Aurelia's Fury)
5d: Damage prevents players from casting noncreature spells this turn (
Aurelia's Fury)
5e: Damage prevents creatures from regenerating this turn (
Flamebreak,
Incinerate,
Jaya Ballard, Task Mage)
5f: Damage creates Skeletons when the creature dies (
Skeletonize)
Note that other cards, like
Disintegrate, generate such effects on their targets regardless on how/whether the damage is actually dealt, so they don't get a mention here.
6: List of applied prevention effects to stop infinite loops. Generally, when an effect is applied, it's added to this list if both the packet and the effect still exist. Example of effects that must be noted like this are
Pariah or
Empyrial Archangel.
Now, all possible damage prevention/replacement effects are applied. These effects generally divide into mandatory and optional. If all effects are optional, there should be an option to not apply anything and continue, if at least one is mandatory, the player must apply one. Each application modifies the damage table and may allow or disallow the use of further effects, therefore they are resolved one-by-one.
Note that I'm not quite sure what happens if there are two packets with same source and recipient differing only in applied effects. I suggest to simply merge them into one packet and combine the lists of effects, but I'm not sure if that's always correct.
Each player handles the effects separately. Each player can make decisions only about packets that aim for himself or his permanents. I think that active player starts making choices, then the other player, then the first player again if there are more choices (for example, the inactive player redirected some damage to first player's creature).
Some examples:
Limited prevention effects (like
Healing Salve).
These effects have number signifying how many damage they can prevent.
Applicable when: There's a packet of preventable damage with their target as recipient.
Effect: If total preventable damage going to their target is less than their number, remove all such packets and decrease the number appropriately.
If the damage is equal to the number, remove all applicable packets and destroy the effect.
If the damage is greater than the number and there's only one packet, reduce the damage of packet by the number and destroy the effect.
If the damage is greater than the number and there's multiple packets, the player gets a choice how many damage to prevent from which packets. Then the effect is destroyed.
Fog effect:
Applicable when: There's a preventable combat damage packet aiming for you or your permanent.
Effect: Destroy all such packets.
This effect is evaluated separately by each player.
Harm's Way:
Has a number.
Applicable when: There's a damage packet from chosen source to you or your permanent, target of
Harm's Way is in play, and,if the damage has "limited redirection" property, its recipient isn't a creature.
Effect: If the damage is less then Number, change its recipient to target of
Harm's Way, reduce Number by amount of damage, add the effect to packet's list of effects used.
If the damage is equal to Number, change the recipient and destroy the effect.
If the damage is greater than the Number, reduce it by number and clone the packet with target of
Harm's Way as recipient and Number as amount of damage, or, if there's already a packet with this source and recipient, increase damage in this packet by Number. Destroy effect of
Harm's Way.
Protection:
Applicable when: There's a preventable packet whose source has given characteristics, aiming for permanent or player with protection.
Effect: Destroy all such packets.
After all effects are dealt with, let the dust settle, and then evaluate the damage according to current table. Note that some non-damage effects might appear in the table as well, for example through
Kill-Suit Cultist,
Swans of Bryn Argoll or
Phytohydra.