mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
- Fix NPE.
- Switch isValidBand to using a CardCollection(View).
This commit is contained in:
@@ -541,7 +541,7 @@ public class AiAttackController {
|
|||||||
bestBand = ComputerUtilCard.getBestCreatureAI(CardLists.getType(attackers, "Dinosaur"));
|
bestBand = ComputerUtilCard.getBestCreatureAI(CardLists.getType(attackers, "Dinosaur"));
|
||||||
} else if (c.hasKeyword("Bands with Other Creatures named Wolves of the Hunt")) {
|
} 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")));
|
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)));
|
bestBand = ComputerUtilCard.getBestCreatureAI(CardLists.filter(attackers, card -> !card.hasAnyKeyword(evasionKeywords)));
|
||||||
} else {
|
} else {
|
||||||
bestBand = bestAttacker;
|
bestBand = bestAttacker;
|
||||||
|
|||||||
@@ -2035,7 +2035,7 @@ public class ComputerUtilCombat {
|
|||||||
|
|
||||||
// Check for Banding, Defensive Formation
|
// Check for Banding, Defensive Formation
|
||||||
boolean isAttackingMe = isAttacking && combat.getDefenderPlayerByAttacker(attacker).equals(self);
|
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 aiDistributesBandingDmg = isAttackingMe || isBlockingMyBand;
|
||||||
|
|
||||||
final boolean hasTrample = attacker.hasKeyword(Keyword.TRAMPLE);
|
final boolean hasTrample = attacker.hasKeyword(Keyword.TRAMPLE);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public class AttackingBand {
|
|||||||
public void addAttacker(Card card) { attackers.add(card); }
|
public void addAttacker(Card card) { attackers.add(card); }
|
||||||
public void removeAttacker(Card card) { attackers.remove(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()) {
|
if (band.isEmpty()) {
|
||||||
// An empty band is not a valid band
|
// An empty band is not a valid band
|
||||||
return false;
|
return false;
|
||||||
@@ -64,7 +64,7 @@ public class AttackingBand {
|
|||||||
|
|
||||||
public boolean canJoinBand(Card card) {
|
public boolean canJoinBand(Card card) {
|
||||||
// Trying to join an existing band, attackers should be non-empty and card should exist
|
// 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) {
|
if (card != null) {
|
||||||
newBand.add(card);
|
newBand.add(card);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user