forked from External/mage
Fixed that AI can handle TargetDiscard or TargetCardInHand with MinNumberOfTargets > 1.
This commit is contained in:
parent
dcce8c30a1
commit
7c6666062e
1 changed files with 17 additions and 7 deletions
|
|
@ -363,11 +363,17 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
|
|||
}
|
||||
if (target instanceof TargetDiscard || target instanceof TargetCardInHand) {
|
||||
if (outcome.isGood()) {
|
||||
Card card = pickBestCard(new ArrayList<Card>(hand.getCards(game)), null, target, source, game);
|
||||
if (card != null) {
|
||||
if (target.canTarget(card.getId(), source, game)) {
|
||||
target.addTarget(card.getId(), source, game);
|
||||
return true;
|
||||
ArrayList<Card> cardsInHand = new ArrayList<Card>(hand.getCards(game));
|
||||
while (!target.isChosen() && !cardsInHand.isEmpty() && target.getMaxNumberOfTargets() < target.getTargets().size()) {
|
||||
Card card = pickBestCard(cardsInHand, null, target, source, game);
|
||||
if (card != null) {
|
||||
if (target.canTarget(card.getId(), source, game)) {
|
||||
target.addTarget(card.getId(), source, game);
|
||||
cardsInHand.remove(card);
|
||||
if (target.isChosen()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -377,7 +383,9 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
|
|||
for (int i = unplayable.size() - 1; i >= 0; i--) {
|
||||
if (target.canTarget(unplayable.values().toArray(new Card[0])[i].getId(), source, game)) {
|
||||
target.addTarget(unplayable.values().toArray(new Card[0])[i].getId(), source, game);
|
||||
return true;
|
||||
if (target.isChosen()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -385,7 +393,9 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
|
|||
for (int i = 0; i < hand.size(); i++) {
|
||||
if (target.canTarget(hand.toArray(new UUID[0])[i], source, game)) {
|
||||
target.addTarget(hand.toArray(new UUID[0])[i], source, game);
|
||||
return true;
|
||||
if (target.isChosen()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue