Search in sources :

Example 1 with SimpleActivatedAbility

use of mage.abilities.common.SimpleActivatedAbility in project mage by magefree.

the class ConditionalAsThoughTest method test_PlayFromNotOwnHandZoneTargetEffect.

@Test
public void test_PlayFromNotOwnHandZoneTargetEffect() {
    Ability ability = new SimpleActivatedAbility(Zone.ALL, new ConditionalAsThoughEffect(new PlayFromNotOwnHandZoneTargetEffect(Zone.GRAVEYARD, TargetController.ANY, Duration.EndOfTurn), new PermanentsOnTheBattlefieldCondition(StaticFilters.FILTER_PERMANENT_CREATURE, ComparisonType.MORE_THAN, 0)).setText("allow target cast"), new ManaCostsImpl("{R}"));
    ability.addTarget(new TargetCardInOpponentsGraveyard(StaticFilters.FILTER_CARD));
    addCustomCardWithAbility("play any opponent hand", playerA, ability);
    addCard(Zone.HAND, playerA, "Grizzly Bears");
    addCard(Zone.GRAVEYARD, playerA, "Silvercoat Lion");
    addCard(Zone.GRAVEYARD, playerB, "Lightning Bolt");
    addCard(Zone.BATTLEFIELD, playerA, "Plains", 5);
    addCard(Zone.BATTLEFIELD, playerA, "Forest", 5);
    addCard(Zone.BATTLEFIELD, playerA, "Mountain", 5);
    // can't play grave before
    checkPlayableAbility("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Grizzly Bears", true);
    checkPlayableAbility("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Silvercoat Lion", false);
    checkPlayableAbility("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Lightning Bolt", false);
    // activate target effect
    activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{R}: Allow");
    addTarget(playerA, "Lightning Bolt");
    waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
    // can't play grave after but without good condition
    checkPlayableAbility("after bad", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Grizzly Bears", true);
    checkPlayableAbility("after bad", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Silvercoat Lion", false);
    checkPlayableAbility("after bad", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Lightning Bolt", false);
    // make good condition - now we can play opponent's grave
    castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Grizzly Bears");
    waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
    checkPlayableAbility("after good", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Grizzly Bears", false);
    checkPlayableAbility("after good", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Silvercoat Lion", false);
    checkPlayableAbility("after good", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Lightning Bolt", true);
    setStrictChooseMode(true);
    setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
    execute();
    assertAllCommandsUsed();
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) Ability(mage.abilities.Ability) ConditionalAsThoughEffect(mage.abilities.decorator.ConditionalAsThoughEffect) PlayFromNotOwnHandZoneTargetEffect(mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect) TargetCardInOpponentsGraveyard(mage.target.common.TargetCardInOpponentsGraveyard) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) PermanentsOnTheBattlefieldCondition(mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) Test(org.junit.Test)

Example 2 with SimpleActivatedAbility

use of mage.abilities.common.SimpleActivatedAbility in project mage by magefree.

the class ConditionalAsThoughTest method test_TargetCardInLibrary_CantUseAsAbilityTarget.

@Test(expected = IllegalArgumentException.class)
public void test_TargetCardInLibrary_CantUseAsAbilityTarget() {
    Ability ability = new SimpleActivatedAbility(Zone.ALL, new InfoEffect("test"), new ManaCostsImpl("{R}"));
    ability.addTarget(new TargetCardInLibrary());
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) Ability(mage.abilities.Ability) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) InfoEffect(mage.abilities.effects.common.InfoEffect) Test(org.junit.Test)

Example 3 with SimpleActivatedAbility

use of mage.abilities.common.SimpleActivatedAbility in project mage by magefree.

the class GigantoplasmCopyApplier method apply.

@Override
public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
    DynamicValue variableMana = ManacostVariableValue.REGULAR;
    Effect effect = new SetPowerToughnessSourceEffect(variableMana, Duration.WhileOnBattlefield, SubLayer.SetPT_7b);
    effect.setText("This creature has base power and toughness X/X");
    Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl("{X}"));
    blueprint.getAbilities().add(ability);
    return true;
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) EntersBattlefieldAbility(mage.abilities.common.EntersBattlefieldAbility) Ability(mage.abilities.Ability) SetPowerToughnessSourceEffect(mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) CopyPermanentEffect(mage.abilities.effects.common.CopyPermanentEffect) SetPowerToughnessSourceEffect(mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect) Effect(mage.abilities.effects.Effect) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) DynamicValue(mage.abilities.dynamicvalue.DynamicValue)

Example 4 with SimpleActivatedAbility

use of mage.abilities.common.SimpleActivatedAbility in project mage by magefree.

the class HeliodsPunishmentEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent sourceEnchantment = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (sourceEnchantment != null && sourceEnchantment.getAttachedTo() != null) {
        Permanent attachedTo = game.getPermanent(sourceEnchantment.getAttachedTo());
        if (attachedTo != null) {
            attachedTo.removeAllAbilities(source.getSourceId(), game);
            HeliodsPunishmentEffect effect = new HeliodsPunishmentEffect(sourceEnchantment.getName());
            Ability ability = new SimpleActivatedAbility(effect, new TapSourceCost());
            effect.setSourceEnchantment(sourceEnchantment.getId());
            attachedTo.addAbility(ability, source.getSourceId(), game);
        }
    }
    return true;
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) EntersBattlefieldAbility(mage.abilities.common.EntersBattlefieldAbility) EnchantAbility(mage.abilities.keyword.EnchantAbility) Ability(mage.abilities.Ability) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) TapSourceCost(mage.abilities.costs.common.TapSourceCost)

Example 5 with SimpleActivatedAbility

use of mage.abilities.common.SimpleActivatedAbility in project mage by magefree.

the class EvilTwinPredicate method apply.

@Override
public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
    Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DestroyTargetEffect(), new ManaCostsImpl("{U}{B}"));
    ability.addCost(new TapSourceCost());
    ability.addTarget(new TargetCreaturePermanent(filter));
    blueprint.getAbilities().add(ability);
    return true;
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) EntersBattlefieldAbility(mage.abilities.common.EntersBattlefieldAbility) Ability(mage.abilities.Ability) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) TapSourceCost(mage.abilities.costs.common.TapSourceCost)

Aggregations

SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)30 Ability (mage.abilities.Ability)27 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)21 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)12 Test (org.junit.Test)12 TapSourceCost (mage.abilities.costs.common.TapSourceCost)8 DamageTargetEffect (mage.abilities.effects.common.DamageTargetEffect)8 TargetAnyTarget (mage.target.common.TargetAnyTarget)7 SpellAbility (mage.abilities.SpellAbility)6 Permanent (mage.game.permanent.Permanent)6 SimpleManaAbility (mage.abilities.mana.SimpleManaAbility)5 TargetPermanent (mage.target.TargetPermanent)5 GenericManaCost (mage.abilities.costs.mana.GenericManaCost)4 AddConditionalManaEffect (mage.abilities.effects.mana.AddConditionalManaEffect)4 EntersBattlefieldAbility (mage.abilities.common.EntersBattlefieldAbility)3 EntersBattlefieldTriggeredAbility (mage.abilities.common.EntersBattlefieldTriggeredAbility)3 AddCountersTargetEffect (mage.abilities.effects.common.counter.AddCountersTargetEffect)3 EnchantAbility (mage.abilities.keyword.EnchantAbility)3 Effect (mage.abilities.effects.Effect)2 CounterUnlessPaysEffect (mage.abilities.effects.common.CounterUnlessPaysEffect)2