use of mage.abilities.effects.common.DamageAllEffect in project mage by magefree.
the class TheFirstEruptionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Target target = new TargetControlledPermanent(1, 1, filter, false);
boolean sacrificed = false;
if (target.canChoose(source.getSourceId(), controller.getId(), game)) {
while (controller.canRespond() && !target.isChosen() && target.canChoose(source.getSourceId(), controller.getId(), game)) {
controller.chooseTarget(Outcome.Sacrifice, target, source, game);
}
for (int idx = 0; idx < target.getTargets().size(); idx++) {
Permanent permanent = game.getPermanent(target.getTargets().get(idx));
if (permanent != null) {
sacrificed |= permanent.sacrifice(source, game);
}
}
}
if (sacrificed) {
return new DamageAllEffect(3, StaticFilters.FILTER_PERMANENT_CREATURE).apply(game, source);
}
return false;
}
use of mage.abilities.effects.common.DamageAllEffect in project mage by magefree.
the class LavabrinkFloodgatesEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(game.getActivePlayerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (player == null || permanent == null) {
return false;
}
Choice choice = new ChoiceImpl();
choice.setChoices(new HashSet(Arrays.asList("Add a doom counter", "Remove a doom counter", "Do nothing")));
player.choose(outcome, choice, game);
switch(choice.getChoice()) {
case "Add a doom counter":
permanent.addCounters(CounterType.DOOM.createInstance(), player.getId(), source, game);
break;
case "Remove a doom counter":
permanent.removeCounters(CounterType.DOOM.createInstance(), source, game);
break;
case "Do nothing":
default:
break;
}
if (permanent.getCounters(game).getCount(CounterType.DOOM) < 3 || !permanent.sacrifice(source, game)) {
return true;
}
game.fireReflexiveTriggeredAbility(new ReflexiveTriggeredAbility(new DamageAllEffect(6, StaticFilters.FILTER_PERMANENT_CREATURE), false, "it deals 6 damage to each creature."), source);
return true;
}
use of mage.abilities.effects.common.DamageAllEffect in project mage by magefree.
the class RowanKenrithDamageEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(TappedPredicate.TAPPED);
filter.add(new ControllerIdPredicate(source.getFirstTarget()));
return new DamageAllEffect(3, filter).apply(game, source);
}
use of mage.abilities.effects.common.DamageAllEffect in project mage by magefree.
the class FlamesOfTheRazeBoarEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent == null) {
return false;
}
permanent.damage(4, source.getSourceId(), source, game);
if (!FerociousCondition.instance.apply(game, source)) {
return true;
}
FilterPermanent filter = new FilterCreaturePermanent();
filter.add(new ControllerIdPredicate(permanent.getControllerId()));
filter.add(Predicates.not(new PermanentIdPredicate(permanent.getId())));
return new DamageAllEffect(2, filter).apply(game, source);
}
use of mage.abilities.effects.common.DamageAllEffect in project mage by magefree.
the class FloodgateDamageEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
int islandCount = new PermanentsOnBattlefieldCount(filter2).calculate(game, source, this);
islandCount = Math.floorDiv(islandCount, 2);
return new DamageAllEffect(islandCount, filter).apply(game, source);
}
Aggregations