Search in sources :

Example 61 with CardsImpl

use of mage.cards.CardsImpl 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 62 with CardsImpl

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

the class MadcapExperimentEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        CardsImpl toReveal = new CardsImpl();
        Card toBattlefield = null;
        for (Card card : controller.getLibrary().getCards(game)) {
            toReveal.add(card);
            game.fireUpdatePlayersEvent();
            if (card.isArtifact(game)) {
                toBattlefield = card;
                break;
            }
        }
        controller.revealCards(source, toReveal, game);
        controller.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game);
        int damage = toReveal.size();
        toReveal.remove(toBattlefield);
        controller.putCardsOnBottomOfLibrary(toReveal, game, source, false);
        controller.damage(damage, source.getSourceId(), source, game);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Example 63 with CardsImpl

use of mage.cards.CardsImpl 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 64 with CardsImpl

use of mage.cards.CardsImpl 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 65 with CardsImpl

use of mage.cards.CardsImpl 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)

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