Search in sources :

Example 6 with DamageTargetEffect

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

the class RodOfSpankingEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player target = game.getPlayer(source.getFirstTarget());
    new DamageTargetEffect(1).apply(game, source);
    if (target != null) {
        if (target.chooseUse(Outcome.Untap, "Say \"Thank you, sir. May I have another?\"", source, game)) {
            game.informPlayers(target.getLogName() + ": Thank you, sir. May I have another?");
        } else {
            new UntapSourceEffect().apply(game, source);
        }
        return true;
    }
    return false;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) UntapSourceEffect(mage.abilities.effects.common.UntapSourceEffect) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect)

Example 7 with DamageTargetEffect

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

the class ToralfsHammerEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedEvent dEvent = (DamagedEvent) event;
    if (dEvent.getExcess() < 1 || dEvent.isCombatDamage() || !game.getOpponents(getControllerId()).contains(game.getControllerId(event.getTargetId()))) {
        return false;
    }
    this.getEffects().clear();
    this.getTargets().clear();
    this.addEffect(new DamageTargetEffect(dEvent.getExcess()));
    FilterCreaturePlayerOrPlaneswalker filter = new FilterCreaturePlayerOrPlaneswalker();
    filter.getPermanentFilter().add(Predicates.not(new MageObjectReferencePredicate(new MageObjectReference(event.getTargetId(), game))));
    this.addTarget(new TargetAnyTarget(filter));
    return true;
}
Also used : DamagedEvent(mage.game.events.DamagedEvent) FilterCreaturePlayerOrPlaneswalker(mage.filter.common.FilterCreaturePlayerOrPlaneswalker) MageObjectReferencePredicate(mage.filter.predicate.mageobject.MageObjectReferencePredicate) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) MageObjectReference(mage.MageObjectReference) TargetAnyTarget(mage.target.common.TargetAnyTarget)

Example 8 with DamageTargetEffect

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

the class HankyuCost method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = source.getSourcePermanentIfItStillExists(game);
    if (permanent == null) {
        return false;
    }
    Permanent creature = game.getPermanent(permanent.getAttachedTo());
    if (creature == null) {
        return false;
    }
    creature.addAbility(new SimpleActivatedAbility(new AddCountersTargetEffect(CounterType.AIM.createInstance()).setTargetPointer(new FixedTarget(permanent, game)).setText("put an aim counter on " + permanent.getName()), new TapSourceCost()), source.getSourceId(), game);
    Ability ability = new SimpleActivatedAbility(new DamageTargetEffect(HankyuValue.instance).setText("this creature deals damage to any target equal " + "to the number of aim counters removed this way"), new TapSourceCost());
    ability.addCost(new HankyuCost().setMageObjectReference(source, game));
    ability.addTarget(new TargetAnyTarget());
    creature.addAbility(ability, source.getSourceId(), game);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) EquipAbility(mage.abilities.keyword.EquipAbility) Ability(mage.abilities.Ability) Permanent(mage.game.permanent.Permanent) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) TapSourceCost(mage.abilities.costs.common.TapSourceCost) TargetAnyTarget(mage.target.common.TargetAnyTarget)

Example 9 with DamageTargetEffect

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

the class MindWhipEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controllerOfEnchantedCreature = game.getPlayer(targetPointer.getFirst(game, source));
    Permanent mindWhip = game.getPermanent(source.getSourceId());
    if (controllerOfEnchantedCreature != null && mindWhip != null) {
        Permanent enchantedCreature = game.getPermanent(mindWhip.getAttachedTo());
        if (enchantedCreature != null) {
            Effect effect = new DamageTargetEffect(2);
            effect.setTargetPointer(new FixedTarget(controllerOfEnchantedCreature.getId()));
            effect.apply(game, source);
            enchantedCreature.tap(source, game);
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) DoUnlessTargetPlayerOrTargetsControllerPaysEffect(mage.abilities.effects.common.DoUnlessTargetPlayerOrTargetsControllerPaysEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) AttachEffect(mage.abilities.effects.common.AttachEffect) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect)

Example 10 with DamageTargetEffect

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

the class TephradermSpellDamageTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (!event.getTargetId().equals(this.getSourceId())) {
        return false;
    }
    Permanent sourcePermanent = game.getPermanent(event.getSourceId());
    if (sourcePermanent != null && FILTER_CREATURE.match(sourcePermanent, getSourceId(), getControllerId(), game)) {
        for (Effect effect : getEffects()) {
            if (effect instanceof DamageTargetEffect) {
                effect.setTargetPointer(new FixedTarget(sourcePermanent.getId(), game));
                ((DamageTargetEffect) effect).setAmount(StaticValue.get(event.getAmount()));
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Effect(mage.abilities.effects.Effect) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect)

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