Search in sources :

Example 91 with Cards

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

the class SearchForBlexEffect method actionWithSelectedCards.

@Override
protected void actionWithSelectedCards(Cards cards, Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player != null) {
        TargetCard target = new TargetCard(0, 5, Zone.LIBRARY, filter);
        if (player.choose(outcome, cards, target, game)) {
            Cards pickedCards = new CardsImpl(target.getTargets());
            cards.removeAll(pickedCards);
            player.moveCards(pickedCards, Zone.HAND, source, game);
            player.loseLife(pickedCards.size() * 3, game, source, false);
        }
    }
}
Also used : Player(mage.players.Player) TargetCard(mage.target.TargetCard) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 92 with Cards

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

the class BloodOathEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    MageObject sourceObject = game.getObject(source.getSourceId());
    Player player = game.getPlayer(source.getControllerId());
    Player opponent = game.getPlayer(source.getFirstTarget());
    if (player != null && opponent != null && sourceObject != null) {
        Choice choiceImpl = new ChoiceImpl();
        choiceImpl.setChoices(choice);
        if (player.choose(Outcome.Neutral, choiceImpl, game)) {
            CardType type = null;
            String choosenType = choiceImpl.getChoice();
            if (choosenType.equals(CardType.ARTIFACT.toString())) {
                type = CardType.ARTIFACT;
            } else if (choosenType.equals(CardType.LAND.toString())) {
                type = CardType.LAND;
            } else if (choosenType.equals(CardType.CREATURE.toString())) {
                type = CardType.CREATURE;
            } else if (choosenType.equals(CardType.ENCHANTMENT.toString())) {
                type = CardType.ENCHANTMENT;
            } else if (choosenType.equals(CardType.INSTANT.toString())) {
                type = CardType.INSTANT;
            } else if (choosenType.equals(CardType.SORCERY.toString())) {
                type = CardType.SORCERY;
            } else if (choosenType.equals(CardType.PLANESWALKER.toString())) {
                type = CardType.PLANESWALKER;
            } else if (choosenType.equals(CardType.TRIBAL.toString())) {
                type = CardType.TRIBAL;
            }
            if (type != null) {
                Cards hand = opponent.getHand();
                opponent.revealCards(sourceObject.getIdName(), hand, game);
                Set<Card> cards = hand.getCards(game);
                int damageToDeal = 0;
                for (Card card : cards) {
                    if (card != null && card.getCardType(game).contains(type)) {
                        damageToDeal += 3;
                    }
                }
                game.informPlayers(sourceObject.getLogName() + " deals " + (damageToDeal == 0 ? "no" : "" + damageToDeal) + " damage to " + opponent.getLogName());
                opponent.damage(damageToDeal, source.getSourceId(), source, game);
                return true;
            }
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) CardType(mage.constants.CardType) MageObject(mage.MageObject) ChoiceImpl(mage.choices.ChoiceImpl) Cards(mage.cards.Cards) Card(mage.cards.Card)

Example 93 with Cards

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

the class BlightHerderEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Target target = new TargetCardInExile(2, 2, filter, null);
        if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
            if (controller.chooseTarget(outcome, target, source, game)) {
                Cards cardsToGraveyard = new CardsImpl(target.getTargets());
                controller.moveCards(cardsToGraveyard, Zone.GRAVEYARD, source, game);
                return new CreateTokenEffect(new EldraziScionToken(), 3).apply(game, source);
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Target(mage.target.Target) TargetCardInExile(mage.target.common.TargetCardInExile) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) EldraziScionToken(mage.game.permanent.token.EldraziScionToken) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 94 with Cards

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

the class CartographersSurveyEffect method actionWithSelectedCards.

@Override
protected void actionWithSelectedCards(Cards cards, Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        TargetCard target = new TargetCard(0, 2, Zone.LIBRARY, StaticFilters.FILTER_CARD_LANDS);
        controller.choose(outcome, cards, target, game);
        Cards pickedCards = new CardsImpl(target.getTargets());
        if (!pickedCards.isEmpty()) {
            cards.removeAll(pickedCards);
            controller.moveCards(pickedCards.getCards(game), Zone.BATTLEFIELD, source, game, true, false, false, null);
        }
    }
}
Also used : Player(mage.players.Player) TargetCard(mage.target.TargetCard) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 95 with Cards

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

the class CrosisThePurgerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    ChoiceColor choice = new ChoiceColor();
    player.choose(outcome, choice, game);
    if (!choice.isChosen()) {
        return false;
    }
    game.informPlayers(player.getLogName() + " chooses " + choice.getColor());
    Player damagedPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
    if (damagedPlayer == null) {
        return false;
    }
    damagedPlayer.revealCards("hand of " + damagedPlayer.getName(), damagedPlayer.getHand(), game);
    Cards cards = new CardsImpl(damagedPlayer.getHand().getCards(game).stream().filter(card -> card.getColor(game).shares(choice.getColor())).collect(Collectors.toSet()));
    damagedPlayer.discard(cards, false, source, game);
    return true;
}
Also used : Player(mage.players.Player) ChoiceColor(mage.choices.ChoiceColor) 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