Package mage.abilities.costs

Examples of mage.abilities.costs.Cost


        for (Permanent creature: game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
            Player player = game.getPlayer(creature.getControllerId());
            if (player != null) {
                boolean paid = false;
                if (player.chooseUse(outcome, new StringBuilder("Pay {3} to keep ").append(creature.getName()).append(" on the battlefield?").toString(), game)) {
                    Cost cost = new GenericManaCost(3);
                    if (!cost.pay(source, game, source.getSourceId(), creature.getControllerId(), false)) {
                        paid = true;
                    }
                    if (!paid) {
                        creature.moveToZone(Zone.HAND, source.getSourceId(), game, true);
                    }
View Full Code Here


        if (spell != null) {
            caster = game.getPlayer(spell.getControllerId());
        }
        if (caster != null) {
            if (caster.chooseUse(Outcome.DrawCard, "Pay {1} to draw a card at the beginning of the next end step?", game)) {
                Cost cost = new ManaCostsImpl("{1}");
                if (cost.pay(source, game, source.getSourceId(), caster.getId(), false)) {
                    Effect effect = new DrawCardTargetEffect(1);
                    effect.setTargetPointer(new FixedTarget(caster.getId()));
                    return new CreateDelayedTriggeredAbilityEffect(new AtEndOfTurnDelayedTriggeredAbility(effect, TargetController.ANY)).apply(game, source);
                }
            }
View Full Code Here

    @Override
    public boolean apply(Game game, Ability source) {
        StackObject spell = game.getStack().getStackObject(
                targetPointer.getFirst(game, source));
        Cost cost = new GenericManaCost(1);
        if (spell != null) {
            Player player = game.getPlayer(spell.getControllerId());
            if (player != null) {
                cost.clearPaid();
                game.getPlayer(spell.getControllerId()).discard(
                        1, source, game);
                if (!cost.pay(source, game, spell.getControllerId(),
                        spell.getControllerId(), false)) {
                    return game.getStack().counter(source.getFirstTarget(),
                            source.getSourceId(), game);
                }
            }
View Full Code Here

        FilterCard filter = new FilterCard("artifact to discard");
        filter.add(new CardTypePredicate(CardType.ARTIFACT));
        if (you != null
                && you.getHand().count(filter, game) > 0
                && you.chooseUse(Outcome.Discard, "Do you want to discard an artifact?  If you don't, you must discard 2 cards", game)) {
            Cost cost = new DiscardTargetCost(new TargetCardInHand(filter));
            if (cost.canPay(source, source.getSourceId(), you.getId(), game)) {
                if (cost.pay(source, game, source.getSourceId(), you.getId(), false)) {
                    return true;
                }
            }
        }
        if (you != null) {
View Full Code Here

        if (player != null && permanent != null) {
            int numCounters = permanent.getCounters().getCount(CounterType.DELAY);
            permanent.removeCounters(CounterType.DELAY.createInstance(), game);
            for (int i = numCounters; i > 0; i--) {
                if (player.chooseUse(Outcome.Benefit, "Pay {1}{W}? (" + i + " counters left to pay)", game)) {
                    Cost cost = new ManaCostsImpl<>("{1}{W}");
                    if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {
                        continue;
                    }
                }
                new LoseLifeSourceControllerEffect(1).apply(game, source);
            }
View Full Code Here

    @Override
    public boolean replaceEvent(GameEvent event, Ability source, Game game) {       
        Player player = game.getPlayer(source.getControllerId());       
        if (player != null){
            TargetCardInHand target = new TargetCardInHand(new FilterLandCard());
            Cost cost = new DiscardTargetCost(target);
            if (cost.canPay(source, source.getSourceId(), source.getControllerId(), game) &&
                    player.chooseUse(outcome, "Discard land? (Otherwise Mox Diamond goes to graveyard)", game) &&
                    player.chooseTarget(Outcome.Discard, target, source, game)){
                player.discard(game.getCard(target.getFirstTarget()), source, game);
                return false;
            }
View Full Code Here

    public boolean apply(Game game, Ability source) {
        UUID defendingPlayerId = game.getCombat().getDefendingPlayerId(source.getSourceId(), game);
        MageObject sourceObject = game.getObject(source.getSourceId());
        Player defender = game.getPlayer(defendingPlayerId);
        if (defender != null && sourceObject != null) {
            Cost cost = new SacrificeTargetCost(new TargetControlledCreaturePermanent());
            if (cost.canPay(source, source.getSourceId(), defendingPlayerId, game) &&
                    defender.chooseUse(Outcome.LoseAbility, "Sacrifice a creature to prevent " + sourceObject.getLogName() + " from getting unblockable?", game)) {
                if (!cost.pay(source, game, source.getSourceId(), defendingPlayerId, false)) {
                    // cost was not payed - so source gets unblockable
                    ContinuousEffect effect = new UnblockableSourceEffect(Duration.EndOfTurn);
                    game.addEffect(effect, source);
                }
            }
View Full Code Here

        int xValue = 0;
        boolean payed = false;
        while (player.isInGame() && !payed) {
            xValue = player.announceXMana(0, Integer.MAX_VALUE, "How much mana will you pay?", game, source);
            if (xValue > 0) {
                Cost cost = new GenericManaCost(xValue);
                payed = cost.pay(source, game, source.getSourceId(), player.getId(), false);
            } else {
                payed = true;
            }
        }
        game.informPlayers(new StringBuilder(player.getName()).append(" pays {").append(xValue).append("}.").toString());
View Full Code Here

        Player player = game.getPlayer(source.getControllerId());
        Permanent permanent = game.getPermanent(source.getSourceId());
        if (player != null && permanent != null) {
            int cmc = permanent.getManaCost().convertedManaCost();
            if (player.chooseUse(Outcome.Benefit, "Pay {" + cmc + "} for " + permanent.getName() + "?", game)) {
                Cost cost = new GenericManaCost(cmc);
                if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false))
                {
                    return true;
                }
            }
            permanent.sacrifice(source.getSourceId(), game);
View Full Code Here

        int xValue = 0;
        boolean payed = false;
        while (player.isInGame() && !payed) {
            xValue = player.announceXMana(0, Integer.MAX_VALUE, "How much mana will you pay?", game, source);
            if (xValue > 0) {
                Cost cost = new GenericManaCost(xValue);
                payed = cost.pay(source, game, source.getSourceId(), player.getId(), false);
            } else {
                payed = true;
            }
        }
        game.informPlayers(new StringBuilder(player.getName()).append(" pays {").append(xValue).append("}.").toString());
View Full Code Here

TOP

Related Classes of mage.abilities.costs.Cost

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.