- Fix NPE.

- Switch isValidBand to using a CardCollection(View).
This commit is contained in:
Agetian
2023-07-03 17:41:45 +03:00
parent a033353167
commit 13a19a1749
3 changed files with 4 additions and 4 deletions

View File

@@ -541,7 +541,7 @@ public class AiAttackController {
bestBand = ComputerUtilCard.getBestCreatureAI(CardLists.getType(attackers, "Dinosaur"));
} else if (c.hasKeyword("Bands with Other Creatures named Wolves of the Hunt")) {
bestBand = ComputerUtilCard.getBestCreatureAI(CardLists.filter(attackers, CardPredicates.nameEquals("Wolves of the Hunt")));
} else if (!c.hasAnyKeyword(evasionKeywords) && bestAttacker.hasAnyKeyword(evasionKeywords)) {
} else if (!c.hasAnyKeyword(evasionKeywords) && bestAttacker != null && bestAttacker.hasAnyKeyword(evasionKeywords)) {
bestBand = ComputerUtilCard.getBestCreatureAI(CardLists.filter(attackers, card -> !card.hasAnyKeyword(evasionKeywords)));
} else {
bestBand = bestAttacker;

View File

@@ -2035,7 +2035,7 @@ public class ComputerUtilCombat {
// Check for Banding, Defensive Formation
boolean isAttackingMe = isAttacking && combat.getDefenderPlayerByAttacker(attacker).equals(self);
boolean isBlockingMyBand = attacker.getController().isOpponentOf(self) && AttackingBand.isValidBand(block.subList(0, block.size()), true);
boolean isBlockingMyBand = attacker.getController().isOpponentOf(self) && AttackingBand.isValidBand(block, true);
final boolean aiDistributesBandingDmg = isAttackingMe || isBlockingMyBand;
final boolean hasTrample = attacker.hasKeyword(Keyword.TRAMPLE);

View File

@@ -26,7 +26,7 @@ public class AttackingBand {
public void addAttacker(Card card) { attackers.add(card); }
public void removeAttacker(Card card) { attackers.remove(card); }
public static boolean isValidBand(List<Card> band, boolean shareDamage) {
public static boolean isValidBand(CardCollectionView band, boolean shareDamage) {
if (band.isEmpty()) {
// An empty band is not a valid band
return false;
@@ -64,7 +64,7 @@ public class AttackingBand {
public boolean canJoinBand(Card card) {
// Trying to join an existing band, attackers should be non-empty and card should exist
List<Card> newBand = new ArrayList<>(attackers);
CardCollection newBand = new CardCollection(attackers);
if (card != null) {
newBand.add(card);
}