Merge branch 'fix' into 'master'

Fix bad refactor

See merge request core-developers/forge!6442
This commit is contained in:
Bug Hunter
2022-03-25 07:18:13 +00:00
4 changed files with 16 additions and 16 deletions

View File

@@ -660,6 +660,7 @@ public class AiAttackController {
int trampleDamage = 0;
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);
int taxCMC = tax != null ? tax.getCostMana().getMana().getCMC() : 0;
if (myFreeMana < currentAttackTax + taxCMC) {

View File

@@ -946,9 +946,8 @@ public class AiBlockController {
}
private void clearBlockers(final Combat combat, final List<Card> possibleBlockers) {
final List<Card> oldBlockers = combat.getAllBlockers();
for (final Card blocker : oldBlockers) {
if (blocker.getController() == ai) // don't touch other player's blockers
for (final Card blocker : CardLists.filterControlledBy(combat.getAllBlockers(), ai)) {
// don't touch other player's blockers
combat.removeFromCombat(blocker);
}
@@ -1346,12 +1345,11 @@ public class AiBlockController {
private boolean removeUnpayableBlocks(final Combat combat) {
int myFreeMana = ComputerUtilMana.getAvailableManaEstimate(ai);
int currentBlockTax = 0;
final List<Card> oldBlockers = combat.getAllBlockers();
List<Card> oldBlockers = CardLists.filterControlledBy(combat.getAllBlockers(), ai);
CardLists.sortByPowerDesc(oldBlockers);
boolean modified = false;
for (final Card blocker : oldBlockers) {
if (blocker.getController() == ai) {
Cost tax = CombatUtil.getBlockCost(blocker.getGame(), blocker, combat.getAttackersBlockedBy(blocker).get(0));
int taxCMC = tax != null ? tax.getCostMana().getMana().getCMC() : 0;
if (myFreeMana < currentBlockTax + taxCMC) {
@@ -1361,7 +1359,6 @@ public class AiBlockController {
}
currentBlockTax += taxCMC;
}
}
return modified;
}
}

View File

@@ -1324,7 +1324,7 @@ public class AiController {
}
public boolean confirmAction(SpellAbility sa, PlayerActionConfirmMode mode, String message) {
if (mode.equals(PlayerActionConfirmMode.AlternativeDamageAssignment)) {
if (mode == PlayerActionConfirmMode.AlternativeDamageAssignment) {
return true;
}

View File

@@ -853,11 +853,13 @@ public class Combat {
Map<Card, Integer> map = assigningPlayer.getController().assignCombatDamage(attacker, orderedBlockers, attackers,
damageDealt, defender, divideCombatDamageAsChoose || getAttackingPlayer() != assigningPlayer);
attackers.remove(attacker);
// player wants to assign another first
if (map == null) {
// add to end
attackers.add(attacker);
continue;
}
attackers.remove(attacker);
for (Entry<Card, Integer> dt : map.entrySet()) {
if (dt.getKey() == null) {