diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/MyojinOfCleansingFire.java b/Mage.Sets/src/mage/sets/championsofkamigawa/MyojinOfCleansingFire.java index d988000541d..fc6dfbcaaa7 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/MyojinOfCleansingFire.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/MyojinOfCleansingFire.java @@ -37,12 +37,15 @@ import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldAbility; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.condition.common.CastFromHandCondition; import mage.abilities.condition.common.HasCounterCondition; import mage.abilities.costs.common.RemoveCountersSourceCost; import mage.abilities.decorator.ConditionalContinousEffect; +import mage.abilities.decorator.ConditionalOneShotEffect; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.DestroyAllEffect; import mage.abilities.effects.common.continious.GainAbilitySourceEffect; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.keyword.IndestructibleAbility; import mage.cards.Card; import mage.cards.CardImpl; @@ -54,7 +57,6 @@ import mage.watchers.Watcher; import mage.watchers.common.CastFromHandWatcher; /** - * * @author Loki */ public class MyojinOfCleansingFire extends CardImpl { @@ -77,7 +79,7 @@ public class MyojinOfCleansingFire extends CardImpl { this.addWatcher(new CastFromHandWatcher()); // Myojin of Cleansing Fire enters the battlefield with a divinity counter on it if you cast it from your hand. - this.addAbility(new EntersBattlefieldAbility(new MyojinOfCleansingFireEntersBattlefieldEffect(), "{this} enters the battlefield with a divinity counter on it if you cast it from your hand")); + this.addAbility(new EntersBattlefieldAbility(new ConditionalOneShotEffect(new AddCountersSourceEffect(CounterType.DIVINITY.createInstance()), new CastFromHandCondition(), ""), "{this} enters the battlefield with a divinity counter on it if you cast it from your hand")); // Myojin of Cleansing Fire is indestructible as long as it has a divinity counter on it. this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new ConditionalContinousEffect(new GainAbilitySourceEffect(IndestructibleAbility.getInstance(), Constants.Duration.WhileOnBattlefield), new HasCounterCondition(CounterType.DIVINITY), "{this} is indestructible as long as it has a divinity counter on it"))); @@ -94,33 +96,3 @@ public class MyojinOfCleansingFire extends CardImpl { return new MyojinOfCleansingFire(this); } } - -class MyojinOfCleansingFireEntersBattlefieldEffect extends OneShotEffect { - MyojinOfCleansingFireEntersBattlefieldEffect() { - super(Constants.Outcome.Benefit); - } - - MyojinOfCleansingFireEntersBattlefieldEffect(final MyojinOfCleansingFireEntersBattlefieldEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Permanent p = game.getPermanent(source.getSourceId()); - if (p != null) { - Watcher watcher = game.getState().getWatchers().get("CastFromHand", source.getSourceId()); - if (watcher != null && watcher.conditionMet()) { - p.addCounters(CounterType.DIVINITY.createInstance(), game); - } - } - return true; - } - - @Override - public MyojinOfCleansingFireEntersBattlefieldEffect copy() { - return new MyojinOfCleansingFireEntersBattlefieldEffect(this); - } -} - - - diff --git a/Mage/src/mage/abilities/condition/common/CastFromHandCondition.java b/Mage/src/mage/abilities/condition/common/CastFromHandCondition.java new file mode 100644 index 00000000000..42345c1f5b3 --- /dev/null +++ b/Mage/src/mage/abilities/condition/common/CastFromHandCondition.java @@ -0,0 +1,26 @@ +package mage.abilities.condition.common; + +import mage.abilities.Ability; +import mage.abilities.condition.Condition; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.watchers.Watcher; + +/** + * Warning: CastFromHandWatcher must be installed to card for proper working. + * + * @author Loki + */ +public class CastFromHandCondition implements Condition { + @Override + public boolean apply(Game game, Ability source) { + Permanent p = game.getPermanent(source.getSourceId()); + if (p != null) { + Watcher watcher = game.getState().getWatchers().get("CastFromHand", source.getSourceId()); + if (watcher != null && watcher.conditionMet()) { + return true; + } + } + return false; + } +}