Search in sources :

Example 41 with Cards

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

the class LanternOfTheLostEffect 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();
    game.getState().getPlayersInRange(source.getControllerId(), game).stream().map(game::getPlayer).filter(Objects::nonNull).map(Player::getGraveyard).forEach(cards::addAll);
    player.moveCards(cards, Zone.EXILED, source, game);
    player.drawCards(1, source, game);
    return true;
}
Also used : Player(mage.players.Player) Objects(java.util.Objects) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 42 with Cards

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

the class MindBombEffect 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;
    }
    Map<UUID, Cards> cardsToDiscard = new HashMap<>();
    // choose
    for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
        Player player = game.getPlayer(playerId);
        if (player == null) {
            continue;
        }
        Cards cards = new CardsImpl();
        Target target = new TargetDiscard(0, 3, new FilterCard(), playerId);
        player.chooseTarget(Outcome.Discard, target, source, game);
        cards.addAll(target.getTargets());
        cardsToDiscard.put(playerId, cards);
    }
    // discard
    for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
        Player player = game.getPlayer(playerId);
        if (player != null) {
            Cards cardsPlayer = cardsToDiscard.get(playerId);
            cardsToDiscard.put(playerId, player.discard(cardsPlayer, false, source, game));
        }
    }
    // damage
    for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
        Player player = game.getPlayer(playerId);
        if (player == null) {
            continue;
        }
        Cards cardsPlayer = cardsToDiscard.get(playerId);
        if (cardsPlayer != null) {
            player.damage(3 - cardsPlayer.size(), source.getSourceId(), source, game);
        }
    }
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) Target(mage.target.Target) HashMap(java.util.HashMap) MageObject(mage.MageObject) UUID(java.util.UUID) TargetDiscard(mage.target.common.TargetDiscard) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 43 with Cards

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

the class MerfolkSpyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(targetPointer.getFirst(game, source));
    if (player != null && !player.getHand().isEmpty()) {
        Cards revealed = new CardsImpl();
        revealed.add(player.getHand().getRandom(game));
        player.revealCards("Merfolk Spy", revealed, game);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 44 with Cards

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

the class MidnightRitualEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Cards cardsToExile = new CardsImpl(getTargetPointer().getTargets(game, source));
        controller.moveCards(cardsToExile, Zone.EXILED, source, game);
        if (!cardsToExile.isEmpty()) {
            new ZombieToken().putOntoBattlefield(cardsToExile.size(), game, source, controller.getId());
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) ZombieToken(mage.game.permanent.token.ZombieToken) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 45 with Cards

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

the class MundaAmbushLeaderEffect 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 allCards = new CardsImpl();
        allCards.addAll(controller.getLibrary().getTopCards(game, 4));
        controller.lookAtCards(sourceObject.getIdName(), allCards, game);
        if (!allCards.isEmpty()) {
            Cards cardsToReveal = new CardsImpl();
            TargetCard target = new TargetCard(0, Integer.MAX_VALUE, Zone.LIBRARY, filter);
            controller.chooseTarget(outcome, allCards, target, source, game);
            cardsToReveal.addAll(target.getTargets());
            if (!cardsToReveal.isEmpty()) {
                controller.revealCards(sourceObject.getIdName(), cardsToReveal, game, true);
                allCards.removeAll(cardsToReveal);
            }
            controller.putCardsOnTopOfLibrary(cardsToReveal, game, source, true);
        }
        if (!allCards.isEmpty()) {
            controller.putCardsOnBottomOfLibrary(allCards, game, source, true);
        }
        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)

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