diff --git a/Mage.Sets/src/mage/sets/timespiral/MoggWarMarshal.java b/Mage.Sets/src/mage/sets/timespiral/MoggWarMarshal.java index f1055e6d85..6f02c577f7 100644 --- a/Mage.Sets/src/mage/sets/timespiral/MoggWarMarshal.java +++ b/Mage.Sets/src/mage/sets/timespiral/MoggWarMarshal.java @@ -28,15 +28,18 @@ package mage.sets.timespiral; import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Rarity; import mage.MageInt; -import mage.abilities.Ability; -import mage.abilities.common.DiesTriggeredAbility; -import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.TriggeredAbilityImpl; import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.keyword.EchoAbility; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Rarity; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.GameEvent.EventType; +import mage.game.events.ZoneChangeEvent; import mage.game.permanent.token.GoblinToken; /** @@ -58,10 +61,7 @@ public class MoggWarMarshal extends CardImpl { // Echo {1}{R} this.addAbility(new EchoAbility("{1}{R}")); // When Mogg War Marshal enters the battlefield or dies, put a 1/1 red Goblin creature token onto the battlefield. - Ability enterAbility = new EntersBattlefieldTriggeredAbility(new CreateTokenEffect(new GoblinToken(), 1), false); - this.addAbility(enterAbility); - Ability diesAbility = new DiesTriggeredAbility(new CreateTokenEffect(new GoblinToken(), 1), false); - this.addAbility(diesAbility); + this.addAbility(new MoggWarMarshallTriggeredAbility()); } public MoggWarMarshal(final MoggWarMarshal card) { @@ -73,3 +73,39 @@ public class MoggWarMarshal extends CardImpl { return new MoggWarMarshal(this); } } + +class MoggWarMarshallTriggeredAbility extends TriggeredAbilityImpl { + + public MoggWarMarshallTriggeredAbility() { + super(Zone.BATTLEFIELD, new CreateTokenEffect(new GoblinToken(), 1), false); + } + + public MoggWarMarshallTriggeredAbility(final MoggWarMarshallTriggeredAbility ability) { + super(ability); + } + + @Override + public MoggWarMarshallTriggeredAbility copy() { + return new MoggWarMarshallTriggeredAbility(this); + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD + && event.getTargetId().equals(getSourceId())) { + return true; + } + if (event.getType() == EventType.ZONE_CHANGE && event.getTargetId().equals(this.getSourceId())) { + ZoneChangeEvent zEvent = (ZoneChangeEvent)event; + if (zEvent.getFromZone().equals(Zone.BATTLEFIELD) && zEvent.getToZone().equals(Zone.GRAVEYARD)) { + return true; + } + } + return false; + } + + @Override + public String getRule() { + return "When Mogg War Marshal enters the battlefield or dies, " + super.getRule(); + } +}