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; int trampleDamage = 0;
CardCollection remainingBlockers = new CardCollection(blockers); CardCollection remainingBlockers = new CardCollection(blockers);
for (Card attacker : CardLists.getKeyword(blockedAttackers, Keyword.TRAMPLE)) { 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(attacker.getGame(), attacker, defendingOpponent);
int taxCMC = tax != null ? tax.getCostMana().getMana().getCMC() : 0; int taxCMC = tax != null ? tax.getCostMana().getMana().getCMC() : 0;
if (myFreeMana < currentAttackTax + taxCMC) { if (myFreeMana < currentAttackTax + taxCMC) {

View File

@@ -946,10 +946,9 @@ public class AiBlockController {
} }
private void clearBlockers(final Combat combat, final List<Card> possibleBlockers) { private void clearBlockers(final Combat combat, final List<Card> possibleBlockers) {
final List<Card> oldBlockers = combat.getAllBlockers(); for (final Card blocker : CardLists.filterControlledBy(combat.getAllBlockers(), ai)) {
for (final Card blocker : oldBlockers) { // don't touch other player's blockers
if (blocker.getController() == ai) // don't touch other player's blockers combat.removeFromCombat(blocker);
combat.removeFromCombat(blocker);
} }
attackersLeft = new ArrayList<>(attackers); // keeps track of all currently unblocked attackers attackersLeft = new ArrayList<>(attackers); // keeps track of all currently unblocked attackers
@@ -1346,21 +1345,19 @@ public class AiBlockController {
private boolean removeUnpayableBlocks(final Combat combat) { private boolean removeUnpayableBlocks(final Combat combat) {
int myFreeMana = ComputerUtilMana.getAvailableManaEstimate(ai); int myFreeMana = ComputerUtilMana.getAvailableManaEstimate(ai);
int currentBlockTax = 0; int currentBlockTax = 0;
final List<Card> oldBlockers = combat.getAllBlockers(); List<Card> oldBlockers = CardLists.filterControlledBy(combat.getAllBlockers(), ai);
CardLists.sortByPowerDesc(oldBlockers); CardLists.sortByPowerDesc(oldBlockers);
boolean modified = false; boolean modified = false;
for (final Card blocker : oldBlockers) { for (final Card blocker : oldBlockers) {
if (blocker.getController() == ai) { Cost tax = CombatUtil.getBlockCost(blocker.getGame(), blocker, combat.getAttackersBlockedBy(blocker).get(0));
Cost tax = CombatUtil.getBlockCost(blocker.getGame(), blocker, combat.getAttackersBlockedBy(blocker).get(0)); int taxCMC = tax != null ? tax.getCostMana().getMana().getCMC() : 0;
int taxCMC = tax != null ? tax.getCostMana().getMana().getCMC() : 0; if (myFreeMana < currentBlockTax + taxCMC) {
if (myFreeMana < currentBlockTax + taxCMC) { combat.removeFromCombat(blocker);
combat.removeFromCombat(blocker); modified = true;
modified = true; continue;
continue;
}
currentBlockTax += taxCMC;
} }
currentBlockTax += taxCMC;
} }
return modified; return modified;
} }

View File

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

View File

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