Search in sources :

Example 56 with Cards

use of mage.cards.Cards in project mage by magefree.

the class ThrillingEncoreEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    CardsPutIntoGraveyardWatcher watcher = game.getState().getWatcher(CardsPutIntoGraveyardWatcher.class);
    if (controller == null || watcher == null) {
        return false;
    }
    Cards cards = new CardsImpl(watcher.getCardsPutIntoGraveyardFromBattlefield(game));
    cards.removeIf(uuid -> !game.getCard(uuid).isCreature(game));
    return controller.moveCards(cards, Zone.BATTLEFIELD, source, game);
}
Also used : Player(mage.players.Player) CardsPutIntoGraveyardWatcher(mage.watchers.common.CardsPutIntoGraveyardWatcher) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 57 with Cards

use of mage.cards.Cards in project mage by magefree.

the class ThoughtDistortionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getFirstTarget());
    if (player == null) {
        return false;
    }
    player.revealCards(source, player.getHand(), game);
    Cards cards = new CardsImpl(player.getHand().getCards(filter, game));
    cards.addAll(player.getGraveyard().getCards(filter, game));
    return player.moveCards(cards, Zone.EXILED, source, game);
}
Also used : Player(mage.players.Player) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 58 with Cards

use of mage.cards.Cards in project mage by magefree.

the class VesselOfNascencyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (controller != null && sourceObject != null) {
        Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 4));
        boolean properCardFound = cards.count(filterPutInHand, source.getControllerId(), source.getSourceId(), game) > 0;
        if (!cards.isEmpty()) {
            controller.revealCards(sourceObject.getName(), cards, game);
            TargetCard target = new TargetCard(Zone.LIBRARY, filterPutInHand);
            if (properCardFound && controller.chooseUse(outcome, "Put an artifact, creature, enchantment, land, or planeswalker card into your hand?", source, game) && controller.choose(Outcome.DrawCard, cards, target, game)) {
                Card card = game.getCard(target.getFirstTarget());
                if (card != null) {
                    cards.remove(card);
                    controller.moveCards(card, Zone.HAND, source, game);
                }
            }
            controller.moveCards(cards, Zone.GRAVEYARD, source, game);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) MageObject(mage.MageObject) TargetCard(mage.target.TargetCard) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) FilterCard(mage.filter.FilterCard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Example 59 with Cards

use of mage.cards.Cards in project mage by magefree.

the class WizardMentorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    Cards cards = new CardsImpl(source.getSourcePermanentIfItStillExists(game));
    cards.add(source.getFirstTarget());
    return player.moveCards(cards, Zone.HAND, source, game);
}
Also used : Player(mage.players.Player) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 60 with Cards

use of mage.cards.Cards in project mage by magefree.

the class AmplifyEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    Permanent sourceCreature = ((EntersTheBattlefieldEvent) event).getTarget();
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null || sourceCreature == null) {
        return false;
    }
    FilterCreatureCard filter = new FilterCreatureCard("creatures cards to reveal");
    filter.add(new AmplifyPredicate(sourceCreature));
    // You can’t reveal this card or any other cards that are entering the battlefield at the same time as this card.
    filter.add(Predicates.not(new CardIdPredicate(source.getSourceId())));
    for (Permanent enteringPermanent : game.getPermanentsEntering().values()) {
        filter.add(Predicates.not(new CardIdPredicate(enteringPermanent.getId())));
    }
    if (controller.getHand().count(filter, source.getSourceId(), source.getControllerId(), game) <= 0) {
        return false;
    }
    if (!controller.chooseUse(outcome, "Reveal cards to Amplify?", source, game)) {
        return false;
    }
    TargetCardInHand target = new TargetCardInHand(0, Integer.MAX_VALUE, filter);
    if (controller.chooseTarget(outcome, target, source, game) && !target.getTargets().isEmpty()) {
        Cards cards = new CardsImpl();
        cards.addAll(target.getTargets());
        int amountCounters = cards.size() * amplifyFactor.getFactor();
        sourceCreature.addCounters(CounterType.P1P1.createInstance(amountCounters), source.getControllerId(), source, game);
        controller.revealCards(sourceCreature.getIdName(), cards, game);
    }
    return false;
}
Also used : Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Permanent(mage.game.permanent.Permanent) EntersTheBattlefieldEvent(mage.game.events.EntersTheBattlefieldEvent) TargetCardInHand(mage.target.common.TargetCardInHand) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) CardIdPredicate(mage.filter.predicate.mageobject.CardIdPredicate)

Aggregations

Cards (mage.cards.Cards)354 Player (mage.players.Player)342 CardsImpl (mage.cards.CardsImpl)328 Card (mage.cards.Card)157 UUID (java.util.UUID)104 FilterCard (mage.filter.FilterCard)86 TargetCard (mage.target.TargetCard)84 MageObject (mage.MageObject)73 Permanent (mage.game.permanent.Permanent)71 TargetPlayer (mage.target.TargetPlayer)35 OneShotEffect (mage.abilities.effects.OneShotEffect)27 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)27 Ability (mage.abilities.Ability)25 Target (mage.target.Target)24 TargetCardInHand (mage.target.common.TargetCardInHand)24 Game (mage.game.Game)23 CardSetInfo (mage.cards.CardSetInfo)22 CardImpl (mage.cards.CardImpl)21 CardType (mage.constants.CardType)21 FilterPermanent (mage.filter.FilterPermanent)19