This commit is contained in:
tool4EvEr
2022-04-29 18:10:12 +02:00
parent 52f1dac9c9
commit 30dda88adb
3 changed files with 20 additions and 27 deletions

View File

@@ -572,8 +572,7 @@ public class AiAttackController {
if (numExtraBlocks > 0) {
// TODO should be limited to how much getBlockCost the opp can pay
while (numExtraBlocks-- > 0 && !remainingAttackers.isEmpty()) {
blockedAttackers.add(remainingAttackers.get(0));
remainingAttackers.remove(0);
blockedAttackers.add(remainingAttackers.remove(0));
maxBlockersAfterCrew--;
}
}
@@ -581,8 +580,7 @@ public class AiAttackController {
if (remainingAttackers.isEmpty()) {
break;
}
blockedAttackers.add(remainingAttackers.get(0));
remainingAttackers.remove(0);
blockedAttackers.add(remainingAttackers.remove(0));
maxBlockersAfterCrew--;
}
unblockedAttackers.addAll(remainingAttackers);
@@ -605,8 +603,8 @@ public class AiAttackController {
final CardCollection unblockableCantPayFor = new CardCollection();
final CardCollection unblockableWithoutCost = new CardCollection();
// TODO also check poison
for (Card attacker : CardLists.getKeyword(unblockedAttackers, Keyword.TRAMPLE)) {
Cost tax = CombatUtil.getAttackCost(attacker.getGame(), attacker, defendingOpponent);
for (Card attacker : unblockedAttackers) {
Cost tax = CombatUtil.getAttackCost(ai.getGame(), attacker, defendingOpponent);
if (tax == null) {
unblockableWithoutCost.add(attacker);
} else {
@@ -620,19 +618,17 @@ public class AiAttackController {
}
}
int dmgUnblockableAfterPaying = ComputerUtilCombat.sumDamageIfUnblocked(unblockableWithPaying, defendingOpponent);
unblockedAttackers = unblockableWithoutCost;
if (dmgUnblockableAfterPaying > trampleDamage) {
unblockedAttackers.removeAll(unblockableCantPayFor);
unblockedAttackers.removeAll(unblockableWithPaying);
myFreeMana -= unblockableAttackTax;
totalCombatDamage = dmgUnblockableAfterPaying;
// recalculate the trampler damage with the reduced mana available now
myFreeMana -= unblockableAttackTax;
trampleDamage = getDamageFromBlockingTramplers(blockedAttackers, remainingBlockers, myFreeMana).getLeft();
} else {
unblockedAttackers = unblockableWithoutCost;
myFreeMana -= tramplerTaxPaid;
// find out if we can still pay for some left
for (Card attacker : unblockableWithPaying) {
Cost tax = CombatUtil.getAttackCost(attacker.getGame(), attacker, defendingOpponent);
Cost tax = CombatUtil.getAttackCost(ai.getGame(), attacker, defendingOpponent);
int taxCMC = tax.getCostMana().getMana().getCMC();
if (myFreeMana < unblockableAttackTax + taxCMC) {
continue;
@@ -664,7 +660,7 @@ public class AiAttackController {
CardCollection remainingBlockers = new CardCollection(blockers);
for (Card attacker : CardLists.getKeyword(blockedAttackers, Keyword.TRAMPLE)) {
// TODO might sort by quotient of dmg/cost for best combination
Cost tax = CombatUtil.getAttackCost(attacker.getGame(), attacker, defendingOpponent);
Cost tax = CombatUtil.getAttackCost(ai.getGame(), attacker, defendingOpponent);
int taxCMC = tax != null ? tax.getCostMana().getMana().getCMC() : 0;
if (myFreeMana < currentAttackTax + taxCMC) {
continue;

View File

@@ -1268,21 +1268,17 @@ public class ComputerUtilCombat {
}
List<Card> list = Lists.newArrayList();
if (!sa.hasParam("ValidCards")) {
list = AbilityUtils.getDefinedCards(source, sa.getParam("Defined"), null);
}
if (sa.hasParam("Defined") && sa.getParam("Defined").startsWith("TriggeredAttacker")) {
list.add(attacker);
}
if (sa.hasParam("ValidCards")) {
if (attacker.isValid(sa.getParam("ValidCards").split(","), source.getController(), source, null)
|| attacker.isValid(sa.getParam("ValidCards").replace("attacking+", "").split(","),
source.getController(), source, null)) {
list.add(attacker);
}
} else {
list = AbilityUtils.getDefinedCards(source, sa.getParam("Defined"), null);
}
if (list.isEmpty()) {
continue;
if (sa.hasParam("Defined") && sa.getParam("Defined").startsWith("TriggeredAttacker")) {
list.add(attacker);
}
if (!list.contains(attacker)) {
continue;
@@ -1464,14 +1460,15 @@ public class ComputerUtilCombat {
toughness -= predictDamageTo(attacker, damage, source, false);
continue;
} else if (ApiType.Pump.equals(sa.getApi())) {
if (!sa.hasParam("NumDef")) {
continue;
}
if (sa.hasParam("Cost")) {
if (!CostPayment.canPayAdditionalCosts(sa.getPayCosts(), sa)) {
continue;
}
}
if (!sa.hasParam("NumDef")) {
continue;
}
final String defined = sa.getParam("Defined");
CardCollection list = AbilityUtils.getDefinedCards(source, defined, sa);
if (defined != null && defined.startsWith("TriggeredAttacker")) {
@@ -1497,6 +1494,9 @@ public class ComputerUtilCombat {
toughness += AbilityUtils.calculateAmount(source, bonus, sa);
}
} else if (ApiType.PumpAll.equals(sa.getApi())) {
if (!sa.hasParam("NumDef")) {
continue;
}
if (sa.hasParam("Cost")) {
if (!CostPayment.canPayAdditionalCosts(sa.getPayCosts(), sa)) {
continue;
@@ -1506,9 +1506,6 @@ public class ComputerUtilCombat {
if (!sa.hasParam("ValidCards")) {
continue;
}
if (!sa.hasParam("NumDef")) {
continue;
}
if (!attacker.isValid(sa.getParam("ValidCards").replace("attacking+", "").split(","), source.getController(), source, sa)) {
continue;
}

View File

@@ -724,7 +724,7 @@ public class ComputerUtilCost {
// ward or human misplay
if (ApiType.Counter.equals(sa.getApi())) {
List<SpellAbility> spells = AbilityUtils.getDefinedSpellAbilities(source, sa.hasParam("Defined") ? sa.getParam("Defined") : "Targeted", sa);
List<SpellAbility> spells = AbilityUtils.getDefinedSpellAbilities(source, sa.getParamOrDefault("Defined", "Targeted"), sa);
for (SpellAbility toBeCountered : spells) {
if (!CardFactoryUtil.isCounterable(toBeCountered.getHostCard())) {
return false;