* Bestow - Fixed handling of Bestow (fixes #772).

This commit is contained in:
LevelX2 2015-03-05 15:42:28 +01:00
parent ed54262b7d
commit 34021ca44d
3 changed files with 18 additions and 3 deletions

View file

@ -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);
}
/**

View file

@ -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;

View file

@ -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();