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) { } else if (ai.canGainLife() && aiLife <= 5) {
// critical Life try to gain more // critical Life try to gain more
chosenList.add(gain); 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 // ai cant gain life, but try to avoid falling to 13
// but if a opponent does control Tainted Remedy its irrelevant // but if a opponent does control Tainted Remedy its irrelevant
chosenList.add(oppTainted ? lose : gain); chosenList.add(oppTainted ? lose : gain);

View File

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

View File

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