Search in sources :

Example 16 with SimpleActivatedAbility

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

the class ManaPoolTest method test_ConditionalMana_OneXSpell.

@Test
public void test_ConditionalMana_OneXSpell() {
    addCustomCardWithAbility("add 10", playerA, new SimpleActivatedAbility(Zone.ALL, new AddConditionalManaEffect(Mana.RedMana(10), new InstantOrSorcerySpellManaBuilder()), new ManaCostsImpl("")));
    // {X}{R}{R}
    addCard(Zone.HAND, playerA, "Volcanic Geyser");
    // make mana
    activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Add {R}");
    waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
    checkManaPool("mana", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "R", 10);
    // use for spell
    castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Volcanic Geyser", playerB);
    setChoice(playerA, "X=1");
    waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
    checkManaPool("mana", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "R", 10 - 3);
    checkLife("after", 1, PhaseStep.END_TURN, playerB, 20 - 1);
    setStopAt(1, PhaseStep.END_TURN);
    setStrictChooseMode(true);
    execute();
    assertAllCommandsUsed();
}
Also used : AddConditionalManaEffect(mage.abilities.effects.mana.AddConditionalManaEffect) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) InstantOrSorcerySpellManaBuilder(mage.abilities.mana.builder.common.InstantOrSorcerySpellManaBuilder) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) Test(org.junit.Test)

Example 17 with SimpleActivatedAbility

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

the class ManaPoolTest method test_ConditionalMana_MultipleXSpell.

@Test
public void test_ConditionalMana_MultipleXSpell() {
    addCustomCardWithAbility("add 10", playerA, new SimpleActivatedAbility(Zone.ALL, new AddConditionalManaEffect(Mana.RedMana(10), new InstantOrSorcerySpellManaBuilder()), new ManaCostsImpl("")));
    // {X}{R}{R}
    addCard(Zone.HAND, playerA, "Volcanic Geyser", 2);
    // make mana
    activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Add {R}");
    waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
    checkManaPool("mana", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "R", 10);
    // use for spell 1
    castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Volcanic Geyser", playerB);
    setChoice(playerA, "X=1");
    waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
    checkManaPool("mana", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "R", 10 - 3);
    // use for spell 2
    castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Volcanic Geyser", playerB);
    setChoice(playerA, "X=1");
    waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
    checkManaPool("mana", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "R", 10 - 3 * 2);
    checkLife("after", 1, PhaseStep.END_TURN, playerB, 20 - 1 * 2);
    setStopAt(1, PhaseStep.END_TURN);
    setStrictChooseMode(true);
    execute();
    assertAllCommandsUsed();
}
Also used : AddConditionalManaEffect(mage.abilities.effects.mana.AddConditionalManaEffect) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) InstantOrSorcerySpellManaBuilder(mage.abilities.mana.builder.common.InstantOrSorcerySpellManaBuilder) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) Test(org.junit.Test)

Example 18 with SimpleActivatedAbility

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

the class ManaPoolTest method test_MultipleMana_OneXPart.

@Test
public void test_MultipleMana_OneXPart() {
    // {R}
    addCard(Zone.HAND, playerA, "Lightning Bolt");
    addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1 + 3 + 1);
    // 
    Ability ability = new SimpleActivatedAbility(Zone.ALL, new DamageTargetEffect(ManacostVariableValue.REGULAR), new ManaCostsImpl(""));
    ability.addTarget(new TargetAnyTarget());
    addCustomCardWithAbility("damage X", playerA, ability);
    // 
    // {X}: Counter target spell
    ability = new SimpleActivatedAbility(Zone.ALL, new CounterUnlessPaysEffect(ManacostVariableValue.REGULAR), new ManaCostsImpl("{X}"));
    ability.addTarget(new TargetSpell());
    addCustomCardWithAbility("counter until pay X", playerB, ability);
    addCard(Zone.BATTLEFIELD, playerB, "Island", 3);
    // make mana for spell
    activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
    checkManaPool("mana spell", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "R", 1);
    // cast spell
    castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", playerB);
    // make mana for pay X to prevent
    activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
    activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
    activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
    // one must be saved in pool
    activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
    checkManaPool("mana prevent", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "R", 4);
    // counter by X=3
    activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerB, "{X}: Counter");
    setChoice(playerB, "X=3");
    addTarget(playerB, "Lightning Bolt");
    // pay to prevent
    // pay 3 to prevent counter
    setChoice(playerA, true);
    waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
    checkManaPool("mana after", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "R", 4 - 3);
    checkLife("after", 1, PhaseStep.END_TURN, playerB, 20 - 3);
    setStopAt(1, PhaseStep.END_TURN);
    setStrictChooseMode(true);
    execute();
    assertAllCommandsUsed();
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) SimpleManaAbility(mage.abilities.mana.SimpleManaAbility) Ability(mage.abilities.Ability) CounterUnlessPaysEffect(mage.abilities.effects.common.CounterUnlessPaysEffect) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) TargetSpell(mage.target.TargetSpell) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) TargetAnyTarget(mage.target.common.TargetAnyTarget) Test(org.junit.Test)

