Search in sources :

Example 46 with Cards

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

the class NoxiousVaporsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
        Player player = game.getPlayer(playerId);
        if (player != null) {
            player.revealCards(player.getName() + "'s hand", player.getHand(), game);
        }
    }
    for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
        Player player = game.getPlayer(playerId);
        if (player == null) {
            continue;
        }
        Set<Card> chosenCards = new HashSet<>();
        chooseCardForColor(ObjectColor.WHITE, chosenCards, player, game, source);
        chooseCardForColor(ObjectColor.BLUE, chosenCards, player, game, source);
        chooseCardForColor(ObjectColor.BLACK, chosenCards, player, game, source);
        chooseCardForColor(ObjectColor.RED, chosenCards, player, game, source);
        chooseCardForColor(ObjectColor.GREEN, chosenCards, player, game, source);
        chosenCards.addAll(player.getHand().getCards(StaticFilters.FILTER_CARD_LAND, game));
        Cards cards = player.getHand().copy();
        cards.removeIf(chosenCards.stream().map(MageItem::getId).collect(Collectors.toSet())::contains);
        player.discard(cards, false, source, game);
    }
    return true;
}
Also used : Player(mage.players.Player) UUID(java.util.UUID) Cards(mage.cards.Cards) FilterCard(mage.filter.FilterCard) FilterNonlandCard(mage.filter.common.FilterNonlandCard) Card(mage.cards.Card) HashSet(java.util.HashSet)

Example 47 with Cards

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

the class ParadoxicalOutcomeNumber method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Cards cards = new CardsImpl(source.getTargets().get(0).getTargets());
        game.getState().setValue(CardUtil.getCardZoneString("ParadoxicalOutcomeEffect", source.getSourceId(), game), cards.size());
        controller.moveCards(new CardsImpl(source.getTargets().get(0).getTargets()), Zone.HAND, source, game);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 48 with Cards

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

the class ParoxysmEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent aura = game.getPermanent(source.getSourceId());
    if (aura != null) {
        Permanent creatureAttachedTo = game.getPermanent(aura.getAttachedTo());
        if (creatureAttachedTo != null) {
            Player controllerOfCreature = game.getPlayer(creatureAttachedTo.getControllerId());
            if (controllerOfCreature != null) {
                Card revealCardFromTop = controllerOfCreature.getLibrary().getFromTop(game);
                if (revealCardFromTop != null) {
                    Cards cards = new CardsImpl(revealCardFromTop);
                    controllerOfCreature.revealCards(source, cards, game);
                    if (revealCardFromTop.isLand(game)) {
                        creatureAttachedTo.destroy(source, game, false);
                    } else {
                        ContinuousEffect effect = new BoostTargetEffect(3, 3, Duration.EndOfTurn);
                        effect.setTargetPointer(new FixedTarget(creatureAttachedTo.getId(), game));
                        game.addEffect(effect, source);
                    }
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) BoostTargetEffect(mage.abilities.effects.common.continuous.BoostTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Example 49 with Cards

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

the class SawtoothLoonEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        controller.drawCards(2, source, game);
        TargetCardInHand target = new TargetCardInHand(2, 2, new FilterCard());
        controller.chooseTarget(Outcome.Detriment, target, source, game);
        Cards cardsToLibrary = new CardsImpl(target.getTargets());
        if (!cardsToLibrary.isEmpty()) {
            controller.putCardsOnBottomOfLibrary(cardsToLibrary, game, source, false);
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) TargetCardInHand(mage.target.common.TargetCardInHand) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 50 with Cards

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

the class SchemingSymmetryEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    source.getTargets().get(0).getTargets().stream().map(playerId -> game.getPlayer(playerId)).filter(player -> player != null).forEach(player -> {
        TargetCardInLibrary targetCard = new TargetCardInLibrary();
        if (player.searchLibrary(targetCard, source, game)) {
            Cards cards = new CardsImpl();
            cards.add(targetCard.getFirstTarget());
            player.shuffleLibrary(source, game);
            player.putCardsOnTopOfLibrary(cards, game, source, false);
        }
    });
    return true;
}
Also used : CardSetInfo(mage.cards.CardSetInfo) Game(mage.game.Game) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) CardImpl(mage.cards.CardImpl) CardType(mage.constants.CardType) Cards(mage.cards.Cards) Outcome(mage.constants.Outcome) OneShotEffect(mage.abilities.effects.OneShotEffect) TargetPlayer(mage.target.TargetPlayer) UUID(java.util.UUID) CardsImpl(mage.cards.CardsImpl) Ability(mage.abilities.Ability) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) 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