Search in sources :

Example 26 with ColorPredicate

use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.

the class AnHavvaConstableEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        MageObject mageObject = game.getObject(source.getSourceId());
        if (mageObject != null) {
            FilterCreaturePermanent filter = new FilterCreaturePermanent("green creatures");
            filter.add(new ColorPredicate(ObjectColor.GREEN));
            int number = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game);
            mageObject.getToughness().setValue(number + 1);
            return true;
        }
    }
    return false;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) MageObject(mage.MageObject)

Example 27 with ColorPredicate

use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.

the class ChandraAblazeEffect5 method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player != null) {
        FilterCard filter = new FilterCard("red instant or sorcery card from your graveyard to play");
        filter.add(new ColorPredicate(ObjectColor.RED));
        filter.add(Predicates.or(CardType.INSTANT.getPredicate(), CardType.SORCERY.getPredicate()));
        String message = "Play red instant or sorcery card from your graveyard without paying its mana cost?";
        Set<Card> cards = player.getGraveyard().getCards(filter, game);
        TargetCardInGraveyard target = new TargetCardInGraveyard(filter);
        while (!cards.isEmpty() && player.chooseUse(outcome, message, source, game)) {
            target.clearChosen();
            if (player.choose(outcome, target, source.getSourceId(), game)) {
                Card card = game.getCard(target.getFirstTarget());
                if (card != null) {
                    game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE);
                    player.cast(player.chooseAbilityForCast(card, game, true), game, true, new ApprovingObject(source, game));
                    game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
                    cards.remove(card);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Player(mage.players.Player) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) ApprovingObject(mage.ApprovingObject) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard)

Example 28 with ColorPredicate

use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.

the class NightshadeAssassinEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObject(game);
    if (controller == null || sourceObject == null) {
        return false;
    }
    FilterCard filter = new FilterCard();
    filter.add(new ColorPredicate(ObjectColor.BLACK));
    int blackCards = controller.getHand().count(filter, source.getSourceId(), source.getControllerId(), game);
    int cardsToReveal = controller.getAmount(0, blackCards, "Reveal how many black cards?", game);
    game.informPlayers(controller.getLogName() + " chooses to reveal " + cardsToReveal + " black cards.");
    if (cardsToReveal > 0) {
        TargetCardInHand target = new TargetCardInHand(cardsToReveal, cardsToReveal, filter);
        if (controller.choose(Outcome.Benefit, target, source.getSourceId(), game)) {
            controller.revealCards(sourceObject.getIdName(), new CardsImpl(target.getTargets()), game);
            int unboost = target.getTargets().size() * -1;
            ContinuousEffect effect = new BoostTargetEffect(unboost, unboost, Duration.EndOfTurn);
            effect.setTargetPointer(getTargetPointer());
            game.addEffect(effect, source);
        }
    }
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Player(mage.players.Player) TargetCardInHand(mage.target.common.TargetCardInHand) BoostTargetEffect(mage.abilities.effects.common.continuous.BoostTargetEffect) MageObject(mage.MageObject) ContinuousEffect(mage.abilities.effects.ContinuousEffect) CardsImpl(mage.cards.CardsImpl)

Example 29 with ColorPredicate

use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.

the class OranRiefTheVastwoodEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    FilterPermanent filter = new FilterPermanent();
    filter.add(CardType.CREATURE.getPredicate());
    filter.add(new ColorPredicate(ObjectColor.GREEN));
    for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
        if (permanent.getTurnsOnBattlefield() == 0) {
            permanent.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
        }
    }
    return true;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) FilterPermanent(mage.filter.FilterPermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent)

Example 30 with ColorPredicate

use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.

the class SearingRaysEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    ChoiceColor choice = new ChoiceColor();
    if (controller != null && controller.choose(outcome, choice, game) && choice.getColor() != null) {
        FilterCreaturePermanent filter = new FilterCreaturePermanent(choice.getColor().getDescription() + " creatures");
        filter.add(new ColorPredicate(choice.getColor()));
        for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
            int amount = game.getBattlefield().countAll(filter, playerId, game);
            if (amount > 0) {
                Player player = game.getPlayer(playerId);
                if (player != null) {
                    player.damage(amount, source.getSourceId(), source, game);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ChoiceColor(mage.choices.ChoiceColor) UUID(java.util.UUID)

Aggregations

ColorPredicate (mage.filter.predicate.mageobject.ColorPredicate)54 Player (mage.players.Player)28 FilterCard (mage.filter.FilterCard)20 ObjectColor (mage.ObjectColor)18 FilterPermanent (mage.filter.FilterPermanent)16 Permanent (mage.game.permanent.Permanent)16 ProtectionAbility (mage.abilities.keyword.ProtectionAbility)14 ChoiceColor (mage.choices.ChoiceColor)14 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)10 Ability (mage.abilities.Ability)6 UUID (java.util.UUID)5 MageObject (mage.MageObject)5 Card (mage.cards.Card)5 FilterObject (mage.filter.FilterObject)5 CardsImpl (mage.cards.CardsImpl)4 ArrayList (java.util.ArrayList)3 ContinuousEffect (mage.abilities.effects.ContinuousEffect)3 ManaValuePredicate (mage.filter.predicate.mageobject.ManaValuePredicate)3 TargetPlayer (mage.target.TargetPlayer)3 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)3