From 74e3fa63a84ee9c5c7eab193048a7482aabc20d0 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Fri, 3 Jan 2014 12:38:51 +0100 Subject: [PATCH] * Bestow - Fixed that creature with bestow went to graveyard if enchanted target got protection from a color of the bestow permanent. --- .../java/mage/client/game/PlayerPanelExt.java | 2 +- .../cards/abilities/keywords/BestowTest.java | 89 +++++++++++++++++++ .../cards/abilities/keywords/EvolveTest.java | 28 ++++++ .../abilities/keywords/HexproofTest.java | 28 +++++- .../java/org/mage/test/player/TestPlayer.java | 3 +- .../mage/abilities/keyword/BestowAbility.java | 3 + Mage/src/mage/game/GameImpl.java | 12 ++- 7 files changed, 158 insertions(+), 7 deletions(-) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/BestowTest.java diff --git a/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java b/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java index 6f33be7cec4..2d0f63afedb 100644 --- a/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java +++ b/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java @@ -411,7 +411,7 @@ public class PlayerPanelExt extends javax.swing.JPanel { r = new Rectangle(21, 21); resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r); commandZone = new HoverButton(null, resized, resized, resized, r); - commandZone.setToolTipText("Command Zone (Emblems)"); + commandZone.setToolTipText("Command Zone (Commander and Emblems)"); commandZone.setOpaque(false); commandZone.setObserver(new Command() { @Override diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/BestowTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/BestowTest.java new file mode 100644 index 00000000000..6682f510ba1 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/BestowTest.java @@ -0,0 +1,89 @@ +/* + * 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.abilities.keywords; + +import mage.abilities.keyword.HexproofAbility; +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author LevelX2 + */ +public class BestowTest extends CardTestPlayerBase { + + /** + * Tests that if from bestow permanent targeted creature + * gets protection from the color of the bestow permanent, + * the bestow permanent becomes a creature on the battlefield. + * + */ + + /* Silent Artisan + * Creature - Giant 3/5 + * + * + * Hopeful Eidolon {W} + * Enchantment Creature - Spirit 1/1 + * Bestow {3}{W} (If you cast this card for its bestow cost, it's an Aura spell with enchant creature. + * It becomes a creature again if it's not attached to a creature.) + * Lifelink (Damage dealt by this creature also causes you to gain that much life.) + * Enchanted creature gets +1/+1 and has lifelink. + * + * Gods Willing {W} + * Instant + * Target creature you control gains protection from the color of your choice until end of turn. + * Scry 1. (Look at the top card of your library. You may put that card on the bottom of your library.) + * + */ + + @Test + public void bestowEnchantmentToCreature() { + addCard(Zone.BATTLEFIELD, playerA, "Plains", 5); + addCard(Zone.BATTLEFIELD, playerA, "Silent Artisan"); + addCard(Zone.HAND, playerA, "Hopeful Eidolon"); + addCard(Zone.HAND, playerA, "Gods Willing"); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Hopeful Eidolon using bestow", "Silent Artisan"); + castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Gods Willing", "Silent Artisan"); + setChoice(playerA, "White"); + + setStopAt(1, PhaseStep.END_TURN); + execute(); + + // because of protection the Hopeful Eidolon should be a creature on the battlefield + assertPermanentCount(playerA, "Silent Artisan", 1); + assertPowerToughness(playerA, "Silent Artisan", 3, 5); + assertPermanentCount(playerA, "Hopeful Eidolon", 1); + assertPowerToughness(playerA, "Hopeful Eidolon", 1, 1); + } + +} diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/EvolveTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/EvolveTest.java index ba2009d4619..02f4baece8c 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/EvolveTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/EvolveTest.java @@ -1,3 +1,31 @@ +/* + * 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.abilities.keywords; import mage.constants.PhaseStep; diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/HexproofTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/HexproofTest.java index b23a5819a1c..10d0b3c74e2 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/HexproofTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/HexproofTest.java @@ -1,7 +1,29 @@ /* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. + * 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.abilities.keywords; diff --git a/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java b/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java index c3afffea621..eed69d091e1 100644 --- a/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java +++ b/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java @@ -255,8 +255,9 @@ public class TestPlayer extends ComputerPlayer { protected Permanent findPermanent(FilterPermanent filter, UUID controllerId, Game game) { List permanents = game.getBattlefield().getAllActivePermanents(filter, controllerId, game); - if (permanents.size() > 0) + if (permanents.size() > 0) { return permanents.get(0); + } return null; } diff --git a/Mage/src/mage/abilities/keyword/BestowAbility.java b/Mage/src/mage/abilities/keyword/BestowAbility.java index 0a5547fdd8a..5b99c92c9c0 100644 --- a/Mage/src/mage/abilities/keyword/BestowAbility.java +++ b/Mage/src/mage/abilities/keyword/BestowAbility.java @@ -70,6 +70,9 @@ import mage.target.common.TargetCreaturePermanent; * it an Aura spell ends. It continues resolving as a creature spell and will be put onto the battlefield * under the control of the spell’s controller. This is an exception to rule 608.3a. * + * 702.102e If an Aura with bestow is attached to an illegal object or player, it becomes unattached. + * This is an exception to rule 704.5n. + * * You don’t choose whether the spell is going to be an Aura spell or not until the spell is already on * the stack. Abilities that affect when you can cast a spell, such as flash, will apply to the creature * card in whatever zone you’re casting it from. For example, an effect that said you can cast creature diff --git a/Mage/src/mage/game/GameImpl.java b/Mage/src/mage/game/GameImpl.java index d23459516f3..6cc8fc00f81 100644 --- a/Mage/src/mage/game/GameImpl.java +++ b/Mage/src/mage/game/GameImpl.java @@ -1296,8 +1296,16 @@ public abstract class GameImpl> implements Game, Serializa } } else { if (!auraFilter.match(attachedTo, this) || attachedTo.hasProtectionFrom(perm, this)) { - if (perm.moveToZone(Zone.GRAVEYARD, null, this, false)) { - somethingHappened = true; + // handle bestow unattachment + Card card = this.getCard(perm.getId()); + if (card != null && card.getCardType().contains(CardType.CREATURE)) { + UUID wasAttachedTo = perm.getAttachedTo(); + perm.attachTo(null, this); + fireEvent(new GameEvent(GameEvent.EventType.UNATTACHED, wasAttachedTo, perm.getId(), perm.getControllerId())); + } else { + if (perm.moveToZone(Zone.GRAVEYARD, null, this, false)) { + somethingHappened = true; + } } } }