From e48be86f7b67f2757451059f77848bea13744066 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sat, 13 Jun 2015 19:21:03 +0200 Subject: [PATCH] * Zoetic Cavern - Fixed that if cast with Morph the spell was not handled as spell with card type "Creature" (e.g. causing problem with Possibility Storm). --- .../mage/sets/commander2014/ZoeticCavern.java | 2 +- .../cards/triggers/PossibilityStormTest.java | 95 +++++++++++++++++++ Mage/src/mage/abilities/AbilityImpl.java | 2 +- Mage/src/mage/constants/SpellAbilityType.java | 2 +- Mage/src/mage/game/stack/Spell.java | 5 + Mage/src/mage/players/PlayerImpl.java | 2 +- 6 files changed, 104 insertions(+), 4 deletions(-) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/triggers/PossibilityStormTest.java diff --git a/Mage.Sets/src/mage/sets/commander2014/ZoeticCavern.java b/Mage.Sets/src/mage/sets/commander2014/ZoeticCavern.java index 6613499c77..ed54e110b3 100644 --- a/Mage.Sets/src/mage/sets/commander2014/ZoeticCavern.java +++ b/Mage.Sets/src/mage/sets/commander2014/ZoeticCavern.java @@ -46,7 +46,7 @@ public class ZoeticCavern extends CardImpl { this.expansionSetCode = "C14"; // {T}: Add {1} to your mana pool. - this.addAbility(new ColorlessManaAbility()); + this.addAbility(new ColorlessManaAbility()); // Morph {2} this.addAbility(new MorphAbility(this, new ManaCostsImpl("{2}"))); } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/PossibilityStormTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/PossibilityStormTest.java new file mode 100644 index 0000000000..6501fbf2ab --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/PossibilityStormTest.java @@ -0,0 +1,95 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package org.mage.test.cards.triggers; + + +import mage.cards.Card; +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Assert; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author LevelX2 + */ + +public class PossibilityStormTest extends CardTestPlayerBase { + + /** + * There's currently a bug with Possibility Storm and Zoetic Cavern. The way + * it's supposed to work is the P. Storm trigger exiles Zoetic Cavern and + * then uses last known information about the spell to determine the type of + * card the trigger is looking for(creature in this instance). Instead it's + * basing the type solely off what's printed on the card. What happened to + * me earlier was the trigger skipped right over an Emrakul and then + * revealed a Flooded Strand. I was prompted whether or not I wanted to + * "cast" Flooded Strand without paying it's cost. Eventually I clicked yes + * and it produced a Game Error that resulted in rollback. I recreated the + * error against an AI opponent and copied the code. Can't actually post it + * because the filter on this site claims it makes my post look too + * "spammy". Here's a screenshot of it instead(in spoiler tag). + */ + + @Test + public void TestWithZoeticCavern() { + addCard(Zone.BATTLEFIELD, playerA, "Swamp", 3); + // Whenever a player casts a spell from his or her hand, that player exiles it, then exiles cards from + // the top of his or her library until he or she exiles a card that shares a card type with it. That + // player may cast that card without paying its mana cost. Then he or she puts all cards exiled with + // Possibility Storm on the bottom of his or her library in a random order. + addCard(Zone.BATTLEFIELD, playerA, "Possibility Storm", 2); + + // {T}: Add {1} to your mana pool. + // Morph {2} + addCard(Zone.HAND, playerA, "Zoetic Cavern"); + + addCard(Zone.LIBRARY, playerA, "Silvercoat Lion"); + skipInitShuffling(); + + playLand(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Zoetic Cavern"); + setChoice(playerA, "Yes"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertPermanentCount(playerA, "Zoetic Cavern", 0); + + boolean zoeticCavernInLibrary = false; + for (Card card: playerA.getLibrary().getCards(currentGame)) { + if (card.getName().equals("Zoetic Cavern")) { + zoeticCavernInLibrary = true; + } + } + Assert.assertEquals("Zoetic Cavern has to be in the library", true, zoeticCavernInLibrary); + + assertPermanentCount(playerA, "Silvercoat Lion", 1); + + } +} \ No newline at end of file diff --git a/Mage/src/mage/abilities/AbilityImpl.java b/Mage/src/mage/abilities/AbilityImpl.java index 7621c9adad..c7bbd061e5 100644 --- a/Mage/src/mage/abilities/AbilityImpl.java +++ b/Mage/src/mage/abilities/AbilityImpl.java @@ -299,7 +299,7 @@ public abstract class AbilityImpl implements Ability { // A player can't apply two alternative methods of casting or two alternative costs to a single spell. if (!activateAlternateOrAdditionalCosts(sourceObject, noMana, controller, game)){ if (getAbilityType().equals(AbilityType.SPELL) - && ((SpellAbility) this).getSpellAbilityType().equals(SpellAbilityType.LAND_ALTERNATE)) { + && ((SpellAbility) this).getSpellAbilityType().equals(SpellAbilityType.FACE_DOWN_CREATURE)) { return false; } } diff --git a/Mage/src/mage/constants/SpellAbilityType.java b/Mage/src/mage/constants/SpellAbilityType.java index 70af522434..881fdf06a6 100644 --- a/Mage/src/mage/constants/SpellAbilityType.java +++ b/Mage/src/mage/constants/SpellAbilityType.java @@ -7,7 +7,7 @@ package mage.constants; public enum SpellAbilityType { BASE("Basic SpellAbility"), BASE_ALTERNATE("Basic SpellAbility Alternate"), // used for Overload, Flashback to know they must be handled as Alternate casting costs - LAND_ALTERNATE("Basic SpellAbility Alternate Land"), // used for Lands with Morph to cast as Face Down creature + FACE_DOWN_CREATURE("Face down creature"), // used for Lands with Morph to cast as Face Down creature SPLIT("Split SpellAbility"), SPLIT_FUSED("Split SpellAbility"), SPLIT_LEFT("LeftSplit SpellAbility"), diff --git a/Mage/src/mage/game/stack/Spell.java b/Mage/src/mage/game/stack/Spell.java index bbb1ef01d8..2ae5dd56c7 100644 --- a/Mage/src/mage/game/stack/Spell.java +++ b/Mage/src/mage/game/stack/Spell.java @@ -372,6 +372,11 @@ public class Spell extends StackObjImpl implements Card { @Override public List getCardType() { + if (this.getSpellAbility().getSpellAbilityType().equals(SpellAbilityType.FACE_DOWN_CREATURE)) { + List cardTypes = new ArrayList<>(); + cardTypes.add(CardType.CREATURE); + return cardTypes; + } if (this.getSpellAbility() instanceof BestowAbility) { List cardTypes = new ArrayList<>(); cardTypes.addAll(card.getCardType()); diff --git a/Mage/src/mage/players/PlayerImpl.java b/Mage/src/mage/players/PlayerImpl.java index eb51a19151..7accbb420a 100644 --- a/Mage/src/mage/players/PlayerImpl.java +++ b/Mage/src/mage/players/PlayerImpl.java @@ -989,7 +989,7 @@ public abstract class PlayerImpl implements Player, Serializable { } } if (found) { - SpellAbility spellAbility = new SpellAbility(null, "", game.getState().getZone(card.getId()), SpellAbilityType.LAND_ALTERNATE); + SpellAbility spellAbility = new SpellAbility(null, "", game.getState().getZone(card.getId()), SpellAbilityType.FACE_DOWN_CREATURE); spellAbility.setControllerId(this.getId()); spellAbility.setSourceId(card.getId()); if (cast(spellAbility, game, false)) {