diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java b/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java index 3429a96e958..9be230185da 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java @@ -697,11 +697,7 @@ public class ComputerUtilMana { // * pay hybrids // * pay phyrexian, keep mana for colorless // * pay colorless - Iterator shards = cost.getDistinctShards().iterator(); - if (shards.hasNext()) { - return shards.next(); - } - return null; + return cost.getShardToPayByPriority(cost.getDistinctShards(), MagicColor.ALL_COLORS); } private static void adjustManaCostToAvoidNegEffects(ManaCostBeingPaid cost, final Card card, Player ai) { diff --git a/forge-game/src/main/java/forge/game/mana/ManaCostBeingPaid.java b/forge-game/src/main/java/forge/game/mana/ManaCostBeingPaid.java index 06b051c2b26..d74b132de2d 100644 --- a/forge-game/src/main/java/forge/game/mana/ManaCostBeingPaid.java +++ b/forge-game/src/main/java/forge/game/mana/ManaCostBeingPaid.java @@ -360,7 +360,7 @@ public class ManaCostBeingPaid { return tryPayMana(color, Iterables.filter(unpaidShards.keySet(), predCanBePaid), (byte)0xFF); } - private ManaCostShard tryPayMana(final byte colorMask, Iterable payableShards, byte possibleUses) { + public ManaCostShard getShardToPayByPriority(Iterable payableShards, byte possibleUses) { Set choice = EnumSet.noneOf(ManaCostShard.class); int priority = Integer.MIN_VALUE; for (ManaCostShard toPay : payableShards) { @@ -378,8 +378,14 @@ public class ManaCostBeingPaid { return null; } - ManaCostShard chosenShard = Iterables.getFirst(choice, null); + return Iterables.getFirst(choice, null); + } + private ManaCostShard tryPayMana(final byte colorMask, Iterable payableShards, byte possibleUses) { + ManaCostShard chosenShard = getShardToPayByPriority(payableShards, possibleUses); + if (chosenShard == null) { + return null; + } ShardCount sc = unpaidShards.get(chosenShard); if (sc != null && sc.xCount > 0) { //if there's any X part of the cost for the chosen shard, pay it off first and track what color was spent to pay X