(Player ai, List<Object> options, SpellAbility sa, Multimap<Object, Player> votes, Player forPlayer)
| 2530 | } |
| 2531 | |
| 2532 | public static Object vote(Player ai, List<Object> options, SpellAbility sa, Multimap<Object, Player> votes, Player forPlayer) { |
| 2533 | final Card source = sa.getHostCard(); |
| 2534 | final Player controller = source.getController(); |
| 2535 | final Game game = controller.getGame(); |
| 2536 | |
| 2537 | boolean opponent = controller.isOpponentOf(ai); |
| 2538 | |
| 2539 | final CounterType p1p1Type = CounterEnumType.P1P1; |
| 2540 | |
| 2541 | if (!sa.hasParam("AILogic")) { |
| 2542 | return Aggregates.random(options); |
| 2543 | } |
| 2544 | |
| 2545 | String logic = sa.getParam("AILogic"); |
| 2546 | switch (logic) { |
| 2547 | case "Torture": |
| 2548 | return options.get(1); |
| 2549 | case "GraceOrCondemnation": |
| 2550 | List<ZoneType> graceZones = new ArrayList<ZoneType>(); |
| 2551 | graceZones.add(ZoneType.Battlefield); |
| 2552 | graceZones.add(ZoneType.Graveyard); |
| 2553 | CardCollection graceCreatures = CardLists.getType(game.getCardsIn(graceZones), "Creature"); |
| 2554 | int humanGrace = CardLists.filterControlledBy(graceCreatures, ai.getOpponents()).size(); |
| 2555 | int aiGrace = CardLists.filterControlledBy(graceCreatures, ai).size(); |
| 2556 | return options.get(aiGrace > humanGrace ? 0 : 1); |
| 2557 | case "CarnageOrHomage": |
| 2558 | CardCollection cardsInPlay = CardLists.getNotType(game.getCardsIn(ZoneType.Battlefield), "Land"); |
| 2559 | CardCollection humanlist = CardLists.filterControlledBy(cardsInPlay, ai.getOpponents()); |
| 2560 | CardCollection computerlist = ai.getCreaturesInPlay(); |
| 2561 | return options.get(ComputerUtilCard.evaluatePermanentList(computerlist) + 3 < ComputerUtilCard.evaluatePermanentList(humanlist) ? 0 : 1); |
| 2562 | case "Judgment": |
| 2563 | if (votes.isEmpty()) { |
| 2564 | CardCollection list = new CardCollection(); |
| 2565 | for (Object o : options) { |
| 2566 | if (o instanceof Card) { |
| 2567 | list.add((Card) o); |
| 2568 | } |
| 2569 | } |
| 2570 | return ComputerUtilCard.getBestAI(list); |
| 2571 | } |
| 2572 | return Iterables.getFirst(votes.keySet(), null); |
| 2573 | case "Protection": |
| 2574 | if (votes.isEmpty()) { |
| 2575 | Map<String, SpellAbility> restrictedToColors = Maps.newHashMap(); |
| 2576 | for (Object o : options) { |
| 2577 | if (o instanceof SpellAbility sp) { // TODO check for Color Word Changes |
| 2578 | restrictedToColors.put(sp.getOriginalDescription(), sp); |
| 2579 | } |
| 2580 | } |
| 2581 | CardCollection lists = CardLists.filterControlledBy(game.getCardsInGame(), ai.getOpponents()); |
| 2582 | return restrictedToColors.get(StringUtils.capitalize(ComputerUtilCard.getMostProminentColor(lists, restrictedToColors.keySet()))); |
| 2583 | } |
| 2584 | return Iterables.getFirst(votes.keySet(), null); |
| 2585 | case "FeatherOrQuill": |
| 2586 | SpellAbility feather = (SpellAbility)options.get(0); |
| 2587 | SpellAbility quill = (SpellAbility)options.get(1); |
| 2588 | // try to mill opponent with Quill vote |
| 2589 | if (opponent && !controller.cantLoseCheck(GameLossReason.Milled)) { |
no test coverage detected