use of mage.abilities.dynamicvalue.common.CardsInControllerGraveyardCount in project mage by magefree.
the class HatcherySpiderEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
int xValue = new CardsInControllerGraveyardCount(StaticFilters.FILTER_CARD_CREATURE).calculate(game, source, this);
FilterCard filter = new FilterPermanentCard("green permanent card with mana value " + xValue + " or less");
filter.add(new ColorPredicate(ObjectColor.GREEN));
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, xValue + 1));
TargetCard target = new TargetCardInLibrary(filter);
Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, xValue));
if (player.chooseUse(outcome, "Put a card onto the battlefield?", source, game) && player.choose(outcome, cards, target, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null && player.moveCards(card, Zone.BATTLEFIELD, source, game)) {
cards.remove(card);
}
}
while (!cards.isEmpty()) {
Card card = cards.getRandom(game);
player.getLibrary().putOnBottom(card, game);
cards.remove(card);
}
return true;
}
use of mage.abilities.dynamicvalue.common.CardsInControllerGraveyardCount in project mage by magefree.
the class WallOfTombstonesEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
int newToughness = CardUtil.overflowInc(1, new CardsInControllerGraveyardCount(StaticFilters.FILTER_CARD_CREATURE).calculate(game, source, this));
game.addEffect(new SetToughnessSourceEffect(StaticValue.get(newToughness), Duration.Custom, SubLayer.SetPT_7b), source);
return true;
}
use of mage.abilities.dynamicvalue.common.CardsInControllerGraveyardCount in project mage by magefree.
the class CleansingMeditationEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Cards cardsToBattlefield = new CardsImpl();
// Threshold?
boolean threshold = false;
DynamicValue c = new CardsInControllerGraveyardCount();
int numCards = c.calculate(game, source, this);
if (numCards >= 7) {
threshold = true;
}
Player controller = game.getPlayer(source.getControllerId());
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_ENCHANTMENT, source.getControllerId(), source.getSourceId(), game)) {
if (permanent != null && permanent.destroy(source, game, false)) {
if (threshold && controller != null && permanent.isOwnedBy(controller.getId())) {
cardsToBattlefield.add(permanent);
}
}
}
if (threshold && controller != null) {
controller.moveCards(cardsToBattlefield, Zone.BATTLEFIELD, source, game);
}
return true;
}
use of mage.abilities.dynamicvalue.common.CardsInControllerGraveyardCount in project mage by magefree.
the class ArchangelsLightEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
DynamicValue value = new CardsInControllerGraveyardCount();
if (controller != null) {
controller.gainLife(value.calculate(game, source, this) * 2, game, source);
for (Card card : controller.getGraveyard().getCards(game)) {
controller.moveCardToLibraryWithInfo(card, source, game, Zone.GRAVEYARD, true, true);
}
controller.shuffleLibrary(source, game);
return true;
}
return false;
}
Aggregations