Fix handling of damage to permanents (WIP) (#7592)

* initial refactor of damage events

* cleaned up some instances of classes that need to be removed

* removed old damage event classes

* removed outdated imports

* temporarily refactor Everlasting Torment (this will need to be changed more)

* updated damage handling to use new changes

* some reworking of lethal/excess damage plus a test

* updated damage marking to handle planeswalkers

* updated implementation of Phyrexian Unlife

* updated implementation of Everlasting Torment

* added some more excess damage tests

* small change to wither check
This commit is contained in:
Evan Kranzler 2021-02-22 17:11:24 -05:00 committed by GitHub
parent 39f6b69391
commit 5390963d38
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
201 changed files with 1132 additions and 1187 deletions

View file

@ -8,7 +8,6 @@ import mage.abilities.keyword.*;
import mage.constants.AsThoughEffectType;
import mage.constants.Outcome;
import mage.filter.StaticFilters;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.events.BlockerDeclaredEvent;
import mage.game.events.DeclareBlockerEvent;
@ -214,6 +213,12 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
permanent.applyDamage(game);
}
}
if (defenderIsPlaneswalker) {
Permanent permanent = game.getPermanent(defenderId);
if (permanent != null) {
permanent.applyDamage(game);
}
}
}
/**
@ -896,27 +901,6 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
}
private static int getLethalDamage(Permanent blocker, Permanent attacker, Game game) {
int lethalDamage;
if (attacker.getAbilities().containsKey(DeathtouchAbility.getInstance().getId())) {
lethalDamage = 1;
} else {
lethalDamage = getLethalDamage(blocker, game);
}
return lethalDamage;
}
public static int getLethalDamage(Permanent damagedPermanent, Game game) {
List<FilterCreaturePermanent> usePowerInsteadOfToughnessForDamageLethalityFilters = game.getState().getActivePowerInsteadOfToughnessForDamageLethalityFilters();
/*
* for handling Zilortha, Strength Incarnate:
* 2020-04-17
* Any time the game is checking whether damage is lethal or if a creature should be destroyed for having lethal damage marked on it, use the power of your creatures rather than their toughness to check the damage against. This includes being assigned trample damage, damage from Flame Spill, and so on.
*/
boolean usePowerInsteadOfToughnessForDamageLethality = usePowerInsteadOfToughnessForDamageLethalityFilters.stream()
.anyMatch(filter -> filter.match(damagedPermanent, game));
int lethalDamageThreshold = usePowerInsteadOfToughnessForDamageLethality ?
// Zilortha, Strength Incarnate, 2020-04-17: A creature with 0 power isnt destroyed unless it has at least 1 damage marked on it.
Math.max(damagedPermanent.getPower().getValue(), 1) : damagedPermanent.getToughness().getValue();
return Math.max(lethalDamageThreshold - damagedPermanent.getDamage(), 0);
return blocker.getLethalDamage(attacker.getId(), game);
}
}