Example 19 with SimpleActivatedAbility

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

the class ManaPoolTest method test_ConditionalMana_OneXAbility.

@Test
public void test_ConditionalMana_OneXAbility() {
    addCustomCardWithAbility("add 10", playerA, new SimpleActivatedAbility(Zone.ALL, new AddConditionalManaEffect(Mana.RedMana(10), new SimpleActivatedAbilityManaBuilder()), new ManaCostsImpl("")));
    // 
    Ability ability = new SimpleActivatedAbility(Zone.ALL, new DamageTargetEffect(ManacostVariableValue.REGULAR), new ManaCostsImpl("{X}"));
    ability.addTarget(new TargetAnyTarget());
    addCustomCardWithAbility("damage X", playerA, ability);
    // make mana
    activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Add {R}");
    waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
    checkManaPool("mana", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "R", 10);
    // use for ability
    activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{X}:", playerB);
    setChoice(playerA, "X=3");
    waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
    checkManaPool("mana", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "R", 10 - 3);
    checkLife("after", 1, PhaseStep.END_TURN, playerB, 20 - 3);
    setStopAt(1, PhaseStep.END_TURN);
    setStrictChooseMode(true);
    execute();
    assertAllCommandsUsed();
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) SimpleManaAbility(mage.abilities.mana.SimpleManaAbility) Ability(mage.abilities.Ability) AddConditionalManaEffect(mage.abilities.effects.mana.AddConditionalManaEffect) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) SimpleActivatedAbilityManaBuilder(mage.abilities.mana.builder.common.SimpleActivatedAbilityManaBuilder) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) TargetAnyTarget(mage.target.common.TargetAnyTarget) Test(org.junit.Test)

Example 20 with SimpleActivatedAbility

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

the class DreadWightCounterCondition method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
    if (permanent != null) {
        // add paralyzation counter
        Effect effect = new AddCountersTargetEffect(CounterType.PARALYZATION.createInstance());
        effect.setTargetPointer(new FixedTarget(permanent, game));
        effect.apply(game, source);
        // tap permanent
        permanent.tap(source, game);
        // does not untap while paralyzation counter is on it
        ContinuousRuleModifyingEffect effect2 = new DreadWightDoNotUntapEffect(Duration.WhileOnBattlefield, permanent.getId());
        effect2.setText("This creature doesn't untap during its controller's untap step for as long as it has a paralyzation counter on it");
        Condition condition = new DreadWightCounterCondition(permanent.getId());
        ConditionalContinuousRuleModifyingEffect conditionalEffect = new ConditionalContinuousRuleModifyingEffect(effect2, condition);
        Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, conditionalEffect);
        ContinuousEffect effect3 = new GainAbilityTargetEffect(ability, Duration.WhileOnBattlefield);
        ability.setRuleVisible(true);
        effect3.setTargetPointer(new FixedTarget(permanent, game));
        game.addEffect(effect3, source);
        // each gains 4: remove paralyzation counter
        Ability activatedAbility = new SimpleActivatedAbility(Zone.BATTLEFIELD, new RemoveCounterSourceEffect(CounterType.PARALYZATION.createInstance()), new ManaCostsImpl("{4}"));
        ContinuousEffect effect4 = new GainAbilityTargetEffect(activatedAbility, Duration.WhileOnBattlefield);
        effect4.setTargetPointer(new FixedTarget(permanent, game));
        game.addEffect(effect4, source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Condition(mage.abilities.condition.Condition) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) AtTheEndOfCombatDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) Ability(mage.abilities.Ability) Permanent(mage.game.permanent.Permanent) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) ConditionalContinuousRuleModifyingEffect(mage.abilities.decorator.ConditionalContinuousRuleModifyingEffect) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ConditionalContinuousRuleModifyingEffect(mage.abilities.decorator.ConditionalContinuousRuleModifyingEffect) ContinuousRuleModifyingEffect(mage.abilities.effects.ContinuousRuleModifyingEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) CreateDelayedTriggeredAbilityEffect(mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect) ConditionalContinuousRuleModifyingEffect(mage.abilities.decorator.ConditionalContinuousRuleModifyingEffect) ContinuousRuleModifyingEffect(mage.abilities.effects.ContinuousRuleModifyingEffect) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) RemoveCounterSourceEffect(mage.abilities.effects.common.counter.RemoveCounterSourceEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) RemoveCounterSourceEffect(mage.abilities.effects.common.counter.RemoveCounterSourceEffect)

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