Search in sources :

Example 1 with BoostCounter

use of mage.counters.BoostCounter in project mage by magefree.

the class GameStateEvaluator method evaluatePermanent.

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(game).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().manaValue();
    // TODO: add a difficulty to calculation to ManaCost - sort permanents by difficulty for casting when evaluating game states
    return value;
}
Also used : BoostCounter(mage.counters.BoostCounter) Counter(mage.counters.Counter) ActivatedAbility(mage.abilities.ActivatedAbility) ActivatedManaAbilityImpl(mage.abilities.mana.ActivatedManaAbilityImpl) BoostCounter(mage.counters.BoostCounter)

Example 2 with BoostCounter

use of mage.counters.BoostCounter in project mage by magefree.

the class LesserWerewolfEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent sourcePermanent = game.getPermanent(source.getSourceId());
    // must be valid target
    Permanent targetPermanent = game.getPermanent(targetPointer.getFirst(game, source));
    if (controller != null && sourcePermanent != null && targetPermanent != null) {
        if (sourcePermanent.getPower().getValue() >= 1) {
            game.addEffect(new BoostSourceEffect(-1, 0, Duration.EndOfTurn), source);
            new AddCountersTargetEffect(new BoostCounter(0, -1), outcome).apply(game, source);
        }
        return true;
    }
    return false;
}
Also used : BoostSourceEffect(mage.abilities.effects.common.continuous.BoostSourceEffect) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) BoostCounter(mage.counters.BoostCounter)

Example 3 with BoostCounter

use of mage.counters.BoostCounter in project mage by magefree.

the class ApplyCountersEffect method apply.

@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
    if (layer == Layer.AbilityAddingRemovingEffects_6) {
        for (Permanent permanent : game.getBattlefield().getAllActivePermanents()) {
            for (AbilityCounter counter : permanent.getCounters(game).getAbilityCounters()) {
                permanent.addAbility(counter.getAbility(), source == null ? permanent.getId() : source.getSourceId(), game);
            }
        }
    }
    if (layer == Layer.PTChangingEffects_7 && sublayer == SubLayer.Counters_7d) {
        for (Permanent permanent : game.getBattlefield().getAllActivePermanents(CardType.CREATURE, game)) {
            for (BoostCounter counter : permanent.getCounters(game).getBoostCounters()) {
                permanent.addPower(counter.getPower() * counter.getCount());
                permanent.addToughness(counter.getToughness() * counter.getCount());
            }
        }
    }
    return true;
}
Also used : AbilityCounter(mage.counters.AbilityCounter) Permanent(mage.game.permanent.Permanent) BoostCounter(mage.counters.BoostCounter)

Aggregations

BoostCounter (mage.counters.BoostCounter)3 Permanent (mage.game.permanent.Permanent)2 ActivatedAbility (mage.abilities.ActivatedAbility)1 BoostSourceEffect (mage.abilities.effects.common.continuous.BoostSourceEffect)1 AddCountersTargetEffect (mage.abilities.effects.common.counter.AddCountersTargetEffect)1 ActivatedManaAbilityImpl (mage.abilities.mana.ActivatedManaAbilityImpl)1 AbilityCounter (mage.counters.AbilityCounter)1 Counter (mage.counters.Counter)1 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)1 Player (mage.players.Player)1 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)1