diff --git a/Mage/src/mage/abilities/common/AttacksCreatureYourControlTriggeredAbility.java b/Mage/src/mage/abilities/common/AttacksCreatureYourControlTriggeredAbility.java index 8985cc5d3d..7350010ed2 100644 --- a/Mage/src/mage/abilities/common/AttacksCreatureYourControlTriggeredAbility.java +++ b/Mage/src/mage/abilities/common/AttacksCreatureYourControlTriggeredAbility.java @@ -31,6 +31,7 @@ package mage.abilities.common; import mage.Constants.Zone; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.effects.Effect; +import mage.filter.common.FilterControlledCreaturePermanent; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; @@ -41,23 +42,31 @@ import mage.game.permanent.Permanent; */ public class AttacksCreatureYourControlTriggeredAbility extends TriggeredAbilityImpl { + protected FilterControlledCreaturePermanent filter; + public AttacksCreatureYourControlTriggeredAbility(Effect effect) { this(effect, false); } public AttacksCreatureYourControlTriggeredAbility(Effect effect, boolean optional) { + this(effect, optional, new FilterControlledCreaturePermanent()); + } + + public AttacksCreatureYourControlTriggeredAbility(Effect effect, boolean optional, FilterControlledCreaturePermanent filter) { super(Zone.BATTLEFIELD, effect, optional); + this.filter = filter; } public AttacksCreatureYourControlTriggeredAbility(AttacksCreatureYourControlTriggeredAbility ability) { super(ability); + this.filter = ability.filter; } @Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED) { - Permanent source = game.getPermanent(event.getSourceId()); - if (source != null && source.getControllerId().equals(controllerId)) { + Permanent sourcePermanent = game.getPermanent(event.getSourceId()); + if (sourcePermanent != null && filter.match(sourcePermanent, sourceId, controllerId, game)) { return true; } } @@ -71,7 +80,7 @@ public class AttacksCreatureYourControlTriggeredAbility extends TriggeredAbility @Override public String getRule() { - return "Whenever a creature you control attacks, " + super.getRule(); + return "Whenever a " + filter.getMessage() + " attacks, " + super.getRule(); } } diff --git a/Mage/src/mage/abilities/dynamicvalue/common/DiscardCostCardConvertedMana.java b/Mage/src/mage/abilities/dynamicvalue/common/DiscardCostCardConvertedMana.java new file mode 100644 index 0000000000..ed27688605 --- /dev/null +++ b/Mage/src/mage/abilities/dynamicvalue/common/DiscardCostCardConvertedMana.java @@ -0,0 +1,45 @@ +package mage.abilities.dynamicvalue.common; + +import mage.abilities.Ability; +import mage.abilities.costs.Cost; +import mage.abilities.costs.common.DiscardCardCost; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.cards.Card; +import mage.game.Game; + +/** + * @author LevelX2 + */ +public class DiscardCostCardConvertedMana implements DynamicValue { + + @Override + public int calculate(Game game, Ability sourceAbility) { + for (Cost cost: sourceAbility.getCosts()) { + if (cost instanceof DiscardCardCost) { + DiscardCardCost discardCost = (DiscardCardCost) cost; + int cmc = 0; + for (Card card :discardCost.getCards()) { + cmc += card.getManaCost().convertedManaCost(); + } + return cmc; + } + } + return 0; + } + + @Override + public DynamicValue clone() { + return new DiscardCostCardConvertedMana(); + } + + @Override + public String toString() { + return ""; + } + + + @Override + public String getMessage() { + return "the discarded card's converted mana cost"; + } +} diff --git a/Mage/src/mage/abilities/dynamicvalue/common/SacrificeCostCreaturesToughness.java b/Mage/src/mage/abilities/dynamicvalue/common/SacrificeCostCreaturesToughness.java index 411038be33..efc8c0aad1 100644 --- a/Mage/src/mage/abilities/dynamicvalue/common/SacrificeCostCreaturesToughness.java +++ b/Mage/src/mage/abilities/dynamicvalue/common/SacrificeCostCreaturesToughness.java @@ -11,6 +11,7 @@ import mage.game.permanent.Permanent; * @author LevelX2 */ public class SacrificeCostCreaturesToughness implements DynamicValue { + @Override public int calculate(Game game, Ability sourceAbility) { for (Cost cost: sourceAbility.getCosts()) { @@ -33,7 +34,7 @@ public class SacrificeCostCreaturesToughness implements DynamicValue { @Override public String toString() { - return "X"; + return ""; } diff --git a/Mage/src/mage/abilities/effects/common/DamageTargetEffect.java b/Mage/src/mage/abilities/effects/common/DamageTargetEffect.java index 05b7841b76..9cf254e495 100644 --- a/Mage/src/mage/abilities/effects/common/DamageTargetEffect.java +++ b/Mage/src/mage/abilities/effects/common/DamageTargetEffect.java @@ -124,12 +124,22 @@ public class DamageTargetEffect extends OneShotEffect { sb.append(amount); } sb.append(" damage to "); - if (targetDescription.length() > 0) + if (targetDescription.length() > 0) { sb.append(targetDescription); - else + } + else { sb.append("target ").append(mode.getTargets().get(0).getTargetName()); + } if (message.length() > 0) { - sb.append(message.equals("1") ? " equal to the number of " : " for each "); + if (message.equals("1")) { + sb.append(" equal to the number of "); + } else { + if (message.startsWith("the")) { + sb.append(" equal to "); + } else { + sb.append(" for each "); + } + } sb.append(message); } if (!preventable) {