Search in sources :

Example 1 with RemoveVariableCountersSourceCost

use of mage.abilities.costs.common.RemoveVariableCountersSourceCost in project mage by magefree.

the class MercadianLiftEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        int numberOfCounters = 0;
        for (Cost cost : source.getCosts()) {
            if (cost instanceof RemoveVariableCountersSourceCost) {
                numberOfCounters = ((RemoveVariableCountersSourceCost) cost).getAmount();
            }
        }
        System.out.println("The number is " + numberOfCounters);
        FilterCreatureCard filter = new FilterCreatureCard();
        filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, numberOfCounters));
        filter.setMessage("creature card with mana value " + numberOfCounters);
        TargetCardInHand target = new TargetCardInHand(filter);
        if (target.canChoose(source.getSourceId(), controller.getId(), game) && controller.chooseUse(Outcome.PutCardInPlay, "Put " + filter.getMessage() + " from your hand onto the battlefield?", source, game) && controller.choose(Outcome.PutCardInPlay, target, source.getSourceId(), game)) {
            target.setRequired(false);
            Card card = game.getCard(target.getFirstTarget());
            if (card != null) {
                return controller.moveCards(card, Zone.BATTLEFIELD, source, game);
            }
        }
    }
    return false;
}
Also used : Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) TargetCardInHand(mage.target.common.TargetCardInHand) RemoveVariableCountersSourceCost(mage.abilities.costs.common.RemoveVariableCountersSourceCost) RemoveVariableCountersSourceCost(mage.abilities.costs.common.RemoveVariableCountersSourceCost) Cost(mage.abilities.costs.Cost) TapSourceCost(mage.abilities.costs.common.TapSourceCost) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card)

Aggregations

Cost (mage.abilities.costs.Cost)1 RemoveVariableCountersSourceCost (mage.abilities.costs.common.RemoveVariableCountersSourceCost)1 TapSourceCost (mage.abilities.costs.common.TapSourceCost)1 Card (mage.cards.Card)1 FilterCreatureCard (mage.filter.common.FilterCreatureCard)1 ManaValuePredicate (mage.filter.predicate.mageobject.ManaValuePredicate)1 Player (mage.players.Player)1 TargetCardInHand (mage.target.common.TargetCardInHand)1