Search in sources :

Example 1 with TargetAttackingOrBlockingCreature

use of mage.target.common.TargetAttackingOrBlockingCreature in project mage by magefree.

the class ArcheryTrainingValue method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent aura = game.getPermanent(source.getSourceId());
    if (aura == null) {
        return false;
    }
    Permanent permanent = game.getPermanent(aura.getAttachedTo());
    if (permanent == null) {
        return false;
    }
    String rule = "this creature deals X damage to target attacking or blocking creature, " + "where X is the number of arrow counters on " + aura.getName();
    Ability ability = new SimpleActivatedAbility(new DamageTargetEffect(new ArcheryTrainingValue(aura)).setText(rule), new TapSourceCost());
    ability.addTarget(new TargetAttackingOrBlockingCreature());
    permanent.addAbility(ability, source.getSourceId(), game);
    return true;
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) EnchantAbility(mage.abilities.keyword.EnchantAbility) BeginningOfUpkeepTriggeredAbility(mage.abilities.common.BeginningOfUpkeepTriggeredAbility) Ability(mage.abilities.Ability) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) TapSourceCost(mage.abilities.costs.common.TapSourceCost) TargetAttackingOrBlockingCreature(mage.target.common.TargetAttackingOrBlockingCreature)

Aggregations

Ability (mage.abilities.Ability)1 BeginningOfUpkeepTriggeredAbility (mage.abilities.common.BeginningOfUpkeepTriggeredAbility)1 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)1 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)1 TapSourceCost (mage.abilities.costs.common.TapSourceCost)1 DamageTargetEffect (mage.abilities.effects.common.DamageTargetEffect)1 EnchantAbility (mage.abilities.keyword.EnchantAbility)1 Permanent (mage.game.permanent.Permanent)1 TargetPermanent (mage.target.TargetPermanent)1 TargetAttackingOrBlockingCreature (mage.target.common.TargetAttackingOrBlockingCreature)1 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)1