Search in sources :

Example 1 with CountersSourceCount

use of mage.abilities.dynamicvalue.common.CountersSourceCount in project mage by magefree.

the class ChargingCinderhornDamageTargetEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent chargingCinderhoof = game.getPermanent(source.getSourceId());
    if (chargingCinderhoof != null) {
        chargingCinderhoof.addCounters(CounterType.FURY.createInstance(), source.getControllerId(), source, game);
    } else {
        chargingCinderhoof = game.getPermanentOrLKIBattlefield(source.getSourceId());
    }
    if (chargingCinderhoof == null) {
        return false;
    }
    DynamicValue amount = new CountersSourceCount(CounterType.FURY);
    Player player = game.getPlayer(targetPointer.getFirst(game, source));
    if (player != null) {
        player.damage(amount.calculate(game, source, this), source.getSourceId(), source, game);
        return true;
    }
    return false;
}
Also used : CountersSourceCount(mage.abilities.dynamicvalue.common.CountersSourceCount) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) DynamicValue(mage.abilities.dynamicvalue.DynamicValue)

Example 2 with CountersSourceCount

use of mage.abilities.dynamicvalue.common.CountersSourceCount in project mage by magefree.

the class NissaStewardOfElementsToken method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    int count = 1 + new CountersSourceCount(CounterType.LOYALTY).calculate(game, source, this);
    FilterPermanentCard filter = new FilterPermanentCard();
    filter.add(Predicates.or(CardType.CREATURE.getPredicate(), CardType.LAND.getPredicate()));
    filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, count));
    Card card = controller.getLibrary().getFromTop(game);
    if (card != null) {
        controller.lookAtCards(source, null, new CardsImpl(card), game);
        if (filter.match(card, game)) {
            if (controller.chooseUse(outcome, "Put " + card.getName() + " onto the battlefield?", source, game)) {
                controller.moveCards(card, Zone.BATTLEFIELD, source, game);
            }
        }
    }
    return true;
}
Also used : CountersSourceCount(mage.abilities.dynamicvalue.common.CountersSourceCount) Player(mage.players.Player) FilterPermanentCard(mage.filter.common.FilterPermanentCard) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card) FilterPermanentCard(mage.filter.common.FilterPermanentCard)

Example 3 with CountersSourceCount

use of mage.abilities.dynamicvalue.common.CountersSourceCount in project mage by magefree.

the class PhantasmalSphereToken method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player targetOpponent = game.getPlayer(source.getFirstTarget());
    if (controller != null && targetOpponent != null) {
        Effect effect = new CreateTokenTargetEffect(new PhantasmalSphereToken(new CountersSourceCount(CounterType.P1P1).calculate(game, source, null)));
        effect.setTargetPointer(new FixedTarget(targetOpponent.getId()));
        effect.apply(game, source);
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) CountersSourceCount(mage.abilities.dynamicvalue.common.CountersSourceCount) Player(mage.players.Player) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) SacrificeSourceUnlessPaysEffect(mage.abilities.effects.common.SacrificeSourceUnlessPaysEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) Effect(mage.abilities.effects.Effect)

Example 4 with CountersSourceCount

use of mage.abilities.dynamicvalue.common.CountersSourceCount in project mage by magefree.

the class RiptideReplicatorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color");
    SubType subType = ChooseCreatureTypeEffect.getChosenCreatureType(source.getSourceId(), game);
    if (subType == null) {
        return false;
    }
    int x = (new CountersSourceCount(CounterType.CHARGE)).calculate(game, source, this);
    Token token = new RiptideReplicatorToken(color, subType, x);
    return token.putOntoBattlefield(1, game, source, source.getControllerId());
}
Also used : CountersSourceCount(mage.abilities.dynamicvalue.common.CountersSourceCount) RiptideReplicatorToken(mage.game.permanent.token.RiptideReplicatorToken) SubType(mage.constants.SubType) ObjectColor(mage.ObjectColor) RiptideReplicatorToken(mage.game.permanent.token.RiptideReplicatorToken) Token(mage.game.permanent.token.Token)

Example 5 with CountersSourceCount

use of mage.abilities.dynamicvalue.common.CountersSourceCount in project mage by magefree.

the class UnboostCreaturesDefendingPlayerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) {
        Permanent permanent = it.next().getPermanent(game);
        if (permanent != null) {
            int unboostCount = -1 * new CountersSourceCount(CounterType.P1P1).calculate(game, source, this);
            permanent.addPower(unboostCount);
            permanent.addToughness(unboostCount);
        } else {
            it.remove();
        }
    }
    return true;
}
Also used : CountersSourceCount(mage.abilities.dynamicvalue.common.CountersSourceCount) Permanent(mage.game.permanent.Permanent) MageObjectReference(mage.MageObjectReference)

Aggregations

CountersSourceCount (mage.abilities.dynamicvalue.common.CountersSourceCount)5 Player (mage.players.Player)3 Permanent (mage.game.permanent.Permanent)2 MageObjectReference (mage.MageObjectReference)1 ObjectColor (mage.ObjectColor)1 DynamicValue (mage.abilities.dynamicvalue.DynamicValue)1 Effect (mage.abilities.effects.Effect)1 OneShotEffect (mage.abilities.effects.OneShotEffect)1 CreateTokenTargetEffect (mage.abilities.effects.common.CreateTokenTargetEffect)1 SacrificeSourceUnlessPaysEffect (mage.abilities.effects.common.SacrificeSourceUnlessPaysEffect)1 AddCountersSourceEffect (mage.abilities.effects.common.counter.AddCountersSourceEffect)1 Card (mage.cards.Card)1 CardsImpl (mage.cards.CardsImpl)1 SubType (mage.constants.SubType)1 FilterPermanentCard (mage.filter.common.FilterPermanentCard)1 ManaValuePredicate (mage.filter.predicate.mageobject.ManaValuePredicate)1 RiptideReplicatorToken (mage.game.permanent.token.RiptideReplicatorToken)1 Token (mage.game.permanent.token.Token)1 FixedTarget (mage.target.targetpointer.FixedTarget)1