Excess damage fix

This commit is contained in:
TRT
2022-02-17 14:16:36 +01:00
parent fab0fc08da
commit 98b6f33d18
3 changed files with 21 additions and 10 deletions

View File

@@ -181,7 +181,7 @@ public class CharmAi extends SpellAbilityAi {
} else if (ai.canGainLife() && aiLife <= 5) {
// critical Life try to gain more
chosenList.add(gain);
} else if (!ai.canGainLife() && aiLife == 14 ) {
} else if (!ai.canGainLife() && aiLife == 14) {
// ai cant gain life, but try to avoid falling to 13
// but if a opponent does control Tainted Remedy its irrelevant
chosenList.add(oppTainted ? lose : gain);

View File

@@ -2260,10 +2260,12 @@ public class GameAction {
public void dealDamage(final boolean isCombat, final CardDamageMap damageMap, final CardDamageMap preventMap,
final GameEntityCounterTable counterTable, final SpellAbility cause) {
// Clear assigned damage if is combat
for (Map.Entry<GameEntity, Map<Card, Integer>> et : damageMap.columnMap().entrySet()) {
final GameEntity ge = et.getKey();
if (isCombat && ge instanceof Card) {
((Card) ge).clearAssignedDamage();
if (isCombat) {
for (Map.Entry<GameEntity, Map<Card, Integer>> et : damageMap.columnMap().entrySet()) {
final GameEntity ge = et.getKey();
if (ge instanceof Card) {
((Card) ge).clearAssignedDamage();
}
}
}
@@ -2282,7 +2284,7 @@ public class GameAction {
sum += e.getValue();
}
if (sourceLKI.hasKeyword(Keyword.LIFELINK)) {
if (sum > 0 && sourceLKI.hasKeyword(Keyword.LIFELINK)) {
sourceLKI.getController().gainLife(sum, sourceLKI, cause);
}
}

View File

@@ -262,11 +262,20 @@ public class DamageDealEffect extends DamageBaseEffect {
final Player activationPlayer = sa.getActivatingPlayer();
int excess = 0;
int dmgToTarget = 0;
if (sa.hasParam("ExcessDamage") || (sa.hasParam("ExcessSVar"))) {
int lethal = c.getLethalDamage();
if (sourceLKI.hasKeyword(Keyword.DEATHTOUCH)) {
lethal = Math.min(lethal, 1);
if (sa.hasParam("ExcessDamage") || sa.hasParam("ExcessSVar")) {
int lethalPW = 0;
int lethalCreature = 0;
if (c.isCreature()) {
lethalCreature = Math.max(0, c.getLethalDamage());
if (sourceLKI.hasKeyword(Keyword.DEATHTOUCH)) {
lethalCreature = Math.min(lethalCreature, 1);
}
}
if (c.isPlaneswalker()) {
lethalPW = c.getCurrentLoyalty();
}
// 120.4a
int lethal = Math.min(lethalPW, lethalCreature);
dmgToTarget = Math.min(lethal, dmg);
excess = dmg - dmgToTarget;
}