* Some update to cards from pull requests.

This commit is contained in:
LevelX2 2015-03-25 23:40:50 +01:00
parent 3cafeb8845
commit 07fdd00fd1
5 changed files with 40 additions and 65 deletions

View file

@ -57,8 +57,8 @@ public class Slaughter extends CardImpl {
this.expansionSetCode = "EXO"; this.expansionSetCode = "EXO";
// Buyback-Pay 4 life. // Buyback-Pay 4 life.
BuybackAbility buybackAbility = new BuybackAbility(new PayLifeCost(4)); this.addAbility(new BuybackAbility(new PayLifeCost(4)));
this.addAbility(buybackAbility);
// Destroy target nonblack creature. It can't be regenerated. // Destroy target nonblack creature. It can't be regenerated.
this.getSpellAbility().addEffect(new DestroyTargetEffect(true)); this.getSpellAbility().addEffect(new DestroyTargetEffect(true));
this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter)); this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter));

View file

@ -59,11 +59,10 @@ public class PhantomTiger extends CardImpl {
this.subtype.add("Spirit"); this.subtype.add("Spirit");
this.power = new MageInt(1); this.power = new MageInt(1);
this.toughness = new MageInt(0); this.toughness = new MageInt(0);
// Phantom Tiger enters the battlefield with two +1/+1 counters on it. // Phantom Tiger enters the battlefield with two +1/+1 counters on it.
this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance(2)), "with two +1/+1 counters on it")); this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance(2)), "with two +1/+1 counters on it"));
// If damage would be dealt to Phantom Tiger, prevent that damage. Remove a +1/+1 counter from Phantom Tiger. // If damage would be dealt to Phantom Tiger, prevent that damage. Remove a +1/+1 counter from Phantom Tiger.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PhantomTigerPreventionEffect())); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PhantomTigerPreventionEffect()));
} }
@ -77,6 +76,7 @@ public class PhantomTiger extends CardImpl {
return new PhantomTiger(this); return new PhantomTiger(this);
} }
} }
class PhantomTigerPreventionEffect extends PreventionEffectImpl { class PhantomTigerPreventionEffect extends PreventionEffectImpl {
// remember turn and phase step to check if counter in this step was already removed // remember turn and phase step to check if counter in this step was already removed
@ -122,7 +122,7 @@ class PhantomTigerPreventionEffect extends PreventionEffectImpl {
} }
} }
if(removeCounter && permanent.getCounters().containsKey(CounterType.P1P1)) { if (removeCounter && permanent.getCounters().getCount(CounterType.P1P1) > 0) {
StringBuilder sb = new StringBuilder(permanent.getName()).append(": "); StringBuilder sb = new StringBuilder(permanent.getName()).append(": ");
permanent.removeCounters(CounterType.P1P1.createInstance(), game); permanent.removeCounters(CounterType.P1P1.createInstance(), game);
sb.append("Removed a +1/+1 counter "); sb.append("Removed a +1/+1 counter ");

View file

@ -27,35 +27,28 @@
*/ */
package mage.sets.judgment; package mage.sets.judgment;
import java.util.ArrayList;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.StaticAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.LeavesBattlefieldTriggeredAbility; import mage.abilities.common.ZoneChangeTriggeredAbility;
import mage.abilities.costs.CostImpl; import mage.abilities.costs.CostImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.ReturnFromExileForSourceEffect; import mage.abilities.effects.common.ReturnFromExileForSourceEffect;
import mage.abilities.effects.common.SacrificeSourceUnlessPaysEffect; import mage.abilities.effects.common.SacrificeSourceUnlessPaysEffect;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.common.FilterControlledPermanent;
import mage.filter.predicate.Predicate;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.filter.predicate.mageobject.NamePredicate;
import mage.filter.predicate.permanent.AnotherPredicate; import mage.filter.predicate.permanent.AnotherPredicate;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.common.TargetControlledPermanent; import mage.target.common.TargetControlledCreaturePermanent;
import mage.util.CardUtil; import mage.util.CardUtil;
/** /**
@ -64,11 +57,7 @@ import mage.util.CardUtil;
*/ */
public class WormfangDrake extends CardImpl { public class WormfangDrake extends CardImpl {
private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
static {
filter.add(Predicates.not(new NamePredicate("Wormfang Drake")));
}
public WormfangDrake(UUID ownerId) { public WormfangDrake(UUID ownerId) {
super(ownerId, 57, "Wormfang Drake", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{2}{U}"); super(ownerId, 57, "Wormfang Drake", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{2}{U}");
@ -80,9 +69,13 @@ public class WormfangDrake extends CardImpl {
// Flying // Flying
this.addAbility(FlyingAbility.getInstance()); this.addAbility(FlyingAbility.getInstance());
// When Wormfang Drake enters the battlefield, sacrifice it unless you exile a creature you control other than Wormfang Drake.
// When Wormfang Drake enters the battlefield, sacrifice it unless you exile a creature you control other than Wormfang Drake.
this.addAbility(new EntersBattlefieldTriggeredAbility(
new SacrificeSourceUnlessPaysEffect(new WormfangDrakeExileCost()), false));
// When Wormfang Drake leaves the battlefield, return the exiled card to the battlefield under its owner's control. // When Wormfang Drake leaves the battlefield, return the exiled card to the battlefield under its owner's control.
this.addAbility(new WormfangDrakeAbility(this, CardType.CREATURE)); this.addAbility(new WormfangDrakeTriggeredAbility(new ReturnFromExileForSourceEffect(Zone.BATTLEFIELD), false));
} }
public WormfangDrake(final WormfangDrake card) { public WormfangDrake(final WormfangDrake card) {
@ -95,62 +88,38 @@ public class WormfangDrake extends CardImpl {
} }
} }
class WormfangDrakeAbility extends StaticAbility { class WormfangDrakeTriggeredAbility extends ZoneChangeTriggeredAbility {
protected CardType cardType; public WormfangDrakeTriggeredAbility(Effect effect, boolean optional) {
protected String objectDescription; super(Zone.BATTLEFIELD, null, effect, "When {this} leaves the battlefield, ", optional);
public WormfangDrakeAbility(Card card, CardType cardtypes) {
super(Zone.BATTLEFIELD, null);
this.cardType = cardtypes;
StringBuilder sb = new StringBuilder("another ");
ArrayList<Predicate<MageObject>> cardtypesPredicates = new ArrayList<>();
cardtypesPredicates.add(new CardTypePredicate(cardType));
sb.append(cardType);
this.objectDescription = sb.toString();
FilterControlledPermanent filter = new FilterControlledPermanent(objectDescription);
filter.add(Predicates.or(cardtypesPredicates));
filter.add(new AnotherPredicate());
// When Wormfang Drake enters the battlefield, sacrifice it unless you exile another creature you control.
Ability ability1 = new EntersBattlefieldTriggeredAbility(new SacrificeSourceUnlessPaysEffect(new WormfangDrakeExileCost(filter, new StringBuilder(card.getName()).append(" WormfangDrakeed permanents").toString())),false);
ability1.setRuleVisible(false);
card.addAbility(ability1);
// When this permanent leaves the battlefield, return the exiled card to the battlefield under its owner's control.
Ability ability2 = new LeavesBattlefieldTriggeredAbility(new ReturnFromExileForSourceEffect(Zone.BATTLEFIELD), false);
ability2.setRuleVisible(false);
card.addAbility(ability2);
} }
public WormfangDrakeAbility(final WormfangDrakeAbility ability) { public WormfangDrakeTriggeredAbility(WormfangDrakeTriggeredAbility ability) {
super(ability); super(ability);
this.cardType = ability.cardType;
this.objectDescription = ability.objectDescription;
} }
@Override @Override
public WormfangDrakeAbility copy() { public WormfangDrakeTriggeredAbility copy() {
return new WormfangDrakeAbility(this); return new WormfangDrakeTriggeredAbility(this);
} }
} }
class WormfangDrakeExileCost extends CostImpl { class WormfangDrakeExileCost extends CostImpl {
private String exileZone = null; private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
public WormfangDrakeExileCost(FilterControlledPermanent filter, String exileZone) { static {
this.addTarget(new TargetControlledPermanent(1,1,filter, true)); filter.add(new AnotherPredicate());
this.text = "exile " + filter.getMessage() + " you control"; }
this.exileZone = exileZone;
public WormfangDrakeExileCost() {
this.addTarget(new TargetControlledCreaturePermanent(1,1,filter, true));
this.text = "Exile a creature you control other than {this}";
} }
public WormfangDrakeExileCost(WormfangDrakeExileCost cost) { public WormfangDrakeExileCost(WormfangDrakeExileCost cost) {
super(cost); super(cost);
this.exileZone = cost.exileZone;
} }
@Override @Override

View file

@ -54,6 +54,7 @@ public class SkirkMarauder extends CardImpl {
// Morph {2}{R} // Morph {2}{R}
this.addAbility(new MorphAbility(this, new ManaCostsImpl("{2}{R}"))); this.addAbility(new MorphAbility(this, new ManaCostsImpl("{2}{R}")));
// When Skirk Marauder is turned face up, it deals 2 damage to target creature or player. // When Skirk Marauder is turned face up, it deals 2 damage to target creature or player.
Ability ability = new TurnedFaceUpSourceTriggeredAbility(new DamageTargetEffect(2)); Ability ability = new TurnedFaceUpSourceTriggeredAbility(new DamageTargetEffect(2));
ability.addTarget(new TargetCreatureOrPlayer()); ability.addTarget(new TargetCreatureOrPlayer());

View file

@ -1,5 +1,6 @@
package mage.abilities.effects.common; package mage.abilities.effects.common;
import mage.MageObject;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.Mode; import mage.abilities.Mode;
@ -8,6 +9,7 @@ import mage.abilities.effects.OneShotEffect;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.util.CardUtil;
/** /**
* Created by IntelliJ IDEA. * Created by IntelliJ IDEA.
@ -32,12 +34,15 @@ public class SacrificeSourceUnlessPaysEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (player != null && permanent != null) { MageObject sourceObject = source.getSourceObject(game);
if (sourceObject != null && player != null && permanent != null) {
StringBuilder sb = new StringBuilder(cost.getText()).append("?"); StringBuilder sb = new StringBuilder(cost.getText()).append("?");
if (!sb.toString().toLowerCase().startsWith("exile ") && !sb.toString().toLowerCase().startsWith("return ") ) { if (!sb.toString().toLowerCase().startsWith("exile ") && !sb.toString().toLowerCase().startsWith("return ") ) {
sb.insert(0, "Pay "); sb.insert(0, "Pay ");
} }
if (player.chooseUse(Outcome.Benefit, sb.toString(), game)) { String message = CardUtil.replaceSourceName(sb.toString(), sourceObject.getLogName());
message = Character.toUpperCase(message.charAt(0)) + message.substring(1);
if (player.chooseUse(Outcome.Benefit, message, game)) {
cost.clearPaid(); cost.clearPaid();
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) { if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {
return true; return true;