diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java index bfb27e308ee..00aeda5eecf 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java @@ -8,13 +8,13 @@ import com.google.common.collect.Iterables; import forge.card.CardType; import forge.card.ColorSet; import forge.card.MagicColor; +import forge.card.MagicColor.Constant; import forge.deck.CardPool; import forge.deck.Deck; import forge.deck.DeckSection; import forge.game.Game; import forge.game.ability.AbilityUtils; import forge.game.card.*; -import forge.game.card.CardCollectionView; import forge.game.combat.Combat; import forge.game.combat.CombatUtil; import forge.game.phase.PhaseHandler; @@ -905,6 +905,24 @@ public class ComputerUtilCard { chosen.add(prominence.get(0)); } } + else if (logic.equals("MostExcessOpponentControls")) { + int maxExcess = 0; + String bestColor = Constant.GREEN; + for (byte color : MagicColor.WUBRG) { + CardCollectionView ailist = ai.getCardsIn(ZoneType.Battlefield); + CardCollectionView opplist = ai.getOpponent().getCardsIn(ZoneType.Battlefield); + + ailist = CardLists.filter(ailist, CardPredicates.isColor(color)); + opplist = CardLists.filter(opplist, CardPredicates.isColor(color)); + + int excess = evaluatePermanentList(opplist) - evaluatePermanentList(ailist); + if (excess > maxExcess) { + maxExcess = excess; + bestColor = MagicColor.toLongString(color); + } + } + chosen.add(bestColor); + } else if (logic.equals("MostProminentKeywordInComputerDeck")) { CardCollectionView list = ai.getAllCards(); int m1 = 0; diff --git a/forge-ai/src/main/java/forge/ai/ability/ChooseColorAi.java b/forge-ai/src/main/java/forge/ai/ability/ChooseColorAi.java index e4b5144491d..520588a7688 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseColorAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseColorAi.java @@ -1,10 +1,16 @@ package forge.ai.ability; import forge.ai.ComputerUtil; +import forge.ai.ComputerUtilCard; import forge.ai.ComputerUtilMana; import forge.ai.SpellAbilityAi; +import forge.card.MagicColor; +import forge.card.MagicColor.Constant; import forge.game.Game; import forge.game.card.Card; +import forge.game.card.CardCollectionView; +import forge.game.card.CardLists; +import forge.game.card.CardPredicates; import forge.game.phase.PhaseHandler; import forge.game.phase.PhaseType; import forge.game.player.Player; @@ -22,6 +28,7 @@ public class ChooseColorAi extends SpellAbilityAi { if (!sa.hasParam("AILogic")) { return false; } + final String logic = sa.getParam("AILogic"); if (ComputerUtil.preventRunAwayActivations(sa)) { return false; @@ -45,6 +52,22 @@ public class ChooseColorAi extends SpellAbilityAi { } return true; } + + if (logic.equals("MostExcessOpponentControls")) { + for (byte color : MagicColor.WUBRG) { + CardCollectionView ailist = ai.getCardsIn(ZoneType.Battlefield); + CardCollectionView opplist = ai.getOpponent().getCardsIn(ZoneType.Battlefield); + + ailist = CardLists.filter(ailist, CardPredicates.isColor(color)); + opplist = CardLists.filter(opplist, CardPredicates.isColor(color)); + + int excess = ComputerUtilCard.evaluatePermanentList(opplist) - ComputerUtilCard.evaluatePermanentList(ailist); + if (excess > 4) { + return true; + } + } + return false; + } boolean chance = MyRandom.getRandom().nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn()); return chance; } diff --git a/forge-gui/res/cardsfolder/w/wash_out.txt b/forge-gui/res/cardsfolder/w/wash_out.txt index caf47cc7756..8d5456f6b29 100644 --- a/forge-gui/res/cardsfolder/w/wash_out.txt +++ b/forge-gui/res/cardsfolder/w/wash_out.txt @@ -1,8 +1,7 @@ Name:Wash Out ManaCost:3 U Types:Sorcery -A:SP$ ChooseColor | Cost$ 3 U | Defined$ You | AILogic$ MostProminentHumanCreatures | SubAbility$ DBWash | SpellDescription$ Return all permanents of the color of your choice to their owners' hands. +A:SP$ ChooseColor | Cost$ 3 U | Defined$ You | AILogic$ MostProminentHumanCreatures | SubAbility$ DBWash | AILogic$ MostExcessOpponentControls | SpellDescription$ Return all permanents of the color of your choice to their owners' hands. SVar:DBWash:DB$ ChangeZoneAll | ChangeType$ Permanent.ChosenColor | Origin$ Battlefield | Destination$ Hand -SVar:RemAIDeck:True SVar:Picture:http://www.wizards.com/global/images/magic/general/wash_out.jpg Oracle:Return all permanents of the color of your choice to their owners' hands.