ComputerUtil: scoreHand, prevent crash on zero lands deck

This commit is contained in:
Hanmac
2016-08-08 12:21:22 +00:00
parent b0f357d0e8
commit 088879bdd0

View File

@@ -1543,6 +1543,14 @@ public class ComputerUtil {
return handList.size(); return handList.size();
} }
CardCollectionView library = ai.getZone(ZoneType.Library).getCards();
int landsInDeck = CardLists.filter(library, CardPredicates.isType("Land")).size();
// no land deck, can't do anything better
if (landsInDeck == 0) {
return handList.size();
}
final CardCollectionView lands = CardLists.filter(handList, new Predicate<Card>() { final CardCollectionView lands = CardLists.filter(handList, new Predicate<Card>() {
@Override @Override
public boolean apply(final Card c) { public boolean apply(final Card c) {
@@ -1581,9 +1589,6 @@ public class ComputerUtil {
return score; return score;
} }
CardCollectionView library = ai.getZone(ZoneType.Library).getCards();
int landsInDeck = CardLists.filter(library, CardPredicates.isType("Land")).size();
// otherwise, reject bad hands or return score // otherwise, reject bad hands or return score
if ( landSize < 2) { if ( landSize < 2) {
// BAD Hands, 0 or 1 lands // BAD Hands, 0 or 1 lands