- PlayerControllerAi: when playing with ordered graveyards and there's a Volrath's Shapeshifter in the game, try to place the best creature on top of the graveyard for the most value if Volrath's Shapeshifter hits the battlefield.

git-svn-id: http://svn.slightlymagic.net/forge/trunk@35788 269b9781-a132-4a9b-9d4e-f004f1b56b58
This commit is contained in:
Agetian 2017-09-27 06:20:25 +00:00
parent 87ff5ea1bc
commit 20d48358ad

View File

@ -293,7 +293,42 @@ public class PlayerControllerAi extends PlayerController {
@Override @Override
public CardCollectionView orderMoveToZoneList(CardCollectionView cards, ZoneType destinationZone, SpellAbility source) { public CardCollectionView orderMoveToZoneList(CardCollectionView cards, ZoneType destinationZone, SpellAbility source) {
//TODO Add logic for AI ordering here //TODO Add more logic for AI ordering here
// In presence of Volrath's Shapeshifter in deck, try to place the best creature on top of the graveyard
if (destinationZone == ZoneType.Graveyard && game.isGraveyardOrdered()) {
if (!CardLists.filter(game.getCardsInGame(), new Predicate<Card>() {
@Override
public boolean apply(Card card) {
// need a custom predicate here since Volrath's Shapeshifter may have a different name OTB
return card.getName().equals("Volrath's Shapeshifter")
|| card.getStates().contains(CardStateName.OriginalText) && card.getState(CardStateName.OriginalText).getName().equals("Volrath's Shapeshifter");
}
}).isEmpty()) {
int bestValue = 0;
Card bestCreature = null;
for (Card c : cards) {
int curValue = ComputerUtilCard.evaluateCreature(c);
if (c.isCreature() && curValue > bestValue) {
bestValue = curValue;
bestCreature = c;
}
}
if (bestCreature != null) {
CardCollection reordered = new CardCollection();
for (Card c : cards) {
if (!c.equals(bestCreature)) {
reordered.add(c);
}
}
reordered.add(bestCreature);
return reordered;
}
}
}
// Default: return with the same order as was passed into this method
return cards; return cards;
} }