From 34021ca44d08f0ab8666eed5639750556874e0ba Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Thu, 5 Mar 2015 15:42:28 +0100 Subject: [PATCH] * Bestow - Fixed handling of Bestow (fixes #772). --- .../mage/test/cards/abilities/keywords/BestowTest.java | 8 +++++++- Mage/src/mage/abilities/keyword/BestowAbility.java | 8 +++++++- Mage/src/mage/game/stack/Spell.java | 5 ++++- 3 files changed, 18 insertions(+), 3 deletions(-) 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 index c684ea65402..ff8db21aebc 100644 --- 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 @@ -95,9 +95,11 @@ public class BestowTest extends CardTestPlayerBase { @Test public void bestowEnchantmentDoesNotTriggerEvolve() { addCard(Zone.BATTLEFIELD, playerA, "Forest", 6); + // Creature - Giant 3/5 addCard(Zone.BATTLEFIELD, playerA, "Silent Artisan"); addCard(Zone.HAND, playerA, "Experiment One"); + // Enchanted creature gets +4/+2. addCard(Zone.HAND, playerA, "Boon Satyr"); castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Experiment One"); @@ -107,10 +109,14 @@ public class BestowTest extends CardTestPlayerBase { execute(); // because Boon Satyr is no creature on the battlefield, evolve may not trigger + assertPermanentCount(playerA, "Boon Satyr", 1); + Permanent boonSatyr = getPermanent("Boon Satyr", playerA); + Assert.assertTrue("Boon Satyr may not be a creature",!boonSatyr.getCardType().contains(CardType.CREATURE)); assertPermanentCount(playerA, "Silent Artisan", 1); - assertPowerToughness(playerA, "Silent Artisan", 7, 7); assertPermanentCount(playerA, "Experiment One", 1); assertPowerToughness(playerA, "Experiment One", 1, 1); + assertPowerToughness(playerA, "Silent Artisan", 7, 7); + } /** diff --git a/Mage/src/mage/abilities/keyword/BestowAbility.java b/Mage/src/mage/abilities/keyword/BestowAbility.java index d8e1289527c..e1efa389490 100644 --- a/Mage/src/mage/abilities/keyword/BestowAbility.java +++ b/Mage/src/mage/abilities/keyword/BestowAbility.java @@ -142,12 +142,16 @@ public class BestowAbility extends SpellAbility { class BestowTypeChangingEffect extends ContinuousEffectImpl implements SourceEffect { + private boolean wasAttached; + public BestowTypeChangingEffect() { super(Duration.WhileOnBattlefield, Outcome.BoostCreature); + wasAttached = false; } public BestowTypeChangingEffect(final BestowTypeChangingEffect effect) { super(effect); + this.wasAttached = effect.wasAttached; } @Override @@ -163,8 +167,9 @@ class BestowTypeChangingEffect extends ContinuousEffectImpl implements SourceEff case TypeChangingEffects_4: if (sublayer == SubLayer.NA) { if (permanent.getAttachedTo() == null) { - if (permanent.getSubtype().contains("Aura")) { + if (wasAttached && permanent.getSubtype().contains("Aura")) { permanent.getSubtype().remove("Aura"); + wasAttached = false; } } else { permanent.getCardType().remove(CardType.CREATURE); @@ -172,6 +177,7 @@ class BestowTypeChangingEffect extends ContinuousEffectImpl implements SourceEff if (!permanent.getSubtype().contains("Aura")) { permanent.getSubtype().add("Aura"); } + wasAttached = true; } } break; diff --git a/Mage/src/mage/game/stack/Spell.java b/Mage/src/mage/game/stack/Spell.java index 81376e0a3ed..472f84daa03 100644 --- a/Mage/src/mage/game/stack/Spell.java +++ b/Mage/src/mage/game/stack/Spell.java @@ -231,6 +231,7 @@ public class Spell implements StackObject, Card { // Must be removed first time, after that will be removed by continous effect // Otherwise effects like evolve trigger from creature comes into play event card.getCardType().remove(CardType.CREATURE); + card.getSubtype().add("Aura"); } if (card.putOntoBattlefield(game, fromZone, ability.getSourceId(), controllerId)) { if (bestow) { @@ -240,8 +241,10 @@ public class Spell implements StackObject, Card { if (permanent != null && permanent instanceof PermanentCard) { permanent.setSpellAbility(ability); // otherwise spell ability without bestow will be set ((PermanentCard) permanent).getCard().getCardType().add(CardType.CREATURE); + ((PermanentCard) permanent).getCard().getSubtype().remove("Aura"); } card.getCardType().add(CardType.CREATURE); + card.getSubtype().remove("Aura"); } game.getState().handleSimultaneousEvent(game); return ability.resolve(game); @@ -642,7 +645,7 @@ public class Spell implements StackObject, Card { cmc += spellAbility.getManaCostsToPay().getX() * xMultiplier; } else { cmc += spellAbility.getManaCosts().convertedManaCost() + spellAbility.getManaCostsToPay().getX() * xMultiplier; - } + } } if (this.getSpellAbility().getSpellAbilityType().equals(SpellAbilityType.BASE_ALTERNATE)) { cmc += getCard().getManaCost().convertedManaCost();