diff --git a/Mage.Sets/src/mage/cards/o/ObsidianFireheart.java b/Mage.Sets/src/mage/cards/o/ObsidianFireheart.java index 8167bc68798..2df1a3b207d 100644 --- a/Mage.Sets/src/mage/cards/o/ObsidianFireheart.java +++ b/Mage.Sets/src/mage/cards/o/ObsidianFireheart.java @@ -1,5 +1,3 @@ - - package mage.cards.o; import java.util.UUID; @@ -7,8 +5,10 @@ import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.Effect; +import mage.abilities.effects.ContinuousEffect; +import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.DamageControllerEffect; import mage.abilities.effects.common.continuous.GainAbilityTargetEffect; import mage.abilities.effects.common.counter.AddCountersTargetEffect; @@ -17,6 +17,7 @@ import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; import mage.constants.Duration; +import mage.constants.Outcome; import mage.constants.TargetController; import mage.constants.Zone; import mage.counters.CounterType; @@ -33,7 +34,9 @@ import mage.target.common.TargetLandPermanent; */ public final class ObsidianFireheart extends CardImpl { - private static final String rule = "For as long as that land has a blaze counter on it, it has \"At the beginning of your upkeep, this land deals 1 damage to you.\" (The land continues to burn after Obsidian Fireheart has left the battlefield.)"; + private static final String rule = "For as long as that land has a blaze counter " + + "on it, it has \"At the beginning of your upkeep, this land deals 1 damage " + + "to you.\" (The land continues to burn after Obsidian Fireheart has left the battlefield.)"; private static final FilterLandPermanent filter = new FilterLandPermanent("land without a blaze counter on it"); static { @@ -41,10 +44,9 @@ public final class ObsidianFireheart extends CardImpl { } public ObsidianFireheart(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{R}{R}{R}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{R}{R}{R}"); this.subtype.add(SubType.ELEMENTAL); - this.power = new MageInt(4); this.toughness = new MageInt(4); @@ -52,14 +54,12 @@ public final class ObsidianFireheart extends CardImpl { // For as long as that land has a blaze counter on it, it has "At the beginning // of your upkeep, this land deals 1 damage to you." (The land continues to burn // after Obsidian Fireheart has left the battlefield.) - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new AddCountersTargetEffect(CounterType.BLAZE.createInstance()),new ManaCostsImpl("{1}{R}{R}")); + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, + new AddCountersTargetEffect(CounterType.BLAZE.createInstance()), + new ManaCostsImpl("{1}{R}{R}")); ability.addTarget(new TargetLandPermanent(filter)); - Effect effect = new ObsidianFireheartGainAbilityEffect( - new BeginningOfUpkeepTriggeredAbility( - new DamageControllerEffect(1), - TargetController.YOU, - false), - Duration.Custom, rule); + OneShotEffect effect = new ObsidianFireheartOneShotEffect(); + effect.setText(rule); ability.addEffect(effect); this.addAbility(ability); @@ -75,6 +75,53 @@ public final class ObsidianFireheart extends CardImpl { } } +class ObsidianFireheartOneShotEffect extends OneShotEffect { + + public ObsidianFireheartOneShotEffect() { + super(Outcome.Detriment); + } + + public ObsidianFireheartOneShotEffect(final ObsidianFireheartOneShotEffect effect) { + super(effect); + } + + @Override + public ObsidianFireheartOneShotEffect copy() { + return new ObsidianFireheartOneShotEffect(this); + } + + @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; + } +} class ObsidianFireheartGainAbilityEffect extends GainAbilityTargetEffect { @@ -88,8 +135,9 @@ class ObsidianFireheartGainAbilityEffect extends GainAbilityTargetEffect { @Override public boolean isInactive(Ability source, Game game) { - Permanent land = game.getPermanent(this.targetPointer.getFirst(game, source)); - if (land != null && land.getCounters(game).getCount(CounterType.BLAZE) < 1) { + Permanent targetLand = game.getPermanent(this.targetPointer.getFirst(game, source)); + if (targetLand != null + && targetLand.getCounters(game).getCount(CounterType.BLAZE) < 1) { return true; } return false;