Search in sources :

Example 11 with DamageTargetEffect

use of mage.abilities.effects.common.DamageTargetEffect in project mage by magefree.

the class CinderSeerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    RevealTargetFromHandCost cost = new RevealTargetFromHandCost(new TargetCardInHand(0, Integer.MAX_VALUE, filter));
    if (!cost.pay(source, game, source, source.getControllerId(), true)) {
        return false;
    }
    int xValue = cost.getNumberRevealedCards();
    return new DamageTargetEffect(xValue).apply(game, source);
}
Also used : RevealTargetFromHandCost(mage.abilities.costs.common.RevealTargetFromHandCost) TargetCardInHand(mage.target.common.TargetCardInHand) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect)

Example 12 with DamageTargetEffect

use of mage.abilities.effects.common.DamageTargetEffect in project mage by magefree.

the class KeranosGodOfStormsTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (!event.getPlayerId().equals(this.getControllerId())) {
        return false;
    }
    if (!game.isActivePlayer(this.getControllerId())) {
        return false;
    }
    CardsAmountDrawnThisTurnWatcher watcher = game.getState().getWatcher(CardsAmountDrawnThisTurnWatcher.class);
    if (watcher != null && watcher.getAmountCardsDrawn(event.getPlayerId()) != 1) {
        return false;
    }
    Card card = game.getCard(event.getTargetId());
    Player controller = game.getPlayer(this.getControllerId());
    Permanent sourcePermanent = (Permanent) getSourceObject(game);
    if (card == null || controller == null || sourcePermanent == null) {
        return false;
    }
    controller.revealCards(sourcePermanent.getIdName(), new CardsImpl(card), game);
    this.getTargets().clear();
    this.getEffects().clear();
    if (card.isLand(game)) {
        this.addEffect(new DrawCardSourceControllerEffect(1));
    } else {
        this.addEffect(new DamageTargetEffect(3));
        this.addTarget(new TargetAnyTarget());
    }
    return true;
}
Also used : CardsAmountDrawnThisTurnWatcher(mage.watchers.common.CardsAmountDrawnThisTurnWatcher) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card) TargetAnyTarget(mage.target.common.TargetAnyTarget)

Example 13 with DamageTargetEffect

use of mage.abilities.effects.common.DamageTargetEffect in project mage by magefree.

the class MagmaPummelerEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    int damage = event.getAmount();
    preventDamageAction(event, source, game);
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (permanent == null) {
        return false;
    }
    int beforeCounters = permanent.getCounters(game).getCount(CounterType.P1P1);
    permanent.removeCounters(CounterType.P1P1.createInstance(damage), source, game);
    int countersRemoved = beforeCounters - permanent.getCounters(game).getCount(CounterType.P1P1);
    if (countersRemoved > 0) {
        ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DamageTargetEffect(countersRemoved), false, "{this} deals that much damage to any target");
        ability.addTarget(new TargetAnyTarget());
        game.fireReflexiveTriggeredAbility(ability, source);
    }
    return false;
}
Also used : Permanent(mage.game.permanent.Permanent) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) TargetAnyTarget(mage.target.common.TargetAnyTarget)

Example 14 with DamageTargetEffect

use of mage.abilities.effects.common.DamageTargetEffect 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 15 with DamageTargetEffect

use of mage.abilities.effects.common.DamageTargetEffect 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)

Aggregations

DamageTargetEffect (mage.abilities.effects.common.DamageTargetEffect)50 Player (mage.players.Player)22 TargetAnyTarget (mage.target.common.TargetAnyTarget)20 Permanent (mage.game.permanent.Permanent)17 ReflexiveTriggeredAbility (mage.abilities.common.delayed.ReflexiveTriggeredAbility)15 Ability (mage.abilities.Ability)12 Effect (mage.abilities.effects.Effect)11 FixedTarget (mage.target.targetpointer.FixedTarget)9 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)8 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)8 Test (org.junit.Test)8 OneShotEffect (mage.abilities.effects.OneShotEffect)7 Card (mage.cards.Card)7 TargetPermanent (mage.target.TargetPermanent)7 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)6 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)5 LeavesBattlefieldTriggeredAbility (mage.abilities.common.LeavesBattlefieldTriggeredAbility)4 GainLifeEffect (mage.abilities.effects.common.GainLifeEffect)4 SimpleManaAbility (mage.abilities.mana.SimpleManaAbility)4 UUID (java.util.UUID)3