Search in sources :

Example 16 with ProtectionAbility

use of mage.abilities.keyword.ProtectionAbility in project mage by magefree.

the class CairnWandererTest method TestCairnWandererEffect.

/*
     * Testing: As long as a creature card with flying is in a graveyard, 
     * {this} has flying. The same is true for fear, first strike, 
     * double strike, deathtouch, haste, landwalk, lifelink, protection, 
     * reach, trample, shroud, and vigilance.
     */
@Test
public void TestCairnWandererEffect() {
    addCard(Zone.BATTLEFIELD, playerA, "Cairn Wanderer");
    // Testing FlyingAbility.
    addCard(Zone.GRAVEYARD, playerA, "Lantern Kami");
    // Testing FearAbility.
    addCard(Zone.GRAVEYARD, playerA, "Prickly Boggart");
    // Testing FirstStrikeAbility.
    addCard(Zone.GRAVEYARD, playerA, "Serra Zealot");
    // Testing DoubleStrikeAbility.
    addCard(Zone.GRAVEYARD, playerA, "Fencing Ace");
    // Testing DeathtouchAbility.
    addCard(Zone.GRAVEYARD, playerA, "Typhoid Rats");
    // Testing HasteAbility.
    addCard(Zone.GRAVEYARD, playerB, "Raging Goblin");
    // Testing LandwalkAbility.
    addCard(Zone.GRAVEYARD, playerB, "Zodiac Rooster");
    // Testing LifelinkAbility.
    addCard(Zone.GRAVEYARD, playerB, "Trained Caracal");
    // Testing ProtectionAbility.
    addCard(Zone.GRAVEYARD, playerB, "Progenitus");
    // Testing ReachAbility.
    addCard(Zone.GRAVEYARD, playerB, "Tree Monkey");
    // Testing TrampleAbility.
    addCard(Zone.GRAVEYARD, playerB, "Defiant Elf");
    // Testing ShroudAbility.
    addCard(Zone.GRAVEYARD, playerB, "Elvish Lookout");
    // Testing VigilanceAbility.
    addCard(Zone.GRAVEYARD, playerB, "Veteran Cavalier");
    execute();
    List<Ability> abilities = new ArrayList<>();
    abilities.add(FlyingAbility.getInstance());
    abilities.add(FearAbility.getInstance());
    abilities.add(FirstStrikeAbility.getInstance());
    abilities.add(DoubleStrikeAbility.getInstance());
    abilities.add(DeathtouchAbility.getInstance());
    abilities.add(HasteAbility.getInstance());
    abilities.add(LifelinkAbility.getInstance());
    abilities.add(ReachAbility.getInstance());
    abilities.add(ShroudAbility.getInstance());
    abilities.add(TrampleAbility.getInstance());
    abilities.add(VigilanceAbility.getInstance());
    assertAbilities(playerA, "Cairn Wanderer", abilities);
    assertAbility(playerA, "Cairn Wanderer", new PlainswalkAbility(), true);
    // Progenitus - protection from everything.
    assertAbility(playerA, "Cairn Wanderer", new ProtectionAbility(new FilterCard("everything")), true);
}
Also used : HasteAbility(mage.abilities.keyword.HasteAbility) LifelinkAbility(mage.abilities.keyword.LifelinkAbility) ReachAbility(mage.abilities.keyword.ReachAbility) DeathtouchAbility(mage.abilities.keyword.DeathtouchAbility) VigilanceAbility(mage.abilities.keyword.VigilanceAbility) DoubleStrikeAbility(mage.abilities.keyword.DoubleStrikeAbility) FirstStrikeAbility(mage.abilities.keyword.FirstStrikeAbility) PlainswalkAbility(mage.abilities.keyword.PlainswalkAbility) TrampleAbility(mage.abilities.keyword.TrampleAbility) FlyingAbility(mage.abilities.keyword.FlyingAbility) FearAbility(mage.abilities.keyword.FearAbility) ProtectionAbility(mage.abilities.keyword.ProtectionAbility) ShroudAbility(mage.abilities.keyword.ShroudAbility) Ability(mage.abilities.Ability) FilterCard(mage.filter.FilterCard) PlainswalkAbility(mage.abilities.keyword.PlainswalkAbility) ArrayList(java.util.ArrayList) ProtectionAbility(mage.abilities.keyword.ProtectionAbility) Test(org.junit.Test)

Example 17 with ProtectionAbility

use of mage.abilities.keyword.ProtectionAbility in project mage by magefree.

the class GainProtectionFromColorAllEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    FilterCard protectionFilter = (FilterCard) ((ProtectionAbility) ability).getFilter();
    protectionFilter.add(new ColorPredicate(choice.getColor()));
    protectionFilter.setMessage(choice.getChoice());
    ((ProtectionAbility) ability).setFilter(protectionFilter);
    return super.apply(game, source);
}
Also used : FilterCard(mage.filter.FilterCard) ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) ProtectionAbility(mage.abilities.keyword.ProtectionAbility)

