From 264433aff7be8a8e54243147781dba2a8063f31e Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Wed, 16 Jan 2019 11:26:38 -0500 Subject: [PATCH] fixed Sun Droplet only triggering if it had counters on it --- Mage.Sets/src/mage/cards/s/SunDroplet.java | 55 ++++++---------------- 1 file changed, 15 insertions(+), 40 deletions(-) diff --git a/Mage.Sets/src/mage/cards/s/SunDroplet.java b/Mage.Sets/src/mage/cards/s/SunDroplet.java index 6ff432b37d..08b3f4e79c 100644 --- a/Mage.Sets/src/mage/cards/s/SunDroplet.java +++ b/Mage.Sets/src/mage/cards/s/SunDroplet.java @@ -1,22 +1,15 @@ package mage.cards.s; -import java.util.UUID; -import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; -import mage.abilities.condition.common.SourceHasCounterCondition; import mage.abilities.costs.common.RemoveCountersSourceCost; -import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility; -import mage.abilities.effects.Effect; -import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.DoIfCostPaid; import mage.abilities.effects.common.GainLifeEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Outcome; import mage.constants.TargetController; import mage.constants.Zone; import mage.counters.CounterType; @@ -24,26 +17,28 @@ import mage.game.Game; import mage.game.events.GameEvent; import mage.game.events.GameEvent.EventType; +import java.util.UUID; + /** - * * @author LevelX2 */ public final class SunDroplet extends CardImpl { public SunDroplet(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{2}"); + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}"); // Whenever you're dealt damage, put that many charge counters on Sun Droplet. this.addAbility(new SunDropletTriggeredAbility()); + // At the beginning of each upkeep, you may remove a charge counter from Sun Droplet. If you do, you gain 1 life. - //TODO this shouldn't be conditional because you can respond to the trigger by adding counters. - Effect effect = new DoIfCostPaid(new GainLifeEffect(1), new RemoveCountersSourceCost(CounterType.CHARGE.createInstance(1))); - this.addAbility(new ConditionalInterveningIfTriggeredAbility(new BeginningOfUpkeepTriggeredAbility(effect, TargetController.ANY, false), - new SourceHasCounterCondition(CounterType.CHARGE, 1), - "At the beginning of each upkeep, you may remove a charge counter from Sun Droplet. If you do, you gain 1 life")); + this.addAbility(new BeginningOfUpkeepTriggeredAbility( + new DoIfCostPaid( + new GainLifeEffect(1), new RemoveCountersSourceCost(CounterType.CHARGE.createInstance()) + ), TargetController.ANY, false + )); } - public SunDroplet(final SunDroplet card) { + private SunDroplet(final SunDroplet card) { super(card); } @@ -55,11 +50,11 @@ public final class SunDroplet extends CardImpl { class SunDropletTriggeredAbility extends TriggeredAbilityImpl { - public SunDropletTriggeredAbility() { - super(Zone.BATTLEFIELD, new SunDropletEffect(), false); + SunDropletTriggeredAbility() { + super(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.CHARGE.createInstance()), false); } - public SunDropletTriggeredAbility(final SunDropletTriggeredAbility ability) { + private SunDropletTriggeredAbility(final SunDropletTriggeredAbility ability) { super(ability); } @@ -76,7 +71,8 @@ class SunDropletTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getTargetId().equals(this.getControllerId())) { - this.getEffects().get(0).setValue("damageAmount", event.getAmount()); + this.getEffects().clear(); + this.addEffect(new AddCountersSourceEffect(CounterType.CHARGE.createInstance(event.getAmount()))); return true; } return false; @@ -87,24 +83,3 @@ class SunDropletTriggeredAbility extends TriggeredAbilityImpl { return "Whenever you're dealt damage, put that many charge counters on {this}."; } } - -class SunDropletEffect extends OneShotEffect { - - public SunDropletEffect() { - super(Outcome.Benefit); - } - - public SunDropletEffect(final SunDropletEffect effect) { - super(effect); - } - - @Override - public SunDropletEffect copy() { - return new SunDropletEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - return new AddCountersSourceEffect(CounterType.CHARGE.createInstance((Integer) this.getValue("damageAmount"))).apply(game, source); - } -}