TriggeredAbilityImpl.java: added optional to getRule

DrawCardTriggerAbility added
Used DrawCardTriggeredAbility for LorescaleCoatl and JacesErasure
This commit is contained in:
North 2011-05-16 20:06:55 +03:00
parent b4ce80dfdc
commit 5e8a744179
4 changed files with 81 additions and 73 deletions

View file

@ -31,14 +31,11 @@ package mage.sets.alarareborn;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.MageInt;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.DrawCardTriggeredAbility;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.CardImpl;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.events.GameEvent;
/**
*
@ -50,11 +47,13 @@ public class LorescaleCoatl extends CardImpl<LorescaleCoatl> {
super(ownerId, 101, "Lorescale Coatl", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{1}{G}{U}");
this.expansionSetCode = "ARB";
this.subtype.add("Snake");
this.color.setGreen(true);
this.color.setBlue(true);
this.power = new MageInt(2);
this.toughness = new MageInt(2);
this.addAbility(new LorescaleCoatlAbility());
this.addAbility(new DrawCardTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance()), true));
}
public LorescaleCoatl (final LorescaleCoatl card) {
@ -65,32 +64,4 @@ public class LorescaleCoatl extends CardImpl<LorescaleCoatl> {
public LorescaleCoatl copy() {
return new LorescaleCoatl(this);
}
}
class LorescaleCoatlAbility extends TriggeredAbilityImpl<LorescaleCoatlAbility> {
public LorescaleCoatlAbility() {
super(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.P1P1.createInstance()), true);
}
public LorescaleCoatlAbility(final LorescaleCoatlAbility ability) {
super(ability);
}
@Override
public LorescaleCoatlAbility copy() {
return new LorescaleCoatlAbility(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.DREW_CARD && event.getPlayerId().equals(controllerId)) {
return true;
}
return false;
}
@Override
public String getRule() {
return "Whenever you draw a card, you may put a +1/+1 counter on Lorescale Coatl.";
}
}

View file

@ -31,14 +31,9 @@ package mage.sets.magic2011;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.DrawCardTriggeredAbility;
import mage.abilities.effects.common.PutLibraryIntoGraveTargetEffect;
import mage.cards.CardImpl;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.target.TargetPlayer;
/**
@ -51,7 +46,10 @@ public class JacesErasure extends CardImpl<JacesErasure> {
super(ownerId, 59, "Jace's Erasure", Rarity.COMMON, new CardType[]{CardType.ENCHANTMENT}, "{1}{U}");
this.expansionSetCode = "M11";
this.color.setBlue(true);
this.addAbility(new JacesErasureAbility());
DrawCardTriggeredAbility ability = new DrawCardTriggeredAbility(new PutLibraryIntoGraveTargetEffect(1), true);
ability.addTarget(new TargetPlayer());
this.addAbility(ability);
}
public JacesErasure(final JacesErasure card) {
@ -67,36 +65,4 @@ public class JacesErasure extends CardImpl<JacesErasure> {
public String getArt() {
return "125788_typ_reg_sty_010.jpg";
}
}
class JacesErasureAbility extends TriggeredAbilityImpl<JacesErasureAbility> {
public JacesErasureAbility() {
super(Zone.BATTLEFIELD, new PutLibraryIntoGraveTargetEffect(1), true);
this.addTarget(new TargetPlayer());
}
public JacesErasureAbility(final JacesErasureAbility ability) {
super(ability);
}
@Override
public JacesErasureAbility copy() {
return new JacesErasureAbility(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == EventType.DREW_CARD && event.getPlayerId().equals(controllerId)) {
return true;
}
return false;
}
@Override
public String getRule() {
return "Whenever you draw a card, you may have target player put the top card of his or her library into his or her graveyard.";
}
}
}