use of mage.abilities.effects.common.DestroyAllEffect in project mage by magefree.
the class PerniciousDeedEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
FilterPermanent filter = new FilterPermanent("artifacts, creatures, and enchantments");
filter.add(Predicates.or(CardType.ARTIFACT.getPredicate(), CardType.CREATURE.getPredicate(), CardType.ENCHANTMENT.getPredicate()));
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, source.getManaCostsToPay().getX() + 1));
return new DestroyAllEffect(filter).apply(game, source);
}
use of mage.abilities.effects.common.DestroyAllEffect in project mage by magefree.
the class ValiantEndeavorEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
List<Integer> results = controller.rollDice(outcome, source, game, 6, 2, 0);
int firstResult = results.get(0);
int secondResult = results.get(1);
int first, second;
if (firstResult != secondResult && controller.chooseUse(outcome, "Destroy each creature with power greater than or equal to your choice", "The other number will be the amount of 2/2 white Knight tokens with vigilance.", "" + firstResult, "" + secondResult, source, game)) {
first = firstResult;
second = secondResult;
} else {
first = secondResult;
second = firstResult;
}
final FilterCreaturePermanent filter = new FilterCreaturePermanent(String.format("creatures with power greater than or equal to %s", first));
filter.add(new PowerPredicate(ComparisonType.MORE_THAN, first - 1));
Effect wrathEffect = new DestroyAllEffect(filter);
wrathEffect.apply(game, source);
new KnightToken().putOntoBattlefield(second, game, source, source.getControllerId());
return true;
}
use of mage.abilities.effects.common.DestroyAllEffect in project mage by magefree.
the class ZzzyxassAbyssEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
List<String> permanentNames = new ArrayList<>();
FilterPermanent filter = new FilterNonlandPermanent();
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, controller.getId(), game)) {
permanentNames.add(permanent.getName());
}
if (permanentNames.isEmpty()) {
return true;
}
Collections.sort(permanentNames);
filter.add(new NamePredicate(permanentNames.get(0)));
return new DestroyAllEffect(filter).apply(game, source);
}
return false;
}
use of mage.abilities.effects.common.DestroyAllEffect in project mage by magefree.
the class CelestialKirinEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Spell spell = game.getSpellOrLKIStack(this.getTargetPointer().getFirst(game, source));
if (spell != null) {
int cmc = spell.getManaValue();
FilterPermanent filter = new FilterPermanent();
filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, cmc));
return new DestroyAllEffect(filter).apply(game, source);
}
return false;
}
use of mage.abilities.effects.common.DestroyAllEffect in project mage by magefree.
the class CoercivePortalEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
// Outcome.Detriment - AI will draw a card all the time (Homage choice)
// TODO: add AI hint logic in the choice method, see Tyrant's Choice as example
TwoChoiceVote vote = new TwoChoiceVote("Carnage (sacrifice and destroy)", "Homage (draw a card)", Outcome.Detriment);
vote.doVotes(source, game);
int carnageCount = vote.getVoteCount(true);
int homageCount = vote.getVoteCount(false);
if (carnageCount > homageCount) {
// carnage
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
if (permanent != null && permanent.isControlledBy(source.getControllerId())) {
permanent.sacrifice(source, game);
}
new DestroyAllEffect(StaticFilters.FILTER_PERMANENT_NON_LAND).apply(game, source);
} else {
// homage or tied
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
player.drawCards(1, source, game);
}
}
return true;
}
Aggregations