From 42dfd16b0279d181c01c14ecc5c112c455f1b254 Mon Sep 17 00:00:00 2001 From: jeffwadsworth Date: Wed, 12 Feb 2020 15:31:06 -0600 Subject: [PATCH] - Fixed Thought Hemorrhage --- .../src/mage/cards/t/ThoughtHemorrhage.java | 40 +++++++++++++------ 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/Mage.Sets/src/mage/cards/t/ThoughtHemorrhage.java b/Mage.Sets/src/mage/cards/t/ThoughtHemorrhage.java index 6aa81b654d8..a4b9bee2e9d 100644 --- a/Mage.Sets/src/mage/cards/t/ThoughtHemorrhage.java +++ b/Mage.Sets/src/mage/cards/t/ThoughtHemorrhage.java @@ -15,14 +15,13 @@ import mage.filter.predicate.mageobject.NamePredicate; import mage.game.Game; import mage.players.Player; import mage.target.TargetPlayer; -import mage.target.common.TargetCardInHand; import mage.target.common.TargetCardInLibrary; import mage.util.CardUtil; - import java.util.LinkedHashSet; import java.util.List; import java.util.Set; import java.util.UUID; +import mage.target.TargetCard; /** * @author jeffwadsworth @@ -32,9 +31,14 @@ public final class ThoughtHemorrhage extends CardImpl { public ThoughtHemorrhage(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{B}{R}"); - // Name a nonland card. Target player reveals their hand. Thought Hemorrhage deals 3 damage to that player for each card with that name revealed this way. Search that player's graveyard, hand, and library for all cards with that name and exile them. Then that player shuffles their library. + // Name a nonland card. Target player reveals their hand. Thought + // Hemorrhage deals 3 damage to that player for each card with that + // name revealed this way. Search that player's graveyard, hand, and + // library for all cards with that name and exile them. Then that + // player shuffles their library. this.getSpellAbility().addTarget(new TargetPlayer()); - this.getSpellAbility().addEffect(new ChooseACardNameEffect(ChooseACardNameEffect.TypeOfName.NON_LAND_NAME)); + this.getSpellAbility().addEffect(new ChooseACardNameEffect( + ChooseACardNameEffect.TypeOfName.NON_LAND_NAME)); this.getSpellAbility().addEffect(new ThoughtHemorrhageEffect()); } @@ -51,8 +55,10 @@ public final class ThoughtHemorrhage extends CardImpl { class ThoughtHemorrhageEffect extends OneShotEffect { static final String rule = "Target player reveals their hand. " - + "{this} deals 3 damage to that player for each card with the chosen name revealed this way. " - + "Search that player's graveyard, hand, and library for all cards with that name and exile them. " + + "{this} deals 3 damage to that player for each card with " + + "the chosen name revealed this way. " + + "Search that player's graveyard, hand, and library for " + + "all cards with that name and exile them. " + "Then that player shuffles their library"; public ThoughtHemorrhageEffect() { @@ -68,11 +74,16 @@ class ThoughtHemorrhageEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = game.getObject(source.getSourceId()); - String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY); - if (sourceObject != null && controller != null && cardName != null && !cardName.isEmpty()) { + String cardName = (String) game.getState().getValue( + source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY); + if (sourceObject != null + && controller != null + && cardName != null + && !cardName.isEmpty()) { Player targetPlayer = game.getPlayer(source.getFirstTarget()); if (targetPlayer != null) { - targetPlayer.revealCards("hand of " + targetPlayer.getName(), targetPlayer.getHand(), game); + targetPlayer.revealCards("hand of " + + targetPlayer.getName(), targetPlayer.getHand(), game); int cardsFound = 0; for (Card card : targetPlayer.getHand().getCards(game)) { if (CardUtil.haveSameNames(card.getName(), cardName)) { @@ -88,8 +99,10 @@ class ThoughtHemorrhageEffect extends OneShotEffect { filterNamedCards.add(new NamePredicate(cardName)); Set toExile = new LinkedHashSet<>(); - // The cards you're searching for must be found and exiled if they're in the graveyard because it's a public zone. - // Finding those cards in the hand and library is optional, because those zones are hidden (even if the hand is temporarily revealed). + // The cards you're searching for must be found and exiled if + // they're in the graveyard because it's a public zone. + // Finding those cards in the hand and library is optional, + // because those zones are hidden (even if the hand is temporarily revealed). // search cards in graveyard for (Card checkCard : targetPlayer.getGraveyard().getCards(game)) { if (checkCard.getName().equals(cardName)) { @@ -98,7 +111,7 @@ class ThoughtHemorrhageEffect extends OneShotEffect { } // search cards in Hand - TargetCardInHand targetCardInHand = new TargetCardInHand(0, Integer.MAX_VALUE, filterNamedCards); + TargetCard targetCardInHand = new TargetCard(0, Integer.MAX_VALUE, Zone.HAND, filterNamedCards); if (controller.chooseTarget(Outcome.Exile, targetPlayer.getHand(), targetCardInHand, source, game)) { List targets = targetCardInHand.getTargets(); for (UUID targetId : targets) { @@ -110,7 +123,8 @@ class ThoughtHemorrhageEffect extends OneShotEffect { } // search cards in Library - // If the player has no nonland cards in their hand, you can still search that player's library and have that player shuffle it. + // If the player has no nonland cards in their hand, you can still search + // that player's library and have that player shuffle it. TargetCardInLibrary targetCardsLibrary = new TargetCardInLibrary(0, Integer.MAX_VALUE, filterNamedCards); controller.searchLibrary(targetCardsLibrary, source, game, targetPlayer.getId()); for (UUID cardId : targetCardsLibrary.getTargets()) {