ComputerUtilCost: checkDiscardCost: remove from hand what is already selected for discard

This commit is contained in:
Hanmac
2016-07-30 18:58:37 +00:00
parent 29c0f4bfaa
commit 443ee670cd

View File

@@ -100,6 +100,9 @@ public class ComputerUtilCost {
if (cost == null) { if (cost == null) {
return true; return true;
} }
CardCollection hand = new CardCollection(ai.getCardsIn(ZoneType.Hand));
for (final CostPart part : cost.getCostParts()) { for (final CostPart part : cost.getCostParts()) {
if (part instanceof CostDiscard) { if (part instanceof CostDiscard) {
final CostDiscard disc = (CostDiscard) part; final CostDiscard disc = (CostDiscard) part;
@@ -108,7 +111,7 @@ public class ComputerUtilCost {
if (type.equals("CARDNAME") && source.getAbilityText().contains("Bloodrush")) { if (type.equals("CARDNAME") && source.getAbilityText().contains("Bloodrush")) {
continue; continue;
} }
final CardCollection typeList = CardLists.getValidCards(ai.getCardsIn(ZoneType.Hand), type.split(","), source.getController(), source, null); final CardCollection typeList = CardLists.getValidCards(hand, type.split(","), source.getController(), source, null);
if (typeList.size() > ai.getMaxHandSize()) { if (typeList.size() > ai.getMaxHandSize()) {
continue; continue;
} }
@@ -119,6 +122,7 @@ public class ComputerUtilCost {
return false; return false;
} else { } else {
typeList.remove(pref); typeList.remove(pref);
hand.remove(pref);
} }
} }
} }