mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
Fix AI assigning more than 1 dmg with trampling deathtouch attacker
This commit is contained in:
@@ -2059,31 +2059,23 @@ public class ComputerUtilCombat {
|
|||||||
|
|
||||||
if (block.size() == 1) {
|
if (block.size() == 1) {
|
||||||
final Card blocker = block.getFirst();
|
final Card blocker = block.getFirst();
|
||||||
|
int dmgToBlocker = dmgCanDeal;
|
||||||
|
|
||||||
if (hasTrample) {
|
if (hasTrample && isAttacking) { // otherwise no entity to deliver damage via trample
|
||||||
int dmgToKill = getEnoughDamageToKill(blocker, dmgCanDeal, attacker, true);
|
dmgToBlocker = getEnoughDamageToKill(blocker, dmgCanDeal, attacker, true);
|
||||||
|
|
||||||
if (dmgCanDeal < dmgToKill) {
|
if (dmgCanDeal < dmgToBlocker) {
|
||||||
dmgToKill = Math.min(blocker.getLethalDamage(), dmgCanDeal);
|
// can't kill so just put the lowest legal amount
|
||||||
} else {
|
dmgToBlocker = Math.min(blocker.getLethalDamage(), dmgCanDeal);
|
||||||
dmgToKill = Math.max(blocker.getLethalDamage(), dmgToKill);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isAttacking) { // no entity to deliver damage via trample
|
final int remainingDmg = dmgCanDeal - dmgToBlocker;
|
||||||
dmgToKill = dmgCanDeal;
|
|
||||||
}
|
|
||||||
|
|
||||||
final int remainingDmg = dmgCanDeal - dmgToKill;
|
|
||||||
|
|
||||||
// If Extra trample damage, assign to defending player/planeswalker (when there is one)
|
// If Extra trample damage, assign to defending player/planeswalker (when there is one)
|
||||||
if (remainingDmg > 0) {
|
if (remainingDmg > 0) {
|
||||||
damageMap.put(null, remainingDmg);
|
damageMap.put(null, remainingDmg);
|
||||||
}
|
}
|
||||||
|
|
||||||
damageMap.put(blocker, dmgToKill);
|
|
||||||
} else {
|
|
||||||
damageMap.put(blocker, dmgCanDeal);
|
|
||||||
}
|
}
|
||||||
|
damageMap.put(blocker, dmgToBlocker);
|
||||||
} // 1 blocker
|
} // 1 blocker
|
||||||
else {
|
else {
|
||||||
// Does the attacker deal lethal damage to all blockers
|
// Does the attacker deal lethal damage to all blockers
|
||||||
|
|||||||
Reference in New Issue
Block a user