Search in sources :

Example 1 with DamageAllEffect

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;
}
Also used : TargetControlledPermanent(mage.target.common.TargetControlledPermanent) Player(mage.players.Player) Target(mage.target.Target) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) DamageAllEffect(mage.abilities.effects.common.DamageAllEffect)

Example 2 with DamageAllEffect

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;
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) Permanent(mage.game.permanent.Permanent) DamageAllEffect(mage.abilities.effects.common.DamageAllEffect) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) ChoiceImpl(mage.choices.ChoiceImpl) HashSet(java.util.HashSet)

Example 3 with DamageAllEffect

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);
}
Also used : FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) DamageAllEffect(mage.abilities.effects.common.DamageAllEffect)

Example 4 with DamageAllEffect

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);
}
Also used : PermanentIdPredicate(mage.filter.predicate.permanent.PermanentIdPredicate) FilterPermanent(mage.filter.FilterPermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) FilterPermanent(mage.filter.FilterPermanent) TargetOpponentsCreaturePermanent(mage.target.common.TargetOpponentsCreaturePermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) DamageAllEffect(mage.abilities.effects.common.DamageAllEffect)

Example 5 with DamageAllEffect

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);
}
Also used : DamageAllEffect(mage.abilities.effects.common.DamageAllEffect) PermanentsOnBattlefieldCount(mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount)

Aggregations

DamageAllEffect (mage.abilities.effects.common.DamageAllEffect)6 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)4 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)3 Permanent (mage.game.permanent.Permanent)3 Player (mage.players.Player)2 HashSet (java.util.HashSet)1 ReflexiveTriggeredAbility (mage.abilities.common.delayed.ReflexiveTriggeredAbility)1 PermanentsOnBattlefieldCount (mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount)1 Choice (mage.choices.Choice)1 ChoiceImpl (mage.choices.ChoiceImpl)1 FilterPermanent (mage.filter.FilterPermanent)1 FilterControlledPermanent (mage.filter.common.FilterControlledPermanent)1 PermanentIdPredicate (mage.filter.predicate.permanent.PermanentIdPredicate)1 Target (mage.target.Target)1 TargetControlledPermanent (mage.target.common.TargetControlledPermanent)1 TargetOpponentsCreaturePermanent (mage.target.common.TargetOpponentsCreaturePermanent)1