Search in sources :

Example 36 with Card

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

the class HarvestHandReturnTransformedEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    MageObject sourceObject = source.getSourceObjectIfItStillExists(game);
    if (!(sourceObject instanceof Card)) {
        return false;
    }
    game.getState().setValue(TransformAbility.VALUE_KEY_ENTER_TRANSFORMED + source.getSourceId(), Boolean.TRUE);
    controller.moveCards((Card) sourceObject, Zone.BATTLEFIELD, source, game);
    return true;
}
Also used : Player(mage.players.Player) MageObject(mage.MageObject) Card(mage.cards.Card)

Example 37 with Card

use of mage.cards.Card 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 38 with Card

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

the class ImpulsiveWagerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player != null) {
        DiscardCardCost cost = (DiscardCardCost) source.getCosts().get(0);
        if (cost != null) {
            List<Card> cards = cost.getCards();
            if (cards.size() == 1 && cards.get(0).isLand(game)) {
                Effect effect = new AddCountersTargetEffect(CounterType.BOUNTY.createInstance());
                effect.setTargetPointer(getTargetPointer());
                effect.apply(game, source);
            } else {
                player.drawCards(2, source, game);
            }
        }
        return true;
    }
    return false;
}
Also used : DiscardCardCost(mage.abilities.costs.common.DiscardCardCost) Player(mage.players.Player) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) Card(mage.cards.Card)

Example 39 with Card

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

the class InameAsOneEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    Card targetCard = game.getCard(getTargetPointer().getFirst(game, source));
    if (controller != null && sourceObject != null && targetCard != null) {
        if (controller.chooseUse(outcome, "Exile " + sourceObject.getLogName() + " to return Spirit card?", source, game)) {
            // In a Commander game, you may send Iname to the Command Zone instead of exiling it during the resolution
            // of its ability. If you do, its ability still works. Iname's ability only requires that you attempted to
            // exile it, not that it actually gets to the exile zone. This is similar to how destroying a creature
            // (with, for example, Rest in Peace) doesn't necessarily ensure that creature will end up in the graveyard;
            // it just so happens that the action of exiling something and the exile zone both use the same word: "exile".
            Effect effect = new ReturnFromGraveyardToBattlefieldTargetEffect();
            effect.setTargetPointer(new FixedTarget(targetCard.getId(), targetCard.getZoneChangeCounter(game)));
            new ExileSourceEffect().apply(game, source);
            return effect.apply(game, source);
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) ExileSourceEffect(mage.abilities.effects.common.ExileSourceEffect) Player(mage.players.Player) ReturnFromGraveyardToBattlefieldTargetEffect(mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect) MageObject(mage.MageObject) ExileSourceEffect(mage.abilities.effects.common.ExileSourceEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) SearchLibraryPutInPlayEffect(mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect) Effect(mage.abilities.effects.Effect) ReturnFromGraveyardToBattlefieldTargetEffect(mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect) Card(mage.cards.Card) FilterPermanentCard(mage.filter.common.FilterPermanentCard)

Example 40 with Card

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

the class IncandescentSoulstokeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        if (controller.chooseUse(Outcome.PutCreatureInPlay, choiceText, source, game)) {
            FilterCard filter = new FilterCreatureCard();
            filter.add(SubType.ELEMENTAL.getPredicate());
            TargetCardInHand target = new TargetCardInHand(filter);
            if (controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) {
                Card card = game.getCard(target.getFirstTarget());
                if (card != null) {
                    if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
                        Permanent permanent = game.getPermanent(card.getId());
                        if (permanent != null) {
                            ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
                            effect.setTargetPointer(new FixedTarget(permanent, game));
                            game.addEffect(effect, source);
                            SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect("sacrifice " + card.getName(), source.getControllerId());
                            sacrificeEffect.setTargetPointer(new FixedTarget(permanent, game));
                            game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect), source);
                        }
                    }
                }
            }
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetCardInHand(mage.target.common.TargetCardInHand) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard)

Aggregations

Card (mage.cards.Card)1448 Player (mage.players.Player)1096 Permanent (mage.game.permanent.Permanent)423 FilterCard (mage.filter.FilterCard)381 UUID (java.util.UUID)340 CardsImpl (mage.cards.CardsImpl)253 MageObject (mage.MageObject)212 FixedTarget (mage.target.targetpointer.FixedTarget)173 TargetCard (mage.target.TargetCard)165 Cards (mage.cards.Cards)159 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)111 ContinuousEffect (mage.abilities.effects.ContinuousEffect)99 TargetCardInHand (mage.target.common.TargetCardInHand)98 Target (mage.target.Target)86 HashSet (java.util.HashSet)85 FilterCreatureCard (mage.filter.common.FilterCreatureCard)84 ApprovingObject (mage.ApprovingObject)77 Ability (mage.abilities.Ability)71 TargetPlayer (mage.target.TargetPlayer)67 TargetPermanent (mage.target.TargetPermanent)64