From c9ea0f187725cc2e68f5a9cecff2e34a8d8bf6ff Mon Sep 17 00:00:00 2001
From: Oleg Agafonov <jaydi85@gmail.com>
Date: Sat, 14 Dec 2019 18:51:35 +0400
Subject: [PATCH] Fixed Bolas's Citadel combo with adventure cards

---
 Mage.Sets/src/mage/cards/b/BolassCitadel.java     | 15 +++++++--------
 .../cards/cost/alternate/BolassCitadelTest.java   |  3 ---
 2 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/Mage.Sets/src/mage/cards/b/BolassCitadel.java b/Mage.Sets/src/mage/cards/b/BolassCitadel.java
index 32da651d46..5741a658b0 100644
--- a/Mage.Sets/src/mage/cards/b/BolassCitadel.java
+++ b/Mage.Sets/src/mage/cards/b/BolassCitadel.java
@@ -96,15 +96,14 @@ class BolassCitadelPlayTheTopCardEffect extends AsThoughEffectImpl {
 
     @Override
     public boolean applies(UUID objectId, Ability affectedAbility, Ability source, Game game, UUID playerId) {
-        Card cardOnTop = game.getCard(objectId);
-        if (cardOnTop == null) {
-            return false;
-        }
-        if (playerId.equals(source.getControllerId())
-                && cardOnTop.isOwnedBy(source.getControllerId())) {
-            Player controller = game.getPlayer(cardOnTop.getOwnerId());
+        Card cardToCheck = game.getCard(objectId);
+        objectId = game.getCard(objectId).getMainCard().getId(); // for split cards
+
+        if (playerId.equals(source.getControllerId()) && cardToCheck.isOwnedBy(source.getControllerId())) {
+            Player controller = game.getPlayer(cardToCheck.getOwnerId());
             if (controller != null
-                    && cardOnTop.equals(controller.getLibrary().getFromTop(game))) {
+                    && controller.getLibrary().getFromTop(game) != null
+                    && objectId.equals(controller.getLibrary().getFromTop(game).getId())) {
                 if (affectedAbility instanceof ActivatedAbility) {
                     ActivatedAbility activatedAbility = (ActivatedAbility) affectedAbility;
                     // add the life cost first
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 f5932c7401..ee0d7c27d6 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
@@ -32,7 +32,6 @@ public class BolassCitadelTest extends CardTestPlayerBase {
     }
 
     @Test
-    @Ignore("This is broken for now.")
     public void testCastAdventure() {
         /*
          * Curious Pair {1}{G}
@@ -44,7 +43,6 @@ public class BolassCitadelTest extends CardTestPlayerBase {
          * Create a Food token.
          */
         setStrictChooseMode(true);
-        addCard(Zone.BATTLEFIELD, playerA, "Forest");
         addCard(Zone.BATTLEFIELD, playerA, "Bolas's Citadel");
         removeAllCardsFromLibrary(playerA);
         addCard(Zone.LIBRARY, playerA, "Curious Pair");
@@ -54,7 +52,6 @@ public class BolassCitadelTest extends CardTestPlayerBase {
         execute();
 
         assertAllCommandsUsed();
-        assertTapped("Forest", false);
         assertHandCount(playerA, 0);
         assertPermanentCount(playerA, "Food", 1);
         assertExileCount(playerA, "Curious Pair", 1);