Search in sources :

Example 36 with Cards

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

the class GisaGloriousResurrectorReturnEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Ability exiledWithSource = (Ability) game.getState().getValue("GisaGloriousResurrectorExile" + source.getSourceId().toString() + game.getState().getZoneChangeCounter(source.getSourceId()));
    if (exiledWithSource == null) {
        return false;
    }
    ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, exiledWithSource));
    if (player == null || exileZone == null || exileZone.isEmpty()) {
        return false;
    }
    Cards cards = new CardsImpl(exileZone.getCards(StaticFilters.FILTER_CARD_CREATURE, game));
    if (cards.isEmpty()) {
        return false;
    }
    player.moveCards(cards, Zone.BATTLEFIELD, source, game);
    cards.retainZone(Zone.BATTLEFIELD, game);
    if (cards.isEmpty()) {
        return false;
    }
    game.addEffect(new GainAbilityTargetEffect(new DecayedAbility(), Duration.Custom).setTargetPointer(new FixedTargets(cards, game)), source);
    return true;
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) BeginningOfUpkeepTriggeredAbility(mage.abilities.common.BeginningOfUpkeepTriggeredAbility) DecayedAbility(mage.abilities.keyword.DecayedAbility) Ability(mage.abilities.Ability) Player(mage.players.Player) FixedTargets(mage.target.targetpointer.FixedTargets) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ExileZone(mage.game.ExileZone) DecayedAbility(mage.abilities.keyword.DecayedAbility) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 37 with Cards

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

the class GlimpseOfTomorrowEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game);
    int count = permanents.size();
    player.shuffleCardsToLibrary(new CardsImpl(permanents), game, source);
    Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, count));
    player.revealCards(source, cards, game);
    Cards toBattlefield = new CardsImpl(cards.getCards(StaticFilters.FILTER_CARD_PERMANENT, game));
    toBattlefield.removeIf(uuid -> game.getCard(uuid).hasSubtype(SubType.AURA, game));
    player.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game);
    toBattlefield.clear();
    cards.retainZone(Zone.LIBRARY, game);
    toBattlefield.addAll(cards.getCards(StaticFilters.FILTER_CARD_PERMANENT, game));
    toBattlefield.removeIf(uuid -> !game.getCard(uuid).hasSubtype(SubType.AURA, game));
    player.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game);
    cards.retainZone(Zone.LIBRARY, game);
    player.putCardsOnBottomOfLibrary(cards, game, source, false);
    return true;
}
Also used : Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) CardsImpl(mage.cards.CardsImpl) Cards(mage.cards.Cards)

Example 38 with Cards

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

the class GrimReminderWatcher 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) {
        TargetCardInLibrary target = new TargetCardInLibrary(StaticFilters.FILTER_CARD_NON_LAND);
        if (controller.searchLibrary(target, source, game)) {
            Card card = game.getCard(target.getFirstTarget());
            if (card != null) {
                Cards cardsToReveal = new CardsImpl(card);
                controller.revealCards(sourceObject.getIdName(), cardsToReveal, game);
                String cardName = card.getName();
                GrimReminderWatcher watcher = game.getState().getWatcher(GrimReminderWatcher.class);
                if (watcher != null) {
                    for (UUID playerId : watcher.getPlayersCastSpell(cardName)) {
                        Player player = game.getPlayer(playerId);
                        if (player != null) {
                            player.loseLife(6, game, source, false);
                        }
                    }
                }
            }
        }
        controller.shuffleLibrary(source, game);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) MageObject(mage.MageObject) UUID(java.util.UUID) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Example 39 with Cards

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

the class HellholeRatsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    int damage = 0;
    Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
    if (targetPlayer != null) {
        Cards cards = targetPlayer.discard(1, false, false, source, game);
        if (!cards.isEmpty()) {
            for (Card card : cards.getCards(game)) {
                damage = card.getManaValue();
            }
            targetPlayer.damage(damage, source.getSourceId(), source, game);
        }
        return true;
    }
    return false;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) Cards(mage.cards.Cards) Card(mage.cards.Card)

Example 40 with Cards

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

the class HedronAlignmentEffect 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) {
        Cards cardsToReveal = new CardsImpl();
        controller.revealCards(sourceObject.getIdName(), cardsToReveal, game);
        // Check battlefield
        if (!game.getBattlefield().contains(filterPermanent, source, game, 1)) {
            return true;
        }
        if (controller.getHand().getCards(filterCard, source.getSourceId(), controller.getId(), game).isEmpty()) {
            return true;
        }
        if (controller.getGraveyard().getCards(filterCard, source.getSourceId(), controller.getId(), game).isEmpty()) {
            return true;
        }
        Cards cardsToCheck = new CardsImpl();
        cardsToCheck.addAll(game.getExile().getAllCards(game));
        if (cardsToCheck.count(filterCard, source.getSourceId(), controller.getId(), game) == 0) {
            return true;
        }
        controller.won(game);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) MageObject(mage.MageObject) 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