* Mortal Obstinacy - Mortal Obstinacy was not sacrificed as the triggered effect was used. Decision to sacrifice Mortal Obstinacy takes place now during resolution instead of while ability goes to stack.

This commit is contained in:
LevelX2 2014-04-26 10:39:45 +02:00
parent a1cfd040d7
commit 63a083ef0d
3 changed files with 10 additions and 18 deletions

View file

@ -31,8 +31,10 @@ import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.abilities.effects.common.DoIfCostPaid;
import mage.abilities.effects.common.continious.BoostEnchantedEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
@ -45,7 +47,6 @@ import mage.game.Game;
import mage.game.events.DamagedPlayerEvent;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPermanent;
import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.common.TargetEnchantmentPermanent;
@ -90,7 +91,8 @@ public class MortalObstinacy extends CardImpl<MortalObstinacy> {
class MortalObstinacyAbility extends TriggeredAbilityImpl<MortalObstinacyAbility> {
public MortalObstinacyAbility() {
super(Zone.BATTLEFIELD, new DestroyTargetEffect());
super(Zone.BATTLEFIELD, new DoIfCostPaid(new DestroyTargetEffect(), new SacrificeSourceCost()));
addTarget(new TargetEnchantmentPermanent(true));
}
public MortalObstinacyAbility(final MortalObstinacyAbility ability) {
@ -108,18 +110,7 @@ class MortalObstinacyAbility extends TriggeredAbilityImpl<MortalObstinacyAbility
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent)event;
Permanent damageMakingCreature = game.getPermanent(event.getSourceId());
if (damageEvent.isCombatDamage() && damageMakingCreature != null && damageMakingCreature.getAttachments().contains(this.getSourceId())) {
Player controller = game.getPlayer(this.getControllerId());
Permanent sourceEnchantment = game.getPermanent(this.getSourceId());
if (controller != null && sourceEnchantment != null) {
StringBuilder sb = new StringBuilder();
sb.append("Do you wish to sacrifice ").append(sourceEnchantment.getName());
sb.append(" to destroy target enchantment?");
if (controller.chooseUse(Outcome.DestroyPermanent, sb.toString(), game)) {
this.getTargets().clear();
this.addTarget(new TargetEnchantmentPermanent(true));
return true;
}
}
return true;
}
}
return false;
@ -127,6 +118,7 @@ class MortalObstinacyAbility extends TriggeredAbilityImpl<MortalObstinacyAbility
@Override
public String getRule() {
return "Whenever enchanted creature deals combat damage to a player, you may sacrifice {this}. If you do, destroy target enchantment.";
return new StringBuilder("Whenever enchanted creature deals combat damage to a player, ").append(super.getRule()).toString();
}
}

View file

@ -45,7 +45,7 @@ public class DoIfCostPaid extends OneShotEffect<DoIfCostPaid> {
message = chooseUseText;
}
message = CardUtil.replaceSourceName(message, mageObject.getName());
if (player.chooseUse(executingEffect.getOutcome(), message, game)) {
if (cost.canPay(source.getSourceId(), player.getId(), game) && player.chooseUse(executingEffect.getOutcome(), message, game)) {
cost.clearPaid();
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {
executingEffect.setTargetPointer(this.targetPointer);

View file

@ -24,7 +24,7 @@ You will need to have the [Java Runtime Environment](http://java.com/en/) Versio
Here you can find a log of the latest changes: [Release changes] (http://github.com/magefree/mage/wiki/Release-changes)
(looke here for more in detail description what to do: http://www.slightlymagic.net/forum/viewtopic.php?f=70&t=13632)
(look here for more in detail description what to do: http://www.slightlymagic.net/forum/viewtopic.php?f=70&t=13632)
## Developer