Search in sources :

Example 1 with PutCardFromHandOntoBattlefieldEffect

use of mage.abilities.effects.common.PutCardFromHandOntoBattlefieldEffect in project mage by magefree.

the class MetathranAerostatEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    int xValue = source.getManaCostsToPay().getX();
    FilterCreatureCard filter = new FilterCreatureCard("a creature with mana value " + xValue);
    filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, xValue));
    if (new PutCardFromHandOntoBattlefieldEffect(filter).apply(game, source)) {
        return new ReturnToHandSourceEffect(true).apply(game, source);
    }
    return false;
}
Also used : Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) ReturnToHandSourceEffect(mage.abilities.effects.common.ReturnToHandSourceEffect) PutCardFromHandOntoBattlefieldEffect(mage.abilities.effects.common.PutCardFromHandOntoBattlefieldEffect)

Example 2 with PutCardFromHandOntoBattlefieldEffect

use of mage.abilities.effects.common.PutCardFromHandOntoBattlefieldEffect in project mage by magefree.

the class CrypticGatewayPredicate method apply.

@Override
public boolean apply(Game game, Ability source) {
    if (source.getCosts() == null) {
        return false;
    }
    FilterCard filter = new FilterCreatureCard("creature card from your hand that shares a creature type with each creature tapped this way");
    for (Cost cost : source.getCosts()) {
        if (cost instanceof CrypticGatewayCost) {
            Predicate predicate = ((CrypticGatewayCost) cost).getPredicate();
            filter.add(predicate);
            return new PutCardFromHandOntoBattlefieldEffect(filter).apply(game, source);
        }
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) PutCardFromHandOntoBattlefieldEffect(mage.abilities.effects.common.PutCardFromHandOntoBattlefieldEffect) Cost(mage.abilities.costs.Cost) Predicate(mage.filter.predicate.Predicate) TappedPredicate(mage.filter.predicate.permanent.TappedPredicate)

Example 3 with PutCardFromHandOntoBattlefieldEffect

use of mage.abilities.effects.common.PutCardFromHandOntoBattlefieldEffect in project mage by magefree.

the class DermoplasmEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent thisCreature = game.getPermanent(source.getId());
    FilterCreatureCard filter = new FilterCreatureCard("a creature card with a morph ability");
    filter.add(new AbilityPredicate(MorphAbility.class));
    Effect effect = new PutCardFromHandOntoBattlefieldEffect(filter);
    if (effect.apply(game, source)) {
        if (thisCreature != null) {
            effect = new ReturnToHandTargetEffect();
            effect.setTargetPointer(new FixedTarget(thisCreature.getId(), game));
            effect.apply(game, source);
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) FilterCreatureCard(mage.filter.common.FilterCreatureCard) MorphAbility(mage.abilities.keyword.MorphAbility) Permanent(mage.game.permanent.Permanent) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) PutCardFromHandOntoBattlefieldEffect(mage.abilities.effects.common.PutCardFromHandOntoBattlefieldEffect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) PutCardFromHandOntoBattlefieldEffect(mage.abilities.effects.common.PutCardFromHandOntoBattlefieldEffect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) AbilityPredicate(mage.filter.predicate.mageobject.AbilityPredicate)

Example 4 with PutCardFromHandOntoBattlefieldEffect

use of mage.abilities.effects.common.PutCardFromHandOntoBattlefieldEffect in project mage by magefree.

the class FloodOfTearsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    List<Permanent> nonlands = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_NON_LAND, source.getControllerId(), source.getSourceId(), game);
    Cards cards = new CardsImpl();
    if (!nonlands.isEmpty()) {
        nonlands.forEach(cards::add);
        boolean putIntoPlay = nonlands.stream().filter(permanent -> permanent.isControlledBy(player.getId())).filter(permanent -> !(permanent instanceof PermanentToken)).count() > 3;
        player.moveCards(cards, Zone.HAND, source, game);
        if (putIntoPlay) {
            new PutCardFromHandOntoBattlefieldEffect().apply(game, source);
        }
        return true;
    }
    return false;
}
Also used : StaticFilters(mage.filter.StaticFilters) Zone(mage.constants.Zone) Cards(mage.cards.Cards) Outcome(mage.constants.Outcome) OneShotEffect(mage.abilities.effects.OneShotEffect) UUID(java.util.UUID) CardsImpl(mage.cards.CardsImpl) Player(mage.players.Player) CardSetInfo(mage.cards.CardSetInfo) Game(mage.game.Game) List(java.util.List) CardImpl(mage.cards.CardImpl) Permanent(mage.game.permanent.Permanent) PermanentToken(mage.game.permanent.PermanentToken) PutCardFromHandOntoBattlefieldEffect(mage.abilities.effects.common.PutCardFromHandOntoBattlefieldEffect) CardType(mage.constants.CardType) Ability(mage.abilities.Ability) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) PermanentToken(mage.game.permanent.PermanentToken) PutCardFromHandOntoBattlefieldEffect(mage.abilities.effects.common.PutCardFromHandOntoBattlefieldEffect) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 5 with PutCardFromHandOntoBattlefieldEffect

use of mage.abilities.effects.common.PutCardFromHandOntoBattlefieldEffect in project mage by magefree.

the class TheUrDragonTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    int attackingDragons = 0;
    for (UUID attacker : game.getCombat().getAttackers()) {
        Permanent creature = game.getPermanent(attacker);
        if (creature != null && creature.getControllerId() != null && creature.isControlledBy(this.getControllerId()) && creature.hasSubtype(SubType.DRAGON, game)) {
            attackingDragons++;
        }
    }
    if (attackingDragons > 0) {
        this.getEffects().clear();
        addEffect(new DrawCardSourceControllerEffect(attackingDragons));
        addEffect(new PutCardFromHandOntoBattlefieldEffect());
        return true;
    }
    return false;
}
Also used : Permanent(mage.game.permanent.Permanent) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect) PutCardFromHandOntoBattlefieldEffect(mage.abilities.effects.common.PutCardFromHandOntoBattlefieldEffect) UUID(java.util.UUID)

Aggregations

PutCardFromHandOntoBattlefieldEffect (mage.abilities.effects.common.PutCardFromHandOntoBattlefieldEffect)7 UUID (java.util.UUID)3 OneShotEffect (mage.abilities.effects.OneShotEffect)3 FilterCreatureCard (mage.filter.common.FilterCreatureCard)3 Permanent (mage.game.permanent.Permanent)3 Player (mage.players.Player)3 Effect (mage.abilities.effects.Effect)2 FilterCard (mage.filter.FilterCard)2 ManaValuePredicate (mage.filter.predicate.mageobject.ManaValuePredicate)2 FixedTarget (mage.target.targetpointer.FixedTarget)2 List (java.util.List)1 Ability (mage.abilities.Ability)1 Cost (mage.abilities.costs.Cost)1 DrawCardSourceControllerEffect (mage.abilities.effects.common.DrawCardSourceControllerEffect)1 ReturnToHandSourceEffect (mage.abilities.effects.common.ReturnToHandSourceEffect)1 ReturnToHandTargetEffect (mage.abilities.effects.common.ReturnToHandTargetEffect)1 MorphAbility (mage.abilities.keyword.MorphAbility)1 CardImpl (mage.cards.CardImpl)1 CardSetInfo (mage.cards.CardSetInfo)1 Cards (mage.cards.Cards)1