Search in sources :

Example 31 with DamageTargetEffect

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

the class CustomTestCard method addCustomEffect_TargetDamage.

/**
 * Add target damage ability that can be called by text: "target damage xxx"
 *
 * @param controller
 * @param damageAmount
 */
protected void addCustomEffect_TargetDamage(TestPlayer controller, int damageAmount) {
    Ability ability = new SimpleActivatedAbility(new DamageTargetEffect(damageAmount).setText("target damage " + damageAmount), new ManaCostsImpl(""));
    ability.addTarget(new TargetAnyTarget());
    addCustomCardWithAbility("target damage " + damageAmount + " for " + controller.getName(), controller, ability);
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) SpellAbility(mage.abilities.SpellAbility) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) Ability(mage.abilities.Ability) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) TargetAnyTarget(mage.target.common.TargetAnyTarget)

Example 32 with DamageTargetEffect

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

the class FieryEncoreEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    Card card = player.discardOne(false, false, source, game);
    player.drawCards(1, source, game);
    if (card == null || card.isLand(game)) {
        return true;
    }
    ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DamageTargetEffect(card.getManaValue()), false, "when you discard a nonland " + "card this way, {this} deals damage equal to that card's mana value to target creature or planeswalker");
    ability.addTarget(new TargetCreatureOrPlaneswalker());
    game.fireReflexiveTriggeredAbility(ability, source);
    return true;
}
Also used : Player(mage.players.Player) TargetCreatureOrPlaneswalker(mage.target.common.TargetCreatureOrPlaneswalker) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) Card(mage.cards.Card)

Example 33 with DamageTargetEffect

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

the class LeylineOfCombustionTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    StackObject sourceObject = game.getStack().getStackObject(event.getSourceId());
    if (sourceObject == null) {
        return false;
    }
    Player targetter = game.getPlayer(event.getPlayerId());
    if (targetter == null || !targetter.hasOpponent(this.controllerId, game)) {
        return false;
    }
    if (!event.getTargetId().equals(this.controllerId)) {
        Permanent permanent = game.getPermanentOrLKIBattlefield(event.getTargetId());
        if (permanent == null || !permanent.isControlledBy(this.controllerId)) {
            return false;
        }
    }
    // If a spell targets you and/or a permanent you control multiple times,
    // or if a spell targets you and one or more permanents you control,
    // Leyline of Combustion’s triggered ability triggers once.
    Set<UUID> sourceObjects = (Set<UUID>) game.getState().getValue("sourceObjects" + this.id);
    if (sourceObjects == null) {
        sourceObjects = new HashSet<>();
    }
    if (!sourceObjects.add(sourceObject.getId())) {
        return false;
    }
    game.getState().setValue("sourceObjects" + this.id, sourceObjects);
    this.getEffects().clear();
    Effect effect = new DamageTargetEffect(2);
    effect.setTargetPointer(new FixedTarget(event.getPlayerId(), game));
    this.addEffect(effect);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Set(java.util.Set) HashSet(java.util.HashSet) Permanent(mage.game.permanent.Permanent) StackObject(mage.game.stack.StackObject) Effect(mage.abilities.effects.Effect) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) UUID(java.util.UUID) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect)

Example 34 with DamageTargetEffect

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

the class ScorchSpitterTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (this.getSourceId().equals(event.getSourceId())) {
        this.getEffects().clear();
        Effect effect = new DamageTargetEffect(1);
        effect.setTargetPointer(new FixedTarget(game.getCombat().getDefenderId(event.getSourceId()), game));
        this.addEffect(effect);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Effect(mage.abilities.effects.Effect) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect)

Example 35 with DamageTargetEffect

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

the class SentinelTowerWatcher method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (game.isActivePlayer(getControllerId()) && super.checkTrigger(event, game)) {
        SentinelTowerWatcher watcher = game.getState().getWatcher(SentinelTowerWatcher.class);
        if (watcher == null) {
            return false;
        }
        List<MageObjectReference> spellsCast = watcher.getSpellsThisTurn();
        MageObject object = game.getObject(event.getTargetId());
        if (object == null || spellsCast == null) {
            return false;
        }
        int damageToDeal = 0;
        for (MageObjectReference mor : spellsCast) {
            damageToDeal++;
            if (mor.refersTo(object, game)) {
                break;
            }
        }
        damageInfo = " (<b>" + damageToDeal + " damage</b>)";
        for (Effect effect : this.getEffects()) {
            if (effect instanceof DamageTargetEffect) {
                ((DamageTargetEffect) effect).setAmount(StaticValue.get(damageToDeal));
                return true;
            }
        }
    }
    return false;
}
Also used : MageObject(mage.MageObject) Effect(mage.abilities.effects.Effect) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) MageObjectReference(mage.MageObjectReference) ValueHint(mage.abilities.hint.ValueHint)

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