fixed Sun Droplet only triggering if it had counters on it

This commit is contained in:
Evan Kranzler 2019-01-16 11:26:38 -05:00
parent 32ecb5ceab
commit 264433aff7

View file

@ -1,22 +1,15 @@
package mage.cards.s; package mage.cards.s;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.condition.common.SourceHasCounterCondition;
import mage.abilities.costs.common.RemoveCountersSourceCost; 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.DoIfCostPaid;
import mage.abilities.effects.common.GainLifeEffect; import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.TargetController; import mage.constants.TargetController;
import mage.constants.Zone; import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
@ -24,26 +17,28 @@ import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType; import mage.game.events.GameEvent.EventType;
import java.util.UUID;
/** /**
*
* @author LevelX2 * @author LevelX2
*/ */
public final class SunDroplet extends CardImpl { public final class SunDroplet extends CardImpl {
public SunDroplet(UUID ownerId, CardSetInfo setInfo) { 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. // Whenever you're dealt damage, put that many charge counters on Sun Droplet.
this.addAbility(new SunDropletTriggeredAbility()); 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. // 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. this.addAbility(new BeginningOfUpkeepTriggeredAbility(
Effect effect = new DoIfCostPaid(new GainLifeEffect(1), new RemoveCountersSourceCost(CounterType.CHARGE.createInstance(1))); new DoIfCostPaid(
this.addAbility(new ConditionalInterveningIfTriggeredAbility(new BeginningOfUpkeepTriggeredAbility(effect, TargetController.ANY, false), new GainLifeEffect(1), new RemoveCountersSourceCost(CounterType.CHARGE.createInstance())
new SourceHasCounterCondition(CounterType.CHARGE, 1), ), TargetController.ANY, false
"At the beginning of each upkeep, you may remove a charge counter from Sun Droplet. If you do, you gain 1 life")); ));
} }
public SunDroplet(final SunDroplet card) { private SunDroplet(final SunDroplet card) {
super(card); super(card);
} }
@ -55,11 +50,11 @@ public final class SunDroplet extends CardImpl {
class SunDropletTriggeredAbility extends TriggeredAbilityImpl { class SunDropletTriggeredAbility extends TriggeredAbilityImpl {
public SunDropletTriggeredAbility() { SunDropletTriggeredAbility() {
super(Zone.BATTLEFIELD, new SunDropletEffect(), false); super(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.CHARGE.createInstance()), false);
} }
public SunDropletTriggeredAbility(final SunDropletTriggeredAbility ability) { private SunDropletTriggeredAbility(final SunDropletTriggeredAbility ability) {
super(ability); super(ability);
} }
@ -76,7 +71,8 @@ class SunDropletTriggeredAbility extends TriggeredAbilityImpl {
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
if (event.getTargetId().equals(this.getControllerId())) { 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 true;
} }
return false; return false;
@ -87,24 +83,3 @@ class SunDropletTriggeredAbility extends TriggeredAbilityImpl {
return "Whenever you're dealt damage, put that many charge counters on {this}."; 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);
}
}