Search in sources :

Example 46 with SimpleStaticAbility

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

the class InfoEffect method addInfoToPermanent.

/**
 * Add temporary information string to permanent (visible in rules list)
 *
 * @param game
 * @param source
 * @param permanent
 * @param info
 * @param duration
 */
public static void addInfoToPermanent(Game game, Ability source, Permanent permanent, String info, Duration duration) {
    // add simple static info to permanent's rules
    SimpleStaticAbility ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new InfoEffect(info));
    GainAbilityTargetEffect gainEffect = new GainAbilityTargetEffect(ability, duration);
    gainEffect.setTargetPointer(new FixedTarget(permanent, game));
    game.addEffect(gainEffect, source);
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect)

Example 47 with SimpleStaticAbility

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

the class MonkClassCastEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    Card card = player.getLibrary().getFromTop(game);
    if (card == null) {
        return false;
    }
    player.moveCards(card, Zone.EXILED, source, game);
    game.addEffect(new GainAbilityTargetEffect(new SimpleStaticAbility(Zone.EXILED, new MonkClassCastEffect()), Duration.Custom, null, true).setTargetPointer(new FixedTarget(card, game)), source);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) Card(mage.cards.Card)

Example 48 with SimpleStaticAbility

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

the class OldGrowthTrollContinuousEffect method makeAbility.

private static final Ability makeAbility() {
    Ability activatedAbility = new SimpleActivatedAbility(new CreateTokenEffect(new TrollWarriorToken(), 1, true, false), new GenericManaCost(1));
    activatedAbility.addCost(new TapSourceCost());
    Cost cost = new SacrificeSourceCost();
    cost.setText("sacrifice this land");
    activatedAbility.addCost(cost);
    Ability ability = new SimpleStaticAbility(new GainAbilityAttachedEffect(new SimpleManaAbility(Zone.BATTLEFIELD, Mana.GreenMana(2), new TapSourceCost()), AttachmentType.AURA).setText("enchanted Forest has \"{T}: Add {G}{G}\""));
    ability.addEffect(new GainAbilityAttachedEffect(activatedAbility, AttachmentType.AURA).setText("and \"{1}, {T}, Sacrifice this land: Create a tapped 4/4 green Troll Warrior creature token with trample.\""));
    return ability;
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) DiesSourceTriggeredAbility(mage.abilities.common.DiesSourceTriggeredAbility) EnchantAbility(mage.abilities.keyword.EnchantAbility) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) SimpleManaAbility(mage.abilities.mana.SimpleManaAbility) SpellAbility(mage.abilities.SpellAbility) ConditionalInterveningIfTriggeredAbility(mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility) TrampleAbility(mage.abilities.keyword.TrampleAbility) Ability(mage.abilities.Ability) TrollWarriorToken(mage.game.permanent.token.TrollWarriorToken) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) SacrificeSourceCost(mage.abilities.costs.common.SacrificeSourceCost) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) GainAbilityAttachedEffect(mage.abilities.effects.common.continuous.GainAbilityAttachedEffect) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) SimpleManaAbility(mage.abilities.mana.SimpleManaAbility) TapSourceCost(mage.abilities.costs.common.TapSourceCost) Cost(mage.abilities.costs.Cost) TapSourceCost(mage.abilities.costs.common.TapSourceCost) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) SacrificeSourceCost(mage.abilities.costs.common.SacrificeSourceCost)

Example 49 with SimpleStaticAbility

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

the class TakeControlWhileSearchingLibraryTest method test_SimpleSearchingLibrary_TakeControl.

