new common triggered ability, more correct Sylvok Lifestaff

This commit is contained in:
Loki 2011-07-23 22:15:28 +03:00
parent a61cddbca8
commit 5ac4a4f0a5
2 changed files with 54 additions and 3 deletions

View file

@ -33,6 +33,8 @@ import mage.Constants.CardType;
import mage.Constants.Outcome;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.abilities.Ability;
import mage.abilities.common.DiesAttachedTriggeredAbility;
import mage.abilities.common.DiesTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.GenericManaCost;
@ -44,7 +46,7 @@ import mage.cards.CardImpl;
/**
*
* @author North
* @author North, Loki
*/
public class SylvokLifestaff extends CardImpl<SylvokLifestaff> {
@ -54,8 +56,7 @@ public class SylvokLifestaff extends CardImpl<SylvokLifestaff> {
this.subtype.add("Equipment");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEquippedEffect(1, 0)));
DiesTriggeredAbility ability = new DiesTriggeredAbility(new GainLifeEffect(3));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(ability, AttachmentType.EQUIPMENT)));
this.addAbility(new DiesAttachedTriggeredAbility(new GainLifeEffect(3), "equipped creature"));
this.addAbility(new EquipAbility(Outcome.BoostCreature, new GenericManaCost(1)));
}

View file

@ -0,0 +1,50 @@
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<DiesAttachedTriggeredAbility> {
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 zEvent = (ZoneChangeEvent)event;
if (zEvent.getFromZone() == Constants.Zone.BATTLEFIELD && zEvent.getToZone() == Constants.Zone.GRAVEYARD) {
Permanent p = (Permanent) game.getLastKnownInformation(event.getTargetId(), Constants.Zone.BATTLEFIELD);
if (p.getAttachments().contains(this.getSourceId()))
return true;
}
}
return false;
}
@Override
public String getRule() {
return "When " + attachedDescription + " dies," + super.getRule();
}
}