Search in sources :

Example 31 with CardsImpl

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

the class TrackDownEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (sourceObject == null || controller == null) {
        return false;
    }
    if (!controller.getLibrary().hasCards()) {
        return false;
    }
    Card card = controller.getLibrary().getFromTop(game);
    if (card == null) {
        return false;
    }
    CardsImpl cards = new CardsImpl();
    cards.add(card);
    controller.revealCards(sourceObject.getName(), cards, game);
    if (card.isLand(game) || card.isCreature(game)) {
        controller.drawCards(1, source, game);
    }
    return true;
}
Also used : Player(mage.players.Player) MageObject(mage.MageObject) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Example 32 with CardsImpl

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

the class VarragothBloodskySireEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getFirstTarget());
    if (player != null) {
        if (player.searchLibrary(target, source, game)) {
            Cards foundCards = new CardsImpl(target.getTargets());
            player.shuffleLibrary(source, game);
            player.putCardsOnTopOfLibrary(foundCards, game, source, false);
            return true;
        }
        player.shuffleLibrary(source, game);
    }
    return false;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 33 with CardsImpl

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

the class VaevictisAsmadiTheDireEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    List<Player> playersToFlip = new ArrayList<>();
    for (Target target : source.getTargets()) {
        for (UUID permId : target.getTargets()) {
            Permanent permanent = game.getPermanent(permId);
            if (permanent == null || !permanent.sacrifice(source, game)) {
                continue;
            }
            Player player = game.getPlayer(permanent.getControllerId());
            if (player != null) {
                playersToFlip.add(player);
            }
        }
    }
    for (Player player : playersToFlip) {
        if (player == null) {
            return false;
        }
        Card card = player.getLibrary().getFromTop(game);
        if (card == null) {
            continue;
        }
        player.revealCards(source, new CardsImpl(card), game);
        if (card.isPermanent(game)) {
            player.moveCards(card, Zone.BATTLEFIELD, source, game);
        }
    }
    return true;
}
Also used : Player(mage.players.Player) Target(mage.target.Target) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) ArrayList(java.util.ArrayList) UUID(java.util.UUID) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Example 34 with CardsImpl

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

the class WandOfDenialEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player targetPlayer = game.getPlayer(source.getFirstTarget());
    if (controller != null && targetPlayer != null) {
        Card card = targetPlayer.getLibrary().getFromTop(game);
        if (card != null) {
            MageObject sourceObject = game.getObject(source.getSourceId());
            controller.lookAtCards(sourceObject != null ? sourceObject.getName() : "", new CardsImpl(card), game);
            if (!card.isLand(game) && controller.canPayLifeCost(source) && controller.getLife() >= 2 && controller.chooseUse(Outcome.Neutral, "Pay 2 life to put " + card.getLogName() + " into graveyard?", source, game)) {
                controller.loseLife(2, game, source, false);
                controller.moveCards(card, Zone.GRAVEYARD, source, game);
            }
            return true;
        }
    }
    return false;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) MageObject(mage.MageObject) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Example 35 with CardsImpl

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

the class ZursWeirdingReplacementEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    boolean paid = false;
    Player player = game.getPlayer(event.getTargetId());
    MageObject sourceObject = source.getSourceObject(game);
    if (player == null || sourceObject == null) {
        return false;
    }
    Card card = player.getLibrary().getFromTop(game);
    if (card == null) {
        return false;
    }
    // Reveals it instead
    player.revealCards(sourceObject.getIdName() + " next draw of " + player.getName() + " (" + game.getTurnNum() + '|' + game.getPhase().getType() + ')', new CardsImpl(card), game);
    // Then any other player may pay 2 life. If a player does, put that card into its owner's graveyard
    String message = "Pay 2 life to put " + card.getLogName() + " into " + player.getLogName() + " graveyard?";
    for (UUID playerId : game.getState().getPlayersInRange(player.getId(), game)) {
        if (playerId.equals(player.getId())) {
            continue;
        }
        Player otherPlayer = game.getPlayer(playerId);
        if (otherPlayer == null || !otherPlayer.canPayLifeCost(source) || otherPlayer.getLife() < 2) {
            continue;
        }
        PayLifeCost lifeCost = new PayLifeCost(2);
        if (otherPlayer.chooseUse(Outcome.Benefit, message, source, game) && lifeCost.pay(source, game, source, otherPlayer.getId(), true)) {
            player.moveCards(card, Zone.GRAVEYARD, source, game);
            return true;
        }
    }
    // This is still replacing the draw, so we still return true
    player.drawCards(1, source, game, event);
    return true;
}
Also used : Player(mage.players.Player) MageObject(mage.MageObject) PayLifeCost(mage.abilities.costs.common.PayLifeCost) UUID(java.util.UUID) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Aggregations

CardsImpl (mage.cards.CardsImpl)507 Player (mage.players.Player)497 Cards (mage.cards.Cards)328 Card (mage.cards.Card)253 UUID (java.util.UUID)135 Permanent (mage.game.permanent.Permanent)114 FilterCard (mage.filter.FilterCard)108 MageObject (mage.MageObject)106 TargetCard (mage.target.TargetCard)99 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)53 TargetPlayer (mage.target.TargetPlayer)47 TargetCardInHand (mage.target.common.TargetCardInHand)41 OneShotEffect (mage.abilities.effects.OneShotEffect)37 Target (mage.target.Target)32 Ability (mage.abilities.Ability)27 FilterPermanent (mage.filter.FilterPermanent)27 CardSetInfo (mage.cards.CardSetInfo)25 Game (mage.game.Game)25 CardImpl (mage.cards.CardImpl)24 FilterCreatureCard (mage.filter.common.FilterCreatureCard)23