Search in sources :

Example 6 with DynamicValue

use of mage.abilities.dynamicvalue.DynamicValue in project mage by magefree.

the class DispersalShieldEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    DynamicValue amount = new HighestManaValueCount();
    Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source));
    if (spell != null && spell.getManaValue() <= amount.calculate(game, source, this)) {
        return game.getStack().counter(source.getFirstTarget(), source, game);
    }
    return false;
}
Also used : DynamicValue(mage.abilities.dynamicvalue.DynamicValue) Spell(mage.game.stack.Spell) TargetSpell(mage.target.TargetSpell) HighestManaValueCount(mage.abilities.dynamicvalue.common.HighestManaValueCount)

Example 7 with DynamicValue

use of mage.abilities.dynamicvalue.DynamicValue in project mage by magefree.

the class PacksDisdainEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
    if (player != null && player.choose(Outcome.UnboostCreature, typeChoice, game)) {
        FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
        filter.add(SubType.byDescription(typeChoice.getChoice()).getPredicate());
        DynamicValue negativePermanentsCount = new PermanentsOnBattlefieldCount(filter, -1);
        ContinuousEffect effect = new BoostTargetEffect(negativePermanentsCount, negativePermanentsCount, Duration.EndOfTurn, true);
        effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
        game.addEffect(effect, source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Choice(mage.choices.Choice) BoostTargetEffect(mage.abilities.effects.common.continuous.BoostTargetEffect) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) ChoiceCreatureType(mage.choices.ChoiceCreatureType) PermanentsOnBattlefieldCount(mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount) ContinuousEffect(mage.abilities.effects.ContinuousEffect) DynamicValue(mage.abilities.dynamicvalue.DynamicValue)

Example 8 with DynamicValue

use of mage.abilities.dynamicvalue.DynamicValue in project mage by magefree.

the class CleansingMeditationEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Cards cardsToBattlefield = new CardsImpl();
    // Threshold?
    boolean threshold = false;
    DynamicValue c = new CardsInControllerGraveyardCount();
    int numCards = c.calculate(game, source, this);
    if (numCards >= 7) {
        threshold = true;
    }
    Player controller = game.getPlayer(source.getControllerId());
    for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_ENCHANTMENT, source.getControllerId(), source.getSourceId(), game)) {
        if (permanent != null && permanent.destroy(source, game, false)) {
            if (threshold && controller != null && permanent.isOwnedBy(controller.getId())) {
                cardsToBattlefield.add(permanent);
            }
        }
    }
    if (threshold && controller != null) {
        controller.moveCards(cardsToBattlefield, Zone.BATTLEFIELD, source, game);
    }
    return true;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) CardsInControllerGraveyardCount(mage.abilities.dynamicvalue.common.CardsInControllerGraveyardCount) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) DynamicValue(mage.abilities.dynamicvalue.DynamicValue)

Example 9 with DynamicValue

use of mage.abilities.dynamicvalue.DynamicValue in project mage by magefree.

the class AncientExcavationEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player != null) {
        DynamicValue numCards = CardsInControllerHandCount.instance;
        int amount = numCards.calculate(game, source, this);
        player.drawCards(amount, source, game);
        player.discard(amount, false, false, source, game);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) DynamicValue(mage.abilities.dynamicvalue.DynamicValue)

Example 10 with DynamicValue

use of mage.abilities.dynamicvalue.DynamicValue in project mage by magefree.

the class ArchangelsLightEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    DynamicValue value = new CardsInControllerGraveyardCount();
    if (controller != null) {
        controller.gainLife(value.calculate(game, source, this) * 2, game, source);
        for (Card card : controller.getGraveyard().getCards(game)) {
            controller.moveCardToLibraryWithInfo(card, source, game, Zone.GRAVEYARD, true, true);
        }
        controller.shuffleLibrary(source, game);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) CardsInControllerGraveyardCount(mage.abilities.dynamicvalue.common.CardsInControllerGraveyardCount) DynamicValue(mage.abilities.dynamicvalue.DynamicValue) Card(mage.cards.Card)

Aggregations

DynamicValue (mage.abilities.dynamicvalue.DynamicValue)10 Player (mage.players.Player)7 Permanent (mage.game.permanent.Permanent)3 CardsInControllerGraveyardCount (mage.abilities.dynamicvalue.common.CardsInControllerGraveyardCount)2 PermanentsOnBattlefieldCount (mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount)2 ContinuousEffect (mage.abilities.effects.ContinuousEffect)2 Effect (mage.abilities.effects.Effect)2 FixedTarget (mage.target.targetpointer.FixedTarget)2 Ability (mage.abilities.Ability)1 EntersBattlefieldAbility (mage.abilities.common.EntersBattlefieldAbility)1 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)1 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)1 ConditionalContinuousEffect (mage.abilities.decorator.ConditionalContinuousEffect)1 CountersSourceCount (mage.abilities.dynamicvalue.common.CountersSourceCount)1 HighestManaValueCount (mage.abilities.dynamicvalue.common.HighestManaValueCount)1 SignInversionDynamicValue (mage.abilities.dynamicvalue.common.SignInversionDynamicValue)1 OneShotEffect (mage.abilities.effects.OneShotEffect)1 CopyPermanentEffect (mage.abilities.effects.common.CopyPermanentEffect)1 SacrificeControllerEffect (mage.abilities.effects.common.SacrificeControllerEffect)1 BoostTargetEffect (mage.abilities.effects.common.continuous.BoostTargetEffect)1