mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
* Fixed that computer player could discard cards that did not match the given filter (to pay e.g. discard costs of Mox Diamond - fixes #7028).
This commit is contained in:
parent
61315ec741
commit
668a21fc18
1 changed files with 12 additions and 12 deletions
|
@ -512,10 +512,10 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
||||||
|| target.getOriginalTarget() instanceof TargetCardInHand) {
|
|| target.getOriginalTarget() instanceof TargetCardInHand) {
|
||||||
if (outcome.isGood()) {
|
if (outcome.isGood()) {
|
||||||
// good
|
// good
|
||||||
Cards cards = new CardsImpl(target.possibleTargets(sourceId, getId(), game));
|
Cards cards = new CardsImpl(possibleTargets);
|
||||||
List<Card> cardsInHand = new ArrayList<>(cards.getCards(game));
|
List<Card> cardsInHand = new ArrayList<>(cards.getCards(game));
|
||||||
while (!target.isChosen()
|
while (!target.isChosen()
|
||||||
&& !target.possibleTargets(sourceId, getId(), game).isEmpty()
|
&& !cardsInHand.isEmpty()
|
||||||
&& target.getMaxNumberOfTargets() > target.getTargets().size()) {
|
&& target.getMaxNumberOfTargets() > target.getTargets().size()) {
|
||||||
Card card = pickBestCard(cardsInHand, null, target, source, game);
|
Card card = pickBestCard(cardsInHand, null, target, source, game);
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
|
@ -531,20 +531,20 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
||||||
} else {
|
} else {
|
||||||
// bad
|
// bad
|
||||||
findPlayables(game);
|
findPlayables(game);
|
||||||
if (!unplayable.isEmpty()) {
|
for (Card card : unplayable.values()) {
|
||||||
for (int i = unplayable.size() - 1; i >= 0; i--) {
|
if (possibleTargets.contains(card.getId())
|
||||||
if (target.canTarget(abilityControllerId, unplayable.values().toArray(new Card[0])[i].getId(), source, game)) {
|
&& target.canTarget(abilityControllerId, card.getId(), source, game)) {
|
||||||
target.addTarget(unplayable.values().toArray(new Card[0])[i].getId(), source, game);
|
target.addTarget(card.getId(), source, game);
|
||||||
if (target.isChosen()) {
|
if (target.isChosen()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!hand.isEmpty()) {
|
if (!hand.isEmpty()) {
|
||||||
for (int i = 0; i < hand.size(); i++) {
|
for (Card card : hand.getCards(game)) {
|
||||||
if (target.canTarget(abilityControllerId, hand.toArray(new UUID[0])[i], source, game)) {
|
if (possibleTargets.contains(card.getId())
|
||||||
target.addTarget(hand.toArray(new UUID[0])[i], source, game);
|
&& target.canTarget(abilityControllerId, card.getId(), source, game)) {
|
||||||
|
target.addTarget(card.getId(), source, game);
|
||||||
if (target.isChosen()) {
|
if (target.isChosen()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue