From acb87e81e18bd7b65b3c4fbfe6a8c4cc66368835 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Wed, 19 Sep 2012 21:15:11 +0200 Subject: [PATCH] Added constructor with optional parameter. --- .../common/DiesAttachedTriggeredAbility.java | 107 +++++++++--------- 1 file changed, 56 insertions(+), 51 deletions(-) diff --git a/Mage/src/mage/abilities/common/DiesAttachedTriggeredAbility.java b/Mage/src/mage/abilities/common/DiesAttachedTriggeredAbility.java index 446c48a03a..dc0ff8882c 100644 --- a/Mage/src/mage/abilities/common/DiesAttachedTriggeredAbility.java +++ b/Mage/src/mage/abilities/common/DiesAttachedTriggeredAbility.java @@ -1,51 +1,56 @@ -package mage.abilities.common; - -import mage.Constants; -import mage.abilities.TriggeredAbilityImpl; -import mage.abilities.effects.Effect; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.events.ZoneChangeEvent; -import mage.game.permanent.Permanent; - -/** - * "When enchanted/equipped creature dies" triggered ability - * @author Loki - */ -public class DiesAttachedTriggeredAbility extends TriggeredAbilityImpl { - private String attachedDescription; - - public DiesAttachedTriggeredAbility(Effect effect, String attachedDescription) { - super(Constants.Zone.BATTLEFIELD, effect); - this.attachedDescription = attachedDescription; - } - - public DiesAttachedTriggeredAbility(final DiesAttachedTriggeredAbility ability) { - super(ability); - this.attachedDescription = ability.attachedDescription; - } - - @Override - public DiesAttachedTriggeredAbility copy() { - return new DiesAttachedTriggeredAbility(this); - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).isDiesEvent()) { - Permanent p = (Permanent) game.getLastKnownInformation(event.getTargetId(), Constants.Zone.BATTLEFIELD); - if (p.getAttachments().contains(this.getSourceId())) { - for (Effect effect : getEffects()) { - effect.setValue("attachedTo", p); - } - return true; - } - } - return false; - } - - @Override - public String getRule() { - return "When " + attachedDescription + " dies, " + super.getRule(); - } -} +package mage.abilities.common; + +import mage.Constants; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.Effect; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.ZoneChangeEvent; +import mage.game.permanent.Permanent; + +/** + * "When enchanted/equipped creature dies" triggered ability + * @author Loki + */ +public class DiesAttachedTriggeredAbility extends TriggeredAbilityImpl { + private String attachedDescription; + + public DiesAttachedTriggeredAbility(Effect effect, String attachedDescription) { + this(effect, attachedDescription, false); + } + + public DiesAttachedTriggeredAbility(Effect effect, String attachedDescription, boolean optional) { + super(Constants.Zone.BATTLEFIELD, effect, optional); + this.attachedDescription = attachedDescription; + } + + + public DiesAttachedTriggeredAbility(final DiesAttachedTriggeredAbility ability) { + super(ability); + this.attachedDescription = ability.attachedDescription; + } + + @Override + public DiesAttachedTriggeredAbility copy() { + return new DiesAttachedTriggeredAbility(this); + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).isDiesEvent()) { + Permanent p = (Permanent) game.getLastKnownInformation(event.getTargetId(), Constants.Zone.BATTLEFIELD); + if (p.getAttachments().contains(this.getSourceId())) { + for (Effect effect : getEffects()) { + effect.setValue("attachedTo", p); + } + return true; + } + } + return false; + } + + @Override + public String getRule() { + return "When " + attachedDescription + " dies, " + super.getRule(); + } +}