Search in sources :

Example 1 with DamageControllerEffect

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

the class ObsidianFireheartGainAbilityEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    // If the owner/controller of this card leaves the game, the blaze counters
    // presence on the targeted land will continue to deal 1 damage every upkeep
    // to the lands controller.
    Permanent targetLand = game.getPermanent(source.getFirstTarget());
    if (targetLand != null && source.getTargets().get(0) != null) {
        ContinuousEffect effect = new ObsidianFireheartGainAbilityEffect(new BeginningOfUpkeepTriggeredAbility(new DamageControllerEffect(1), TargetController.YOU, false), Duration.Custom, "");
        // add a new independent ability that is not reliant on the source ability
        SimpleStaticAbility gainAbility = new SimpleStaticAbility(Zone.BATTLEFIELD, effect);
        // set sourcecard of the independent ability to the targeted permanent of the source ability
        gainAbility.setSourceId(targetLand.getId());
        // the target of the source ability is added to the new independent ability
        gainAbility.getTargets().add(source.getTargets().get(0));
        // add the continuous effect to the game with the independent ability
        game.addEffect(effect, gainAbility);
        return true;
    }
    return false;
}
Also used : DamageControllerEffect(mage.abilities.effects.common.DamageControllerEffect) FilterLandPermanent(mage.filter.common.FilterLandPermanent) TargetLandPermanent(mage.target.common.TargetLandPermanent) Permanent(mage.game.permanent.Permanent) BeginningOfUpkeepTriggeredAbility(mage.abilities.common.BeginningOfUpkeepTriggeredAbility) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

Aggregations

BeginningOfUpkeepTriggeredAbility (mage.abilities.common.BeginningOfUpkeepTriggeredAbility)1 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)1 ContinuousEffect (mage.abilities.effects.ContinuousEffect)1 DamageControllerEffect (mage.abilities.effects.common.DamageControllerEffect)1 FilterLandPermanent (mage.filter.common.FilterLandPermanent)1 Permanent (mage.game.permanent.Permanent)1 TargetLandPermanent (mage.target.common.TargetLandPermanent)1