From bdc9260dfa72ec46da2251881e786749048b1ada Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sun, 13 Dec 2015 17:39:38 +0100 Subject: [PATCH] * Corpse Augur - Fixed that all cards in target players graveyard were counted instead of only creature cards. --- .../mage/sets/commander2015/CorpseAugur.java | 6 +++-- .../CardsInTargetPlayersGraveyardCount.java | 25 ++++++++++++++++--- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/Mage.Sets/src/mage/sets/commander2015/CorpseAugur.java b/Mage.Sets/src/mage/sets/commander2015/CorpseAugur.java index 28a05b4c32..f7a629f52f 100644 --- a/Mage.Sets/src/mage/sets/commander2015/CorpseAugur.java +++ b/Mage.Sets/src/mage/sets/commander2015/CorpseAugur.java @@ -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()); diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/CardsInTargetPlayersGraveyardCount.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/CardsInTargetPlayersGraveyardCount.java index b5f39f1276..2371e658fb 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/CardsInTargetPlayersGraveyardCount.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/CardsInTargetPlayersGraveyardCount.java @@ -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"; } }