* Corpse Augur - Fixed that all cards in target players graveyard were counted instead of only creature cards.

This commit is contained in:
LevelX2 2015-12-13 17:39:38 +01:00
parent 63915101f5
commit bdc9260dfa
2 changed files with 26 additions and 5 deletions

View file

@ -38,6 +38,7 @@ import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.filter.common.FilterCreatureCard;
import mage.target.TargetPlayer;
/**
@ -55,10 +56,11 @@ public class CorpseAugur extends CardImpl {
this.toughness = new MageInt(2);
// When Corpse Augur dies, you draw X cards and you lose X life, where X is the number of creature cards in target player's graveyard.
Effect effect = new DrawCardSourceControllerEffect(new CardsInTargetPlayersGraveyardCount());
CardsInTargetPlayersGraveyardCount dynamicValue = new CardsInTargetPlayersGraveyardCount(new FilterCreatureCard("the number of creature cards"));
Effect effect = new DrawCardSourceControllerEffect(dynamicValue);
effect.setText("You draw X cards");
Ability ability = new DiesTriggeredAbility(effect, false);
effect = new LoseLifeSourceControllerEffect(new CardsInTargetPlayersGraveyardCount());
effect = new LoseLifeSourceControllerEffect(dynamicValue);
effect.setText("and you lose X life, where X is the number of creature cards in target player's graveyard");
ability.addEffect(effect);
ability.addTarget(new TargetPlayer());

View file

@ -30,6 +30,7 @@ package mage.abilities.dynamicvalue.common;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.players.Player;
@ -39,23 +40,41 @@ import mage.players.Player;
*/
public class CardsInTargetPlayersGraveyardCount implements DynamicValue {
private final FilterCard filter;
public CardsInTargetPlayersGraveyardCount() {
this.filter = null;
}
public CardsInTargetPlayersGraveyardCount(FilterCard filter) {
this.filter = filter;
}
public CardsInTargetPlayersGraveyardCount(final CardsInTargetPlayersGraveyardCount dynamicValue) {
this.filter = dynamicValue.filter;
}
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
Player player = game.getPlayer(effect.getTargetPointer().getFirst(game, sourceAbility));
if (player != null) {
return player.getGraveyard().size();
if (filter == null) {
return player.getGraveyard().size();
} else {
return player.getGraveyard().count(filter, sourceAbility.getControllerId(), sourceAbility.getSourceId(), game);
}
}
return 0;
}
@Override
public CardsInTargetPlayersGraveyardCount copy() {
return new CardsInTargetPlayersGraveyardCount();
return new CardsInTargetPlayersGraveyardCount(this);
}
@Override
public String getMessage() {
return "cards in target player's graveyard";
return (filter == null ? "cards" : filter.getMessage()) + " in target player's graveyard";
}
}