Examples of canPay()


Examples of mage.abilities.costs.Cost.canPay()

                if (card.putOntoBattlefield(game, Zone.HAND, source.getSourceId(), source.getControllerId())) {
                    Permanent permanent = game.getPermanent(card.getId());
                    if (permanent != null) {
                        permanent.addCounters(CounterType.LUCK.createInstance(), game);
                        Cost cost = new ExileFromHandCost(new TargetCardInHand());
                        if (cost.canPay(source, source.getSourceId(), source.getControllerId(), game)) {
                            cost.pay(source, game, source.getSourceId(), source.getControllerId(), true);
                        }
                    }
                }
            }
View Full Code Here

Examples of mage.abilities.costs.Cost.canPay()

    @Override
    public boolean apply(Game game, Ability source) {
        Player player = game.getPlayer(targetPointer.getFirst(game, source));
        if (player != null) {
            Cost cost = new DiscardTargetCost(new TargetCardInHand());
            if (cost.canPay(source, player.getId(), player.getId(), game)) {
                if (!cost.pay(source, game, player.getId(), player.getId(), false)) {
                    player.loseLife(5, game);
                }
                return true;
            }
View Full Code Here

Examples of mage.abilities.costs.Cost.canPay()

    @Override
    public boolean apply(Game game, Ability source) {
        Player opponent = game.getPlayer(source.getFirstTarget());
        if (opponent != null) {
            Cost cost = new SacrificeTargetCost(new TargetControlledCreaturePermanent());
            if (cost.canPay(source, source.getSourceId(), opponent.getId(), game)
                    && opponent.chooseUse(outcome, "Sacrifice a creature to prevent the card draw?", game)) {
                if (cost.pay(source, game, source.getSourceId(), opponent.getId(), false)) {
                    return true;
                }
            }
View Full Code Here

Examples of mage.abilities.costs.Cost.canPay()

                if (cost.pay(source, game, source.getSourceId(), opponent.getId(), false)) {
                    return true;
                }
            }
            cost = new PayLifeCost(3);
            if (cost.canPay(source, source.getSourceId(), opponent.getId(), game)
                    && opponent.chooseUse(outcome, "Pay 3 life to prevent the card draw?", game)) {
                if (cost.pay(source, game, source.getSourceId(), opponent.getId(), false)) {
                    return true;
                }
            }
View Full Code Here

Examples of mage.abilities.costs.Cost.canPay()

        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.getSourceId(), source.getControllerId(), game)
                    && player.chooseUse(Outcome.Detriment, message, game)) {
                if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {
                    Card card = game.getCard(cost.getTargets().getFirstTarget());
                    if (card == null) {
                        return false;
View Full Code Here

Examples of mage.abilities.costs.Cost.canPay()

            if (creature != null) {
                Player opponent = game.getPlayer(source.getFirstTarget());
                boolean paid = false;
                if (opponent != null) {
                    Cost cost = new PayLifeCost(3);
                    if (cost.canPay(source, source.getSourceId(), opponent.getId(), game)
                            && opponent.chooseUse(outcome, new StringBuilder("Pay 3 live to prevent that ").append(creature.getLogName()).append(" returns to ").append(controller.getName()).append("'s hand?").toString(), game)) {
                        if (cost.pay(source, game, source.getSourceId(), opponent.getId(), false)) {
                            paid = true;
                        }
                    }           
View Full Code Here

Examples of mage.abilities.costs.Cost.canPay()

        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;
                }
            }
        }
View Full Code Here

Examples of mage.abilities.costs.Cost.canPay()

    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

Examples of mage.abilities.costs.Cost.canPay()

        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

Examples of mage.abilities.costs.common.DiscardTargetCost.canPay()

    @Override
    public boolean apply(Game game, Ability source) {
        Player player = game.getPlayer(targetPointer.getFirst(game, source));
        if (player != null) {
            Cost cost = new DiscardTargetCost(new TargetCardInHand());
            if (cost.canPay(source, player.getId(), player.getId(), game)) {
                if (!cost.pay(source, game, player.getId(), player.getId(), false)) {
                    player.loseLife(5, game);
                }
                return true;
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.