Search in sources :

Example 1 with Cost

use of mage.abilities.costs.Cost in project mage by magefree.

the class DemilichPlayEffect method applies.

@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
    if (source.getSourceId().equals(objectId) && source.isControlledBy(affectedControllerId) && game.getState().getZone(objectId) == Zone.GRAVEYARD) {
        Player controller = game.getPlayer(affectedControllerId);
        if (controller != null) {
            Costs<Cost> costs = new CostsImpl<>();
            costs.add(new ExileFromGraveCost(new TargetCardInYourGraveyard(4, StaticFilters.FILTER_CARD_INSTANT_OR_SORCERY_FROM_YOUR_GRAVEYARD)));
            controller.setCastSourceIdWithAlternateMana(objectId, new ManaCostsImpl<>("{U}{U}{U}{U}"), costs);
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) ExileFromGraveCost(mage.abilities.costs.common.ExileFromGraveCost) CostsImpl(mage.abilities.costs.CostsImpl) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) Cost(mage.abilities.costs.Cost) ExileFromGraveCost(mage.abilities.costs.common.ExileFromGraveCost)

Example 2 with Cost

use of mage.abilities.costs.Cost in project mage by magefree.

the class DiscipleOfDeceitEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    MageObject mageObject = game.getObject(source.getSourceId());
    if (player != null && mageObject != null) {
        Cost cost = new DiscardTargetCost(new TargetCardInHand(new FilterNonlandCard()));
        String message = "Discard a nonland card to search your library?";
        if (cost.canPay(source, source, source.getControllerId(), game) && player.chooseUse(Outcome.Detriment, message, source, game)) {
            if (cost.pay(source, game, source, source.getControllerId(), false, null)) {
                Card card = game.getCard(cost.getTargets().getFirstTarget());
                if (card == null) {
                    return false;
                }
                String targetName = "card with mana value of " + card.getManaValue();
                FilterCard filter = new FilterCard(targetName);
                filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, card.getManaValue()));
                return new SearchLibraryPutInHandEffect(new TargetCardInLibrary(filter), true, true).apply(game, source);
            }
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) FilterNonlandCard(mage.filter.common.FilterNonlandCard) TargetCardInHand(mage.target.common.TargetCardInHand) DiscardTargetCost(mage.abilities.costs.common.DiscardTargetCost) MageObject(mage.MageObject) SearchLibraryPutInHandEffect(mage.abilities.effects.common.search.SearchLibraryPutInHandEffect) DiscardTargetCost(mage.abilities.costs.common.DiscardTargetCost) Cost(mage.abilities.costs.Cost) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) FilterCard(mage.filter.FilterCard) FilterNonlandCard(mage.filter.common.FilterNonlandCard) Card(mage.cards.Card)

Example 3 with Cost

use of mage.abilities.costs.Cost in project mage by magefree.

the class EmberwildeDjinnEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(game.getActivePlayerId());
    MageObject sourceObject = source.getSourceObject(game);
    if (player == null || sourceObject == null) {
        return false;
    }
    Cost cost = new OrCost(new ManaCostsImpl("{R}{R}"), new PayLifeCost(2), "{R}{R} or 2 life");
    if (player.chooseUse(Outcome.GainControl, "Gain control of " + sourceObject.getLogName() + "?", source, game)) {
        if (cost.pay(source, game, source, player.getId(), false)) {
            ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, false, player.getId());
            effect.setTargetPointer(new FixedTarget(source.getSourceId(), source.getSourceObjectZoneChangeCounter()));
            game.addEffect(effect, source);
            player.resetStoredBookmark(game);
        }
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) OrCost(mage.abilities.costs.OrCost) MageObject(mage.MageObject) PayLifeCost(mage.abilities.costs.common.PayLifeCost) ContinuousEffect(mage.abilities.effects.ContinuousEffect) PayLifeCost(mage.abilities.costs.common.PayLifeCost) Cost(mage.abilities.costs.Cost) OrCost(mage.abilities.costs.OrCost) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect)

Example 4 with Cost

use of mage.abilities.costs.Cost in project mage by magefree.

the class FrightfulDelusionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    StackObject spell = game.getStack().getStackObject(targetPointer.getFirst(game, source));
    Cost cost = ManaUtil.createManaCost(1, false);
    if (spell != null) {
        Player player = game.getPlayer(spell.getControllerId());
        if (player != null) {
            cost.clearPaid();
            game.getPlayer(spell.getControllerId()).discard(1, false, false, source, game);
            if (!cost.pay(source, game, source, spell.getControllerId(), false, null)) {
                return game.getStack().counter(source.getFirstTarget(), source, game);
            }
        }
    }
    return false;
}
Also used : Player(mage.players.Player) StackObject(mage.game.stack.StackObject) Cost(mage.abilities.costs.Cost)

Example 5 with Cost

use of mage.abilities.costs.Cost in project mage by magefree.

the class LorcanWarlockCollectorReplacementEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Card card = game.getCard(getTargetPointer().getFirst(game, source));
    if (player == null || card == null) {
        return false;
    }
    Cost cost = new PayLifeCost(card.getManaValue());
    if (!cost.canPay(source, source, source.getControllerId(), game) || !cost.pay(source, game, source, source.getControllerId(), true)) {
        return false;
    }
    game.addEffect(new AddCardSubTypeTargetEffect(SubType.WARLOCK, Duration.Custom).setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game) + 1)), source);
    player.moveCards(card, Zone.BATTLEFIELD, source, game);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) PayLifeCost(mage.abilities.costs.common.PayLifeCost) PayLifeCost(mage.abilities.costs.common.PayLifeCost) Cost(mage.abilities.costs.Cost) Card(mage.cards.Card) AddCardSubTypeTargetEffect(mage.abilities.effects.common.continuous.AddCardSubTypeTargetEffect)

Aggregations

Cost (mage.abilities.costs.Cost)174 Player (mage.players.Player)142 Permanent (mage.game.permanent.Permanent)86 SacrificeTargetCost (mage.abilities.costs.common.SacrificeTargetCost)41 Card (mage.cards.Card)32 UUID (java.util.UUID)30 TargetControlledCreaturePermanent (mage.target.common.TargetControlledCreaturePermanent)29 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)26 TapSourceCost (mage.abilities.costs.common.TapSourceCost)23 FilterCard (mage.filter.FilterCard)22 MageObject (mage.MageObject)19 PayLifeCost (mage.abilities.costs.common.PayLifeCost)17 GenericManaCost (mage.abilities.costs.mana.GenericManaCost)16 FixedTarget (mage.target.targetpointer.FixedTarget)16 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)14 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)14 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)13 ContinuousEffect (mage.abilities.effects.ContinuousEffect)12 TargetControlledPermanent (mage.target.common.TargetControlledPermanent)11 OneShotEffect (mage.abilities.effects.OneShotEffect)9