Search in sources :

Example 1 with GainAbilityControllerEffect

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

the class SehtsTigerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject mageObject = game.getObject(source.getSourceId());
    ChoiceColor choice = new ChoiceColor();
    if (controller != null && mageObject != null && controller.choose(Outcome.Protect, choice, game)) {
        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 GainAbilityControllerEffect(ability, Duration.EndOfTurn), source);
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) EntersBattlefieldTriggeredAbility(mage.abilities.common.EntersBattlefieldTriggeredAbility) FlashAbility(mage.abilities.keyword.FlashAbility) ProtectionAbility(mage.abilities.keyword.ProtectionAbility) Ability(mage.abilities.Ability) Player(mage.players.Player) MageObject(mage.MageObject) ProtectionAbility(mage.abilities.keyword.ProtectionAbility) ChoiceColor(mage.choices.ChoiceColor) GainAbilityControllerEffect(mage.abilities.effects.common.continuous.GainAbilityControllerEffect)

Example 2 with GainAbilityControllerEffect

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

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

the class RunedHaloSetProtectionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY);
    if (controller != null && cardName != null && !cardName.isEmpty()) {
        FilterObject filter = new FilterObject("the card name [" + cardName + ']');
        filter.add(new NamePredicate(cardName));
        ContinuousEffect effect = new GainAbilityControllerEffect(new ProtectionAbility(filter), Duration.Custom);
        game.addEffect(effect, source);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) NamePredicate(mage.filter.predicate.mageobject.NamePredicate) FilterObject(mage.filter.FilterObject) ProtectionAbility(mage.abilities.keyword.ProtectionAbility) ContinuousEffect(mage.abilities.effects.ContinuousEffect) GainAbilityControllerEffect(mage.abilities.effects.common.continuous.GainAbilityControllerEffect)

Example 4 with GainAbilityControllerEffect

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

the class EonFrolickerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getFirstTarget());
    if (player == null) {
        return false;
    }
    game.getState().getTurnMods().add(new TurnMod(player.getId(), false));
    FilterPlayer filter = new FilterPlayer(player.getName());
    filter.add(new PlayerIdPredicate(player.getId()));
    Ability ability = new ProtectionAbility(filter);
    game.addEffect(new GainAbilityControlledEffect(ability, Duration.UntilYourNextTurn, StaticFilters.FILTER_PERMANENT_PLANESWALKER), source);
    game.addEffect(new GainAbilityControllerEffect(ability, Duration.UntilYourNextTurn), source);
    return true;
}
Also used : EntersBattlefieldTriggeredAbility(mage.abilities.common.EntersBattlefieldTriggeredAbility) ConditionalInterveningIfTriggeredAbility(mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility) FlyingAbility(mage.abilities.keyword.FlyingAbility) ProtectionAbility(mage.abilities.keyword.ProtectionAbility) Ability(mage.abilities.Ability) Player(mage.players.Player) FilterPlayer(mage.filter.FilterPlayer) GainAbilityControlledEffect(mage.abilities.effects.common.continuous.GainAbilityControlledEffect) FilterPlayer(mage.filter.FilterPlayer) PlayerIdPredicate(mage.filter.predicate.other.PlayerIdPredicate) ProtectionAbility(mage.abilities.keyword.ProtectionAbility) TurnMod(mage.game.turn.TurnMod) GainAbilityControllerEffect(mage.abilities.effects.common.continuous.GainAbilityControllerEffect)

Example 5 with GainAbilityControllerEffect

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

the class GuardianArchonProtectionAbility method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(ChooseSecretOpponentEffect.getChosenPlayer(source, game));
    if (player == null) {
        return false;
    }
    game.addEffect(new GainAbilityTargetEffect(new GuardianArchonProtectionAbility(player.getId()), Duration.EndOfTurn), source);
    game.addEffect(new GainAbilityControllerEffect(new GuardianArchonProtectionAbility(player.getId()), Duration.EndOfTurn), source);
    return true;
}
Also used : Player(mage.players.Player) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) GainAbilityControllerEffect(mage.abilities.effects.common.continuous.GainAbilityControllerEffect)

Aggregations

GainAbilityControllerEffect (mage.abilities.effects.common.continuous.GainAbilityControllerEffect)6 Player (mage.players.Player)5 ProtectionAbility (mage.abilities.keyword.ProtectionAbility)4 Ability (mage.abilities.Ability)3 GainAbilityControlledEffect (mage.abilities.effects.common.continuous.GainAbilityControlledEffect)3 MageObject (mage.MageObject)2 EntersBattlefieldTriggeredAbility (mage.abilities.common.EntersBattlefieldTriggeredAbility)2 ChoiceColor (mage.choices.ChoiceColor)2 FilterCard (mage.filter.FilterCard)2 ColorPredicate (mage.filter.predicate.mageobject.ColorPredicate)2 ConditionalInterveningIfTriggeredAbility (mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility)1 ContinuousEffect (mage.abilities.effects.ContinuousEffect)1 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)1 GainProtectionFromColorTargetEffect (mage.abilities.effects.common.continuous.GainProtectionFromColorTargetEffect)1 FlashAbility (mage.abilities.keyword.FlashAbility)1 FlyingAbility (mage.abilities.keyword.FlyingAbility)1 FilterObject (mage.filter.FilterObject)1 FilterPlayer (mage.filter.FilterPlayer)1 NamePredicate (mage.filter.predicate.mageobject.NamePredicate)1 PlayerIdPredicate (mage.filter.predicate.other.PlayerIdPredicate)1