Example 18 with ProtectionAbility

use of mage.abilities.keyword.ProtectionAbility in project mage by magefree.

the class JeweledSpiritEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    ChoiceColorOrArtifact choice = new ChoiceColorOrArtifact();
    if (controller != null && controller.choose(outcome, choice, game)) {
        FilterCard protectionFilter = new FilterCard();
        if (choice.isArtifactSelected()) {
            protectionFilter.add(CardType.ARTIFACT.getPredicate());
        } else {
            protectionFilter.add(new ColorPredicate(choice.getColor()));
        }
        protectionFilter.setMessage(choice.getChoice());
        ProtectionAbility protectionAbility = new ProtectionAbility(protectionFilter);
        ContinuousEffect effect = new GainAbilitySourceEffect(protectionAbility, Duration.EndOfTurn);
        game.addEffect(effect, source);
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) ChoiceColorOrArtifact(mage.choices.ChoiceColorOrArtifact) Player(mage.players.Player) GainAbilitySourceEffect(mage.abilities.effects.common.continuous.GainAbilitySourceEffect) ProtectionAbility(mage.abilities.keyword.ProtectionAbility) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

Example 19 with ProtectionAbility

use of mage.abilities.keyword.ProtectionAbility in project mage by magefree.

the class SerrasEmissaryEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Object savedType = game.getState().getValue(source.getSourceId() + "_type");
    if (controller == null || savedType == null) {
        return false;
    }
    if (savedType instanceof String) {
        CardType cardType = CardType.fromString((String) savedType);
        FilterCard filter = new FilterCard(cardType + "s");
        filter.add(cardType.getPredicate());
        Ability ability = new ProtectionAbility(filter);
        controller.addAbility(ability);
        for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CONTROLLED_CREATURE, source.getControllerId(), source.getSourceId(), game)) {
            permanent.addAbility(ability, source.getSourceId(), game);
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) AsEntersBattlefieldAbility(mage.abilities.common.AsEntersBattlefieldAbility) FlyingAbility(mage.abilities.keyword.FlyingAbility) ProtectionAbility(mage.abilities.keyword.ProtectionAbility) Ability(mage.abilities.Ability) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) ProtectionAbility(mage.abilities.keyword.ProtectionAbility)

Example 20 with ProtectionAbility

use of mage.abilities.keyword.ProtectionAbility in project mage by magefree.

the class WardSliverGainAbilityControlledEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    if (protectionFilter == null) {
        Permanent permanent = game.getPermanent(source.getSourceId());
        if (permanent != null) {
            ObjectColor color = (ObjectColor) game.getState().getValue(permanent.getId() + "_color");
            if (color != null) {
                protectionFilter = new FilterPermanent(color.getDescription());
                protectionFilter.add(new ColorPredicate(color));
            }
        }
    }
    if (protectionFilter != null) {
        for (Permanent perm : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_ALL_SLIVERS, game)) {
            perm.addAbility(new ProtectionAbility(protectionFilter), source.getSourceId(), game);
        }
        return true;
    }
    return false;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) FilterPermanent(mage.filter.FilterPermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ObjectColor(mage.ObjectColor) ProtectionAbility(mage.abilities.keyword.ProtectionAbility)

Aggregations

ProtectionAbility (mage.abilities.keyword.ProtectionAbility)24 ColorPredicate (mage.filter.predicate.mageobject.ColorPredicate)14 Permanent (mage.game.permanent.Permanent)13 FilterCard (mage.filter.FilterCard)12 Player (mage.players.Player)10 ObjectColor (mage.ObjectColor)7 Ability (mage.abilities.Ability)7 GainAbilityControllerEffect (mage.abilities.effects.common.continuous.GainAbilityControllerEffect)4 FilterObject (mage.filter.FilterObject)4 ContinuousEffect (mage.abilities.effects.ContinuousEffect)3 GainAbilityControlledEffect (mage.abilities.effects.common.continuous.GainAbilityControlledEffect)3 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)3 GainProtectionFromColorTargetEffect (mage.abilities.effects.common.continuous.GainProtectionFromColorTargetEffect)3 FlyingAbility (mage.abilities.keyword.FlyingAbility)3 ChoiceColor (mage.choices.ChoiceColor)3 FilterPermanent (mage.filter.FilterPermanent)3 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)3 ArrayList (java.util.ArrayList)2 MageObject (mage.MageObject)2 EntersBattlefieldTriggeredAbility (mage.abilities.common.EntersBattlefieldTriggeredAbility)2