Search in sources :

Example 11 with Counters

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

the class UndyingEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Counters countersToAdd = new Counters();
    countersToAdd.addCounter(CounterType.P1P1.createInstance());
    game.setEnterWithCounters(source.getSourceId(), countersToAdd);
    return true;
}
Also used : Counters(mage.counters.Counters)

Example 12 with Counters

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

the class SkullbriarEffect method updateZoneChangeCounter.

@Override
public void updateZoneChangeCounter(Game game, ZoneChangeEvent event) {
    boolean skullBriarEffectApplied = false;
    if (event.getToZone() != Zone.HAND && event.getToZone() != Zone.LIBRARY) {
        for (StaticAbility ability : getAbilities(game).getStaticAbilities(event.getFromZone())) {
            for (Effect effect : ability.getEffects(game, EffectType.REPLACEMENT)) {
                if (effect instanceof SkullbriarEffect && event.getAppliedEffects().contains(effect.getId())) {
                    skullBriarEffectApplied = true;
                }
            }
        }
    }
    Counters copyFrom = null;
    if (skullBriarEffectApplied) {
        if (event.getTarget() != null && event.getFromZone() == Zone.BATTLEFIELD) {
            copyFrom = new Counters(event.getTarget().getCounters(game));
        } else {
            copyFrom = new Counters(this.getCounters(game));
        }
    }
    super.updateZoneChangeCounter(game, event);
    Counters copyTo = null;
    if (event.getTarget() != null && event.getToZone() == Zone.BATTLEFIELD) {
        if (event.getFromZone() != Zone.BATTLEFIELD) {
            copyTo = event.getTarget().getCounters(game);
        }
    } else {
        copyTo = this.getCounters(game);
    }
    if (copyTo != null && copyFrom != null) {
        for (Counter counter : copyFrom.values()) {
            copyTo.addCounter(counter);
        }
    }
}
Also used : Counter(mage.counters.Counter) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) StaticAbility(mage.abilities.StaticAbility) ContinuousEffect(mage.abilities.effects.ContinuousEffect) AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) Effect(mage.abilities.effects.Effect) Counters(mage.counters.Counters)

Example 13 with Counters

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

the class IsarethTheAwakenerReplacementEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Card card = game.getCard(this.getTargetPointer().getFirst(game, source));
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null || card == null) {
        return false;
    }
    Counters countersToAdd = new Counters();
    countersToAdd.addCounter(CounterType.CORPSE.createInstance());
    game.setEnterWithCounters(card.getId(), countersToAdd);
    return controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
Also used : Player(mage.players.Player) Counters(mage.counters.Counters) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard)

Example 14 with Counters

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

the class TheOzolithMoveCountersEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (!super.checkTrigger(event, game)) {
        return false;
    }
    Permanent permanent = ((ZoneChangeEvent) event).getTarget();
    Counters counters = permanent.getCounters(game);
    if (counters.values().stream().mapToInt(Counter::getCount).noneMatch(x -> x > 0)) {
        return false;
    }
    this.getEffects().clear();
    this.addEffect(new TheOzolithLeaveEffect(counters));
    return true;
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Counters(mage.counters.Counters)

Example 15 with Counters

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

the class PersistEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Counters countersToAdd = new Counters();
    countersToAdd.addCounter(CounterType.M1M1.createInstance());
    game.setEnterWithCounters(source.getSourceId(), countersToAdd);
    return true;
}
Also used : Counters(mage.counters.Counters)

Aggregations

Counters (mage.counters.Counters)17 Permanent (mage.game.permanent.Permanent)13 Player (mage.players.Player)10 Counter (mage.counters.Counter)7 Card (mage.cards.Card)5 CounterType (mage.counters.CounterType)4 TargetPermanent (mage.target.TargetPermanent)4 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)3 ContinuousEffect (mage.abilities.effects.ContinuousEffect)3 PermanentToken (mage.game.permanent.PermanentToken)3 UUID (java.util.UUID)2 Effect (mage.abilities.effects.Effect)2 FilterPermanent (mage.filter.FilterPermanent)2 TargetPermanentOrPlayer (mage.target.common.TargetPermanentOrPlayer)2 IOException (java.io.IOException)1 Serializable (java.io.Serializable)1 java.util (java.util)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1