Search in sources :

Example 1 with SetPowerToughnessAllEffect

use of mage.abilities.effects.common.continuous.SetPowerToughnessAllEffect in project mage by magefree.

the class BrineHagEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (sourcePermanent != null) {
        List<Permanent> list = new ArrayList<>();
        for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
            Player player = game.getPlayer(playerId);
            if (player != null) {
                for (Permanent creature : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, playerId, game)) {
                    if (sourcePermanent.getDealtDamageByThisTurn().contains(new MageObjectReference(creature.getId(), game))) {
                        list.add(creature);
                    }
                }
            }
        }
        if (!list.isEmpty()) {
            FilterCreaturePermanent filter = new FilterCreaturePermanent();
            filter.add(new PermanentInListPredicate(list));
            game.addEffect(new SetPowerToughnessAllEffect(0, 2, Duration.Custom, filter, true), source);
        }
        return true;
    }
    return false;
}
Also used : SetPowerToughnessAllEffect(mage.abilities.effects.common.continuous.SetPowerToughnessAllEffect) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) PermanentInListPredicate(mage.filter.predicate.permanent.PermanentInListPredicate) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ArrayList(java.util.ArrayList) UUID(java.util.UUID) MageObjectReference(mage.MageObjectReference)

Example 2 with SetPowerToughnessAllEffect

use of mage.abilities.effects.common.continuous.SetPowerToughnessAllEffect in project mage by magefree.

the class MassDiminishEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    FilterCreaturePermanent filter = new FilterCreaturePermanent();
    filter.add(new ControllerIdPredicate(source.getFirstTarget()));
    game.addEffect(new SetPowerToughnessAllEffect(1, 1, Duration.UntilYourNextTurn, filter, true), source);
    return true;
}
Also used : SetPowerToughnessAllEffect(mage.abilities.effects.common.continuous.SetPowerToughnessAllEffect) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate)

Aggregations

SetPowerToughnessAllEffect (mage.abilities.effects.common.continuous.SetPowerToughnessAllEffect)2 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)2 ArrayList (java.util.ArrayList)1 UUID (java.util.UUID)1 MageObjectReference (mage.MageObjectReference)1 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)1 PermanentInListPredicate (mage.filter.predicate.permanent.PermanentInListPredicate)1 Permanent (mage.game.permanent.Permanent)1 Player (mage.players.Player)1