From 5ed5bce718156d3025442780335305c2516e6b80 Mon Sep 17 00:00:00 2001 From: jeffwadsworth Date: Fri, 3 Jan 2020 11:30:29 -0600 Subject: [PATCH] - Fixed #6127 --- .../effects/keyword/ExploreSourceEffect.java | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/Mage/src/main/java/mage/abilities/effects/keyword/ExploreSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/keyword/ExploreSourceEffect.java index 7113010041..6ff8e1ea2f 100644 --- a/Mage/src/main/java/mage/abilities/effects/keyword/ExploreSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/keyword/ExploreSourceEffect.java @@ -1,4 +1,3 @@ - package mage.abilities.effects.keyword; import java.util.UUID; @@ -21,19 +20,26 @@ import mage.players.Player; */ public class ExploreSourceEffect extends OneShotEffect { - // "it explores. (Reveal the top card of your library. Put that card into your hand if it's a land. Otherwise, put a +1/+1 counter on this creature, then put the card back or put it into your graveyard.)"; + // "it explores. (Reveal the top card of your library. Put that card into + // your hand if it's a land. Otherwise, put a +1/+1 counter on this creature, + // then put the card back or put it into your graveyard.)"; private static final String RULE_TEXT_START = "explores."; - private static final String RULE_TEXT_HINT = "(Reveal the top card of your library. Put that card into your hand if it's a land. Otherwise, put a +1/+1 counter on this creature, then put the card back or put it into your graveyard.)"; + private static final String RULE_TEXT_HINT = "(Reveal the top card of your library. " + + "Put that card into your hand if it's a land. Otherwise, put a +1/+1 counter on " + + "this creature, then put the card back or put it into your graveyard.)"; public static String getRuleText(boolean showAbilityHint) { return getRuleText(showAbilityHint, null); } + public static String getRuleText(boolean showAbilityHint, String whosExplores) { String res = whosExplores; - if(res == null){ res = "it"; } + if (res == null) { + res = "it"; + } - res += " " + RULE_TEXT_START; + res += " " + RULE_TEXT_START; if (showAbilityHint) { res += " " + RULE_TEXT_HINT; @@ -55,7 +61,7 @@ public class ExploreSourceEffect extends OneShotEffect { public ExploreSourceEffect(boolean showAbilityHint, String whosExplores) { super(Outcome.Benefit); - if(whosExplores != null) { + if (whosExplores != null) { this.sourceName = whosExplores; } setText(); @@ -68,7 +74,7 @@ public class ExploreSourceEffect extends OneShotEffect { setText(); } - private void setText(){ + private void setText() { this.staticText = getRuleText(this.showAbilityHint, this.sourceName); } @@ -83,6 +89,7 @@ public class ExploreSourceEffect extends OneShotEffect { } public static boolean explorePermanent(Game game, UUID permanentId, Ability source) { + Boolean cardWasRevealed = false; Permanent permanent = game.getPermanentOrLKIBattlefield(permanentId); if (permanent == null) { return false; @@ -91,18 +98,21 @@ public class ExploreSourceEffect extends OneShotEffect { if (permanentController == null) { return false; } - game.fireEvent(GameEvent.getEvent(GameEvent.EventType.EXPLORED, permanentId, source.getSourceId(), permanent.getControllerId())); + game.fireEvent(GameEvent.getEvent(GameEvent.EventType.EXPLORED, permanentId, + source.getSourceId(), permanent.getControllerId())); if (permanentController.getLibrary().hasCards()) { Card card = permanentController.getLibrary().getFromTop(game); Cards cards = new CardsImpl(); cards.add(card); permanentController.revealCards("Explored card", cards, game); - + cardWasRevealed = true; if (card != null) { if (card.isLand()) { card.moveToZone(Zone.HAND, source.getSourceId(), game, true); } else { - permanent.addCounters(CounterType.P1P1.createInstance(), source, game); + if (game.getState().getZone(permanentId) == Zone.BATTLEFIELD) { // needed in case LKI object is used + permanent.addCounters(CounterType.P1P1.createInstance(), source, game); + } if (permanentController.chooseUse(Outcome.Neutral, "Put " + card.getLogName() + " in your graveyard?", source, game)) { card.moveToZone(Zone.GRAVEYARD, source.getSourceId(), game, true); game.informPlayers(permanentController.getLogName() + " puts " + card.getLogName() + " into their graveyard."); @@ -112,6 +122,12 @@ public class ExploreSourceEffect extends OneShotEffect { } } } + if (!cardWasRevealed + && game.getState().getZone(permanentId) == Zone.BATTLEFIELD) { + // If no card is revealed, most likely because that player's library is empty, + // the exploring creature receives a +1/+1 counter. + permanent.addCounters(CounterType.P1P1.createInstance(), source, game); + } return true; } }