Search in sources :

Example 1 with GainAbilityControlledEffect

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

the class FaithsShieldEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject mageObject = game.getObject(source.getSourceId());
    if (controller != null && mageObject != null) {
        if (FatefulHourCondition.instance.apply(game, source)) {
            ChoiceColor choice = new ChoiceColor();
            if (!controller.choose(Outcome.Protect, choice, game)) {
                return false;
            }
            if (choice.getColor() != null) {
                game.informPlayers(mageObject.getLogName() + ": " + controller.getLogName() + " has chosen " + choice.getChoice());
                FilterCard filter = new FilterCard();
                filter.add(new ColorPredicate(choice.getColor()));
                filter.setMessage(choice.getChoice());
                Ability ability = new ProtectionAbility(filter);
                game.addEffect(new GainAbilityControlledEffect(ability, Duration.EndOfTurn), source);
                game.addEffect(new GainAbilityControllerEffect(ability, Duration.EndOfTurn), source);
                return true;
            }
        } else {
            game.addEffect(new GainProtectionFromColorTargetEffect(Duration.EndOfTurn), source);
            return true;
        }
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) ProtectionAbility(mage.abilities.keyword.ProtectionAbility) Ability(mage.abilities.Ability) Player(mage.players.Player) GainProtectionFromColorTargetEffect(mage.abilities.effects.common.continuous.GainProtectionFromColorTargetEffect) GainAbilityControlledEffect(mage.abilities.effects.common.continuous.GainAbilityControlledEffect) MageObject(mage.MageObject) ProtectionAbility(mage.abilities.keyword.ProtectionAbility) ChoiceColor(mage.choices.ChoiceColor) GainAbilityControllerEffect(mage.abilities.effects.common.continuous.GainAbilityControllerEffect)

Example 2 with GainAbilityControlledEffect

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

the class PathbreakerIbexEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    int maxPower = 0;
    for (Permanent perm : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), game)) {
        if (perm.getPower().getValue() > maxPower) {
            maxPower = perm.getPower().getValue();
        }
    }
    ContinuousEffect effect = new GainAbilityControlledEffect(TrampleAbility.getInstance(), Duration.EndOfTurn, StaticFilters.FILTER_PERMANENT_CREATURES);
    game.addEffect(effect, source);
    if (maxPower != 0) {
        effect = new BoostControlledEffect(maxPower, maxPower, Duration.EndOfTurn);
        game.addEffect(effect, source);
    }
    return true;
}
Also used : Permanent(mage.game.permanent.Permanent) GainAbilityControlledEffect(mage.abilities.effects.common.continuous.GainAbilityControlledEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) BoostControlledEffect(mage.abilities.effects.common.continuous.BoostControlledEffect)

Example 3 with GainAbilityControlledEffect

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

the class FinaleOfDevastationEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    int xValue = source.getManaCostsToPay().getX();
    if (xValue >= 10) {
        ContinuousEffect effect1 = new BoostControlledEffect(xValue, xValue, Duration.EndOfTurn);
        game.addEffect(effect1, source);
        ContinuousEffect effect2 = new GainAbilityControlledEffect(HasteAbility.getInstance(), Duration.EndOfTurn, new FilterCreaturePermanent());
        game.addEffect(effect2, source);
    }
    return true;
}
Also used : FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) GainAbilityControlledEffect(mage.abilities.effects.common.continuous.GainAbilityControlledEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) BoostControlledEffect(mage.abilities.effects.common.continuous.BoostControlledEffect)

Example 4 with GainAbilityControlledEffect

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

the class OverwhelmingStampedeInitEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    int maxPower = 0;
    for (Permanent perm : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), game)) {
        if (perm.getPower().getValue() > maxPower) {
            maxPower = perm.getPower().getValue();
        }
    }
    ContinuousEffect effect = new GainAbilityControlledEffect(TrampleAbility.getInstance(), Duration.EndOfTurn, new FilterCreaturePermanent());
    game.addEffect(effect, source);
    if (maxPower != 0) {
        effect = new BoostControlledEffect(maxPower, maxPower, Duration.EndOfTurn);
        game.addEffect(effect, source);
    }
    return true;
}
Also used : FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) GainAbilityControlledEffect(mage.abilities.effects.common.continuous.GainAbilityControlledEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) BoostControlledEffect(mage.abilities.effects.common.continuous.BoostControlledEffect)

Example 5 with GainAbilityControlledEffect

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

the class SamiteElderEffect method apply.

public boolean apply(Game game, Ability source) {
    Permanent target = game.getPermanent(source.getFirstTarget());
    if (target != null) {
        for (ObjectColor color : target.getColor(game).getColors()) {
            FilterCard filter = new FilterCard(color.getDescription());
            filter.add(new ColorPredicate(color));
            game.addEffect(new GainAbilityControlledEffect(new ProtectionAbility(filter), Duration.EndOfTurn, new FilterControlledCreaturePermanent()), source);
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) GainAbilityControlledEffect(mage.abilities.effects.common.continuous.GainAbilityControlledEffect) ObjectColor(mage.ObjectColor) ProtectionAbility(mage.abilities.keyword.ProtectionAbility) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent)

Aggregations

GainAbilityControlledEffect (mage.abilities.effects.common.continuous.GainAbilityControlledEffect)11 Permanent (mage.game.permanent.Permanent)5 Ability (mage.abilities.Ability)4 BoostControlledEffect (mage.abilities.effects.common.continuous.BoostControlledEffect)4 Player (mage.players.Player)4 ContinuousEffect (mage.abilities.effects.ContinuousEffect)3 GainAbilityControllerEffect (mage.abilities.effects.common.continuous.GainAbilityControllerEffect)3 FlyingAbility (mage.abilities.keyword.FlyingAbility)3 ProtectionAbility (mage.abilities.keyword.ProtectionAbility)3 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)3 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)3 BeginningOfCombatTriggeredAbility (mage.abilities.common.BeginningOfCombatTriggeredAbility)2 ConditionalInterveningIfTriggeredAbility (mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility)2 FilterCard (mage.filter.FilterCard)2 ColorPredicate (mage.filter.predicate.mageobject.ColorPredicate)2 HashSet (java.util.HashSet)1 MageObject (mage.MageObject)1 ObjectColor (mage.ObjectColor)1 EntersBattlefieldTriggeredAbility (mage.abilities.common.EntersBattlefieldTriggeredAbility)1 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)1