From 7db40252d1d277acc126cae1e07909a8738ce5bf Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sun, 3 Nov 2013 20:56:57 +0100 Subject: [PATCH] * Chronicler of Heroes - Fixed a bug that wrongly was not only checked at resolving time, if a creature with a +1/+1 counter did exist. --- .../mage/sets/theros/ChroniclerOfHeroes.java | 53 ++++++++++++++----- 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/Mage.Sets/src/mage/sets/theros/ChroniclerOfHeroes.java b/Mage.Sets/src/mage/sets/theros/ChroniclerOfHeroes.java index ffcc086ebda..a8d42a7e9b4 100644 --- a/Mage.Sets/src/mage/sets/theros/ChroniclerOfHeroes.java +++ b/Mage.Sets/src/mage/sets/theros/ChroniclerOfHeroes.java @@ -29,18 +29,21 @@ package mage.sets.theros; import java.util.UUID; import mage.MageInt; +import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.condition.common.ControlsPermanentCondition; -import mage.abilities.decorator.ConditionalOneShotEffect; -import mage.abilities.effects.common.DrawCardControllerEffect; +import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; import mage.constants.CardType; +import mage.constants.Outcome; import mage.constants.Rarity; import mage.constants.TargetController; import mage.counters.CounterType; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.permanent.ControllerPredicate; import mage.filter.predicate.permanent.CounterPredicate; +import mage.game.Game; +import mage.players.Player; /** * @@ -48,12 +51,6 @@ import mage.filter.predicate.permanent.CounterPredicate; */ public class ChroniclerOfHeroes extends CardImpl { - private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("a creature with a +1/+1 counter on it"); - static { - filter.add(new ControllerPredicate(TargetController.YOU)); - filter.add(new CounterPredicate(CounterType.P1P1)); - } - public ChroniclerOfHeroes(UUID ownerId) { super(ownerId, 190, "Chronicler of Heroes", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{1}{G}{W}"); this.expansionSetCode = "THS"; @@ -66,10 +63,7 @@ public class ChroniclerOfHeroes extends CardImpl { this.toughness = new MageInt(3); // When Chronicler of Heroes enters the battlefield, draw a card if you control a creature with a +1/+1 counter on it. - this.addAbility(new EntersBattlefieldTriggeredAbility(new ConditionalOneShotEffect( - new DrawCardControllerEffect(1), - new ControlsPermanentCondition(filter, ControlsPermanentCondition.CountType.MORE_THAN, 0), - "draw a card if you control a creature with a +1/+1 counter on it"))); + this.addAbility(new EntersBattlefieldTriggeredAbility(new ChroniclerOfHeroesEffect())); } public ChroniclerOfHeroes(final ChroniclerOfHeroes card) { @@ -81,3 +75,38 @@ public class ChroniclerOfHeroes extends CardImpl { return new ChroniclerOfHeroes(this); } } + +class ChroniclerOfHeroesEffect extends OneShotEffect { + + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("a creature with a +1/+1 counter on it"); + static { + filter.add(new ControllerPredicate(TargetController.YOU)); + filter.add(new CounterPredicate(CounterType.P1P1)); + } + + public ChroniclerOfHeroesEffect() { + super(Outcome.DrawCard); + this.staticText = "draw a card if you control a creature with a +1/+1 counter on it"; + } + + public ChroniclerOfHeroesEffect(final ChroniclerOfHeroesEffect effect) { + super(effect); + } + + @Override + public ChroniclerOfHeroesEffect copy() { + return new ChroniclerOfHeroesEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + if (new ControlsPermanentCondition(filter, ControlsPermanentCondition.CountType.MORE_THAN, 0).apply(game, source)) { + controller.drawCards(1, game); + } + return true; + } + return false; + } +}