@Test
public void test_SimpleSearchingLibrary_TakeControl() {
    removeAllCardsFromLibrary(playerA);
    removeAllCardsFromLibrary(playerB);
    addCard(Zone.LIBRARY, playerA, "Balduvian Bears", 1);
    addCard(Zone.LIBRARY, playerB, "Kitesail Corsair", 1);
    // 
    // Search your library for up to three creature cards and put them into your graveyard. Then shuffle your library.
    // {2}{B}
    addCard(Zone.HAND, playerA, "Buried Alive", 1);
    addCard(Zone.BATTLEFIELD, playerA, "Swamp", 3);
    // 
    // You control your opponents while they’re searching their libraries.
    addCustomCardWithAbility("control", playerB, new SimpleStaticAbility(new YouControlYourOpponentsWhileSearchingReplacementEffect()));
    // 
    addCard(Zone.HAND, playerA, "Lightning Bolt", 1);
    addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
    // before
    checkGraveyardCount("before a", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Balduvian Bears", 0);
    checkGraveyardCount("before b", 1, PhaseStep.PRECOMBAT_MAIN, playerB, "Kitesail Corsair", 0);
    // search under control of B
    activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {B}", 3);
    castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Buried Alive");
    // continue
    setChoice(playerB, true);
    // player B must take control for searching
    addTarget(playerB, "Balduvian Bears");
    waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
    // after
    checkGraveyardCount("after a", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Balduvian Bears", 1);
    checkGraveyardCount("after b", 1, PhaseStep.PRECOMBAT_MAIN, playerB, "Kitesail Corsair", 0);
    // check that control returned
    castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt");
    addTarget(playerA, playerB);
    setStrictChooseMode(true);
    setStopAt(1, PhaseStep.BEGIN_COMBAT);
    execute();
    assertAllCommandsUsed();
}
Also used : YouControlYourOpponentsWhileSearchingReplacementEffect(mage.abilities.effects.common.replacement.YouControlYourOpponentsWhileSearchingReplacementEffect) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) Test(org.junit.Test)

Example 50 with SimpleStaticAbility

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

the class WallOfDustNextTurnTest method test_SingleOpponentMustAttack.

@Test
public void test_SingleOpponentMustAttack() {
    // Whenever Wall of Dust blocks a creature, that creature can't attack during its controller's next turn.
    addCard(Zone.BATTLEFIELD, playerA, "Wall of Dust");
    // 2/2
    addCard(Zone.BATTLEFIELD, playerB, "Balduvian Bears", 1);
    // 2/2
    addCard(Zone.BATTLEFIELD, playerB, "Ashcoat Bear", 1);
    // 
    Ability ability = new SimpleStaticAbility(new AttacksIfAbleAllEffect(StaticFilters.FILTER_OPPONENTS_PERMANENT_CREATURE, Duration.EndOfGame));
    ability.addWatcher(new AttackedThisTurnWatcher());
    addCustomCardWithAbility("all attacks", playerA, ability);
    // 1 - nothing
    checkPermanentCount("turn 1", 1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Balduvian Bears", 1);
    checkPermanentCount("turn 1", 1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Ashcoat Bear", 1);
    checkLife("turn 1", 1, PhaseStep.POSTCOMBAT_MAIN, playerA, 20);
    // 2 - auto-attack B -> A, 1 attacked, 1 blocked (by wall)
    block(2, playerA, "Wall of Dust", "Balduvian Bears");
    checkPermanentCount("turn 2", 2, PhaseStep.POSTCOMBAT_MAIN, playerB, "Balduvian Bears", 1);
    checkPermanentCount("turn 2", 2, PhaseStep.POSTCOMBAT_MAIN, playerB, "Ashcoat Bear", 1);
    checkLife("turn 2", 2, PhaseStep.POSTCOMBAT_MAIN, playerA, 20 - 2);
    // 3 - nothing
    checkPermanentCount("turn 3", 3, PhaseStep.POSTCOMBAT_MAIN, playerB, "Balduvian Bears", 1);
    checkPermanentCount("turn 3", 3, PhaseStep.POSTCOMBAT_MAIN, playerB, "Ashcoat Bear", 1);
    checkLife("turn 3", 3, PhaseStep.POSTCOMBAT_MAIN, playerA, 20 - 2);
    // 4 - auto-attack, B -> A, 1 attacked, 1 can't attacked (by wall's abilitiy during next turn)
    checkPermanentCount("turn 4", 4, PhaseStep.POSTCOMBAT_MAIN, playerB, "Balduvian Bears", 1);
    checkPermanentCount("turn 4", 4, PhaseStep.POSTCOMBAT_MAIN, playerB, "Ashcoat Bear", 1);
    checkLife("turn 4", 4, PhaseStep.POSTCOMBAT_MAIN, playerA, 20 - 2 * 2);
    // 5 - nothing
    checkPermanentCount("turn 5", 5, PhaseStep.POSTCOMBAT_MAIN, playerB, "Balduvian Bears", 1);
    checkPermanentCount("turn 5", 5, PhaseStep.POSTCOMBAT_MAIN, playerB, "Ashcoat Bear", 1);
    checkLife("turn 5", 5, PhaseStep.POSTCOMBAT_MAIN, playerA, 20 - 2 * 2);
    // 6 - auto-attack, B -> A, 2 attacked
    checkPermanentCount("turn 6", 6, PhaseStep.POSTCOMBAT_MAIN, playerB, "Balduvian Bears", 1);
    checkPermanentCount("turn 6", 6, PhaseStep.POSTCOMBAT_MAIN, playerB, "Ashcoat Bear", 1);
    checkLife("turn 6", 6, PhaseStep.POSTCOMBAT_MAIN, playerA, 20 - 2 * 2 - 2 * 2);
    setStopAt(6, PhaseStep.END_TURN);
    setStrictChooseMode(true);
    execute();
    assertAllCommandsUsed();
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) Ability(mage.abilities.Ability) AttackedThisTurnWatcher(mage.watchers.common.AttackedThisTurnWatcher) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) AttacksIfAbleAllEffect(mage.abilities.effects.common.combat.AttacksIfAbleAllEffect) Test(org.junit.Test)

Aggregations

SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)61 Test (org.junit.Test)27 Ability (mage.abilities.Ability)21 Player (mage.players.Player)14 Permanent (mage.game.permanent.Permanent)11 InfoEffect (mage.abilities.effects.common.InfoEffect)10 BoostAllEffect (mage.abilities.effects.common.continuous.BoostAllEffect)10 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)9 Card (mage.cards.Card)9 FixedTarget (mage.target.targetpointer.FixedTarget)9 UUID (java.util.UUID)8 LeavesBattlefieldTriggeredAbility (mage.abilities.common.LeavesBattlefieldTriggeredAbility)6 ContinuousEffect (mage.abilities.effects.ContinuousEffect)6 GainLifeEffect (mage.abilities.effects.common.GainLifeEffect)6 FilterCard (mage.filter.FilterCard)5 MageObject (mage.MageObject)4 DamageTargetEffect (mage.abilities.effects.common.DamageTargetEffect)4 PreventAllDamageToAllEffect (mage.abilities.effects.common.PreventAllDamageToAllEffect)4 BoostSourceEffect (mage.abilities.effects.common.continuous.BoostSourceEffect)4 AbilitiesCostReductionControllerEffect (mage.abilities.effects.common.cost.AbilitiesCostReductionControllerEffect)4