use of mage.abilities.dynamicvalue.DynamicValue in project mage by magefree.
the class DispersalShieldEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
DynamicValue amount = new HighestManaValueCount();
Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source));
if (spell != null && spell.getManaValue() <= amount.calculate(game, source, this)) {
return game.getStack().counter(source.getFirstTarget(), source, game);
}
return false;
}
use of mage.abilities.dynamicvalue.DynamicValue in project mage by magefree.
the class PacksDisdainEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
if (player != null && player.choose(Outcome.UnboostCreature, typeChoice, game)) {
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
filter.add(SubType.byDescription(typeChoice.getChoice()).getPredicate());
DynamicValue negativePermanentsCount = new PermanentsOnBattlefieldCount(filter, -1);
ContinuousEffect effect = new BoostTargetEffect(negativePermanentsCount, negativePermanentsCount, Duration.EndOfTurn, true);
effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
game.addEffect(effect, source);
return true;
}
return false;
}
use of mage.abilities.dynamicvalue.DynamicValue 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.DynamicValue in project mage by magefree.
the class AncientExcavationEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
DynamicValue numCards = CardsInControllerHandCount.instance;
int amount = numCards.calculate(game, source, this);
player.drawCards(amount, source, game);
player.discard(amount, false, false, source, game);
return true;
}
return false;
}
use of mage.abilities.dynamicvalue.DynamicValue 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