From ca4a4528fb647c843b9b1801533fd5595dce0472 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Wed, 8 Jan 2020 04:54:17 +0400 Subject: [PATCH] * Play with top card library - fixed that player can see next top card before casting current top card; --- .../effects/ContinuousEffectImpl.java | 15 +++++++++++++ .../LookAtTopCardOfLibraryAnyTimeEffect.java | 10 ++++----- .../PlayWithTheTopCardRevealedEffect.java | 21 ++++--------------- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/Mage/src/main/java/mage/abilities/effects/ContinuousEffectImpl.java b/Mage/src/main/java/mage/abilities/effects/ContinuousEffectImpl.java index 012e935d053..425aee2c120 100644 --- a/Mage/src/main/java/mage/abilities/effects/ContinuousEffectImpl.java +++ b/Mage/src/main/java/mage/abilities/effects/ContinuousEffectImpl.java @@ -14,6 +14,8 @@ import mage.filter.Filter; import mage.filter.predicate.Predicate; import mage.filter.predicate.Predicates; import mage.game.Game; +import mage.game.stack.Spell; +import mage.game.stack.StackObject; import mage.players.Player; import mage.target.targetpointer.TargetPointer; @@ -395,4 +397,17 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu this.addDependedToType(DependencyType.AddingCreatureType); } } + + public boolean isCanLookAtNextTopLibraryCard(Game game) { + // If the top card of your library changes while you’re casting a spell, playing a land, or activating an ability, + // you can’t look at the new top card until you finish doing so. This means that if you cast the top card of + // your library, you can’t look at the next one until you’re done paying for that spell. (2019-05-03) + if (!game.getStack().isEmpty()) { + StackObject stackObject = game.getStack().getFirst(); + return !(stackObject instanceof Spell) + || !Zone.LIBRARY.equals(((Spell) stackObject).getFromZone()) + || ((Spell) stackObject).isDoneActivatingManaAbilities(); + } + return true; + } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/LookAtTopCardOfLibraryAnyTimeEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/LookAtTopCardOfLibraryAnyTimeEffect.java index 5d97877ba77..5749b100b1e 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/LookAtTopCardOfLibraryAnyTimeEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/LookAtTopCardOfLibraryAnyTimeEffect.java @@ -29,18 +29,18 @@ public class LookAtTopCardOfLibraryAnyTimeEffect extends ContinuousEffectImpl { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller == null) { - return true; + return false; } Card topCard = controller.getLibrary().getFromTop(game); if (topCard == null) { - return true; + return false; } MageObject obj = source.getSourceObject(game); if (obj == null) { - return true; + return false; } - if (!game.getState().getStack().isEmpty()) { // if a card is on the stack, don't allow it - return true; + if (!isCanLookAtNextTopLibraryCard(game)) { + return false; } controller.lookAtCards("Top card of " + obj.getIdName() + " controller's library", topCard, game); return true; diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/PlayWithTheTopCardRevealedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/PlayWithTheTopCardRevealedEffect.java index 4ac2f57f494..a826bc0cd15 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/PlayWithTheTopCardRevealedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/PlayWithTheTopCardRevealedEffect.java @@ -1,19 +1,16 @@ - package mage.abilities.effects.common.continuous; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.ContinuousEffectImpl; import mage.constants.Duration; import mage.constants.Layer; import mage.constants.Outcome; import mage.constants.SubLayer; -import mage.constants.Zone; import mage.game.Game; -import mage.game.stack.Spell; -import mage.game.stack.StackObject; import mage.players.Player; +import java.util.UUID; + /** * @author nantuko */ @@ -47,11 +44,11 @@ public class PlayWithTheTopCardRevealedEffect extends ContinuousEffectImpl { if (allPlayers) { for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); - if (player != null && !isCastFromPlayersLibrary(game, playerId)) { + if (player != null && isCanLookAtNextTopLibraryCard(game)) { player.setTopCardRevealed(true); } } - } else if (!isCastFromPlayersLibrary(game, controller.getId())) { + } else if (isCanLookAtNextTopLibraryCard(game)) { controller.setTopCardRevealed(true); } return true; @@ -59,16 +56,6 @@ public class PlayWithTheTopCardRevealedEffect extends ContinuousEffectImpl { return false; } - boolean isCastFromPlayersLibrary(Game game, UUID playerId) { - if (!game.getStack().isEmpty()) { - StackObject stackObject = game.getStack().getLast(); - return stackObject instanceof Spell - && !((Spell) stackObject).isDoneActivatingManaAbilities() - && Zone.LIBRARY.equals(((Spell) stackObject).getFromZone()); - } - return false; - } - @Override public PlayWithTheTopCardRevealedEffect copy() { return new PlayWithTheTopCardRevealedEffect(this);