Search in sources :

Example 71 with Cards

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

the class LensOfClarityLookFaceDownEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject mageObject = game.getObject(source.getSourceId());
    if (controller == null || mageObject == null) {
        return false;
    }
    Permanent faceDownCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
    if (faceDownCreature != null) {
        Permanent copyFaceDown = faceDownCreature.copy();
        copyFaceDown.setFaceDown(false, game);
        Cards cards = new CardsImpl(copyFaceDown);
        Player player = game.getPlayer(faceDownCreature.getControllerId());
        controller.lookAtCards("face down card - " + mageObject.getName(), cards, game);
        if (player != null) {
            game.informPlayers(controller.getLogName() + " looks at a face down creature of " + player.getLogName());
        }
    } else {
        return false;
    }
    return true;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) MageObject(mage.MageObject) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 72 with Cards

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

the class LevelerExileLibraryEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        int count = controller.getLibrary().size();
        Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, count));
        controller.moveCards(cards, Zone.EXILED, source, game);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 73 with Cards

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

the class MassPolymorphEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        // Cards creatures = new CardsImpl();
        Set<Card> creaturesToExile = new HashSet<>(game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), game));
        int count = creaturesToExile.size();
        controller.moveCards(creaturesToExile, Zone.EXILED, source, game);
        Cards revealed = new CardsImpl();
        Set<Card> creatureCards = new LinkedHashSet<>();
        for (Card card : controller.getLibrary().getCards(game)) {
            revealed.add(card);
            if (card.isCreature(game)) {
                creatureCards.add(card);
                if (creatureCards.size() == count) {
                    break;
                }
            }
        }
        controller.revealCards(source, revealed, game);
        controller.moveCards(creatureCards, Zone.BATTLEFIELD, source, game, false, false, true, null);
        controller.shuffleLibrary(source, game);
        return true;
    }
    return false;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Player(mage.players.Player) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 74 with Cards

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

the class MoonlightBargainEffect 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) {
        Set<Card> topFive = controller.getLibrary().getTopCards(game, 5);
        Cards lookAtCards = new CardsImpl();
        lookAtCards.addAll(topFive);
        controller.lookAtCards(sourceObject.getIdName(), lookAtCards, game);
        Cards toHand = new CardsImpl();
        for (Card card : topFive) {
            PayLifeCost cost = new PayLifeCost(2);
            if (cost.canPay(source, source, source.getControllerId(), game)) {
                if (controller.chooseUse(outcome, "Put " + card.getIdName() + " into your graveyard unless you pay 2 life", sourceObject.getIdName(), "Pay 2 life and put into hand", "Put into your graveyard", source, game)) {
                    if (cost.pay(source, game, source, source.getControllerId(), false)) {
                        toHand.add(card);
                    } else {
                        controller.moveCards(card, Zone.GRAVEYARD, source, game);
                    }
                } else {
                    controller.moveCards(card, Zone.GRAVEYARD, source, game);
                }
            }
        }
        controller.moveCards(toHand, Zone.HAND, source, game);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) MageObject(mage.MageObject) PayLifeCost(mage.abilities.costs.common.PayLifeCost) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Example 75 with Cards

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

the class MonomaniaEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getFirstTarget());
    if (player == null || player.getHand().isEmpty()) {
        return false;
    }
    TargetCard target = new TargetDiscard(player.getId());
    player.choose(Outcome.Benefit, player.getHand(), target, game);
    Cards cards = player.getHand().copy();
    cards.removeIf(target.getTargets()::contains);
    return !player.discard(cards, false, source, game).isEmpty();
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) TargetCard(mage.target.TargetCard) TargetDiscard(mage.target.common.TargetDiscard) Cards(mage.cards.Cards)

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