Search in sources :

Example 1 with GainProtectionFromColorTargetEffect

use of mage.abilities.effects.common.continuous.GainProtectionFromColorTargetEffect 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 GainProtectionFromColorTargetEffect

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

the class GiverOfRunesEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    if (player.chooseUse(outcome, "Give the targeted creature protection from colorless?", null, "Yes", "No (choose a color instead)", source, game)) {
        game.addEffect(new GainAbilityTargetEffect(new ProtectionAbility(filter), Duration.EndOfTurn), source);
        return true;
    }
    game.addEffect(new GainProtectionFromColorTargetEffect(Duration.EndOfTurn), source);
    return true;
}
Also used : Player(mage.players.Player) GainProtectionFromColorTargetEffect(mage.abilities.effects.common.continuous.GainProtectionFromColorTargetEffect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ProtectionAbility(mage.abilities.keyword.ProtectionAbility)

Example 3 with GainProtectionFromColorTargetEffect

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

the class RazorBarrierEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    if (player.chooseUse(outcome, "Give the targeted permanent protection from artifacts?", null, "Yes", "No (choose a color instead)", source, game)) {
        game.addEffect(new GainAbilityTargetEffect(new ProtectionAbility(filter), Duration.EndOfTurn), source);
        return true;
    }
    game.addEffect(new GainProtectionFromColorTargetEffect(Duration.EndOfTurn), source);
    return true;
}
Also used : Player(mage.players.Player) GainProtectionFromColorTargetEffect(mage.abilities.effects.common.continuous.GainProtectionFromColorTargetEffect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ProtectionAbility(mage.abilities.keyword.ProtectionAbility)

Aggregations

GainProtectionFromColorTargetEffect (mage.abilities.effects.common.continuous.GainProtectionFromColorTargetEffect)3 ProtectionAbility (mage.abilities.keyword.ProtectionAbility)3 Player (mage.players.Player)3 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)2 MageObject (mage.MageObject)1 Ability (mage.abilities.Ability)1 GainAbilityControlledEffect (mage.abilities.effects.common.continuous.GainAbilityControlledEffect)1 GainAbilityControllerEffect (mage.abilities.effects.common.continuous.GainAbilityControllerEffect)1 ChoiceColor (mage.choices.ChoiceColor)1 FilterCard (mage.filter.FilterCard)1 ColorPredicate (mage.filter.predicate.mageobject.ColorPredicate)1