From 20d48358addfb9ab2dba2c84915b85f9b14e7cf2 Mon Sep 17 00:00:00 2001 From: Agetian Date: Wed, 27 Sep 2017 06:20:25 +0000 Subject: [PATCH] - 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 --- .../java/forge/ai/PlayerControllerAi.java | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java b/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java index 8100c047..f0d5667e 100644 --- a/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java +++ b/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java @@ -293,7 +293,42 @@ public class PlayerControllerAi extends PlayerController { @Override 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() { + @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; }