Search in sources :

Example 1 with CardsInControllerGraveyardCount

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

the class HatcherySpiderEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    int xValue = new CardsInControllerGraveyardCount(StaticFilters.FILTER_CARD_CREATURE).calculate(game, source, this);
    FilterCard filter = new FilterPermanentCard("green permanent card with mana value " + xValue + " or less");
    filter.add(new ColorPredicate(ObjectColor.GREEN));
    filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, xValue + 1));
    TargetCard target = new TargetCardInLibrary(filter);
    Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, xValue));
    if (player.chooseUse(outcome, "Put a card onto the battlefield?", source, game) && player.choose(outcome, cards, target, game)) {
        Card card = game.getCard(target.getFirstTarget());
        if (card != null && player.moveCards(card, Zone.BATTLEFIELD, source, game)) {
            cards.remove(card);
        }
    }
    while (!cards.isEmpty()) {
        Card card = cards.getRandom(game);
        player.getLibrary().putOnBottom(card, game);
        cards.remove(card);
    }
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Player(mage.players.Player) FilterPermanentCard(mage.filter.common.FilterPermanentCard) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) TargetCard(mage.target.TargetCard) CardsInControllerGraveyardCount(mage.abilities.dynamicvalue.common.CardsInControllerGraveyardCount) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) TargetCard(mage.target.TargetCard) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard) FilterPermanentCard(mage.filter.common.FilterPermanentCard)

Example 2 with CardsInControllerGraveyardCount

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

the class WallOfTombstonesEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    int newToughness = CardUtil.overflowInc(1, new CardsInControllerGraveyardCount(StaticFilters.FILTER_CARD_CREATURE).calculate(game, source, this));
    game.addEffect(new SetToughnessSourceEffect(StaticValue.get(newToughness), Duration.Custom, SubLayer.SetPT_7b), source);
    return true;
}
Also used : SetToughnessSourceEffect(mage.abilities.effects.common.continuous.SetToughnessSourceEffect) CardsInControllerGraveyardCount(mage.abilities.dynamicvalue.common.CardsInControllerGraveyardCount)

Example 3 with CardsInControllerGraveyardCount

use of mage.abilities.dynamicvalue.common.CardsInControllerGraveyardCount 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 4 with CardsInControllerGraveyardCount

use of mage.abilities.dynamicvalue.common.CardsInControllerGraveyardCount 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

CardsInControllerGraveyardCount (mage.abilities.dynamicvalue.common.CardsInControllerGraveyardCount)4 Player (mage.players.Player)3 DynamicValue (mage.abilities.dynamicvalue.DynamicValue)2 Card (mage.cards.Card)2 Cards (mage.cards.Cards)2 CardsImpl (mage.cards.CardsImpl)2 SetToughnessSourceEffect (mage.abilities.effects.common.continuous.SetToughnessSourceEffect)1 FilterCard (mage.filter.FilterCard)1 FilterPermanentCard (mage.filter.common.FilterPermanentCard)1 ColorPredicate (mage.filter.predicate.mageobject.ColorPredicate)1 ManaValuePredicate (mage.filter.predicate.mageobject.ManaValuePredicate)1 Permanent (mage.game.permanent.Permanent)1 TargetCard (mage.target.TargetCard)1 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)1