Search in sources :

Example 1 with TargetPermanentOrSuspendedCard

use of mage.target.common.TargetPermanentOrSuspendedCard in project mage by magefree.

the class RiftElementalCost method pay.

@Override
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
    paid = false;
    Player controller = game.getPlayer(controllerId);
    if (controller != null) {
        Target target = new TargetPermanentOrSuspendedCard(filter, true);
        if (target.choose(Outcome.Neutral, controllerId, source.getSourceId(), game)) {
            Permanent permanent = game.getPermanent(target.getFirstTarget());
            if (permanent != null) {
                permanent.removeCounters(CounterType.TIME.createInstance(), source, game);
                this.paid = true;
            } else {
                Card card = game.getCard(target.getFirstTarget());
                if (card != null) {
                    card.removeCounters(CounterType.TIME.createInstance(), source, game);
                    this.paid = true;
                }
            }
        }
    }
    return paid;
}
Also used : Player(mage.players.Player) Target(mage.target.Target) Permanent(mage.game.permanent.Permanent) TargetPermanentOrSuspendedCard(mage.target.common.TargetPermanentOrSuspendedCard) TargetPermanentOrSuspendedCard(mage.target.common.TargetPermanentOrSuspendedCard) FilterPermanentOrSuspendedCard(mage.filter.common.FilterPermanentOrSuspendedCard) Card(mage.cards.Card)

Aggregations

Card (mage.cards.Card)1 FilterPermanentOrSuspendedCard (mage.filter.common.FilterPermanentOrSuspendedCard)1 Permanent (mage.game.permanent.Permanent)1 Player (mage.players.Player)1 Target (mage.target.Target)1 TargetPermanentOrSuspendedCard (mage.target.common.TargetPermanentOrSuspendedCard)1