Search in sources :

Example 21 with SimpleStaticAbility

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

the class CantStayAwayReplacementEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Card targetCard = game.getCard(source.getFirstTarget());
    if (controller == null || targetCard == null || game.getState().getZone(targetCard.getId()) != Zone.GRAVEYARD) {
        return false;
    }
    controller.moveCards(targetCard, Zone.BATTLEFIELD, source, game);
    Permanent permanent = game.getPermanent(targetCard.getId());
    if (permanent != null) {
        ContinuousEffect effect = new GainAbilityTargetEffect(new SimpleStaticAbility(new CantStayAwayReplacementEffect()), Duration.Custom);
        effect.setTargetPointer(new FixedTarget(permanent, game));
        game.addEffect(effect, source);
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) ContinuousEffect(mage.abilities.effects.ContinuousEffect) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card)

Example 22 with SimpleStaticAbility

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

the class OutcomesTest method test_FromEffects_Multi.

@Test
public void test_FromEffects_Multi() {
    Ability abilityGood = new SimpleStaticAbility(new GainLifeEffect(10));
    abilityGood.addEffect(new BoostSourceEffect(10, 10, Duration.EndOfTurn));
    Assert.assertEquals(1 + 1, abilityGood.getEffects().getOutcomeScore(abilityGood));
    Ability abilityBad = new SimpleStaticAbility(new DamageTargetEffect(10));
    abilityBad.addEffect(new ExileTargetEffect());
    Assert.assertEquals(-1 + -1, abilityBad.getEffects().getOutcomeScore(abilityBad));
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) LeavesBattlefieldTriggeredAbility(mage.abilities.common.LeavesBattlefieldTriggeredAbility) Ability(mage.abilities.Ability) BoostSourceEffect(mage.abilities.effects.common.continuous.BoostSourceEffect) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) GainLifeEffect(mage.abilities.effects.common.GainLifeEffect) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect) Test(org.junit.Test)

Example 23 with SimpleStaticAbility

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

the class OutcomesTest method test_FromAbility_MultiCombine.

@Test
public void test_FromAbility_MultiCombine() {
    Ability ability = new SimpleStaticAbility(new GainLifeEffect(10));
    ability.addEffect(new BoostSourceEffect(10, 10, Duration.EndOfTurn));
    ability.addEffect(new ExileTargetEffect());
    // must "convert" all effects to good
    ability.addCustomOutcome(Outcome.Neutral);
    Assert.assertEquals(1 + 1 + 1, ability.getEffects().getOutcomeScore(ability));
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) LeavesBattlefieldTriggeredAbility(mage.abilities.common.LeavesBattlefieldTriggeredAbility) Ability(mage.abilities.Ability) BoostSourceEffect(mage.abilities.effects.common.continuous.BoostSourceEffect) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) GainLifeEffect(mage.abilities.effects.common.GainLifeEffect) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect) Test(org.junit.Test)

Example 24 with SimpleStaticAbility

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

the class OutcomesTest method test_FromAbility_Single.

/**
 * Special outcome from ability (AI activates only good abilities)
 */
@Test
public void test_FromAbility_Single() {
    Ability abilityGood = new SimpleStaticAbility(new GainLifeEffect(10));
    abilityGood.addCustomOutcome(Outcome.Detriment);
    Assert.assertEquals(-1, abilityGood.getEffects().getOutcomeScore(abilityGood));
    Assert.assertEquals(Outcome.Detriment, abilityGood.getEffects().getOutcome(abilityGood));
    Ability abilityBad = new SimpleStaticAbility(new DamageTargetEffect(10));
    abilityBad.addCustomOutcome(Outcome.Neutral);
    Assert.assertEquals(1, abilityBad.getEffects().getOutcomeScore(abilityBad));
    Assert.assertEquals(Outcome.Neutral, abilityBad.getEffects().getOutcome(abilityBad));
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) LeavesBattlefieldTriggeredAbility(mage.abilities.common.LeavesBattlefieldTriggeredAbility) Ability(mage.abilities.Ability) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) GainLifeEffect(mage.abilities.effects.common.GainLifeEffect) Test(org.junit.Test)

Example 25 with SimpleStaticAbility

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

the class OutcomesTest method test_FromAbility_Multi.

@Test
public void test_FromAbility_Multi() {
    Ability abilityGood = new SimpleStaticAbility(new GainLifeEffect(10));
    abilityGood.addEffect(new BoostSourceEffect(10, 10, Duration.EndOfTurn));
    abilityGood.addCustomOutcome(Outcome.Detriment);
    Assert.assertEquals(-1 + -1, abilityGood.getEffects().getOutcomeScore(abilityGood));
    Ability abilityBad = new SimpleStaticAbility(new DamageTargetEffect(10));
    abilityBad.addEffect(new ExileTargetEffect());
    abilityBad.addCustomOutcome(Outcome.Neutral);
    Assert.assertEquals(1 + 1, abilityBad.getEffects().getOutcomeScore(abilityBad));
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) LeavesBattlefieldTriggeredAbility(mage.abilities.common.LeavesBattlefieldTriggeredAbility) Ability(mage.abilities.Ability) BoostSourceEffect(mage.abilities.effects.common.continuous.BoostSourceEffect) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) GainLifeEffect(mage.abilities.effects.common.GainLifeEffect) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect) 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