@Override protected int evaluate(Player player, Game game) { if (player.getOutcome().hasWon()) { for (Player p : game.getRegisteredPlayers()) { if (p.isOpponentOf(player) && p.getOutcome().lossState == GameLossReason.CommanderDamage) { Integer damage = p.getCommanderDamage(player.getCommander()); if (damage != null && damage >= THRESHOLD) { return damage; } } } } return 0; }
@Override public Player chooseSinglePlayer(Player ai, SpellAbility sa, Iterable<Player> choices) { Player chosen = null; if ("Curse".equals(sa.getParam("AILogic"))) { for (Player pc : choices) { if (pc.isOpponentOf(ai)) { chosen = pc; break; } } if (chosen == null) { chosen = Iterables.getFirst(choices, null); System.out.println("No good curse choices. Picking first available: " + chosen); } } else if ("Pump".equals(sa.getParam("AILogic"))) { chosen = Iterables.contains(choices, ai) ? ai : Iterables.getFirst(choices, null); } else if ("BestAllyBoardPosition".equals(sa.getParam("AILogic"))) { List<Player> prefChoices = Lists.newArrayList(choices); prefChoices.removeAll(ai.getOpponents()); if (!prefChoices.isEmpty()) { chosen = ComputerUtil.evaluateBoardPosition(prefChoices); } if (chosen == null) { chosen = Iterables.getFirst(choices, null); System.out.println("No good curse choices. Picking first available: " + chosen); } } else if ("MostCardsInHand".equals(sa.getParam("AILogic"))) { int cardsInHand = 0; for (final Player p : choices) { int hand = p.getCardsIn(ZoneType.Hand).size(); if (hand >= cardsInHand) { chosen = p; cardsInHand = hand; } } } else if ("LeastCreatures".equals(sa.getParam("AILogic"))) { int creats = 50; for (final Player p : choices) { int curr = p.getCreaturesInPlay().size(); if (curr <= creats) { chosen = p; creats = curr; } } } else { System.out.println("Default player choice logic."); chosen = Iterables.contains(choices, ai) ? ai : Iterables.getFirst(choices, null); } return chosen; }