/** * chooseBoonTarget. * * @param list a {@link forge.CardList} object. * @param type a {@link java.lang.String} object. * @return a {@link forge.game.card.Card} object. */ public static Card chooseBoonTarget(final CardCollectionView list, final String type) { Card choice = null; if (type.equals("P1P1")) { choice = ComputerUtilCard.getBestCreatureAI(list); if (choice == null) { // We'd only get here if list isn't empty, maybe we're trying to animate a land? choice = ComputerUtilCard.getBestLandToAnimate(list); } } else if (type.equals("DIVINITY")) { final CardCollection boon = CardLists.filter( list, new Predicate<Card>() { @Override public boolean apply(final Card c) { return c.getCounters(CounterType.DIVINITY) == 0; } }); choice = ComputerUtilCard.getMostExpensivePermanentAI(boon, null, false); } else { // The AI really should put counters on cards that can use it. // Charge counters on things with Charge abilities, etc. Expand // these above choice = Aggregates.random(list); } return choice; }
private boolean pumpMandatoryTarget( final Player ai, final SpellAbility sa, final boolean mandatory) { final Game game = ai.getGame(); List<Card> list = game.getCardsIn(ZoneType.Battlefield); final TargetRestrictions tgt = sa.getTargetRestrictions(); final Player opp = ai.getOpponent(); list = CardLists.getValidCards( list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getHostCard()); list = CardLists.getTargetableCards(list, sa); if (list.size() < tgt.getMinTargets(sa.getHostCard(), sa)) { sa.resetTargets(); return false; } // Remove anything that's already been targeted for (final Card c : sa.getTargets().getTargetCards()) { list.remove(c); } List<Card> pref; List<Card> forced; final Card source = sa.getHostCard(); if (sa.isCurse()) { pref = CardLists.filterControlledBy(list, opp); forced = CardLists.filterControlledBy(list, ai); } else { pref = CardLists.filterControlledBy(list, ai); forced = CardLists.filterControlledBy(list, opp); } while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(source, sa)) { if (pref.isEmpty()) { break; } Card c; if (CardLists.getNotType(pref, "Creature").isEmpty()) { c = ComputerUtilCard.getBestCreatureAI(pref); } else { c = ComputerUtilCard.getMostExpensivePermanentAI(pref, sa, true); } pref.remove(c); sa.getTargets().add(c); } while (sa.getTargets().getNumTargeted() < tgt.getMinTargets(source, sa)) { if (forced.isEmpty()) { break; } Card c; if (CardLists.getNotType(forced, "Creature").isEmpty()) { c = ComputerUtilCard.getWorstCreatureAI(forced); } else { c = ComputerUtilCard.getCheapestPermanentAI(forced, sa, true); } forced.remove(c); sa.getTargets().add(c); } if (sa.getTargets().getNumTargeted() < tgt.getMinTargets(source, sa)) { sa.resetTargets(); return false; } return true; } // pumpMandatoryTarget()