Search in sources :

Example 76 with CardsImpl

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

Example 77 with CardsImpl

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

the class ScapeshiftEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    int amount = 0;
    TargetControlledPermanent sacrificeLand = new TargetControlledPermanent(0, Integer.MAX_VALUE, new FilterControlledLandPermanent("lands you control"), true);
    if (controller.chooseTarget(Outcome.Sacrifice, sacrificeLand, source, game)) {
        for (UUID uuid : sacrificeLand.getTargets()) {
            Permanent land = game.getPermanent(uuid);
            if (land != null) {
                land.sacrifice(source, game);
                amount++;
            }
        }
    }
    TargetCardInLibrary target = new TargetCardInLibrary(amount, new FilterLandCard("lands"));
    if (controller.searchLibrary(target, source, game)) {
        controller.moveCards(new CardsImpl(target.getTargets()).getCards(game), Zone.BATTLEFIELD, source, game, true, false, false, null);
        controller.shuffleLibrary(source, game);
        return true;
    }
    controller.shuffleLibrary(source, game);
    return false;
}
Also used : TargetControlledPermanent(mage.target.common.TargetControlledPermanent) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) FilterControlledLandPermanent(mage.filter.common.FilterControlledLandPermanent) FilterLandCard(mage.filter.common.FilterLandCard) UUID(java.util.UUID) FilterControlledLandPermanent(mage.filter.common.FilterControlledLandPermanent) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) CardsImpl(mage.cards.CardsImpl)

Example 78 with CardsImpl

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

the class ScalpelexisEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
    if (targetPlayer == null) {
        return false;
    }
    Set<String> cardNames = new HashSet<>();
    boolean doubleName;
    do {
        doubleName = false;
        Cards toExile = new CardsImpl(targetPlayer.getLibrary().getTopCards(game, 4));
        cardNames.clear();
        for (Card card : toExile.getCards(game)) {
            if (cardNames.contains(card.getName())) {
                doubleName = true;
                break;
            } else {
                cardNames.add(card.getName());
            }
        }
        targetPlayer.moveCards(toExile, Zone.EXILED, source, game);
    } while (doubleName);
    return true;
}
Also used : Player(mage.players.Player) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) HashSet(java.util.HashSet) Card(mage.cards.Card)

Example 79 with CardsImpl

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

the class ShrineOfPiercingVisionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Permanent permanent = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
    if (player == null || permanent == null) {
        return false;
    }
    Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, permanent.getCounters(game).getCount(CounterType.CHARGE)));
    if (!cards.isEmpty()) {
        player.lookAtCards(source, null, cards, game);
        TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put into your hand"));
        if (player.choose(Outcome.DrawCard, cards, target, game)) {
            Card card = cards.get(target.getFirstTarget(), game);
            if (card != null) {
                cards.remove(card);
                player.moveCards(card, Zone.HAND, source, game);
            }
        }
        player.putCardsOnBottomOfLibrary(cards, game, source, true);
    }
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCard(mage.target.TargetCard) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) TargetCard(mage.target.TargetCard) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard)

Example 80 with CardsImpl

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

the class SzatsWillEffect 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.getOpponents(source.getControllerId()).stream().map(game::getPlayer).filter(Objects::nonNull).map(Player::getGraveyard).flatMap(Collection::stream).collect(Collectors.toSet()));
    player.moveCards(cards, Zone.EXILED, source, game);
    cards.removeIf(uuid -> game.getState().getZone(uuid) != Zone.EXILED);
    int maxPower = cards.getCards(game).stream().filter(Objects::nonNull).filter(card -> card.isCreature(game)).map(MageObject::getPower).mapToInt(MageInt::getValue).max().orElse(0);
    if (maxPower > 0) {
        new BreedingPitThrullToken().putOntoBattlefield(maxPower, game, source, source.getControllerId());
    }
    return true;
}
Also used : Player(mage.players.Player) BreedingPitThrullToken(mage.game.permanent.token.BreedingPitThrullToken) Objects(java.util.Objects) Collection(java.util.Collection) MageInt(mage.MageInt) 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