* Mogg War Marshal - Fixed the triggered ability.

This commit is contained in:
LevelX2 2013-06-23 15:10:13 +02:00
parent 9180ecc1f0
commit d5a7f90130

View file

@ -28,15 +28,18 @@
package mage.sets.timespiral; package mage.sets.timespiral;
import java.util.UUID; import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.DiesTriggeredAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.keyword.EchoAbility; import mage.abilities.keyword.EchoAbility;
import mage.cards.CardImpl; 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; import mage.game.permanent.token.GoblinToken;
/** /**
@ -58,10 +61,7 @@ public class MoggWarMarshal extends CardImpl<MoggWarMarshal> {
// Echo {1}{R} // Echo {1}{R}
this.addAbility(new EchoAbility("{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. // 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(new MoggWarMarshallTriggeredAbility());
this.addAbility(enterAbility);
Ability diesAbility = new DiesTriggeredAbility(new CreateTokenEffect(new GoblinToken(), 1), false);
this.addAbility(diesAbility);
} }
public MoggWarMarshal(final MoggWarMarshal card) { public MoggWarMarshal(final MoggWarMarshal card) {
@ -73,3 +73,39 @@ public class MoggWarMarshal extends CardImpl<MoggWarMarshal> {
return new MoggWarMarshal(this); return new MoggWarMarshal(this);
} }
} }
class MoggWarMarshallTriggeredAbility extends TriggeredAbilityImpl<MoggWarMarshallTriggeredAbility> {
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();
}
}