boolean result = true; if (cost.canPay(source, source.getSourceId(), player.getId(), game) && executingEffects.size() > 0 && (!optional || player.chooseUse(executingEffects.get(0).getOutcome(), message, source, game))) { cost.clearPaid(); int bookmark = game.bookmarkState();
public static int evaluatePermanent(Permanent permanent, Game game, boolean ignoreTapped) { int value = 0; if (ignoreTapped) { value = 5; } else { value = permanent.isTapped() ? 4 : 5; } if (permanent.getCardType().contains(CardType.CREATURE)) { value += evaluateCreature(permanent, game) * CREATURE_FACTOR; } value += permanent.getAbilities().getActivatedManaAbilities(Zone.BATTLEFIELD).size(); for (ActivatedAbility ability : permanent.getAbilities().getActivatedAbilities(Zone.BATTLEFIELD)) { if (!(ability instanceof ActivatedManaAbilityImpl) && ability.canActivate(ability.getControllerId(), game).canActivate()) { value += ability.getEffects().size(); } } for (Counter counter : permanent.getCounters(game).values()) { if (!(counter instanceof BoostCounter)) { value += counter.getCount(); } } value += permanent.getAbilities().getStaticAbilities(Zone.BATTLEFIELD).size(); value += permanent.getAbilities().getTriggeredAbilities(Zone.BATTLEFIELD).size(); value += permanent.getManaCost().convertedManaCost(); //TODO: add a difficulty to calculation to ManaCost - sort permanents by difficulty for casting when evaluating game states return value; }