Search in sources :

Example 1 with AbilityCounter

use of mage.counters.AbilityCounter 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

AbilityCounter (mage.counters.AbilityCounter)1 BoostCounter (mage.counters.BoostCounter)1 Permanent (mage.game.permanent.Permanent)1