mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
- The AI will no longer hold back creatures from attacking if they can't block any of the human creatures (for example creatures with shadow).
This commit is contained in:
@@ -38,7 +38,7 @@ public class ComputerUtil_Attack2 {
|
|||||||
playerCreatures = playerCreatures.getType("Creature");
|
playerCreatures = playerCreatures.getType("Creature");
|
||||||
|
|
||||||
attackers = getPossibleAttackers(possibleAttackers);
|
attackers = getPossibleAttackers(possibleAttackers);
|
||||||
blockers = getPossibleBlockers(possibleBlockers);
|
blockers = getPossibleBlockers(possibleBlockers, attackers);
|
||||||
this.blockerLife = blockerLife;
|
this.blockerLife = blockerLife;
|
||||||
}//constructor
|
}//constructor
|
||||||
|
|
||||||
@@ -52,15 +52,20 @@ public class ComputerUtil_Attack2 {
|
|||||||
return list;
|
return list;
|
||||||
}//getUntappedCreatures()
|
}//getUntappedCreatures()
|
||||||
|
|
||||||
public CardList getPossibleBlockers(CardList in)
|
public CardList getPossibleBlockers(CardList blockers, CardList attackers)
|
||||||
{
|
{
|
||||||
CardList list = new CardList(in.toArray());
|
CardList possibleBlockers = new CardList(blockers.toArray());
|
||||||
list = list.filter(new CardListFilter()
|
final CardList attackerList = new CardList(attackers.toArray());
|
||||||
{
|
possibleBlockers = possibleBlockers.filter(new CardListFilter() {
|
||||||
public boolean addCard(Card c) { return c.isCreature() && CombatUtil.canBlock(c); }
|
public boolean addCard(Card c) {
|
||||||
|
if (!c.isCreature()) return false;
|
||||||
|
for (Card attacker:attackerList) {
|
||||||
|
if(CombatUtil.canBlock(attacker, c)) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return list;
|
return possibleBlockers;
|
||||||
}//getUntappedCreatures()
|
}//getUntappedCreatures()
|
||||||
|
|
||||||
//this checks to make sure that the computer player
|
//this checks to make sure that the computer player
|
||||||
@@ -72,7 +77,8 @@ public class ComputerUtil_Attack2 {
|
|||||||
CardListUtil.sortAttackLowFirst(attackers);
|
CardListUtil.sortAttackLowFirst(attackers);
|
||||||
int blockersNeeded = attackers.size();
|
int blockersNeeded = attackers.size();
|
||||||
|
|
||||||
CardList list = getPossibleBlockers(attackers);
|
//don't hold back creatures that can't block any of the human creatures
|
||||||
|
CardList list = getPossibleBlockers(attackers, humanList);
|
||||||
|
|
||||||
for(int i = 0; i < list.size(); i++) {
|
for(int i = 0; i < list.size(); i++) {
|
||||||
if(!doesHumanAttackAndWin(i)) {
|
if(!doesHumanAttackAndWin(i)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user