From ad186480a3a44ab1d848b087adc8afccef3e549f Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sat, 13 Jun 2015 00:18:32 +0200 Subject: [PATCH] * Quenchable Fire - Fixed that the delayed triggered effect could not be removed by the special action. --- .../src/mage/sets/conflux/QuenchableFire.java | 52 ++++++++++++------- Mage/src/mage/game/Game.java | 2 +- Mage/src/mage/game/GameImpl.java | 3 +- 3 files changed, 35 insertions(+), 22 deletions(-) diff --git a/Mage.Sets/src/mage/sets/conflux/QuenchableFire.java b/Mage.Sets/src/mage/sets/conflux/QuenchableFire.java index 9b7f9cdaf3..7338637ae0 100644 --- a/Mage.Sets/src/mage/sets/conflux/QuenchableFire.java +++ b/Mage.Sets/src/mage/sets/conflux/QuenchableFire.java @@ -29,6 +29,7 @@ package mage.sets.conflux; import java.util.UUID; +import mage.MageObject; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Rarity; @@ -36,6 +37,7 @@ import mage.abilities.Ability; import mage.abilities.DelayedTriggeredAbility; import mage.abilities.SpecialAction; import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.RemoveDelayedTriggeredAbilityEffect; @@ -78,7 +80,8 @@ class QuenchableFireEffect extends OneShotEffect { public QuenchableFireEffect() { super(Outcome.Damage); - staticText = "{this} deals an additional 3 damage to that player at the beginning of your next upkeep step unless he or she pays {U} before that step"; + staticText = "{this} deals an additional 3 damage to that player at the beginning of your next upkeep step unless he or she pays {U} before that step." + + "
Use the Special button to pay the {U} with a special action before the beginning of your next upkeep step."; } public QuenchableFireEffect(final QuenchableFireEffect effect) { @@ -92,22 +95,34 @@ class QuenchableFireEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - //create delayed triggered ability - QuenchableFireDelayedTriggeredAbility delayedAbility = new QuenchableFireDelayedTriggeredAbility(); - delayedAbility.setSourceId(source.getSourceId()); - delayedAbility.setControllerId(source.getControllerId()); - delayedAbility.setSourceObject(source.getSourceObject(game), game); - delayedAbility.getTargets().addAll(source.getTargets()); - game.addDelayedTriggeredAbility(delayedAbility); + MageObject sourceObject = source.getSourceObject(game); + if (sourceObject != null) { + + //create special action + QuenchableFireSpecialAction newAction = new QuenchableFireSpecialAction(); - //create special action - QuenchableFireSpecialAction newAction = new QuenchableFireSpecialAction(delayedAbility.getId()); - delayedAbility.setSpecialActionId(newAction.getId()); - newAction.setSourceId(source.getSourceId()); - newAction.setControllerId(source.getFirstTarget()); - newAction.getTargets().addAll(source.getTargets()); - game.getState().getSpecialActions().add(newAction); - return true; + //create delayed triggered ability + QuenchableFireDelayedTriggeredAbility delayedAbility = new QuenchableFireDelayedTriggeredAbility(); + delayedAbility.setSourceId(source.getSourceId()); + delayedAbility.setControllerId(source.getControllerId()); + delayedAbility.setSourceObject(sourceObject, game); + delayedAbility.getTargets().addAll(source.getTargets()); + delayedAbility.setSpecialActionId(newAction.getId()); + UUID delayedAbilityId = game.addDelayedTriggeredAbility(delayedAbility); + + // update special action + newAction.addCost(new ManaCostsImpl("{U}")); + Effect effect = new RemoveDelayedTriggeredAbilityEffect(delayedAbilityId); + newAction.addEffect(effect); + effect.setText(sourceObject.getIdName() + " - Pay {U} to remove the triggered ability that deals 3 damage to you at the beginning of your next upkeep step"); + newAction.addEffect(new RemoveSpecialActionEffect(newAction.getId())); + newAction.setSourceId(source.getSourceId()); + newAction.setControllerId(source.getFirstTarget()); + newAction.getTargets().addAll(source.getTargets()); + game.getState().getSpecialActions().add(newAction); + return true; + } + return false; } } @@ -151,11 +166,8 @@ class QuenchableFireDelayedTriggeredAbility extends DelayedTriggeredAbility { class QuenchableFireSpecialAction extends SpecialAction { - public QuenchableFireSpecialAction(UUID effectId) { + public QuenchableFireSpecialAction() { super(); - this.addCost(new ManaCostsImpl("{U}")); - this.addEffect(new RemoveDelayedTriggeredAbilityEffect(effectId)); - this.addEffect(new RemoveSpecialActionEffect(this.getId())); } public QuenchableFireSpecialAction(final QuenchableFireSpecialAction ability) { diff --git a/Mage/src/mage/game/Game.java b/Mage/src/mage/game/Game.java index 3743aae59c..40c78f0512 100644 --- a/Mage/src/mage/game/Game.java +++ b/Mage/src/mage/game/Game.java @@ -253,7 +253,7 @@ public interface Game extends MageItem, Serializable { Card copyCard(Card cardToCopy, Ability source, UUID newController); void addTriggeredAbility(TriggeredAbility ability); - void addDelayedTriggeredAbility(DelayedTriggeredAbility delayedAbility); + UUID addDelayedTriggeredAbility(DelayedTriggeredAbility delayedAbility); void applyEffects(); boolean checkStateAndTriggered(); void playPriority(UUID activePlayerId, boolean resuming); diff --git a/Mage/src/mage/game/GameImpl.java b/Mage/src/mage/game/GameImpl.java index 23561b3425..505bfa8c0f 100644 --- a/Mage/src/mage/game/GameImpl.java +++ b/Mage/src/mage/game/GameImpl.java @@ -1383,11 +1383,12 @@ public abstract class GameImpl implements Game, Serializable { } @Override - public void addDelayedTriggeredAbility(DelayedTriggeredAbility delayedAbility) { + public UUID addDelayedTriggeredAbility(DelayedTriggeredAbility delayedAbility) { DelayedTriggeredAbility newAbility = delayedAbility.copy(); newAbility.newId(); newAbility.init(this); state.addDelayedTriggeredAbility(newAbility); + return newAbility.getId(); } /**