use of mage.abilities.dynamicvalue.common.CardsInAllGraveyardsCount in project mage by magefree.
the class NamelessRaceEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanentEntering(source.getSourceId());
if (controller == null || permanent == null) {
return false;
}
int permanentsInPlay = new PermanentsOnBattlefieldCount(filter).calculate(game, source, null);
int cardsInGraveyards = new CardsInAllGraveyardsCount(filter2).calculate(game, source, null);
int maxAmount = Math.min(permanentsInPlay + cardsInGraveyards, controller.getLife());
int payAmount = controller.getAmount(0, maxAmount, "Pay up to " + maxAmount + " life", game);
Cost cost = new PayLifeCost(payAmount);
if (!cost.pay(source, game, source, source.getControllerId(), true)) {
return false;
}
Card sourceCard = game.getCard(source.getSourceId());
game.informPlayers((sourceCard != null ? sourceCard.getLogName() : "") + ": " + controller.getLogName() + " pays " + payAmount + " life");
game.addEffect(new SetPowerToughnessSourceEffect(payAmount, payAmount, Duration.Custom, SubLayer.CharacteristicDefining_7a), source);
permanent.addInfo("life paid", CardUtil.addToolTipMarkTags("Life paid: " + payAmount), game);
return true;
}
use of mage.abilities.dynamicvalue.common.CardsInAllGraveyardsCount in project mage by magefree.
the class TheMimeoplasmEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanentEntering(source.getSourceId());
if (controller != null && permanent != null) {
if (new CardsInAllGraveyardsCount(StaticFilters.FILTER_CARD_CREATURE).calculate(game, source, this) >= 2) {
if (controller.chooseUse(Outcome.Benefit, "Do you want to exile two creature cards from graveyards?", source, game)) {
TargetCardInGraveyard targetCopy = new TargetCardInGraveyard(new FilterCreatureCard("creature card to become a copy of"));
targetCopy.setNotTarget(true);
if (controller.choose(Outcome.Copy, targetCopy, source.getSourceId(), game)) {
Card cardToCopy = game.getCard(targetCopy.getFirstTarget());
if (cardToCopy != null) {
FilterCreatureCard filter = new FilterCreatureCard("creature card to determine amount of additional +1/+1 counters");
filter.add(Predicates.not(new CardIdPredicate(cardToCopy.getId())));
TargetCardInGraveyard targetCounters = new TargetCardInGraveyard(filter);
targetCounters.setNotTarget(true);
if (controller.choose(Outcome.Copy, targetCounters, source.getSourceId(), game)) {
Card cardForCounters = game.getCard(targetCounters.getFirstTarget());
if (cardForCounters != null) {
Cards cardsToExile = new CardsImpl();
cardsToExile.add(cardToCopy);
cardsToExile.add(cardForCounters);
controller.moveCards(cardsToExile, Zone.EXILED, source, game);
CopyEffect copyEffect = new CopyEffect(Duration.Custom, cardToCopy, source.getSourceId());
game.addEffect(copyEffect, source);
permanent.addCounters(CounterType.P1P1.createInstance(cardForCounters.getPower().getValue()), source.getControllerId(), source, game);
}
}
}
}
}
}
return true;
}
return false;
}
Aggregations