* BestowAbility - Fixed a problem that bestow cards that was put onto the battlefiedl as Auras were affected by abilities that should only affect creatures (e.g. Imposing Sovereign).

This commit is contained in:
LevelX2 2014-04-22 15:12:14 +02:00
parent db509c85b9
commit e0ce6df6b3
4 changed files with 55 additions and 22 deletions

View file

@ -48,8 +48,10 @@ import mage.game.stack.Spell;
/**
* Cards with the Aura subtype don't change the zone they are in, if there is no
* valid target on the battlefield. Also, when entering the Battlefield and it
* was not cast, this effect gets the target to witch to attach it.
* valid target on the battlefield. Also, when entering the battlefield and it
* was not cast (so from Zone != Hand), this effect gets the target to witch to attach it
* and adds the Aura the the battlefield and attachs it to the target.
* The "attachTo:" value in game state has to be set therefore.
*
* This effect is automatically added to ContinuousEffects at the start of a game
*
@ -149,12 +151,13 @@ public class AuraReplacementEffect extends ReplacementEffectImpl<AuraReplacement
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.ZONE_CHANGE
&& ((ZoneChangeEvent) event).getToZone() == Zone.BATTLEFIELD
&& ((ZoneChangeEvent) event).getFromZone() != Zone.HAND) {
Card card = game.getCard(event.getTargetId());
if (card != null && card.getCardType().contains(CardType.ENCHANTMENT) && card.hasSubtype("Aura")) {
return true;
if (event.getType().equals(GameEvent.EventType.ZONE_CHANGE)) {
if (((ZoneChangeEvent) event).getToZone().equals(Zone.BATTLEFIELD)
&& !(((ZoneChangeEvent) event).getFromZone().equals(Zone.HAND)) ) {
Card card = game.getCard(event.getTargetId());
if (card != null && card.getCardType().contains(CardType.ENCHANTMENT) && card.hasSubtype("Aura")) {
return true;
}
}
}
return false;

View file

@ -200,18 +200,22 @@ public class Spell<T extends Spell<T>> implements StackObject, Card {
} else if (this.getCardType().contains(CardType.ENCHANTMENT) && this.getSubtype().contains("Aura")) {
if (ability.getTargets().stillLegal(ability, game)) {
updateOptionalCosts(0);
boolean bestow = this.getSpellAbility() instanceof BestowAbility;
if (bestow) {
// 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);
}
if (card.putOntoBattlefield(game, fromZone, ability.getId(), controllerId)) {
if (this.getSpellAbility() instanceof BestowAbility) {
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
// Must be removed first time, after that will be removed by continous effect
// Otherwise effects like evolve trigger from creature comes into play event
permanent.getCardType().remove(CardType.CREATURE);
}
}
if (bestow) {
card.getCardType().add(CardType.CREATURE);
}
game.getState().handleSimultaneousEvent(game);
return ability.resolve(game);
}
if (bestow) {
card.getCardType().add(CardType.CREATURE);
}
return false;
}
// Aura has no legal target and its a bestow enchantment -> Add it to battlefield as creature