diff --git a/Mage/src/main/java/mage/abilities/common/DealsDamageToACreatureAllTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/DealsDamageToACreatureAllTriggeredAbility.java
index 713625ba41..e45cc5850c 100644
--- a/Mage/src/main/java/mage/abilities/common/DealsDamageToACreatureAllTriggeredAbility.java
+++ b/Mage/src/main/java/mage/abilities/common/DealsDamageToACreatureAllTriggeredAbility.java
@@ -16,7 +16,7 @@ import mage.target.targetpointer.FixedTarget;
*/
public class DealsDamageToACreatureAllTriggeredAbility extends TriggeredAbilityImpl {
- private final boolean combatDamageOnly;
+ private final boolean combatOnly;
private final FilterPermanent filterPermanent;
private final SetTargetPointer setTargetPointer;
@@ -32,19 +32,19 @@ public class DealsDamageToACreatureAllTriggeredAbility extends TriggeredAbilityI
* - PLAYER = player controlling the damage source.
* - PERMANENT = source permanent.
* - PERMANENT_TARGET = damaged creature.
- * @param combatDamageOnly The flag to determine if only combat damage has
+ * @param combatOnly The flag to determine if only combat damage has
* to trigger
*/
- public DealsDamageToACreatureAllTriggeredAbility(Effect effect, boolean optional, FilterPermanent filterPermanent, SetTargetPointer setTargetPointer, boolean combatDamageOnly) {
+ public DealsDamageToACreatureAllTriggeredAbility(Effect effect, boolean optional, FilterPermanent filterPermanent, SetTargetPointer setTargetPointer, boolean combatOnly) {
super(Zone.BATTLEFIELD, effect, optional);
- this.combatDamageOnly = combatDamageOnly;
+ this.combatOnly = combatOnly;
this.setTargetPointer = setTargetPointer;
this.filterPermanent = filterPermanent;
}
public DealsDamageToACreatureAllTriggeredAbility(final DealsDamageToACreatureAllTriggeredAbility ability) {
super(ability);
- this.combatDamageOnly = ability.combatDamageOnly;
+ this.combatOnly = ability.combatOnly;
this.filterPermanent = ability.filterPermanent;
this.setTargetPointer = ability.setTargetPointer;
}
@@ -65,7 +65,7 @@ public class DealsDamageToACreatureAllTriggeredAbility extends TriggeredAbilityI
if (permanent == null || !permanent.isCreature(game)) {
return false;
}
- if (combatDamageOnly && !((DamagedEvent) event).isCombatDamage()) {
+ if (combatOnly && !((DamagedEvent) event).isCombatDamage()) {
return false;
}
permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
@@ -94,6 +94,6 @@ public class DealsDamageToACreatureAllTriggeredAbility extends TriggeredAbilityI
@Override
public String getTriggerPhrase() {
return "Whenever " + filterPermanent.getMessage() + " deals "
- + (combatDamageOnly ? "combat " : "") + "damage to a creature, ";
+ + (combatOnly ? "combat " : "") + "damage to a creature, ";
}
}
diff --git a/Mage/src/main/java/mage/abilities/common/DealsDamageToACreatureAttachedTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/DealsDamageToACreatureAttachedTriggeredAbility.java
index 60e86de639..dbab9650e6 100644
--- a/Mage/src/main/java/mage/abilities/common/DealsDamageToACreatureAttachedTriggeredAbility.java
+++ b/Mage/src/main/java/mage/abilities/common/DealsDamageToACreatureAttachedTriggeredAbility.java
@@ -22,14 +22,15 @@ public class DealsDamageToACreatureAttachedTriggeredAbility extends TriggeredAbi
public DealsDamageToACreatureAttachedTriggeredAbility(Effect effect, boolean combatOnly, String attachedDescription, boolean optional, boolean setTargetPointer) {
super(Zone.BATTLEFIELD, effect, optional);
+ this.combatOnly = combatOnly;
this.setTargetPointer = setTargetPointer;
this.attachedDescription = attachedDescription;
}
public DealsDamageToACreatureAttachedTriggeredAbility(final DealsDamageToACreatureAttachedTriggeredAbility ability) {
super(ability);
- this.setTargetPointer = ability.setTargetPointer;
this.combatOnly = ability.combatOnly;
+ this.setTargetPointer = ability.setTargetPointer;
this.attachedDescription = ability.attachedDescription;
}
@@ -45,29 +46,29 @@ public class DealsDamageToACreatureAttachedTriggeredAbility extends TriggeredAbi
@Override
public boolean checkTrigger(GameEvent event, Game game) {
- if (!combatOnly || ((DamagedEvent) event).isCombatDamage()) {
- Permanent attachment = game.getPermanent(this.getSourceId());
- if (attachment != null
- && attachment.isAttachedTo(event.getSourceId())) {
- if (setTargetPointer) {
- for (Effect effect : this.getEffects()) {
- effect.setTargetPointer(new FixedTarget(event.getTargetId(), game));
- effect.setValue("damage", event.getAmount());
- }
- }
- return true;
- }
-
+ Permanent permanent = game.getPermanent(event.getTargetId());
+ if (permanent == null || !permanent.isCreature(game)) {
+ return false;
}
- return false;
+ if (combatOnly && !((DamagedEvent) event).isCombatDamage()) {
+ return false;
+ }
+ Permanent attachment = game.getPermanent(this.getSourceId());
+ if (attachment == null || !attachment.isAttachedTo(event.getSourceId())) {
+ return false;
+ }
+ if (setTargetPointer) {
+ for (Effect effect : this.getEffects()) {
+ effect.setTargetPointer(new FixedTarget(event.getTargetId(), game));
+ effect.setValue("damage", event.getAmount());
+ }
+ }
+ return true;
}
@Override
public String getTriggerPhrase() {
- return new StringBuilder("Whenever ").append(attachedDescription)
- .append(" deals ")
- .append(combatOnly ? "combat " : "")
- .append("damage to a creature, ").toString();
+ return "Whenever " + attachedDescription + " deals "
+ + (combatOnly ? "combat " : "") + "damage to a creature, ";
}
-
}
diff --git a/Mage/src/main/java/mage/abilities/common/DealsDamageToACreatureTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/DealsDamageToACreatureTriggeredAbility.java
index b59a77ee88..4d7009a497 100644
--- a/Mage/src/main/java/mage/abilities/common/DealsDamageToACreatureTriggeredAbility.java
+++ b/Mage/src/main/java/mage/abilities/common/DealsDamageToACreatureTriggeredAbility.java
@@ -4,6 +4,7 @@ package mage.abilities.common;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.constants.Zone;
+import mage.filter.StaticFilters;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.events.DamagedEvent;
@@ -16,12 +17,12 @@ import mage.target.targetpointer.FixedTarget;
*/
public class DealsDamageToACreatureTriggeredAbility extends TriggeredAbilityImpl {
- private boolean combatOnly;
+ protected boolean combatOnly;
private final boolean setTargetPointer;
private FilterCreaturePermanent filter;
public DealsDamageToACreatureTriggeredAbility(Effect effect, boolean combatOnly, boolean optional, boolean setTargetPointer) {
- this(effect, combatOnly, optional, setTargetPointer, null);
+ this(effect, combatOnly, optional, setTargetPointer, StaticFilters.FILTER_PERMANENT_A_CREATURE);
}
public DealsDamageToACreatureTriggeredAbility(Effect effect, boolean combatOnly, boolean optional, boolean setTargetPointer, FilterCreaturePermanent filter) {
@@ -52,12 +53,12 @@ public class DealsDamageToACreatureTriggeredAbility extends TriggeredAbilityImpl
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getSourceId().equals(this.sourceId)
&& (!combatOnly || ((DamagedEvent) event).isCombatDamage())) {
- if (filter != null) {
- Permanent creature = game.getPermanentOrLKIBattlefield(event.getTargetId());
- if (!filter.match(creature, getControllerId(), this, game)) {
- return false;
- }
+
+ Permanent creature = game.getPermanentOrLKIBattlefield(event.getTargetId());
+ if (!filter.match(creature, getControllerId(), this, game)) {
+ return false;
}
+
if (setTargetPointer) {
this.getEffects().setTargetPointer(new FixedTarget(event.getTargetId(), game));
this.getEffects().setValue("damage", event.getAmount());
@@ -69,18 +70,6 @@ public class DealsDamageToACreatureTriggeredAbility extends TriggeredAbilityImpl
@Override
public String getTriggerPhrase() {
- StringBuilder sb = new StringBuilder("Whenever {this} deals ");
- if (combatOnly) {
- sb.append("combat ");
- }
- sb.append("damage to ");
- if (filter == null) {
- sb.append("a creature, ");
- } else {
- sb.append(filter.getMessage());
- sb.append(", ");
- }
- return sb.toString();
+ return "Whenever {this} deals " + (combatOnly ? "combat " : "") + "damage to " + filter.getMessage() + ", ";
}
-
}
diff --git a/Mage/src/main/java/mage/abilities/common/DealsDamageToOneOrMoreCreaturesTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/DealsDamageToOneOrMoreCreaturesTriggeredAbility.java
index ee98442827..c5ce962ac5 100644
--- a/Mage/src/main/java/mage/abilities/common/DealsDamageToOneOrMoreCreaturesTriggeredAbility.java
+++ b/Mage/src/main/java/mage/abilities/common/DealsDamageToOneOrMoreCreaturesTriggeredAbility.java
@@ -46,4 +46,8 @@ public class DealsDamageToOneOrMoreCreaturesTriggeredAbility extends DealsDamage
return new DealsDamageToOneOrMoreCreaturesTriggeredAbility(this);
}
+ @Override
+ public String getTriggerPhrase() {
+ return "Whenever {this} deals " + (combatOnly ? "combat " : "") + "damage to one or more creatures, ";
+ }
}