Search in sources :

Example 11 with CardsImpl

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

the class GlowsporeShamanEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    Target target = new TargetCardInYourGraveyard(0, 1, filter, true);
    if (player.chooseUse(outcome, "Put a land card on top of your library?", source, game) && player.choose(outcome, target, source.getSourceId(), game)) {
        Card card = game.getCard(target.getFirstTarget());
        if (card != null) {
            return player.putCardsOnTopOfLibrary(new CardsImpl(card), game, source, false);
        }
    }
    return true;
}
Also used : Player(mage.players.Player) Target(mage.target.Target) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) CardsImpl(mage.cards.CardsImpl) FilterLandCard(mage.filter.common.FilterLandCard) Card(mage.cards.Card)

Example 12 with CardsImpl

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

the class HarvestSeasonEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        int tappedCreatures = new PermanentsOnBattlefieldCount(filter).calculate(game, source, this);
        if (tappedCreatures > 0) {
            TargetCardInLibrary target = new TargetCardInLibrary(0, tappedCreatures, StaticFilters.FILTER_CARD_BASIC_LAND);
            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;
    }
    return false;
}
Also used : Player(mage.players.Player) PermanentsOnBattlefieldCount(mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) CardsImpl(mage.cards.CardsImpl)

Example 13 with CardsImpl

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

the class HatcherySpiderEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    int xValue = new CardsInControllerGraveyardCount(StaticFilters.FILTER_CARD_CREATURE).calculate(game, source, this);
    FilterCard filter = new FilterPermanentCard("green permanent card with mana value " + xValue + " or less");
    filter.add(new ColorPredicate(ObjectColor.GREEN));
    filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, xValue + 1));
    TargetCard target = new TargetCardInLibrary(filter);
    Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, xValue));
    if (player.chooseUse(outcome, "Put a card onto the battlefield?", source, game) && player.choose(outcome, cards, target, game)) {
        Card card = game.getCard(target.getFirstTarget());
        if (card != null && player.moveCards(card, Zone.BATTLEFIELD, source, game)) {
            cards.remove(card);
        }
    }
    while (!cards.isEmpty()) {
        Card card = cards.getRandom(game);
        player.getLibrary().putOnBottom(card, game);
        cards.remove(card);
    }
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Player(mage.players.Player) FilterPermanentCard(mage.filter.common.FilterPermanentCard) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) TargetCard(mage.target.TargetCard) CardsInControllerGraveyardCount(mage.abilities.dynamicvalue.common.CardsInControllerGraveyardCount) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) TargetCard(mage.target.TargetCard) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard) FilterPermanentCard(mage.filter.common.FilterPermanentCard)

Example 14 with CardsImpl

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

the class IncomingEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
            Player player = game.getPlayer(playerId);
            if (player != null) {
                TargetCardInLibrary target = new TargetCardInLibrary(0, Integer.MAX_VALUE, filter);
                if (player.searchLibrary(target, source, game)) {
                    player.moveCards(new CardsImpl(target.getTargets()), Zone.BATTLEFIELD, source, game);
                    player.shuffleLibrary(source, game);
                }
            }
        }
        // prevent undo
        controller.resetStoredBookmark(game);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) UUID(java.util.UUID) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) CardsImpl(mage.cards.CardsImpl)

Example 15 with CardsImpl

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

the class ImpromptuRaidEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (sourceObject != null && controller != null) {
        Card card = controller.getLibrary().getFromTop(game);
        if (card != null) {
            Cards cards = new CardsImpl();
            cards.add(card);
            controller.revealCards(sourceObject.getName(), cards, game);
            if (filterPutInGraveyard.match(card, source.getSourceId(), source.getControllerId(), game)) {
                controller.moveCards(card, Zone.GRAVEYARD, source, game);
                return true;
            }
            if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
                Permanent permanent = game.getPermanent(card.getId());
                if (permanent != null) {
                    ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
                    effect.setTargetPointer(new FixedTarget(permanent, game));
                    game.addEffect(effect, source);
                    SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect("", source.getControllerId());
                    sacrificeEffect.setTargetPointer(new FixedTarget(permanent, game));
                    DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect);
                    game.addDelayedTriggeredAbility(delayedAbility, source);
                }
                return true;
            }
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) MageObject(mage.MageObject) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard)

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