Search in sources :

Example 6 with AddCountersSourceEffect

use of mage.abilities.effects.common.counter.AddCountersSourceEffect in project mage by magefree.

the class JinxedChokerCounterEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent sourcePermanent = game.getPermanent(source.getSourceId());
    if (controller != null && sourcePermanent != null) {
        if (!sourcePermanent.getCounters(game).containsKey(CounterType.CHARGE) || controller.chooseUse(outcome, "Put a charge counter on? (No removes one)", source, game)) {
            return new AddCountersSourceEffect(CounterType.CHARGE.createInstance(), true).apply(game, source);
        } else {
            return new RemoveCounterSourceEffect(CounterType.CHARGE.createInstance()).apply(game, source);
        }
    }
    return false;
}
Also used : AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) RemoveCounterSourceEffect(mage.abilities.effects.common.counter.RemoveCounterSourceEffect)

Example 7 with AddCountersSourceEffect

use of mage.abilities.effects.common.counter.AddCountersSourceEffect in project mage by magefree.

the class LaeliaTheBladeReforgedAddCountersTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    ZoneChangeGroupEvent zEvent = (ZoneChangeGroupEvent) event;
    final int numberExiled = zEvent.getCards().size();
    if (zEvent.getToZone() != Zone.EXILED || numberExiled == 0) {
        return false;
    }
    switch(zEvent.getFromZone()) {
        case LIBRARY:
            if (zEvent.getCards().stream().filter(Objects::nonNull).map(Card::getOwnerId).anyMatch(this::isControlledBy) && numberExiled > 0) {
                this.getEffects().clear();
                this.getEffects().add(new AddCountersSourceEffect(CounterType.P1P1.createInstance()));
                return true;
            }
        case GRAVEYARD:
            if (zEvent.getCards().stream().filter(Objects::nonNull).map(Card::getOwnerId).anyMatch(this::isControlledBy) && numberExiled > 0) {
                this.getEffects().clear();
                this.getEffects().add(new AddCountersSourceEffect(CounterType.P1P1.createInstance()));
                return true;
            }
    }
    return false;
}
Also used : AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) ZoneChangeGroupEvent(mage.game.events.ZoneChangeGroupEvent) Card(mage.cards.Card)

Example 8 with AddCountersSourceEffect

use of mage.abilities.effects.common.counter.AddCountersSourceEffect in project mage by magefree.

the class PrimalAdversaryToken method apply.

@Override
public boolean apply(Game game, Ability source) {
    Integer timesPaid = (Integer) getValue("timesPaid");
    if (timesPaid == null || timesPaid <= 0) {
        return false;
    }
    ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance(timesPaid)), false, staticText);
    ability.addEffect(new BecomesCreatureTargetEffect(new PrimalAdversaryToken(), false, true, Duration.Custom));
    ability.addTarget(new TargetPermanent(0, timesPaid, StaticFilters.FILTER_CONTROLLED_PERMANENT_LANDS));
    game.fireReflexiveTriggeredAbility(ability, source);
    return true;
}
Also used : AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) BecomesCreatureTargetEffect(mage.abilities.effects.common.continuous.BecomesCreatureTargetEffect) TargetPermanent(mage.target.TargetPermanent)

Example 9 with AddCountersSourceEffect

use of mage.abilities.effects.common.counter.AddCountersSourceEffect in project mage by magefree.

the class RakshasaVizierTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    ZoneChangeGroupEvent zEvent = (ZoneChangeGroupEvent) event;
    if (zEvent != null && Zone.GRAVEYARD == zEvent.getFromZone() && Zone.EXILED == zEvent.getToZone() && zEvent.getCards() != null) {
        int cardCount = 0;
        for (Card card : zEvent.getCards()) {
            if (card != null && card.isOwnedBy(getControllerId())) {
                cardCount++;
            }
        }
        if (cardCount == 0) {
            return false;
        }
        this.getEffects().clear();
        this.getEffects().add(new AddCountersSourceEffect(CounterType.P1P1.createInstance(cardCount)));
        return true;
    }
    return false;
}
Also used : AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) ZoneChangeGroupEvent(mage.game.events.ZoneChangeGroupEvent) Card(mage.cards.Card)

Example 10 with AddCountersSourceEffect

use of mage.abilities.effects.common.counter.AddCountersSourceEffect in project mage by magefree.

the class ScourgeOfSkolaValeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    for (Cost cost : source.getCosts()) {
        if (cost instanceof SacrificeTargetCost) {
            int amount = ((SacrificeTargetCost) cost).getPermanents().get(0).getToughness().getValue();
            Player player = game.getPlayer(source.getControllerId());
            if (amount > 0 && player != null) {
                return new AddCountersSourceEffect(CounterType.P1P1.createInstance(amount), true).apply(game, source);
            }
        }
    }
    return false;
}
Also used : AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) Player(mage.players.Player) Cost(mage.abilities.costs.Cost) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) TapSourceCost(mage.abilities.costs.common.TapSourceCost)

Aggregations

AddCountersSourceEffect (mage.abilities.effects.common.counter.AddCountersSourceEffect)40 Player (mage.players.Player)21 Permanent (mage.game.permanent.Permanent)20 ReflexiveTriggeredAbility (mage.abilities.common.delayed.ReflexiveTriggeredAbility)5 Cost (mage.abilities.costs.Cost)5 UUID (java.util.UUID)4 RemoveCounterSourceEffect (mage.abilities.effects.common.counter.RemoveCounterSourceEffect)4 Card (mage.cards.Card)4 ZoneChangeGroupEvent (mage.game.events.ZoneChangeGroupEvent)4 Target (mage.target.Target)4 TargetPermanent (mage.target.TargetPermanent)3 MageInt (mage.MageInt)2 Ability (mage.abilities.Ability)2 TapSourceCost (mage.abilities.costs.common.TapSourceCost)2 GenericManaCost (mage.abilities.costs.mana.GenericManaCost)2 ManaCosts (mage.abilities.costs.mana.ManaCosts)2 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)2 CreateTokenEffect (mage.abilities.effects.common.CreateTokenEffect)2 FlyingAbility (mage.abilities.keyword.FlyingAbility)2 CardImpl (mage.cards.CardImpl)2