Merge branch 'assorted-fixes' into 'master'

AI: fixed a logic error in DealDamage, somewhat better prediction of noncombat damage for assault attacks

See merge request core-developers/forge!475
This commit is contained in:
Michael Kamensky
2018-04-25 04:14:28 +00:00
3 changed files with 23 additions and 5 deletions

View File

@@ -525,13 +525,15 @@ public class AiAttackController {
}
}
if (ComputerUtilCombat.sumDamageIfUnblocked(unblockedAttackers, opp) + ComputerUtil.possibleNonCombatDamage(ai)
+ trampleDamage >= opp.getLife()
int totalCombatDamage = ComputerUtilCombat.sumDamageIfUnblocked(unblockedAttackers, opp) + trampleDamage;
int totalPoisonDamage = ComputerUtilCombat.sumPoisonIfUnblocked(unblockedAttackers, opp);
if (totalCombatDamage + ComputerUtil.possibleNonCombatDamage(ai) >= opp.getLife()
&& !((opp.cantLoseForZeroOrLessLife() || ai.cantWin()) && opp.getLife() < 1)) {
return true;
}
if (ComputerUtilCombat.sumPoisonIfUnblocked(unblockedAttackers, opp) >= 10 - opp.getPoisonCounters()) {
if (totalPoisonDamage >= 10 - opp.getPoisonCounters()) {
return true;
}

View File

@@ -1353,7 +1353,7 @@ public class ComputerUtil {
int damage = 0;
final CardCollection all = new CardCollection(ai.getCardsIn(ZoneType.Battlefield));
all.addAll(ai.getCardsActivableInExternalZones(true));
all.addAll(ai.getCardsIn(ZoneType.Hand));
all.addAll(CardLists.filter(ai.getCardsIn(ZoneType.Hand), Predicates.not(Presets.PERMANENTS)));
for (final Card c : all) {
for (final SpellAbility sa : c.getSpellAbilities()) {
@@ -1378,7 +1378,23 @@ public class ComputerUtil {
}
damage = dmg;
}
// Triggered abilities
if (c.isCreature() && c.isInZone(ZoneType.Battlefield) && CombatUtil.canAttack(c)) {
for (final Trigger t : c.getTriggers()) {
if ("Attacks".equals(t.getParam("Mode")) && t.hasParam("Execute")) {
SpellAbility trigSa = AbilityFactory.getAbility(c.getSVar(t.getParam("Execute")), c);
if (trigSa != null && trigSa.getApi() == ApiType.LoseLife
&& trigSa.getParamOrDefault("Defined", "").contains("Opponent")) {
trigSa.setHostCard(c);
damage += AbilityUtils.calculateAmount(trigSa.getHostCard(), trigSa.getParam("LifeAmount"), trigSa);
}
}
}
}
}
return damage;
}

View File

@@ -272,7 +272,7 @@ public class DamageDealAi extends DamageAiBase {
final Player activator = sa.getActivatingPlayer();
final Card source = sa.getHostCard();
final Game game = source.getGame();
List<Card> hPlay = CardLists.filter(getTargetableCards(ai, sa, pl, tgt, activator, source, game), CardPredicates.Presets.PLANESWALKERS);
List<Card> hPlay = getTargetableCards(ai, sa, pl, tgt, activator, source, game);
List<Card> killables = CardLists.filter(hPlay, new Predicate<Card>() {
@Override