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;
}
Aggregations