Search in sources :

Example 66 with FilterCreatureCard

use of mage.filter.common.FilterCreatureCard in project mage by magefree.

the class AetherVialEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId());
    if (permanent == null) {
        permanent = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
        if (permanent == null) {
            return false;
        }
    }
    int count = permanent.getCounters(game).getCount(CounterType.CHARGE);
    FilterCreatureCard filter = new FilterCreatureCard("creature card with mana value equal to " + count);
    filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, count));
    String choiceText = "Put a " + filter.getMessage() + " from your hand onto the battlefield?";
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    if (controller.getHand().count(filter, game) == 0 || !controller.chooseUse(this.outcome, choiceText, source, game)) {
        return true;
    }
    TargetCardInHand target = new TargetCardInHand(filter);
    if (controller.choose(this.outcome, target, source.getSourceId(), game)) {
        Card card = game.getCard(target.getFirstTarget());
        if (card != null) {
            return controller.moveCards(card, Zone.BATTLEFIELD, source, game);
        }
    }
    return false;
}
Also used : FilterCreatureCard(mage.filter.common.FilterCreatureCard) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCardInHand(mage.target.common.TargetCardInHand) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card)

Example 67 with FilterCreatureCard

use of mage.filter.common.FilterCreatureCard in project mage by magefree.

the class CitanulFluteSearchEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    FilterCard filter = new FilterCreatureCard("creature card with mana value X or less");
    // Set the mana cost one higher to 'emulate' a less than or equal to comparison.
    filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, source.getManaCostsToPay().getX() + 1));
    TargetCardInLibrary target = new TargetCardInLibrary(filter);
    player.searchLibrary(target, source, game);
    Card card = player.getLibrary().getCard(target.getFirstTarget(), game);
    if (card != null) {
        player.revealCards(source, new CardsImpl(card), game);
        player.moveCards(card, Zone.HAND, source, game);
    }
    player.shuffleLibrary(source, game);
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) CardsImpl(mage.cards.CardsImpl) FilterCard(mage.filter.FilterCard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card)

Example 68 with FilterCreatureCard

use of mage.filter.common.FilterCreatureCard in project mage by magefree.

the class AngelOfGlorysRiseEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Set<Card> toExile = new HashSet<>(game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(SubType.ZOMBIE, "Zombie"), source.getControllerId(), source.getSourceId(), game));
        controller.moveCards(toExile, Zone.EXILED, source, game);
        FilterCreatureCard filterHuman = new FilterCreatureCard();
        filterHuman.add(SubType.HUMAN.getPredicate());
        controller.moveCards(controller.getGraveyard().getCards(filterHuman, game), Zone.BATTLEFIELD, source, game);
    }
    return true;
}
Also used : Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card) HashSet(java.util.HashSet)

Example 69 with FilterCreatureCard

use of mage.filter.common.FilterCreatureCard in project mage by magefree.

the class DimirDoppelgangerCopyApplier method apply.

@Override
public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
    Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DimirDoppelgangerEffect(), new ManaCostsImpl("{1}{U}{B}"));
    ability.addTarget(new TargetCardInGraveyard(new FilterCreatureCard("creature card in a graveyard")));
    blueprint.getAbilities().add(ability);
    return true;
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) Ability(mage.abilities.Ability) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl)

Aggregations

FilterCreatureCard (mage.filter.common.FilterCreatureCard)69 Player (mage.players.Player)58 Card (mage.cards.Card)31 FilterCard (mage.filter.FilterCard)26 Permanent (mage.game.permanent.Permanent)22 UUID (java.util.UUID)17 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)17 TargetCard (mage.target.TargetCard)16 CardsImpl (mage.cards.CardsImpl)15 ManaValuePredicate (mage.filter.predicate.mageobject.ManaValuePredicate)15 TargetCardInGraveyard (mage.target.common.TargetCardInGraveyard)14 MageObject (mage.MageObject)13 OwnerIdPredicate (mage.filter.predicate.card.OwnerIdPredicate)10 Target (mage.target.Target)10 HashSet (java.util.HashSet)8 Cards (mage.cards.Cards)8 TargetCardInYourGraveyard (mage.target.common.TargetCardInYourGraveyard)7 Ability (mage.abilities.Ability)6 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)6 OneShotEffect (mage.abilities.effects.OneShotEffect)4