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;
}
Aggregations