From d1ccb621a1535c9533be5771798d3028f02316ec Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Mon, 6 Jul 2020 15:44:31 +0400 Subject: [PATCH] * Bolas's Citadel - fixed that opponent can use Bolas's play ability for own cards (#6741); --- Mage.Sets/src/mage/cards/b/BolassCitadel.java | 17 ++++++----- .../cost/alternate/BolassCitadelTest.java | 30 +++++++++++++++++++ .../effects/common/AmplifyEffect.java | 2 -- 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/Mage.Sets/src/mage/cards/b/BolassCitadel.java b/Mage.Sets/src/mage/cards/b/BolassCitadel.java index 00c6d09653..03c06175b4 100644 --- a/Mage.Sets/src/mage/cards/b/BolassCitadel.java +++ b/Mage.Sets/src/mage/cards/b/BolassCitadel.java @@ -11,21 +11,18 @@ import mage.abilities.costs.common.TapSourceCost; import mage.abilities.effects.AsThoughEffectImpl; import mage.abilities.effects.common.LoseLifeOpponentsEffect; import mage.abilities.effects.common.continuous.LookAtTopCardOfLibraryAnyTimeEffect; -import mage.cards.Card; -import mage.cards.CardImpl; -import mage.cards.CardSetInfo; +import mage.cards.*; import mage.constants.*; import mage.filter.common.FilterControlledPermanent; import mage.filter.predicate.Predicates; import mage.game.Game; import mage.players.Player; import mage.target.common.TargetControlledPermanent; - -import java.util.UUID; -import mage.cards.SplitCard; -import mage.cards.SplitCardHalf; import mage.util.CardUtil; +import java.util.Objects; +import java.util.UUID; + /** * @author jeffwadsworth @@ -97,6 +94,10 @@ class BolassCitadelPlayTheTopCardEffect extends AsThoughEffectImpl { @Override public boolean applies(UUID objectId, Ability affectedAbility, Ability source, Game game, UUID playerId) { + if (!Objects.equals(source.getControllerId(), playerId)) { + return false; + } + Player player = game.getPlayer(playerId); if (player != null) { Card topCard = player.getLibrary().getFromTop(game); @@ -121,7 +122,7 @@ class BolassCitadelPlayTheTopCardEffect extends AsThoughEffectImpl { player.setCastSourceIdWithAlternateMana(rightCard.getId(), null, rightCosts); } else { if (affectedAbility == null) { - affectedAbility = topCard.getSpellAbility(); + affectedAbility = topCard.getSpellAbility(); } else { objectIdToCast = affectedAbility.getSourceId(); } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/cost/alternate/BolassCitadelTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/cost/alternate/BolassCitadelTest.java index 8fba1058df..7a49cae4be 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/cost/alternate/BolassCitadelTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/cost/alternate/BolassCitadelTest.java @@ -129,4 +129,34 @@ public class BolassCitadelTest extends CardTestPlayerBase { assertGraveyardCount(playerA, "Ferocious Zheng", 1); assertLife(playerA, 20 - 3); } + + @Test + public void testOpponentCantUseMyBolas() { + // https://github.com/magefree/mage/issues/6741 + removeAllCardsFromLibrary(playerA); + removeAllCardsFromLibrary(playerB); + + // You may play the top card of your library. If you cast a spell this way, pay life equal to its converted mana cost rather than pay its mana cost. + addCard(Zone.BATTLEFIELD, playerA, "Bolas's Citadel"); + // + addCard(Zone.LIBRARY, playerA, "Balduvian Bears", 2); // {1}{G} + addCard(Zone.LIBRARY, playerB, "Grizzly Bears", 2); // {1}{G} + + // 1 turn + checkPlayableAbility("A can use bolas on 1", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Balduvian Bears", true); + checkPlayableAbility("B cant use bolas on 1", 1, PhaseStep.PRECOMBAT_MAIN, playerB, "Cast Grizzly Bears", false); + + // 2 turn + checkPlayableAbility("A can't use bolas on 2", 2, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Balduvian Bears", false); + checkPlayableAbility("B can't use bolas on 2", 2, PhaseStep.PRECOMBAT_MAIN, playerB, "Cast Grizzly Bears", false); + + // 3 turn + checkPlayableAbility("A can use bolas on 1", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Balduvian Bears", true); + checkPlayableAbility("B cant use bolas on 1", 1, PhaseStep.PRECOMBAT_MAIN, playerB, "Cast Grizzly Bears", false); + + setStrictChooseMode(true); + setStopAt(3, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/AmplifyEffect.java b/Mage/src/main/java/mage/abilities/effects/common/AmplifyEffect.java index 59dc9f1430..bbe980d2b8 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/AmplifyEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/AmplifyEffect.java @@ -8,7 +8,6 @@ package mage.abilities.effects.common; import mage.abilities.Ability; import mage.abilities.Mode; import mage.abilities.effects.ReplacementEffectImpl; -import mage.cards.Card; import mage.cards.Cards; import mage.cards.CardsImpl; import mage.constants.Duration; @@ -114,7 +113,6 @@ public class AmplifyEffect extends ReplacementEffectImpl { // You can’t reveal this card or any other cards that are entering the battlefield at the same time as this card. filter.add(Predicates.not(new CardIdPredicate(source.getSourceId()))); for (Permanent enteringPermanent : game.getPermanentsEntering().values()) { - Card card = game.getCard(enteringPermanent.getId()); filter.add(Predicates.not(new CardIdPredicate(enteringPermanent.getId()))); }